summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNilsIrl <nils@nilsand.re>2019-07-29 16:21:54 +0200
committerNilsIrl <nils@nilsand.re>2019-07-29 16:47:47 +0200
commitdfecd62235af1209c11bfc359ef9338e4349f3f5 (patch)
tree4365105cb7e83f55df6cffe625260d51e385e0f3
parent639127de0967bf32b20dac9a54c4bba44d2786ad (diff)
Change if to switch in OptionButton
-rw-r--r--scene/gui/option_button.cpp63
1 files changed, 33 insertions, 30 deletions
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index 58671655dc..01ef98bfd9 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -43,40 +43,43 @@ Size2 OptionButton::get_minimum_size() const {
void OptionButton::_notification(int p_what) {
- if (p_what == NOTIFICATION_DRAW) {
-
- if (!has_icon("arrow"))
- return;
-
- RID ci = get_canvas_item();
- Ref<Texture> arrow = Control::get_icon("arrow");
- Ref<StyleBox> normal = get_stylebox("normal");
- Color clr = Color(1, 1, 1);
- if (get_constant("modulate_arrow")) {
- switch (get_draw_mode()) {
- case DRAW_PRESSED:
- clr = get_color("font_color_pressed");
- break;
- case DRAW_HOVER:
- clr = get_color("font_color_hover");
- break;
- case DRAW_DISABLED:
- clr = get_color("font_color_disabled");
- break;
- default:
- clr = get_color("font_color");
+ switch (p_what) {
+ case NOTIFICATION_DRAW: {
+
+ if (!has_icon("arrow"))
+ return;
+
+ RID ci = get_canvas_item();
+ Ref<Texture> arrow = Control::get_icon("arrow");
+ Ref<StyleBox> normal = get_stylebox("normal");
+ Color clr = Color(1, 1, 1);
+ if (get_constant("modulate_arrow")) {
+ switch (get_draw_mode()) {
+ case DRAW_PRESSED:
+ clr = get_color("font_color_pressed");
+ break;
+ case DRAW_HOVER:
+ clr = get_color("font_color_hover");
+ break;
+ case DRAW_DISABLED:
+ clr = get_color("font_color_disabled");
+ break;
+ default:
+ clr = get_color("font_color");
+ }
}
- }
- Size2 size = get_size();
+ Size2 size = get_size();
- Point2 ofs(size.width - arrow->get_width() - get_constant("arrow_margin"), int(Math::abs((size.height - arrow->get_height()) / 2)));
- arrow->draw(ci, ofs, clr);
- } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
+ Point2 ofs(size.width - arrow->get_width() - get_constant("arrow_margin"), int(Math::abs((size.height - arrow->get_height()) / 2)));
+ arrow->draw(ci, ofs, clr);
+ } break;
+ case NOTIFICATION_VISIBILITY_CHANGED: {
- if (!is_visible_in_tree()) {
- popup->hide();
- }
+ if (!is_visible_in_tree()) {
+ popup->hide();
+ }
+ } break;
}
}