summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-01-27 17:03:17 +0100
committerGitHub <noreply@github.com>2019-01-27 17:03:17 +0100
commitb494de34aa28e6c562e5ac8e767db1245b37bd8f (patch)
treefc247dd112442f1481443c3bee043136a139a34e /editor/plugins
parent92a3f11de6da26173cc44499b94290a5b70592b0 (diff)
parentd3619f8743400624549fe9ee33cc430cb99a157c (diff)
Merge pull request #25381 from groud/disable_layout_menu
Disables the Layout menu when a Control node is child of a container
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp19
1 files changed, 18 insertions, 1 deletions
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<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) {
+ Control *control = Object::cast_to<Control>(E->get());
+ if (!control || Object::cast_to<Container>(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<BoneKey, BoneList>::Element *E = bone_list.front(); E; E = E->next()) {