diff options
author | Bernhard Liebl <Bernhard.Liebl@gmx.org> | 2017-11-04 14:46:49 +0100 |
---|---|---|
committer | Bernhard Liebl <Bernhard.Liebl@gmx.org> | 2017-11-04 20:26:38 +0100 |
commit | 88007e91cf063fa92eda5fb6e3f504fc210a36f9 (patch) | |
tree | 05daa25bf4b5ca0db33ca22e3c030c9d804a65df /editor/plugins/line_2d_editor_plugin.h | |
parent | 3cbcf5c2ddadf1cd630137d6bd438634b8517b00 (diff) |
Use AbstractPolygon2DEditor for Line2D
Diffstat (limited to 'editor/plugins/line_2d_editor_plugin.h')
-rw-r--r-- | editor/plugins/line_2d_editor_plugin.h | 68 |
1 files changed, 12 insertions, 56 deletions
diff --git a/editor/plugins/line_2d_editor_plugin.h b/editor/plugins/line_2d_editor_plugin.h index 6858680aed..24c19c420d 100644 --- a/editor/plugins/line_2d_editor_plugin.h +++ b/editor/plugins/line_2d_editor_plugin.h @@ -30,78 +30,34 @@ #ifndef LINE_2D_EDITOR_PLUGIN_H #define LINE_2D_EDITOR_PLUGIN_H -#include "editor/editor_node.h" -#include "editor/editor_plugin.h" +#include "editor/plugins/abstract_polygon_2d_editor.h" #include "scene/2d/line_2d.h" -#include "scene/2d/path_2d.h" -#include "scene/gui/tool_button.h" -class CanvasItemEditor; +class Line2DEditor : public AbstractPolygon2DEditor { -class Line2DEditor : public HBoxContainer { - GDCLASS(Line2DEditor, HBoxContainer) -private: - void _mode_selected(int p_mode); - void _node_visibility_changed(); + GDCLASS(Line2DEditor, AbstractPolygon2DEditor); - int get_point_index_at(const Transform2D &xform, Vector2 gpos); - - UndoRedo *undo_redo; - - CanvasItemEditor *canvas_item_editor; - EditorNode *editor; - Panel *panel; Line2D *node; - HBoxContainer *base_hb; - Separator *sep; - - enum Mode { - MODE_CREATE = 0, - MODE_EDIT, - MODE_DELETE, - _MODE_COUNT - }; - - Mode mode; - ToolButton *toolbar_buttons[_MODE_COUNT]; - - bool _dragging; - int action_point; - Point2 moving_from; - Point2 moving_screen_from; - protected: - void _node_removed(Node *p_node); - void _notification(int p_what); + virtual Node2D *_get_node() const; + virtual void _set_node(Node *p_line); - static void _bind_methods(); + virtual bool _is_line() const; + virtual Variant _get_polygon(int p_idx) const; + virtual void _set_polygon(int p_idx, const Variant &p_polygon) const; + virtual void _action_set_polygon(int p_idx, const Variant &p_previous, const Variant &p_polygon); public: - bool forward_canvas_gui_input(const Ref<InputEvent> &p_event); - void forward_draw_over_canvas(Control *p_canvas); - void edit(Node *p_line2d); Line2DEditor(EditorNode *p_editor); }; -class Line2DEditorPlugin : public EditorPlugin { - GDCLASS(Line2DEditorPlugin, EditorPlugin) - -public: - virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return line2d_editor->forward_canvas_gui_input(p_event); } - virtual void forward_draw_over_canvas(Control *p_canvas) { return line2d_editor->forward_draw_over_canvas(p_canvas); } +class Line2DEditorPlugin : public AbstractPolygon2DEditorPlugin { - virtual String get_name() const { return "Line2D"; } - 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); + GDCLASS(Line2DEditorPlugin, AbstractPolygon2DEditorPlugin); +public: Line2DEditorPlugin(EditorNode *p_node); - -private: - Line2DEditor *line2d_editor; - EditorNode *editor; }; #endif // LINE_2D_EDITOR_PLUGIN_H |