diff options
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/gradient_edit.cpp | 4 | ||||
-rw-r--r-- | scene/gui/item_list.cpp | 1 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 2 | ||||
-rw-r--r-- | scene/gui/tabs.cpp | 81 | ||||
-rw-r--r-- | scene/gui/tabs.h | 2 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 1 |
6 files changed, 55 insertions, 36 deletions
diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp index 934b84ec0c..c13964d196 100644 --- a/scene/gui/gradient_edit.cpp +++ b/scene/gui/gradient_edit.cpp @@ -236,8 +236,8 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) { //Snap to nearest point if holding shift if (mm->get_shift()) { - float snap_treshhold = 0.03; - float smallest_ofs = snap_treshhold; + float snap_threshold = 0.03; + float smallest_ofs = snap_threshold; bool found = false; int nearest_point = 0; for (int i = 0; i < points.size(); ++i) { diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 0d5fbee9ee..494995fb85 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -1524,6 +1524,7 @@ void ItemList::_bind_methods() { ADD_SIGNAL(MethodInfo("nothing_selected")); GLOBAL_DEF("gui/timers/incremental_search_max_interval_msec", 2000); + ProjectSettings::get_singleton()->set_custom_property_info("gui/timers/incremental_search_max_interval_msec", PropertyInfo(Variant::INT, "gui/timers/incremental_search_max_interval_msec", PROPERTY_HINT_RANGE, "0,10000,1,or_greater")); // No negative numbers } ItemList::ItemList() { diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 6f344f1028..c4373876b1 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -1608,6 +1608,8 @@ LineEdit::LineEdit() { text_changed_dirty = false; placeholder_alpha = 0.6; clear_button_enabled = false; + clear_button_status.press_attempt = false; + clear_button_status.pressing_inside = false; deselect(); set_focus_mode(FOCUS_ALL); diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index c56b7d0f26..b7f8c74046 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -106,41 +106,8 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) { } } - // test hovering to display right or close button - int hover_now = -1; - int hover_buttons = -1; - for (int i = 0; i < tabs.size(); i++) { - - if (i < offset) - continue; - - Rect2 rect = get_tab_rect(i); - if (rect.has_point(pos)) { - hover_now = i; - } - if (tabs[i].rb_rect.has_point(pos)) { - rb_hover = i; - cb_hover = -1; - hover_buttons = i; - break; - } else if (!tabs[i].disabled && tabs[i].cb_rect.has_point(pos)) { - cb_hover = i; - rb_hover = -1; - hover_buttons = i; - break; - } - } - if (hover != hover_now) { - hover = hover_now; - emit_signal("tab_hover", hover); - } - - if (hover_buttons == -1) { // no hover - rb_hover = hover_buttons; - cb_hover = hover_buttons; - } + _update_hover(); update(); - return; } @@ -522,6 +489,48 @@ Ref<Texture> Tabs::get_tab_right_button(int p_tab) const { return tabs[p_tab].right_button; } +void Tabs::_update_hover() { + + if (!is_inside_tree()) { + return; + } + + const Point2 &pos = get_local_mouse_position(); + // test hovering to display right or close button + int hover_now = -1; + int hover_buttons = -1; + for (int i = 0; i < tabs.size(); i++) { + + if (i < offset) + continue; + + Rect2 rect = get_tab_rect(i); + if (rect.has_point(pos)) { + hover_now = i; + } + if (tabs[i].rb_rect.has_point(pos)) { + rb_hover = i; + cb_hover = -1; + hover_buttons = i; + break; + } else if (!tabs[i].disabled && tabs[i].cb_rect.has_point(pos)) { + cb_hover = i; + rb_hover = -1; + hover_buttons = i; + break; + } + } + if (hover != hover_now) { + hover = hover_now; + emit_signal("tab_hover", hover); + } + + if (hover_buttons == -1) { // no hover + rb_hover = hover_buttons; + cb_hover = hover_buttons; + } +} + void Tabs::_update_cache() { Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled"); Ref<StyleBox> tab_bg = get_stylebox("tab_bg"); @@ -597,6 +606,7 @@ void Tabs::add_tab(const String &p_str, const Ref<Texture> &p_icon) { tabs.push_back(t); _update_cache(); + call_deferred("_update_hover"); update(); minimum_size_changed(); } @@ -604,6 +614,7 @@ void Tabs::add_tab(const String &p_str, const Ref<Texture> &p_icon) { void Tabs::clear_tabs() { tabs.clear(); current = 0; + call_deferred("_update_hover"); update(); } @@ -614,6 +625,7 @@ void Tabs::remove_tab(int p_idx) { if (current >= p_idx) current--; _update_cache(); + call_deferred("_update_hover"); update(); minimum_size_changed(); @@ -931,6 +943,7 @@ bool Tabs::get_select_with_rmb() const { void Tabs::_bind_methods() { ClassDB::bind_method(D_METHOD("_gui_input"), &Tabs::_gui_input); + ClassDB::bind_method(D_METHOD("_update_hover"), &Tabs::_update_hover); ClassDB::bind_method(D_METHOD("get_tab_count"), &Tabs::get_tab_count); ClassDB::bind_method(D_METHOD("set_current_tab", "tab_idx"), &Tabs::set_current_tab); ClassDB::bind_method(D_METHOD("get_current_tab"), &Tabs::get_current_tab); diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h index e204f4364b..a98744b804 100644 --- a/scene/gui/tabs.h +++ b/scene/gui/tabs.h @@ -97,6 +97,8 @@ private: int get_tab_width(int p_idx) const; void _ensure_no_over_offset(); + + void _update_hover(); void _update_cache(); protected: diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index f8a5c4cea3..bb56eea98e 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -6232,6 +6232,7 @@ void TextEdit::_bind_methods() { BIND_ENUM_CONSTANT(MENU_MAX); GLOBAL_DEF("gui/timers/text_edit_idle_detect_sec", 3); + ProjectSettings::get_singleton()->set_custom_property_info("gui/timers/text_edit_idle_detect_sec", PropertyInfo(Variant::REAL, "gui/timers/text_edit_idle_detect_sec", PROPERTY_HINT_RANGE, "0,10,0.01,or_greater")); // No negative numbers } TextEdit::TextEdit() { |