You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Move Polygon2D editor to bottom panel
Move UV editor to bottom panel to allow realtime preview of results. Rename the editor to Polygon editor. Refactor enums and rename polygon editor members. Remove "uv" prefixes and clarify some names. Reorder/regroup some members in header file.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -51,50 +51,62 @@ class VScrollBar;
|
|||||||
class Polygon2DEditor : public AbstractPolygon2DEditor {
|
class Polygon2DEditor : public AbstractPolygon2DEditor {
|
||||||
GDCLASS(Polygon2DEditor, AbstractPolygon2DEditor);
|
GDCLASS(Polygon2DEditor, AbstractPolygon2DEditor);
|
||||||
|
|
||||||
|
enum {
|
||||||
|
MENU_POLYGON_TO_UV,
|
||||||
|
MENU_UV_TO_POLYGON,
|
||||||
|
MENU_UV_CLEAR,
|
||||||
|
MENU_GRID_SETTINGS,
|
||||||
|
};
|
||||||
|
|
||||||
enum Mode {
|
enum Mode {
|
||||||
MODE_EDIT_UV = MODE_CONT,
|
MODE_POINTS,
|
||||||
UVEDIT_POLYGON_TO_UV,
|
MODE_POLYGONS,
|
||||||
UVEDIT_UV_TO_POLYGON,
|
MODE_UV,
|
||||||
UVEDIT_UV_CLEAR,
|
MODE_BONES,
|
||||||
UVEDIT_GRID_SETTINGS
|
MODE_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
enum UVMode {
|
enum Action {
|
||||||
UV_MODE_CREATE,
|
ACTION_CREATE,
|
||||||
UV_MODE_CREATE_INTERNAL,
|
ACTION_CREATE_INTERNAL,
|
||||||
UV_MODE_REMOVE_INTERNAL,
|
ACTION_REMOVE_INTERNAL,
|
||||||
UV_MODE_EDIT_POINT,
|
ACTION_EDIT_POINT,
|
||||||
UV_MODE_MOVE,
|
ACTION_MOVE,
|
||||||
UV_MODE_ROTATE,
|
ACTION_ROTATE,
|
||||||
UV_MODE_SCALE,
|
ACTION_SCALE,
|
||||||
UV_MODE_ADD_POLYGON,
|
ACTION_ADD_POLYGON,
|
||||||
UV_MODE_REMOVE_POLYGON,
|
ACTION_REMOVE_POLYGON,
|
||||||
UV_MODE_PAINT_WEIGHT,
|
ACTION_PAINT_WEIGHT,
|
||||||
UV_MODE_CLEAR_WEIGHT,
|
ACTION_CLEAR_WEIGHT,
|
||||||
UV_MODE_MAX
|
ACTION_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
Button *uv_edit_mode[4];
|
|
||||||
Ref<ButtonGroup> uv_edit_group;
|
|
||||||
|
|
||||||
Polygon2D *node = nullptr;
|
Polygon2D *node = nullptr;
|
||||||
|
Polygon2D *previous_node = nullptr;
|
||||||
|
|
||||||
UVMode uv_mode;
|
Button *dock_button = nullptr;
|
||||||
AcceptDialog *uv_edit = nullptr;
|
VBoxContainer *polygon_edit = nullptr;
|
||||||
Button *uv_button[UV_MODE_MAX];
|
Mode current_mode = MODE_MAX; // Uninitialized.
|
||||||
|
Button *mode_buttons[MODE_MAX];
|
||||||
|
Action selected_action = ACTION_CREATE;
|
||||||
|
Button *action_buttons[ACTION_MAX];
|
||||||
Button *b_snap_enable = nullptr;
|
Button *b_snap_enable = nullptr;
|
||||||
Button *b_snap_grid = nullptr;
|
Button *b_snap_grid = nullptr;
|
||||||
Panel *uv_edit_background = nullptr;
|
MenuButton *edit_menu = nullptr;
|
||||||
Polygon2D *preview_polygon = nullptr;
|
|
||||||
Control *uv_edit_draw = nullptr;
|
|
||||||
EditorZoomWidget *zoom_widget = nullptr;
|
|
||||||
HScrollBar *uv_hscroll = nullptr;
|
|
||||||
VScrollBar *uv_vscroll = nullptr;
|
|
||||||
MenuButton *uv_menu = nullptr;
|
|
||||||
|
|
||||||
Ref<ViewPanner> uv_panner;
|
Control *canvas = nullptr;
|
||||||
void _uv_pan_callback(Vector2 p_scroll_vec, Ref<InputEvent> p_event);
|
Panel *canvas_background = nullptr;
|
||||||
void _uv_zoom_callback(float p_zoom_factor, Vector2 p_origin, Ref<InputEvent> p_event);
|
Polygon2D *preview_polygon = nullptr;
|
||||||
|
EditorZoomWidget *zoom_widget = nullptr;
|
||||||
|
HScrollBar *hscroll = nullptr;
|
||||||
|
VScrollBar *vscroll = nullptr;
|
||||||
|
bool center_view_on_draw = false;
|
||||||
|
|
||||||
|
Ref<ViewPanner> panner;
|
||||||
|
void _pan_callback(Vector2 p_scroll_vec, Ref<InputEvent> p_event);
|
||||||
|
void _zoom_callback(float p_zoom_factor, Vector2 p_origin, Ref<InputEvent> p_event);
|
||||||
|
Vector2 draw_offset;
|
||||||
|
real_t draw_zoom = 1.0;
|
||||||
|
|
||||||
VBoxContainer *bone_scroll_main_vb = nullptr;
|
VBoxContainer *bone_scroll_main_vb = nullptr;
|
||||||
ScrollContainer *bone_scroll = nullptr;
|
ScrollContainer *bone_scroll = nullptr;
|
||||||
@@ -103,7 +115,7 @@ class Polygon2DEditor : public AbstractPolygon2DEditor {
|
|||||||
HSlider *bone_paint_strength = nullptr;
|
HSlider *bone_paint_strength = nullptr;
|
||||||
SpinBox *bone_paint_radius = nullptr;
|
SpinBox *bone_paint_radius = nullptr;
|
||||||
Label *bone_paint_radius_label = nullptr;
|
Label *bone_paint_radius_label = nullptr;
|
||||||
bool bone_painting;
|
bool bone_painting = false;
|
||||||
int bone_painting_bone = 0;
|
int bone_painting_bone = 0;
|
||||||
Vector<float> prev_weights;
|
Vector<float> prev_weights;
|
||||||
Vector2 bone_paint_pos;
|
Vector2 bone_paint_pos;
|
||||||
@@ -112,34 +124,30 @@ class Polygon2DEditor : public AbstractPolygon2DEditor {
|
|||||||
void _sync_bones();
|
void _sync_bones();
|
||||||
void _update_bone_list();
|
void _update_bone_list();
|
||||||
|
|
||||||
Vector2 uv_draw_ofs;
|
Vector<Vector2> editing_points;
|
||||||
real_t uv_draw_zoom;
|
Vector<Vector2> previous_uv;
|
||||||
Vector<Vector2> points_prev;
|
Vector<Vector2> previous_polygon;
|
||||||
Vector<Vector2> uv_create_uv_prev;
|
Vector<Color> previous_colors;
|
||||||
Vector<Vector2> uv_create_poly_prev;
|
int previous_internal_vertices = 0;
|
||||||
Vector<Color> uv_create_colors_prev;
|
Array previous_bones;
|
||||||
int uv_create_prev_internal_vertices = 0;
|
Array previous_polygons;
|
||||||
Array uv_create_bones_prev;
|
|
||||||
Array polygons_prev;
|
|
||||||
|
|
||||||
Vector2 uv_create_to;
|
Vector2 create_to;
|
||||||
int point_drag_index;
|
int point_drag_index = -1;
|
||||||
bool uv_drag;
|
bool is_dragging = false;
|
||||||
bool uv_create;
|
bool is_creating = false;
|
||||||
Vector<int> polygon_create;
|
Vector<int> polygon_create;
|
||||||
UVMode uv_move_current;
|
Action current_action = ACTION_CREATE;
|
||||||
Vector2 uv_drag_from;
|
Vector2 drag_from;
|
||||||
|
|
||||||
AcceptDialog *error = nullptr;
|
AcceptDialog *error = nullptr;
|
||||||
|
|
||||||
Button *button_uv = nullptr;
|
bool use_snap = false;
|
||||||
|
bool snap_show_grid = false;
|
||||||
bool use_snap;
|
|
||||||
bool snap_show_grid;
|
|
||||||
Vector2 snap_offset;
|
Vector2 snap_offset;
|
||||||
Vector2 snap_step;
|
Vector2 snap_step;
|
||||||
|
|
||||||
virtual void _menu_option(int p_option) override;
|
void _edit_menu_option(int p_option);
|
||||||
|
|
||||||
void _cancel_editing();
|
void _cancel_editing();
|
||||||
void _update_polygon_editing_state();
|
void _update_polygon_editing_state();
|
||||||
@@ -147,9 +155,10 @@ class Polygon2DEditor : public AbstractPolygon2DEditor {
|
|||||||
|
|
||||||
void _center_view();
|
void _center_view();
|
||||||
void _update_zoom_and_pan(bool p_zoom_at_center);
|
void _update_zoom_and_pan(bool p_zoom_at_center);
|
||||||
void _uv_input(const Ref<InputEvent> &p_input);
|
void _canvas_input(const Ref<InputEvent> &p_input);
|
||||||
void _uv_draw();
|
void _center_view_on_draw(bool p_enabled = true);
|
||||||
void _uv_mode(int p_mode);
|
void _canvas_draw();
|
||||||
|
void _set_action(int p_mode);
|
||||||
|
|
||||||
void _set_use_snap(bool p_use);
|
void _set_use_snap(bool p_use);
|
||||||
void _set_show_grid(bool p_show);
|
void _set_show_grid(bool p_show);
|
||||||
@@ -158,9 +167,7 @@ class Polygon2DEditor : public AbstractPolygon2DEditor {
|
|||||||
void _set_snap_step_x(real_t p_val);
|
void _set_snap_step_x(real_t p_val);
|
||||||
void _set_snap_step_y(real_t p_val);
|
void _set_snap_step_y(real_t p_val);
|
||||||
|
|
||||||
void _uv_edit_mode_select(int p_mode);
|
void _select_mode(int p_mode);
|
||||||
void _uv_edit_popup_show();
|
|
||||||
void _uv_edit_popup_hide();
|
|
||||||
void _bone_paint_selected(int p_index);
|
void _bone_paint_selected(int p_index);
|
||||||
|
|
||||||
int _get_polygon_count() const override;
|
int _get_polygon_count() const override;
|
||||||
|
|||||||
Reference in New Issue
Block a user