summaryrefslogtreecommitdiff
path: root/scene/gui/control.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/control.cpp')
-rw-r--r--scene/gui/control.cpp224
1 files changed, 149 insertions, 75 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 02be8f23fb..96aaec6ae9 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -160,8 +160,9 @@ Size2 Control::_edit_get_minimum_size() const {
#endif
void Control::set_custom_minimum_size(const Size2 &p_custom) {
- if (p_custom == data.custom_minimum_size)
+ if (p_custom == data.custom_minimum_size) {
return;
+ }
data.custom_minimum_size = p_custom;
minimum_size_changed();
}
@@ -176,14 +177,16 @@ void Control::_update_minimum_size_cache() {
minsize.y = MAX(minsize.y, data.custom_minimum_size.y);
bool size_changed = false;
- if (data.minimum_size_cache != minsize)
+ if (data.minimum_size_cache != minsize) {
size_changed = true;
+ }
data.minimum_size_cache = minsize;
data.minimum_size_valid = true;
- if (size_changed)
+ if (size_changed) {
minimum_size_changed();
+ }
}
Size2 Control::get_combined_minimum_size() const {
@@ -245,8 +248,9 @@ bool Control::_set(const StringName &p_name, const Variant &p_value) {
String dname = name.get_slicec('/', 1);
data.constant_override.erase(dname);
notification(NOTIFICATION_THEME_CHANGED);
- } else
+ } else {
return false;
+ }
} else {
if (name.begins_with("custom_icons/")) {
@@ -267,15 +271,17 @@ bool Control::_set(const StringName &p_name, const Variant &p_value) {
} else if (name.begins_with("custom_constants/")) {
String dname = name.get_slicec('/', 1);
add_theme_constant_override(dname, p_value);
- } else
+ } else {
return false;
+ }
}
return true;
}
void Control::_update_minimum_size() {
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
Size2 minsize = get_combined_minimum_size();
if (minsize.x > data.size_cache.x ||
@@ -321,8 +327,9 @@ bool Control::_get(const StringName &p_name, Variant &r_ret) const {
String name = sname.get_slicec('/', 1);
r_ret = data.constant_override.has(name) ? Variant(data.constant_override[name]) : Variant();
- } else
+ } else {
return false;
+ }
return true;
}
@@ -343,8 +350,9 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const {
theme->get_icon_list(get_class_name(), &names);
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE;
- if (data.icon_override.has(E->get()))
+ if (data.icon_override.has(E->get())) {
hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
+ }
p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_icons/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", hint));
}
@@ -354,8 +362,9 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const {
theme->get_shader_list(get_class_name(), &names);
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE;
- if (data.shader_override.has(E->get()))
+ if (data.shader_override.has(E->get())) {
hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
+ }
p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_shaders/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "Shader,VisualShader", hint));
}
@@ -365,8 +374,9 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const {
theme->get_stylebox_list(get_class_name(), &names);
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE;
- if (data.style_override.has(E->get()))
+ if (data.style_override.has(E->get())) {
hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
+ }
p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_styles/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "StyleBox", hint));
}
@@ -376,8 +386,9 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const {
theme->get_font_list(get_class_name(), &names);
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE;
- if (data.font_override.has(E->get()))
+ if (data.font_override.has(E->get())) {
hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
+ }
p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_fonts/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "Font", hint));
}
@@ -387,8 +398,9 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const {
theme->get_color_list(get_class_name(), &names);
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE;
- if (data.color_override.has(E->get()))
+ if (data.color_override.has(E->get())) {
hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
+ }
p_list->push_back(PropertyInfo(Variant::COLOR, "custom_colors/" + E->get(), PROPERTY_HINT_NONE, "", hint));
}
@@ -398,8 +410,9 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const {
theme->get_constant_list(get_class_name(), &names);
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE;
- if (data.constant_override.has(E->get()))
+ if (data.constant_override.has(E->get())) {
hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
+ }
p_list->push_back(PropertyInfo(Variant::INT, "custom_constants/" + E->get(), PROPERTY_HINT_RANGE, "-16384,16384", hint));
}
@@ -474,8 +487,9 @@ void Control::_notification(int p_notification) {
while (parent) {
parent = parent->get_parent();
- if (!parent)
+ if (!parent) {
break;
+ }
CanvasItem *ci = Object::cast_to<CanvasItem>(parent);
if (ci && ci->is_set_as_toplevel()) {
@@ -534,8 +548,9 @@ void Control::_notification(int p_notification) {
case NOTIFICATION_MOVED_IN_PARENT: {
// some parents need to know the order of the childrens to draw (like TabContainer)
// update if necessary
- if (data.parent)
+ if (data.parent) {
data.parent->update();
+ }
update();
if (data.RI) {
@@ -574,8 +589,9 @@ void Control::_notification(int p_notification) {
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
if (!is_visible_in_tree()) {
- if (get_viewport() != nullptr)
+ if (get_viewport() != nullptr) {
get_viewport()->_gui_hid_control(this);
+ }
//remove key focus
@@ -613,10 +629,11 @@ bool Control::has_point(const Point2 &p_point) const {
}
void Control::set_drag_forwarding(Control *p_target) {
- if (p_target)
+ if (p_target) {
data.drag_owner = p_target->get_instance_id();
- else
+ } else {
data.drag_owner = ObjectID();
+ }
}
Variant Control::get_drag_data(const Point2 &p_point) {
@@ -633,8 +650,9 @@ Variant Control::get_drag_data(const Point2 &p_point) {
const Variant *p = &v;
Callable::CallError ce;
Variant ret = get_script_instance()->call(SceneStringNames::get_singleton()->get_drag_data, &p, 1, ce);
- if (ce.error == Callable::CallError::CALL_OK)
+ if (ce.error == Callable::CallError::CALL_OK) {
return ret;
+ }
}
return Variant();
@@ -654,8 +672,9 @@ bool Control::can_drop_data(const Point2 &p_point, const Variant &p_data) const
const Variant *p[2] = { &v, &p_data };
Callable::CallError ce;
Variant ret = get_script_instance()->call(SceneStringNames::get_singleton()->can_drop_data, p, 2, ce);
- if (ce.error == Callable::CallError::CALL_OK)
+ if (ce.error == Callable::CallError::CALL_OK) {
return ret;
+ }
}
return Variant();
@@ -676,8 +695,9 @@ void Control::drop_data(const Point2 &p_point, const Variant &p_data) {
const Variant *p[2] = { &v, &p_data };
Callable::CallError ce;
Variant ret = get_script_instance()->call(SceneStringNames::get_singleton()->drop_data, p, 2, ce);
- if (ce.error == Callable::CallError::CALL_OK)
+ if (ce.error == Callable::CallError::CALL_OK) {
return;
+ }
}
}
@@ -699,8 +719,9 @@ Size2 Control::get_minimum_size() const {
if (si) {
Callable::CallError ce;
Variant s = si->call(SceneStringNames::get_singleton()->_get_minimum_size, nullptr, 0, ce);
- if (ce.error == Callable::CallError::CALL_OK)
+ if (ce.error == Callable::CallError::CALL_OK) {
return s;
+ }
}
return Size2();
}
@@ -793,8 +814,9 @@ bool Control::_has_theme_item(Control *p_theme_owner, Window *p_theme_owner_wind
Ref<Texture2D> Control::get_theme_icon(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
const Ref<Texture2D> *tex = data.icon_override.getptr(p_name);
- if (tex)
+ if (tex) {
return *tex;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -821,8 +843,9 @@ Ref<Texture2D> Control::get_icons(Control *p_theme_owner, Window *p_theme_owner_
Ref<Shader> Control::get_theme_shader(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
const Ref<Shader> *sdr = data.shader_override.getptr(p_name);
- if (sdr)
+ if (sdr) {
return *sdr;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -849,8 +872,9 @@ Ref<Shader> Control::get_shaders(Control *p_theme_owner, Window *p_theme_owner_w
Ref<StyleBox> Control::get_theme_stylebox(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
const Ref<StyleBox> *style = data.style_override.getptr(p_name);
- if (style)
+ if (style) {
return *style;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -877,8 +901,9 @@ Ref<StyleBox> Control::get_styleboxs(Control *p_theme_owner, Window *p_theme_own
Ref<Font> Control::get_theme_font(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
const Ref<Font> *font = data.font_override.getptr(p_name);
- if (font)
+ if (font) {
return *font;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -905,8 +930,9 @@ Ref<Font> Control::get_fonts(Control *p_theme_owner, Window *p_theme_owner_windo
Color Control::get_theme_color(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
const Color *color = data.color_override.getptr(p_name);
- if (color)
+ if (color) {
return *color;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -932,8 +958,9 @@ Color Control::get_colors(Control *p_theme_owner, Window *p_theme_owner_window,
int Control::get_theme_constant(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
const int *constant = data.constant_override.getptr(p_name);
- if (constant)
+ if (constant) {
return *constant;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -988,8 +1015,9 @@ bool Control::has_theme_constant_override(const StringName &p_name) const {
bool Control::has_theme_icon(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
- if (has_theme_icon_override(p_name))
+ if (has_theme_icon_override(p_name)) {
return true;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -1012,8 +1040,9 @@ bool Control::has_icons(Control *p_theme_owner, Window *p_theme_owner_window, co
bool Control::has_theme_shader(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
- if (has_theme_shader_override(p_name))
+ if (has_theme_shader_override(p_name)) {
return true;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -1036,8 +1065,9 @@ bool Control::has_shaders(Control *p_theme_owner, Window *p_theme_owner_window,
bool Control::has_theme_stylebox(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
- if (has_theme_stylebox_override(p_name))
+ if (has_theme_stylebox_override(p_name)) {
return true;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -1060,8 +1090,9 @@ bool Control::has_styleboxs(Control *p_theme_owner, Window *p_theme_owner_window
bool Control::has_theme_font(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
- if (has_theme_font_override(p_name))
+ if (has_theme_font_override(p_name)) {
return true;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -1084,8 +1115,9 @@ bool Control::has_fonts(Control *p_theme_owner, Window *p_theme_owner_window, co
bool Control::has_theme_color(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
- if (has_theme_color_override(p_name))
+ if (has_theme_color_override(p_name)) {
return true;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -1108,8 +1140,9 @@ bool Control::has_colors(Control *p_theme_owner, Window *p_theme_owner_window, c
bool Control::has_theme_constant(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
- if (has_theme_constant_override(p_name))
+ if (has_theme_constant_override(p_name)) {
return true;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -1131,8 +1164,9 @@ bool Control::has_constants(Control *p_theme_owner, Window *p_theme_owner_window
}
Rect2 Control::get_parent_anchorable_rect() const {
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return Rect2();
+ }
Rect2 parent_rect;
if (data.parent_canvas_item) {
@@ -1623,10 +1657,12 @@ void Control::_set_size(const Size2 &p_size) {
void Control::set_size(const Size2 &p_size, bool p_keep_margins) {
Size2 new_size = p_size;
Size2 min = get_combined_minimum_size();
- if (new_size.x < min.x)
+ if (new_size.x < min.x) {
new_size.x = min.x;
- if (new_size.y < min.y)
+ }
+ if (new_size.y < min.y) {
new_size.y = min.y;
+ }
if (p_keep_margins) {
_compute_anchors(Rect2(data.pos_cache, new_size), data.margin, data.anchor);
@@ -1761,15 +1797,17 @@ void Control::add_theme_constant_override(const StringName &p_name, int p_consta
void Control::set_focus_mode(FocusMode p_focus_mode) {
ERR_FAIL_INDEX((int)p_focus_mode, 3);
- if (is_inside_tree() && p_focus_mode == FOCUS_NONE && data.focus_mode != FOCUS_NONE && has_focus())
+ if (is_inside_tree() && p_focus_mode == FOCUS_NONE && data.focus_mode != FOCUS_NONE && has_focus()) {
release_focus();
+ }
data.focus_mode = p_focus_mode;
}
static Control *_next_control(Control *p_from) {
- if (p_from->is_set_as_toplevel())
+ if (p_from->is_set_as_toplevel()) {
return nullptr; // can't go above
+ }
Control *parent = Object::cast_to<Control>(p_from->get_parent());
@@ -1781,8 +1819,9 @@ static Control *_next_control(Control *p_from) {
ERR_FAIL_INDEX_V(next, parent->get_child_count(), nullptr);
for (int i = (next + 1); i < parent->get_child_count(); i++) {
Control *c = Object::cast_to<Control>(parent->get_child(i));
- if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel())
+ if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) {
continue;
+ }
return c;
}
@@ -1806,8 +1845,9 @@ Control *Control::find_next_valid_focus() const {
} else {
return nullptr;
}
- if (c->is_visible() && c->get_focus_mode() != FOCUS_NONE)
+ if (c->is_visible() && c->get_focus_mode() != FOCUS_NONE) {
return c;
+ }
}
// find next child
@@ -1835,22 +1875,26 @@ Control *Control::find_next_valid_focus() const {
if (!next_child) {
next_child = const_cast<Control *>(this);
while (next_child) {
- if (next_child->data.RI)
+ if (next_child->data.RI) {
break;
+ }
next_child = next_child->get_parent_control();
}
}
}
}
- if (next_child == this) // no next control->
+ if (next_child == this) { // no next control->
return (get_focus_mode() == FOCUS_ALL) ? next_child : nullptr;
+ }
if (next_child) {
- if (next_child->get_focus_mode() == FOCUS_ALL)
+ if (next_child->get_focus_mode() == FOCUS_ALL) {
return next_child;
+ }
from = next_child;
- } else
+ } else {
break;
+ }
}
return nullptr;
@@ -1860,15 +1904,17 @@ static Control *_prev_control(Control *p_from) {
Control *child = nullptr;
for (int i = p_from->get_child_count() - 1; i >= 0; i--) {
Control *c = Object::cast_to<Control>(p_from->get_child(i));
- if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel())
+ if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) {
continue;
+ }
child = c;
break;
}
- if (!child)
+ if (!child) {
return p_from;
+ }
//no prev in parent, try the same in parent
return _prev_control(child);
@@ -1889,8 +1935,9 @@ Control *Control::find_prev_valid_focus() const {
} else {
return nullptr;
}
- if (c->is_visible() && c->get_focus_mode() != FOCUS_NONE)
+ if (c->is_visible() && c->get_focus_mode() != FOCUS_NONE) {
return c;
+ }
}
// find prev child
@@ -1921,11 +1968,13 @@ Control *Control::find_prev_valid_focus() const {
}
}
- if (prev_child == this) // no prev control->
+ if (prev_child == this) { // no prev control->
return (get_focus_mode() == FOCUS_ALL) ? prev_child : nullptr;
+ }
- if (prev_child->get_focus_mode() == FOCUS_ALL)
+ if (prev_child->get_focus_mode() == FOCUS_ALL) {
return prev_child;
+ }
from = prev_child;
}
@@ -1955,8 +2004,9 @@ void Control::grab_focus() {
void Control::release_focus() {
ERR_FAIL_COND(!is_inside_tree());
- if (!has_focus())
+ if (!has_focus()) {
return;
+ }
get_viewport()->_gui_remove_focus();
update();
@@ -1969,13 +2019,15 @@ bool Control::is_toplevel_control() const {
void Control::_propagate_theme_changed(Node *p_at, Control *p_owner, Window *p_owner_window, bool p_assign) {
Control *c = Object::cast_to<Control>(p_at);
- if (c && c != p_owner && c->data.theme.is_valid()) // has a theme, this can't be propagated
+ if (c && c != p_owner && c->data.theme.is_valid()) { // has a theme, this can't be propagated
return;
+ }
Window *w = c == nullptr ? Object::cast_to<Window>(p_at) : nullptr;
- if (w && w != p_owner_window && w->theme.is_valid()) // has a theme, this can't be propagated
+ if (w && w != p_owner_window && w->theme.is_valid()) { // has a theme, this can't be propagated
return;
+ }
for (int i = 0; i < p_at->get_child_count(); i++) {
CanvasItem *child = Object::cast_to<CanvasItem>(p_at->get_child(i));
@@ -2013,8 +2065,9 @@ void Control::_theme_changed() {
}
void Control::set_theme(const Ref<Theme> &p_theme) {
- if (data.theme == p_theme)
+ if (data.theme == p_theme) {
return;
+ }
if (data.theme.is_valid()) {
data.theme->disconnect("changed", callable_mp(this, &Control::_theme_changed));
@@ -2046,8 +2099,9 @@ void Control::set_theme(const Ref<Theme> &p_theme) {
}
void Control::accept_event() {
- if (is_inside_tree())
+ if (is_inside_tree()) {
get_viewport()->_gui_accept_event();
+ }
}
Ref<Theme> Control::get_theme() const {
@@ -2125,8 +2179,9 @@ NodePath Control::get_focus_previous() const {
Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) {
ERR_FAIL_INDEX_V((int)p_margin, 4, nullptr);
- if (p_count >= MAX_NEIGHBOUR_SEARCH_COUNT)
+ if (p_count >= MAX_NEIGHBOUR_SEARCH_COUNT) {
return nullptr;
+ }
if (!data.focus_neighbour[p_margin].is_empty()) {
Control *c = nullptr;
Node *n = get_node(data.focus_neighbour[p_margin]);
@@ -2137,12 +2192,15 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) {
return nullptr;
}
bool valid = true;
- if (!c->is_visible())
+ if (!c->is_visible()) {
valid = false;
- if (c->get_focus_mode() == FOCUS_NONE)
+ }
+ if (c->get_focus_mode() == FOCUS_NONE) {
valid = false;
- if (valid)
+ }
+ if (valid) {
return c;
+ }
c = c->_get_focus_neighbour(p_margin, p_count + 1);
return c;
@@ -2173,8 +2231,9 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) {
for (int i = 0; i < 4; i++) {
float d = vdir.dot(points[i]);
- if (d > maxd)
+ if (d > maxd) {
maxd = d;
+ }
}
Node *base = this;
@@ -2182,14 +2241,16 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) {
while (base) {
Control *c = Object::cast_to<Control>(base);
if (c) {
- if (c->data.RI)
+ if (c->data.RI) {
break;
+ }
}
base = base->get_parent();
}
- if (!base)
+ if (!base) {
return nullptr;
+ }
_window_find_focus_neighbour(vdir, base, points, maxd, dist, &result);
@@ -2197,8 +2258,9 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) {
}
void Control::_window_find_focus_neighbour(const Vector2 &p_dir, Node *p_at, const Point2 *p_points, float p_min, float &r_closest_dist, Control **r_closest) {
- if (Object::cast_to<Viewport>(p_at))
+ if (Object::cast_to<Viewport>(p_at)) {
return; //bye
+ }
Control *c = Object::cast_to<Control>(p_at);
@@ -2216,8 +2278,9 @@ void Control::_window_find_focus_neighbour(const Vector2 &p_dir, Node *p_at, con
for (int i = 0; i < 4; i++) {
float d = p_dir.dot(points[i]);
- if (d < min)
+ if (d < min) {
min = d;
+ }
}
if (min > (p_min - CMP_EPSILON)) {
@@ -2244,15 +2307,17 @@ void Control::_window_find_focus_neighbour(const Vector2 &p_dir, Node *p_at, con
for (int i = 0; i < p_at->get_child_count(); i++) {
Node *child = p_at->get_child(i);
Control *childc = Object::cast_to<Control>(child);
- if (childc && childc->data.RI)
+ if (childc && childc->data.RI) {
continue; //subwindow, ignore
+ }
_window_find_focus_neighbour(p_dir, p_at->get_child(i), p_points, p_min, r_closest_dist, r_closest);
}
}
void Control::set_h_size_flags(int p_flags) {
- if (data.h_size_flags == p_flags)
+ if (data.h_size_flags == p_flags) {
return;
+ }
data.h_size_flags = p_flags;
emit_signal(SceneStringNames::get_singleton()->size_flags_changed);
}
@@ -2262,15 +2327,17 @@ int Control::get_h_size_flags() const {
}
void Control::set_v_size_flags(int p_flags) {
- if (data.v_size_flags == p_flags)
+ if (data.v_size_flags == p_flags) {
return;
+ }
data.v_size_flags = p_flags;
emit_signal(SceneStringNames::get_singleton()->size_flags_changed);
}
void Control::set_stretch_ratio(float p_ratio) {
- if (data.expand == p_ratio)
+ if (data.expand == p_ratio) {
return;
+ }
data.expand = p_ratio;
emit_signal(SceneStringNames::get_singleton()->size_flags_changed);
@@ -2287,16 +2354,18 @@ void Control::grab_click_focus() {
}
void Control::minimum_size_changed() {
- if (!is_inside_tree() || data.block_minimum_size_adjust)
+ if (!is_inside_tree() || data.block_minimum_size_adjust) {
return;
+ }
Control *invalidate = this;
//invalidate cache upwards
while (invalidate && invalidate->data.minimum_size_valid) {
invalidate->data.minimum_size_valid = false;
- if (invalidate->is_set_as_toplevel())
+ if (invalidate->is_set_as_toplevel()) {
break; // do not go further up
+ }
if (!invalidate->data.parent && get_parent()) {
Window *parent_window = Object::cast_to<Window>(get_parent());
if (parent_window && parent_window->is_wrapping_controls()) {
@@ -2306,11 +2375,13 @@ void Control::minimum_size_changed() {
invalidate = invalidate->data.parent;
}
- if (!is_visible_in_tree())
+ if (!is_visible_in_tree()) {
return;
+ }
- if (data.updating_last_minimum_size)
+ if (data.updating_last_minimum_size) {
return;
+ }
data.updating_last_minimum_size = true;
@@ -2394,10 +2465,12 @@ Vector2 Control::get_pivot_offset() const {
void Control::set_scale(const Vector2 &p_scale) {
data.scale = p_scale;
// Avoid having 0 scale values, can lead to errors in physics and rendering.
- if (data.scale.x == 0)
+ if (data.scale.x == 0) {
data.scale.x = CMP_EPSILON;
- if (data.scale.y == 0)
+ }
+ if (data.scale.y == 0) {
data.scale.y = CMP_EPSILON;
+ }
update();
_notify_transform();
}
@@ -2415,8 +2488,9 @@ Control *Control::get_root_parent_control() const {
if (c) {
root = c;
- if (c->data.RI || c->is_toplevel_control())
+ if (c->data.RI || c->is_toplevel_control()) {
break;
+ }
}
ci = ci->get_parent_item();