diff options
Diffstat (limited to 'editor/plugins/polygon_2d_editor_plugin.h')
-rwxr-xr-x[-rw-r--r--] | editor/plugins/polygon_2d_editor_plugin.h | 61 |
1 files changed, 14 insertions, 47 deletions
diff --git a/editor/plugins/polygon_2d_editor_plugin.h b/editor/plugins/polygon_2d_editor_plugin.h index f9d6a6b4b6..90da3e61c1 100644..100755 --- a/editor/plugins/polygon_2d_editor_plugin.h +++ b/editor/plugins/polygon_2d_editor_plugin.h @@ -30,26 +30,18 @@ #ifndef POLYGON_2D_EDITOR_PLUGIN_H #define POLYGON_2D_EDITOR_PLUGIN_H -#include "editor/editor_node.h" -#include "editor/editor_plugin.h" -#include "scene/2d/polygon_2d.h" -#include "scene/gui/tool_button.h" +#include "editor/plugins/abstract_polygon_2d_editor.h" /** @author Juan Linietsky <reduzio@gmail.com> */ -class CanvasItemEditor; +class Polygon2DEditor : public AbstractPolygon2DEditor { -class Polygon2DEditor : public HBoxContainer { + GDCLASS(Polygon2DEditor, AbstractPolygon2DEditor); - GDCLASS(Polygon2DEditor, HBoxContainer); - - UndoRedo *undo_redo; enum Mode { - MODE_CREATE, - MODE_EDIT, - MODE_EDIT_UV, + MODE_EDIT_UV = MODE_CONT, UVEDIT_POLYGON_TO_UV, UVEDIT_UV_TO_POLYGON, UVEDIT_UV_CLEAR @@ -64,7 +56,7 @@ class Polygon2DEditor : public HBoxContainer { UV_MODE_MAX }; - Mode mode; + Polygon2D *node; UVMode uv_mode; AcceptDialog *uv_edit; @@ -90,34 +82,19 @@ class Polygon2DEditor : public HBoxContainer { AcceptDialog *error; - ToolButton *button_create; - ToolButton *button_edit; ToolButton *button_uv; - CanvasItemEditor *canvas_item_editor; - EditorNode *editor; - Panel *panel; - Polygon2D *node; - MenuButton *options; - - int edited_point; - Vector2 edited_point_pos; - Vector<Vector2> pre_move_edit; - Vector<Vector2> wip; - bool wip_active; - bool use_snap; bool snap_show_grid; Vector2 snap_offset; Vector2 snap_step; + virtual void _menu_option(int p_option); + void _uv_scroll_changed(float); void _uv_input(const Ref<InputEvent> &p_input); void _uv_draw(); void _uv_mode(int p_mode); - void _wip_close(); - void _canvas_draw(); - void _menu_option(int p_option); void _set_use_snap(bool p_use); void _set_show_grid(bool p_show); @@ -127,36 +104,26 @@ class Polygon2DEditor : public HBoxContainer { void _set_snap_step_y(float p_val); protected: + virtual Node2D *_get_node() const; + virtual void _set_node(Node *p_polygon); + + virtual Vector2 _get_offset(int p_idx) const; + void _notification(int p_what); - void _node_removed(Node *p_node); static void _bind_methods(); Vector2 snap_point(Vector2 p_target) const; public: - bool forward_gui_input(const Ref<InputEvent> &p_event); - void edit(Node *p_collision_polygon); Polygon2DEditor(EditorNode *p_editor); }; -class Polygon2DEditorPlugin : public EditorPlugin { - - GDCLASS(Polygon2DEditorPlugin, EditorPlugin); +class Polygon2DEditorPlugin : public AbstractPolygon2DEditorPlugin { - Polygon2DEditor *collision_polygon_editor; - EditorNode *editor; + GDCLASS(Polygon2DEditorPlugin, AbstractPolygon2DEditorPlugin); public: - virtual bool forward_canvas_gui_input(const Transform2D &p_canvas_xform, const Ref<InputEvent> &p_event) { return collision_polygon_editor->forward_gui_input(p_event); } - - virtual String get_name() const { return "Polygon2D"; } - bool has_main_screen() const { return false; } - virtual void edit(Object *p_object); - virtual bool handles(Object *p_object) const; - virtual void make_visible(bool p_visible); - Polygon2DEditorPlugin(EditorNode *p_node); - ~Polygon2DEditorPlugin(); }; #endif // POLYGON_2D_EDITOR_PLUGIN_H |