1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Improve SpriteFrameEditor frame addition ordering

This commit is contained in:
Ninni Pipping
2023-02-24 16:00:28 +01:00
parent c29866dbc0
commit 83d85048ea
2 changed files with 339 additions and 90 deletions

View File

@@ -45,6 +45,7 @@
#include "scene/gui/texture_rect.h"
#include "scene/gui/tree.h"
class OptionButton;
class EditorFileDialog;
class EditorSpriteFramesFrame : public Resource {
@@ -68,6 +69,22 @@ class SpriteFramesEditor : public HSplitContainer {
};
int dominant_param = PARAM_FRAME_COUNT;
enum {
FRAME_ORDER_SELECTION, // Order frames were selected in.
// By Row.
FRAME_ORDER_LEFT_RIGHT_TOP_BOTTOM,
FRAME_ORDER_LEFT_RIGHT_BOTTOM_TOP,
FRAME_ORDER_RIGHT_LEFT_TOP_BOTTOM,
FRAME_ORDER_RIGHT_LEFT_BOTTOM_TOP,
// By Column.
FRAME_ORDER_TOP_BOTTOM_LEFT_RIGHT,
FRAME_ORDER_TOP_BOTTOM_RIGHT_LEFT,
FRAME_ORDER_BOTTOM_TOP_LEFT_RIGHT,
FRAME_ORDER_BOTTOM_TOP_RIGHT_LEFT,
};
bool read_only = false;
Ref<Texture2D> autoplay_icon;
@@ -121,6 +138,7 @@ class SpriteFramesEditor : public HSplitContainer {
ConfirmationDialog *split_sheet_dialog = nullptr;
ScrollContainer *split_sheet_scroll = nullptr;
TextureRect *split_sheet_preview = nullptr;
VBoxContainer *split_sheet_settings_vb = nullptr;
SpinBox *split_sheet_h = nullptr;
SpinBox *split_sheet_v = nullptr;
SpinBox *split_sheet_size_x = nullptr;
@@ -132,9 +150,14 @@ class SpriteFramesEditor : public HSplitContainer {
Button *split_sheet_zoom_out = nullptr;
Button *split_sheet_zoom_reset = nullptr;
Button *split_sheet_zoom_in = nullptr;
Button *toggle_settings_button = nullptr;
OptionButton *split_sheet_order = nullptr;
EditorFileDialog *file_split_sheet = nullptr;
HashSet<int> frames_selected;
HashMap<int, int> frames_selected; // Key is frame index. Value is selection order.
HashSet<int> frames_toggled_by_mouse_hover;
Vector<Pair<int, int>> frames_ordered; // First is the index to be ordered by. Second is the actual frame index.
int selected_count = 0;
bool frames_need_sort = false;
int last_frame_selected = 0;
float scale_ratio;
@@ -206,7 +229,12 @@ class SpriteFramesEditor : public HSplitContainer {
void _sheet_zoom_in();
void _sheet_zoom_out();
void _sheet_zoom_reset();
void _sheet_select_clear_all_frames();
void _sheet_order_selected(int p_option);
void _sheet_select_all_frames();
void _sheet_clear_all_frames();
void _sheet_sort_frames();
void _toggle_show_settings();
void _update_show_settings();
void _edit();
void _regist_scene_undo(EditorUndoRedoManager *undo_redo);