Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update size or size cache when toggling expand_icon in Button #75958

Merged
merged 1 commit into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions scene/gui/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ void Button::_set_internal_margin(Side p_side, float p_value) {
_internal_margin[p_side] = p_value;
}

void Button::_queue_update_size_cache() {
}

void Button::_update_theme_item_cache() {
BaseButton::_update_theme_item_cache();

Expand Down Expand Up @@ -544,6 +547,7 @@ Ref<Texture2D> Button::get_icon() const {
void Button::set_expand_icon(bool p_enabled) {
if (expand_icon != p_enabled) {
expand_icon = p_enabled;
_queue_update_size_cache();
queue_redraw();
update_minimum_size();
}
Expand Down
1 change: 1 addition & 0 deletions scene/gui/button.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class Button : public BaseButton {
protected:
void _set_internal_margin(Side p_side, float p_value);
virtual void _update_theme_item_cache() override;
virtual void _queue_update_size_cache();
void _notification(int p_what);
static void _bind_methods();

Expand Down
14 changes: 7 additions & 7 deletions scene/gui/option_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ bool OptionButton::_set(const StringName &p_name, const Variant &p_value) {
}

if (property == "text" || property == "icon") {
_queue_refresh_cache();
_queue_update_size_cache();
}

return valid;
Expand Down Expand Up @@ -243,7 +243,7 @@ void OptionButton::add_icon_item(const Ref<Texture2D> &p_icon, const String &p_l
if (first_selectable) {
select(get_item_count() - 1);
}
_queue_refresh_cache();
_queue_update_size_cache();
}

void OptionButton::add_item(const String &p_label, int p_id) {
Expand All @@ -252,7 +252,7 @@ void OptionButton::add_item(const String &p_label, int p_id) {
if (first_selectable) {
select(get_item_count() - 1);
}
_queue_refresh_cache();
_queue_update_size_cache();
}

void OptionButton::set_item_text(int p_idx, const String &p_text) {
Expand All @@ -261,7 +261,7 @@ void OptionButton::set_item_text(int p_idx, const String &p_text) {
if (current == p_idx) {
set_text(p_text);
}
_queue_refresh_cache();
_queue_update_size_cache();
}

void OptionButton::set_item_icon(int p_idx, const Ref<Texture2D> &p_icon) {
Expand All @@ -270,7 +270,7 @@ void OptionButton::set_item_icon(int p_idx, const Ref<Texture2D> &p_icon) {
if (current == p_idx) {
set_icon(p_icon);
}
_queue_refresh_cache();
_queue_update_size_cache();
}

void OptionButton::set_item_id(int p_idx, int p_id) {
Expand Down Expand Up @@ -456,7 +456,7 @@ void OptionButton::_refresh_size_cache() {
update_minimum_size();
}

void OptionButton::_queue_refresh_cache() {
void OptionButton::_queue_update_size_cache() {
if (cache_refresh_pending) {
return;
}
Expand Down Expand Up @@ -490,7 +490,7 @@ void OptionButton::remove_item(int p_idx) {
if (current == p_idx) {
_select(NONE_SELECTED);
}
_queue_refresh_cache();
_queue_update_size_cache();
}

PopupMenu *OptionButton::get_popup() const {
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/option_button.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ class OptionButton : public Button {
void _select(int p_which, bool p_emit = false);
void _select_int(int p_which);
void _refresh_size_cache();
void _queue_refresh_cache();

virtual void pressed() override;

protected:
Size2 get_minimum_size() const override;
virtual void _update_theme_item_cache() override;
virtual void _queue_update_size_cache() override;
void _notification(int p_what);
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
Expand Down