Deprecate updown icon

This commit is contained in:
kobewi 2025-07-17 22:12:42 +02:00
parent f92f1ce9c0
commit 917f8b1ba8
3 changed files with 19 additions and 9 deletions

View file

@ -399,7 +399,9 @@ inline void SpinBox::_compute_sizes() {
inline int SpinBox::_get_widest_button_icon_width() {
int max = 0;
#ifndef DISABLE_DEPRECATED
max = MAX(max, theme_cache.updown_icon->get_width());
#endif
max = MAX(max, theme_cache.up_icon->get_width());
max = MAX(max, theme_cache.up_hover_icon->get_width());
max = MAX(max, theme_cache.up_pressed_icon->get_width());
@ -417,7 +419,6 @@ void SpinBox::_notification(int p_what) {
_update_text(true);
_compute_sizes();
RID ci = get_canvas_item();
Size2i size = get_size();
Ref<StyleBox> up_stylebox = theme_cache.up_base_stylebox;
@ -457,9 +458,6 @@ void SpinBox::_notification(int p_what) {
down_icon_modulate = theme_cache.down_hover_icon_modulate;
}
int updown_icon_left = sizing_cache.buttons_left + (sizing_cache.buttons_width - theme_cache.updown_icon->get_width()) / 2;
int updown_icon_top = (size.height - theme_cache.updown_icon->get_height()) / 2;
// Compute center icon positions once we know which one is used.
int up_icon_left = sizing_cache.buttons_left + (sizing_cache.buttons_width - up_icon->get_width()) / 2;
int up_icon_top = (sizing_cache.button_up_height - up_icon->get_height()) / 2;
@ -474,8 +472,16 @@ void SpinBox::_notification(int p_what) {
draw_style_box(up_stylebox, Rect2(sizing_cache.buttons_left, 0, sizing_cache.buttons_width, sizing_cache.button_up_height));
draw_style_box(down_stylebox, Rect2(sizing_cache.buttons_left, sizing_cache.second_button_top, sizing_cache.buttons_width, sizing_cache.button_down_height));
#ifndef DISABLE_DEPRECATED
if (theme_cache.is_updown_assigned) {
int updown_icon_left = sizing_cache.buttons_left + (sizing_cache.buttons_width - theme_cache.updown_icon->get_width()) / 2;
int updown_icon_top = (size.height - theme_cache.updown_icon->get_height()) / 2;
theme_cache.updown_icon->draw(get_canvas_item(), Point2i(updown_icon_left, updown_icon_top));
break; // If updown is a valid texture, skip other arrows (for compatibility).
}
#endif
// Draw arrows.
theme_cache.updown_icon->draw(ci, Point2i(updown_icon_left, updown_icon_top));
draw_texture(up_icon, Point2i(up_icon_left, up_icon_top), up_icon_modulate);
draw_texture(down_icon, Point2i(down_icon_left, down_icon_top), down_icon_modulate);
@ -503,6 +509,9 @@ void SpinBox::_notification(int p_what) {
} break;
case NOTIFICATION_THEME_CHANGED: {
#ifndef DISABLE_DEPRECATED
theme_cache.is_updown_assigned = !theme_cache.updown_icon->get_size().is_zero_approx();
#endif
callable_mp((Control *)this, &Control::update_minimum_size).call_deferred();
callable_mp((Control *)get_line_edit(), &Control::update_minimum_size).call_deferred();
} break;
@ -647,9 +656,9 @@ void SpinBox::_bind_methods() {
BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, SpinBox, buttons_width);
#ifndef DISABLE_DEPRECATED
BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, SpinBox, set_min_buttons_width_from_icons);
#endif
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_ICON, SpinBox, updown_icon, "updown");
#endif
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_ICON, SpinBox, up_icon, "up");
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_ICON, SpinBox, up_hover_icon, "up_hover");
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_ICON, SpinBox, up_pressed_icon, "up_pressed");