mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
Improve SpinBox interaction, split arrows, add theme attributes
This commit is contained in:
parent
739019e4e4
commit
e371587147
12 changed files with 460 additions and 28 deletions
|
|
@ -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;
|
||||
|
||||
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_focus_enter();
|
||||
void _line_edit_focus_exit();
|
||||
|
||||
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;
|
||||
int set_min_buttons_width_from_icons = 0;
|
||||
|
||||
} 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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue