Use switch consistently in _notification (scene folder)

This commit is contained in:
Rémi Verschelde 2022-02-15 18:06:48 +01:00
parent 171021145d
commit 0f5455230c
No known key found for this signature in database
GPG key ID: C3336907360768E1
127 changed files with 2853 additions and 2601 deletions

View file

@ -79,46 +79,48 @@ Vector<int> PanelContainer::get_allowed_size_flags_vertical() const {
}
void PanelContainer::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
RID ci = get_canvas_item();
Ref<StyleBox> style;
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"));
}
style->draw(ci, Rect2(Point2(), get_size()));
}
if (p_what == 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"));
}
Size2 size = get_size();
Point2 ofs;
if (style.is_valid()) {
size -= style->get_minimum_size();
ofs += style->get_offset();
}
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;
if (has_theme_stylebox(SNAME("panel"))) {
style = get_theme_stylebox(SNAME("panel"));
} else {
style = get_theme_stylebox(SNAME("panel"), SNAME("PanelContainer"));
}
fit_child_in_rect(c, Rect2(ofs, size));
}
style->draw(ci, Rect2(Point2(), get_size()));
} break;
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"));
}
Size2 size = get_size();
Point2 ofs;
if (style.is_valid()) {
size -= style->get_minimum_size();
ofs += style->get_offset();
}
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;
}
}