Fixes polygon editor blocking other editor actions (move, scale...)

This commit is contained in:
groud 2018-09-19 14:26:04 +02:00
parent 6f1513545b
commit c3e66536cc
2 changed files with 12 additions and 4 deletions

View file

@ -275,6 +275,10 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
return (mb.is_valid() && mb->get_button_index() == 1); return (mb.is_valid() && mb->get_button_index() == 1);
} }
CanvasItemEditor::Tool tool = CanvasItemEditor::get_singleton()->get_current_tool();
if (tool != CanvasItemEditor::TOOL_SELECT)
return false;
if (mb.is_valid()) { if (mb.is_valid()) {
Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform(); Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform();
@ -283,10 +287,10 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
Vector2 cpoint = _get_node()->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mb->get_position()))); Vector2 cpoint = _get_node()->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mb->get_position())));
if (mode == MODE_EDIT || (_is_line() && mode == MODE_CREATE)) { if (mode == MODE_EDIT || (_is_line() && mode == MODE_CREATE)) {
if (mb->get_button_index() == BUTTON_LEFT) { if (mb->get_button_index() == BUTTON_LEFT) {
if (mb->is_pressed()) { if (mb->is_pressed()) {
if (mb->get_control() || mb->get_shift() || mb->get_alt())
return false;
const PosVertex insert = closest_edge_point(gpoint); const PosVertex insert = closest_edge_point(gpoint);

View file

@ -71,8 +71,7 @@ class CanvasItemEditor : public VBoxContainer {
GDCLASS(CanvasItemEditor, VBoxContainer); GDCLASS(CanvasItemEditor, VBoxContainer);
EditorNode *editor; public:
enum Tool { enum Tool {
TOOL_SELECT, TOOL_SELECT,
TOOL_LIST_SELECT, TOOL_LIST_SELECT,
@ -84,6 +83,9 @@ class CanvasItemEditor : public VBoxContainer {
TOOL_MAX TOOL_MAX
}; };
private:
EditorNode *editor;
enum MenuOption { enum MenuOption {
SNAP_USE, SNAP_USE,
SNAP_USE_NODE_PARENT, SNAP_USE_NODE_PARENT,
@ -535,6 +537,8 @@ public:
Control *get_viewport_control() { return viewport; } Control *get_viewport_control() { return viewport; }
Tool get_current_tool() { return tool; }
void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; } void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; }
void edit(CanvasItem *p_canvas_item); void edit(CanvasItem *p_canvas_item);