diff options
Diffstat (limited to 'scene/gui/panel_container.cpp')
-rw-r--r-- | scene/gui/panel_container.cpp | 86 |
1 files changed, 53 insertions, 33 deletions
diff --git a/scene/gui/panel_container.cpp b/scene/gui/panel_container.cpp index 463ad3c513..fe01712a89 100644 --- a/scene/gui/panel_container.cpp +++ b/scene/gui/panel_container.cpp @@ -60,47 +60,67 @@ Size2 PanelContainer::get_minimum_size() const { return ms; } -void PanelContainer::_notification(int p_what) { - if (p_what == NOTIFICATION_DRAW) { - RID ci = get_canvas_item(); - Ref<StyleBox> style; - - if (has_theme_stylebox(SNAME("panel"))) { - style = get_theme_stylebox(SNAME("panel")); - } else { - style = get_theme_stylebox(SNAME("panel"), SNAME("PanelContainer")); - } +Vector<int> PanelContainer::get_allowed_size_flags_horizontal() const { + Vector<int> flags; + flags.append(SIZE_FILL); + flags.append(SIZE_SHRINK_BEGIN); + flags.append(SIZE_SHRINK_CENTER); + flags.append(SIZE_SHRINK_END); + return flags; +} - style->draw(ci, Rect2(Point2(), get_size())); - } +Vector<int> PanelContainer::get_allowed_size_flags_vertical() const { + Vector<int> flags; + flags.append(SIZE_FILL); + flags.append(SIZE_SHRINK_BEGIN); + flags.append(SIZE_SHRINK_CENTER); + flags.append(SIZE_SHRINK_END); + return flags; +} - if (p_what == NOTIFICATION_SORT_CHILDREN) { - Ref<StyleBox> style; +void PanelContainer::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_DRAW: { + RID ci = get_canvas_item(); + Ref<StyleBox> style; - if (has_theme_stylebox(SNAME("panel"))) { - style = get_theme_stylebox(SNAME("panel")); - } else { - style = get_theme_stylebox(SNAME("panel"), SNAME("PanelContainer")); - } + if (has_theme_stylebox(SNAME("panel"))) { + style = get_theme_stylebox(SNAME("panel")); + } else { + style = get_theme_stylebox(SNAME("panel"), SNAME("PanelContainer")); + } - Size2 size = get_size(); - Point2 ofs; - if (style.is_valid()) { - size -= style->get_minimum_size(); - ofs += style->get_offset(); - } + style->draw(ci, Rect2(Point2(), get_size())); + } break; - for (int i = 0; i < get_child_count(); i++) { - Control *c = Object::cast_to<Control>(get_child(i)); - if (!c || !c->is_visible_in_tree()) { - continue; + case NOTIFICATION_SORT_CHILDREN: { + Ref<StyleBox> style; + + if (has_theme_stylebox(SNAME("panel"))) { + style = get_theme_stylebox(SNAME("panel")); + } else { + style = get_theme_stylebox(SNAME("panel"), SNAME("PanelContainer")); } - if (c->is_set_as_top_level()) { - continue; + + Size2 size = get_size(); + Point2 ofs; + if (style.is_valid()) { + size -= style->get_minimum_size(); + ofs += style->get_offset(); } - fit_child_in_rect(c, Rect2(ofs, size)); - } + for (int i = 0; i < get_child_count(); i++) { + Control *c = Object::cast_to<Control>(get_child(i)); + if (!c || !c->is_visible_in_tree()) { + continue; + } + if (c->is_set_as_top_level()) { + continue; + } + + fit_child_in_rect(c, Rect2(ofs, size)); + } + } break; } } |