Merge pull request #93285 from rune-scape/listen-for-changes

More GUI nodes listening for texture changes
This commit is contained in:
Rémi Verschelde 2024-11-29 22:45:39 +01:00
commit abf9eb5903
No known key found for this signature in database
GPG Key ID: C3336907360768E1
3 changed files with 18 additions and 1 deletions

View File

@ -2482,11 +2482,27 @@ bool LineEdit::is_drag_and_drop_selection_enabled() const {
return drag_and_drop_selection_enabled; 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) { void LineEdit::set_right_icon(const Ref<Texture2D> &p_icon) {
if (right_icon == p_icon) { if (right_icon == p_icon) {
return; return;
} }
if (right_icon.is_valid()) {
right_icon->disconnect_changed(callable_mp(this, &LineEdit::_texture_changed));
}
right_icon = p_icon; right_icon = p_icon;
if (right_icon.is_valid()) {
right_icon->connect_changed(callable_mp(this, &LineEdit::_texture_changed));
}
_fit_to_width(); _fit_to_width();
update_minimum_size(); update_minimum_size();
queue_redraw(); queue_redraw();

View File

@ -248,6 +248,7 @@ private:
void _move_caret_end(bool p_select); void _move_caret_end(bool p_select);
void _backspace(bool p_word = false, bool p_all_to_left = false); 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 _delete(bool p_word = false, bool p_all_to_right = false);
void _texture_changed();
protected: protected:
bool _is_over_clear_button(const Point2 &p_pos) const; bool _is_over_clear_button(const Point2 &p_pos) const;

View File

@ -343,7 +343,7 @@ Ref<Texture2D> TextureButton::get_texture_focused() const {
} }
void TextureButton::set_texture_focused(const Ref<Texture2D> &p_focused) { 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) { void TextureButton::_set_texture(Ref<Texture2D> *p_destination, const Ref<Texture2D> &p_texture) {