Skip to content

Commit

Permalink
various gui nodes now listen for the changed signal on textures
Browse files Browse the repository at this point in the history
  • Loading branch information
rune-scape committed Nov 8, 2024
1 parent b00e1cb commit dd1372b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions scene/gui/line_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2482,11 +2482,27 @@ bool LineEdit::is_drag_and_drop_selection_enabled() const {
return drag_and_drop_selection_enabled;
}

void LineEdit::_texture_changed() {
_fit_to_width();
update_minimum_size();
queue_redraw();
}

void LineEdit::set_right_icon(const Ref<Texture2D> &p_icon) {
if (right_icon == p_icon) {
return;
}

if (right_icon.is_valid()) {
right_icon->disconnect_changed(callable_mp(this, &LineEdit::_texture_changed));
}

right_icon = p_icon;

if (right_icon.is_valid()) {
right_icon->connect_changed(callable_mp(this, &LineEdit::_texture_changed));
}

_fit_to_width();
update_minimum_size();
queue_redraw();
Expand Down
1 change: 1 addition & 0 deletions scene/gui/line_edit.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ class LineEdit : public Control {
void _move_caret_end(bool p_select);
void _backspace(bool p_word = false, bool p_all_to_left = false);
void _delete(bool p_word = false, bool p_all_to_right = false);
void _texture_changed();

protected:
bool _is_over_clear_button(const Point2 &p_pos) const;
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/texture_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ Ref<Texture2D> TextureButton::get_texture_focused() const {
}

void TextureButton::set_texture_focused(const Ref<Texture2D> &p_focused) {
focused = p_focused;
_set_texture(&focused, p_focused);
}

void TextureButton::_set_texture(Ref<Texture2D> *p_destination, const Ref<Texture2D> &p_texture) {
Expand Down

0 comments on commit dd1372b

Please sign in to comment.