diff options
| author | Ovnuniarchos | 2018-02-05 22:42:30 +0100 |
|---|---|---|
| committer | Ovnuniarchos | 2018-02-05 22:42:30 +0100 |
| commit | fe1ca3c6e649ac599029b71f4508f840fa91f208 (patch) | |
| tree | 72b4c8944790a964505b5f75b3d2b88267c5ee32 /scene/gui/spin_box.cpp | |
| parent | 5c9ecc174b60cd654102a3a77692cc80a2224253 (diff) | |
| download | godot-fe1ca3c6e649ac599029b71f4508f840fa91f208.tar.gz godot-fe1ca3c6e649ac599029b71f4508f840fa91f208.tar.zst godot-fe1ca3c6e649ac599029b71f4508f840fa91f208.zip | |
Diffstat (limited to 'scene/gui/spin_box.cpp')
| -rw-r--r-- | scene/gui/spin_box.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index 3c5d524d8..145981d49 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -185,17 +185,22 @@ void SpinBox::_line_edit_focus_exit() { _text_entered(line_edit->get_text()); } +inline void SpinBox::_adjust_width_for_icon(const Ref<Texture> icon) { + + int w = icon->get_width(); + if (w != last_w) { + line_edit->set_margin(MARGIN_RIGHT, -w); + last_w = w; + } +} + void SpinBox::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { Ref<Texture> updown = get_icon("updown"); - int w = updown->get_width(); - if (w != last_w) { - line_edit->set_margin(MARGIN_RIGHT, -w); - last_w = w; - } + _adjust_width_for_icon(updown); RID ci = get_canvas_item(); Size2i size = get_size(); @@ -207,6 +212,7 @@ void SpinBox::_notification(int p_what) { //_value_changed(0); } else if (p_what == NOTIFICATION_ENTER_TREE) { + _adjust_width_for_icon(get_icon("updown")); _value_changed(0); } } |
