diff options
Diffstat (limited to 'scene/gui/margin_container.cpp')
-rw-r--r-- | scene/gui/margin_container.cpp | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/scene/gui/margin_container.cpp b/scene/gui/margin_container.cpp index 62ba45c484..0299065f77 100644 --- a/scene/gui/margin_container.cpp +++ b/scene/gui/margin_container.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -31,29 +31,32 @@ #include "margin_container.h" Size2 MarginContainer::get_minimum_size() const { - - int margin_left = get_constant("margin_left"); - int margin_top = get_constant("margin_top"); - int margin_right = get_constant("margin_right"); - int margin_bottom = get_constant("margin_bottom"); + int margin_left = get_theme_constant("margin_left"); + int margin_top = get_theme_constant("margin_top"); + int margin_right = get_theme_constant("margin_right"); + int margin_bottom = get_theme_constant("margin_bottom"); Size2 max; for (int i = 0; i < get_child_count(); i++) { - Control *c = Object::cast_to<Control>(get_child(i)); - if (!c) + if (!c) { continue; - if (c->is_set_as_toplevel()) + } + if (c->is_set_as_toplevel()) { continue; - if (!c->is_visible()) + } + if (!c->is_visible()) { continue; + } Size2 s = c->get_combined_minimum_size(); - if (s.width > max.width) + if (s.width > max.width) { max.width = s.width; - if (s.height > max.height) + } + if (s.height > max.height) { max.height = s.height; + } } max.width += (margin_left + margin_right); @@ -63,24 +66,23 @@ Size2 MarginContainer::get_minimum_size() const { } void MarginContainer::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_SORT_CHILDREN: { - - int margin_left = get_constant("margin_left"); - int margin_top = get_constant("margin_top"); - int margin_right = get_constant("margin_right"); - int margin_bottom = get_constant("margin_bottom"); + int margin_left = get_theme_constant("margin_left"); + int margin_top = get_theme_constant("margin_top"); + int margin_right = get_theme_constant("margin_right"); + int margin_bottom = get_theme_constant("margin_bottom"); Size2 s = get_size(); for (int i = 0; i < get_child_count(); i++) { - Control *c = Object::cast_to<Control>(get_child(i)); - if (!c) + if (!c) { continue; - if (c->is_set_as_toplevel()) + } + if (c->is_set_as_toplevel()) { continue; + } int w = s.width - margin_left - margin_right; int h = s.height - margin_top - margin_bottom; @@ -88,7 +90,6 @@ void MarginContainer::_notification(int p_what) { } } break; case NOTIFICATION_THEME_CHANGED: { - minimum_size_changed(); } break; } |