diff options
author | Rindbee <idleman@yeah.net> | 2022-08-13 13:46:07 +0800 |
---|---|---|
committer | 风青山 <idleman@yeah.net> | 2024-01-18 22:57:22 +0800 |
commit | f29a7d302e0de7eb4b10f57c849d369210c1be55 (patch) | |
tree | 28554abc3f53ad2f7e4e51b9989c1a3d3ca23e75 /scene/gui/option_button.cpp | |
parent | 107f2961ccfac179af7682eb5f6e7ea91e80040c (diff) | |
download | redot-engine-f29a7d302e0de7eb4b10f57c849d369210c1be55.tar.gz |
Make the drawing logic clearer in `Button`
The drawing logic follows the calculation logic in `Button::get_minimum_size`.
According to the order of `stylebox`, `icon`, and `text`, and follow properties
such as alignment mode, to fill the display space of the button.
Add a `Button::_set_h_separation_is_valid_when_no_text` for Button derived
classes (like `OptionButton`) that expects a `h_separation` between `icon`
and theme icon even if the `text` is empty.
Diffstat (limited to 'scene/gui/option_button.cpp')
-rw-r--r-- | scene/gui/option_button.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index 6386bb20c3..45cc9623be 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -60,7 +60,7 @@ Size2 OptionButton::get_minimum_size() const { } if (has_theme_icon(SNAME("arrow"))) { - const Size2 padding = theme_cache.normal->get_minimum_size(); + const Size2 padding = _get_current_stylebox()->get_minimum_size(); const Size2 arrow_size = theme_cache.arrow_icon->get_size(); Size2 content_size = minsize - padding; @@ -605,6 +605,8 @@ void OptionButton::set_disable_shortcuts(bool p_disabled) { OptionButton::OptionButton(const String &p_text) : Button(p_text) { + _set_h_separation_is_valid_when_no_text(true); + set_toggle_mode(true); set_process_shortcut_input(true); set_text_alignment(HORIZONTAL_ALIGNMENT_LEFT); |