summaryrefslogtreecommitdiff
path: root/scene/gui/spin_box.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/spin_box.cpp')
-rw-r--r--scene/gui/spin_box.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index bf067898e6..1200877127 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -182,7 +182,7 @@ void SpinBox::_line_edit_focus_exit() {
_text_entered(line_edit->get_text());
}
-inline void SpinBox::_adjust_width_for_icon(const Ref<Texture> &icon) {
+inline void SpinBox::_adjust_width_for_icon(const Ref<Texture2D> &icon) {
int w = icon->get_width();
if (w != last_w) {
@@ -195,7 +195,7 @@ void SpinBox::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
- Ref<Texture> updown = get_icon("updown");
+ Ref<Texture2D> updown = get_icon("updown");
_adjust_width_for_icon(updown);
@@ -211,6 +211,10 @@ void SpinBox::_notification(int p_what) {
_adjust_width_for_icon(get_icon("updown"));
_value_changed(0);
+ } else if (p_what == NOTIFICATION_THEME_CHANGED) {
+
+ call_deferred("minimum_size_changed");
+ get_line_edit()->call_deferred("minimum_size_changed");
}
}
@@ -255,6 +259,10 @@ bool SpinBox::is_editable() const {
return line_edit->is_editable();
}
+void SpinBox::apply() {
+ _text_entered(line_edit->get_text());
+}
+
void SpinBox::_bind_methods() {
//ClassDB::bind_method(D_METHOD("_value_changed"),&SpinBox::_value_changed);
@@ -268,6 +276,7 @@ void SpinBox::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_prefix"), &SpinBox::get_prefix);
ClassDB::bind_method(D_METHOD("set_editable", "editable"), &SpinBox::set_editable);
ClassDB::bind_method(D_METHOD("is_editable"), &SpinBox::is_editable);
+ ClassDB::bind_method(D_METHOD("apply"), &SpinBox::apply);
ClassDB::bind_method(D_METHOD("_line_edit_focus_exit"), &SpinBox::_line_edit_focus_exit);
ClassDB::bind_method(D_METHOD("get_line_edit"), &SpinBox::get_line_edit);
ClassDB::bind_method(D_METHOD("_line_edit_input"), &SpinBox::_line_edit_input);
@@ -288,12 +297,12 @@ SpinBox::SpinBox() {
line_edit->set_anchors_and_margins_preset(Control::PRESET_WIDE);
line_edit->set_mouse_filter(MOUSE_FILTER_PASS);
//connect("value_changed",this,"_value_changed");
- line_edit->connect("text_entered", this, "_text_entered", Vector<Variant>(), CONNECT_DEFERRED);
- line_edit->connect("focus_exited", this, "_line_edit_focus_exit", Vector<Variant>(), CONNECT_DEFERRED);
- line_edit->connect("gui_input", this, "_line_edit_input");
+ line_edit->connect_compat("text_entered", this, "_text_entered", Vector<Variant>(), CONNECT_DEFERRED);
+ line_edit->connect_compat("focus_exited", this, "_line_edit_focus_exit", Vector<Variant>(), CONNECT_DEFERRED);
+ line_edit->connect_compat("gui_input", this, "_line_edit_input");
drag.enabled = false;
range_click_timer = memnew(Timer);
- range_click_timer->connect("timeout", this, "_range_click_timeout");
+ range_click_timer->connect_compat("timeout", this, "_range_click_timeout");
add_child(range_click_timer);
}