Skip to content

Commit

Permalink
-avoid allowing selection of canvasitems inside a viewport, fixes #1383
Browse files Browse the repository at this point in the history
  • Loading branch information
reduz committed Jan 24, 2016
1 parent 35a28f3 commit e997c0d
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tools/editor/plugins/canvas_item_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,9 @@ bool CanvasItemEditor::_select(CanvasItem *item, Point2 p_click_pos, bool p_appe
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;

CanvasItemEditorSelectedItem *se=editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
if (!se)
continue;
Expand Down Expand Up @@ -643,6 +646,9 @@ void CanvasItemEditor::_key_move(const Vector2& p_dir, bool p_snap, KeyMoveMODE
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;

CanvasItemEditorSelectedItem *se=editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
if (!se)
continue;
Expand Down Expand Up @@ -702,6 +708,9 @@ Point2 CanvasItemEditor::_find_topleftmost_point() {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;




Expand Down Expand Up @@ -731,6 +740,9 @@ int CanvasItemEditor::get_item_count() {
if (!canvas_item || !canvas_item->is_visible())
continue;

if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;

ic++;
};

Expand All @@ -749,6 +761,8 @@ CanvasItem *CanvasItemEditor::get_single_item() {
CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;

if (single_item)
return NULL; //morethan one
Expand Down Expand Up @@ -1102,6 +1116,9 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;


CanvasItemEditorSelectedItem *se=editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
if (!se)
Expand Down Expand Up @@ -1194,6 +1211,9 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;

CanvasItemEditorSelectedItem *se=editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
if (!se)
continue;
Expand Down Expand Up @@ -1400,6 +1420,9 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;

CanvasItemEditorSelectedItem *se=editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
if (!se)
continue;
Expand Down Expand Up @@ -1507,6 +1530,9 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;

CanvasItemEditorSelectedItem *se=editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
if (!se)
continue;
Expand Down Expand Up @@ -1881,6 +1907,8 @@ void CanvasItemEditor::_viewport_draw() {
CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;
CanvasItemEditorSelectedItem *se=editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
if (!se)
continue;
Expand Down Expand Up @@ -2104,6 +2132,9 @@ void CanvasItemEditor::_notification(int p_what) {
if (!canvas_item || !canvas_item->is_visible())
continue;

if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;

if (canvas_item->cast_to<Control>())
has_control=true;
else
Expand Down Expand Up @@ -2509,6 +2540,9 @@ void CanvasItemEditor::_popup_callback(int p_op) {
if (!canvas_item || !canvas_item->is_visible())
continue;

if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;

canvas_item->set_meta("_edit_lock_",true);
emit_signal("item_lock_status_changed");
}
Expand All @@ -2524,6 +2558,9 @@ void CanvasItemEditor::_popup_callback(int p_op) {
if (!canvas_item || !canvas_item->is_visible())
continue;

if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;


canvas_item->set_meta("_edit_lock_",Variant());
emit_signal("item_lock_status_changed");
Expand All @@ -2542,6 +2579,9 @@ void CanvasItemEditor::_popup_callback(int p_op) {
if (!canvas_item || !canvas_item->is_visible())
continue;

if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;

canvas_item->set_meta("_edit_group_",true);
emit_signal("item_group_status_changed");
}
Expand All @@ -2557,6 +2597,9 @@ void CanvasItemEditor::_popup_callback(int p_op) {
if (!canvas_item || !canvas_item->is_visible())
continue;

if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;

canvas_item->set_meta("_edit_group_",Variant());
emit_signal("item_group_status_changed");
}
Expand All @@ -2575,6 +2618,9 @@ void CanvasItemEditor::_popup_callback(int p_op) {
if (!canvas_item || !canvas_item->is_visible())
continue;

if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;


Control *c = canvas_item->cast_to<Control>();
if (!c)
Expand Down Expand Up @@ -2693,6 +2739,9 @@ void CanvasItemEditor::_popup_callback(int p_op) {
if (!canvas_item || !canvas_item->is_visible())
continue;

if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;

if (canvas_item->cast_to<Node2D>()) {
Node2D *n2d = canvas_item->cast_to<Node2D>();

Expand Down Expand Up @@ -2803,6 +2852,8 @@ void CanvasItemEditor::_popup_callback(int p_op) {
if (!canvas_item || !canvas_item->is_visible())
continue;

if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;


if (canvas_item->cast_to<Node2D>()) {
Expand Down Expand Up @@ -2853,6 +2904,9 @@ void CanvasItemEditor::_popup_callback(int p_op) {
if (!canvas_item || !canvas_item->is_visible())
continue;

if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;

if (canvas_item->cast_to<Node2D>()) {
Node2D *n2d = canvas_item->cast_to<Node2D>();

Expand Down Expand Up @@ -2887,6 +2941,9 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for(Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
if (!canvas_item) continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;


// counting invisible items, for now
//if (!canvas_item->is_visible()) continue;
Expand Down Expand Up @@ -2979,6 +3036,8 @@ void CanvasItemEditor::_popup_callback(int p_op) {
if (!canvas_item || !canvas_item->is_visible())
continue;

if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;

canvas_item->set_meta("_edit_ik_",true);

Expand Down

0 comments on commit e997c0d

Please sign in to comment.