Change if to switch in OptionButton
This commit is contained in:
parent
639127de09
commit
dfecd62235
|
@ -43,40 +43,43 @@ Size2 OptionButton::get_minimum_size() const {
|
||||||
|
|
||||||
void OptionButton::_notification(int p_what) {
|
void OptionButton::_notification(int p_what) {
|
||||||
|
|
||||||
if (p_what == NOTIFICATION_DRAW) {
|
switch (p_what) {
|
||||||
|
case NOTIFICATION_DRAW: {
|
||||||
|
|
||||||
if (!has_icon("arrow"))
|
if (!has_icon("arrow"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RID ci = get_canvas_item();
|
RID ci = get_canvas_item();
|
||||||
Ref<Texture> arrow = Control::get_icon("arrow");
|
Ref<Texture> arrow = Control::get_icon("arrow");
|
||||||
Ref<StyleBox> normal = get_stylebox("normal");
|
Ref<StyleBox> normal = get_stylebox("normal");
|
||||||
Color clr = Color(1, 1, 1);
|
Color clr = Color(1, 1, 1);
|
||||||
if (get_constant("modulate_arrow")) {
|
if (get_constant("modulate_arrow")) {
|
||||||
switch (get_draw_mode()) {
|
switch (get_draw_mode()) {
|
||||||
case DRAW_PRESSED:
|
case DRAW_PRESSED:
|
||||||
clr = get_color("font_color_pressed");
|
clr = get_color("font_color_pressed");
|
||||||
break;
|
break;
|
||||||
case DRAW_HOVER:
|
case DRAW_HOVER:
|
||||||
clr = get_color("font_color_hover");
|
clr = get_color("font_color_hover");
|
||||||
break;
|
break;
|
||||||
case DRAW_DISABLED:
|
case DRAW_DISABLED:
|
||||||
clr = get_color("font_color_disabled");
|
clr = get_color("font_color_disabled");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
clr = get_color("font_color");
|
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)));
|
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);
|
arrow->draw(ci, ofs, clr);
|
||||||
} else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
|
} break;
|
||||||
|
case NOTIFICATION_VISIBILITY_CHANGED: {
|
||||||
|
|
||||||
if (!is_visible_in_tree()) {
|
if (!is_visible_in_tree()) {
|
||||||
popup->hide();
|
popup->hide();
|
||||||
}
|
}
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue