From d3619f8743400624549fe9ee33cc430cb99a157c Mon Sep 17 00:00:00 2001 From: Gilles Roudiere Date: Sun, 27 Jan 2019 16:36:10 +0100 Subject: [PATCH] Disables the Layout menu when a Control node is child of a container --- editor/plugins/canvas_item_editor_plugin.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 2913c4ce56..b4618a4eb6 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3277,7 +3277,24 @@ void CanvasItemEditor::_notification(int p_what) { pivot_button->set_disabled(nb_having_pivot == 0); // Show / Hide the layout button - presets_menu->set_visible(nb_control > 0 && nb_control == selection.size()); + if (nb_control > 0 && nb_control == selection.size()) { + presets_menu->set_visible(true); + presets_menu->set_tooltip(TTR("Presets for the anchors and margins values of a Control node.")); + + // Disable if the selected node is child of a container + presets_menu->set_disabled(false); + for (List::Element *E = selection.front(); E; E = E->next()) { + Control *control = Object::cast_to(E->get()); + if (!control || Object::cast_to(control->get_parent())) { + presets_menu->set_disabled(true); + presets_menu->set_tooltip(TTR("A child of a container gets its anchors and margins values overriden by its parent.")); + break; + } + } + + } else { + presets_menu->set_visible(false); + } // Update the viewport if bones changes for (Map::Element *E = bone_list.front(); E; E = E->next()) {