diff options
Diffstat (limited to 'scene/gui/spin_box.h')
-rw-r--r-- | scene/gui/spin_box.h | 71 |
1 files changed, 66 insertions, 5 deletions
diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h index 4d49626d71..294dc3e5d5 100644 --- a/scene/gui/spin_box.h +++ b/scene/gui/spin_box.h @@ -39,12 +39,24 @@ class SpinBox : public Range { GDCLASS(SpinBox, Range); LineEdit *line_edit = nullptr; - int last_w = 0; bool update_on_text_changed = false; + struct SizingCache { + int buttons_block_width = 0; + int buttons_width = 0; + int buttons_vertical_separation = 0; + int buttons_left = 0; + int button_up_height = 0; + int button_down_height = 0; + int second_button_top = 0; + int buttons_separator_top = 0; + int field_and_buttons_separator_left = 0; + int field_and_buttons_separator_width = 0; + } sizing_cache; + Timer *range_click_timer = nullptr; void _range_click_timeout(); - void _release_mouse(); + void _release_mouse_from_drag_mode(); void _update_text(bool p_keep_line_edit = false); void _text_submitted(const String &p_string); @@ -65,17 +77,66 @@ class SpinBox : public Range { double diff_y = 0.0; } drag; - void _line_edit_focus_enter(); - void _line_edit_focus_exit(); + struct StateCache { + bool up_button_hovered = false; + bool up_button_pressed = false; + bool up_button_disabled = false; + bool down_button_hovered = false; + bool down_button_pressed = false; + bool down_button_disabled = false; + } state_cache; + + void _line_edit_editing_toggled(bool p_toggled_on); - inline void _adjust_width_for_icon(const Ref<Texture2D> &icon); + inline void _compute_sizes(); + inline int _get_widest_button_icon_width(); struct ThemeCache { Ref<Texture2D> updown_icon; + Ref<Texture2D> up_icon; + Ref<Texture2D> up_hover_icon; + Ref<Texture2D> up_pressed_icon; + Ref<Texture2D> up_disabled_icon; + Ref<Texture2D> down_icon; + Ref<Texture2D> down_hover_icon; + Ref<Texture2D> down_pressed_icon; + Ref<Texture2D> down_disabled_icon; + + Ref<StyleBox> up_base_stylebox; + Ref<StyleBox> up_hover_stylebox; + Ref<StyleBox> up_pressed_stylebox; + Ref<StyleBox> up_disabled_stylebox; + Ref<StyleBox> down_base_stylebox; + Ref<StyleBox> down_hover_stylebox; + Ref<StyleBox> down_pressed_stylebox; + Ref<StyleBox> down_disabled_stylebox; + + Color up_icon_modulate; + Color up_hover_icon_modulate; + Color up_pressed_icon_modulate; + Color up_disabled_icon_modulate; + Color down_icon_modulate; + Color down_hover_icon_modulate; + Color down_pressed_icon_modulate; + Color down_disabled_icon_modulate; + + Ref<StyleBox> field_and_buttons_separator; + Ref<StyleBox> up_down_buttons_separator; + + int buttons_vertical_separation = 0; + int field_and_buttons_separation = 0; + int buttons_width = 0; +#ifndef DISABLE_DEPRECATED + bool set_min_buttons_width_from_icons = false; +#endif } theme_cache; + void _mouse_exited(); + void _update_buttons_state_for_current_value(); + protected: virtual void gui_input(const Ref<InputEvent> &p_event) override; + void _value_changed(double p_value) override; void _notification(int p_what); static void _bind_methods(); |