summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-05-31 10:17:56 +0200
committerGitHub <noreply@github.com>2019-05-31 10:17:56 +0200
commit1f91de4783204e74209e9c5157a8e683e61a4856 (patch)
tree301934fbf9adcf8db85b6dbd4b58e681a638ece4 /editor/plugins
parent710827c5dbc499c45df90c600540be6fcb781b1e (diff)
parent647fb155c3b748acf7f87e016b56094146502853 (diff)
Merge pull request #29318 from bojidar-bg/29313-control-constant-update
Fix constant redrawing of the editor when selecting a Control in a Container
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 92cc12d931..e8ef689ca3 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -3280,6 +3280,7 @@ void CanvasItemEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_PHYSICS_PROCESS) {
EditorNode::get_singleton()->get_scene_root()->set_snap_controls_to_pixels(GLOBAL_GET("gui/common/snap_controls_to_pixels"));
+ bool has_container_parents = false;
int nb_control = 0;
int nb_having_pivot = 0;
@@ -3323,6 +3324,10 @@ void CanvasItemEditor::_notification(int p_what) {
viewport->update();
}
nb_control++;
+
+ if (Object::cast_to<Container>(control->get_parent())) {
+ has_container_parents = true;
+ }
}
if (canvas_item->_edit_use_pivot()) {
@@ -3336,25 +3341,22 @@ void CanvasItemEditor::_notification(int p_what) {
// Show / Hide the layout and anchors mode buttons
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."));
anchor_mode_button->set_visible(true);
- anchor_mode_button->set_tooltip(TTR("When active, moving Control nodes changes their anchors instead of their margins."));
// Set the pressed state of the node
anchor_mode_button->set_pressed(anchors_mode);
// Disable if the selected node is child of a container
- presets_menu->set_disabled(false);
- anchor_mode_button->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("Children of containers have their anchors and margins values overridden by their parent."));
- anchor_mode_button->set_disabled(true);
- anchor_mode_button->set_tooltip(TTR("Children of containers have their anchors and margins values overridden by their parent."));
- break;
- }
+ if (has_container_parents) {
+ presets_menu->set_disabled(true);
+ presets_menu->set_tooltip(TTR("Children of containers have their anchors and margins values overridden by their parent."));
+ anchor_mode_button->set_disabled(true);
+ anchor_mode_button->set_tooltip(TTR("Children of containers have their anchors and margins values overridden by their parent."));
+ } else {
+ presets_menu->set_disabled(false);
+ presets_menu->set_tooltip(TTR("Presets for the anchors and margins values of a Control node."));
+ anchor_mode_button->set_disabled(false);
+ anchor_mode_button->set_tooltip(TTR("When active, moving Control nodes changes their anchors instead of their margins."));
}
} else {
presets_menu->set_visible(false);