diff options
Diffstat (limited to 'scene')
27 files changed, 263 insertions, 90 deletions
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index a2fed718be..c8eb270a0a 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -741,12 +741,12 @@ bool PropertyTweener::step(float &r_delta) { } float time = MIN(elapsed_time - delay, duration); - target_instance->set_indexed(property, tween->interpolate_variant(initial_val, delta_val, time, duration, trans_type, ease_type)); - if (time < duration) { + target_instance->set_indexed(property, tween->interpolate_variant(initial_val, delta_val, time, duration, trans_type, ease_type)); r_delta = 0; return true; } else { + target_instance->set_indexed(property, final_val); finished = true; r_delta = elapsed_time - delay - duration; emit_signal(SNAME("finished")); @@ -895,8 +895,13 @@ bool MethodTweener::step(float &r_delta) { return true; } + Variant current_val; float time = MIN(elapsed_time - delay, duration); - Variant current_val = tween->interpolate_variant(initial_val, delta_val, time, duration, trans_type, ease_type); + if (time < duration) { + current_val = tween->interpolate_variant(initial_val, delta_val, time, duration, trans_type, ease_type); + } else { + current_val = final_val; + } const Variant **argptr = (const Variant **)alloca(sizeof(Variant *)); argptr[0] = ¤t_val; @@ -938,6 +943,7 @@ MethodTweener::MethodTweener(Callable p_callback, Variant p_from, Variant p_to, callback = p_callback; initial_val = p_from; delta_val = tween->calculate_delta_value(p_from, p_to); + final_val = p_to; duration = p_duration; } diff --git a/scene/animation/tween.h b/scene/animation/tween.h index 5b0745b2b3..62c357dfb4 100644 --- a/scene/animation/tween.h +++ b/scene/animation/tween.h @@ -274,6 +274,7 @@ private: Ref<Tween> tween; Variant initial_val; Variant delta_val; + Variant final_val; Callable callback; }; diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp index 3fa0cec302..e094c4546b 100644 --- a/scene/gui/code_edit.cpp +++ b/scene/gui/code_edit.cpp @@ -1782,10 +1782,10 @@ void CodeEdit::request_code_completion(bool p_force) { /* Don't re-query if all existing options are quoted types, eg path, signal. */ bool ignored = code_completion_active && !code_completion_options.is_empty(); if (ignored) { - ScriptCodeCompletionOption::Kind kind = ScriptCodeCompletionOption::KIND_PLAIN_TEXT; - const ScriptCodeCompletionOption *previous_option = nullptr; + ScriptLanguage::CodeCompletionKind kind = ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT; + const ScriptLanguage::CodeCompletionOption *previous_option = nullptr; for (int i = 0; i < code_completion_options.size(); i++) { - const ScriptCodeCompletionOption ¤t_option = code_completion_options[i]; + const ScriptLanguage::CodeCompletionOption ¤t_option = code_completion_options[i]; if (!previous_option) { previous_option = ¤t_option; kind = current_option.kind; @@ -1795,7 +1795,7 @@ void CodeEdit::request_code_completion(bool p_force) { break; } } - ignored = ignored && (kind == ScriptCodeCompletionOption::KIND_FILE_PATH || kind == ScriptCodeCompletionOption::KIND_NODE_PATH || kind == ScriptCodeCompletionOption::KIND_SIGNAL); + ignored = ignored && (kind == ScriptLanguage::CODE_COMPLETION_KIND_FILE_PATH || kind == ScriptLanguage::CODE_COMPLETION_KIND_NODE_PATH || kind == ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL); } if (ignored) { @@ -1818,8 +1818,8 @@ void CodeEdit::request_code_completion(bool p_force) { } void CodeEdit::add_code_completion_option(CodeCompletionKind p_type, const String &p_display_text, const String &p_insert_text, const Color &p_text_color, const RES &p_icon, const Variant &p_value) { - ScriptCodeCompletionOption completion_option; - completion_option.kind = (ScriptCodeCompletionOption::Kind)p_type; + ScriptLanguage::CodeCompletionOption completion_option; + completion_option.kind = (ScriptLanguage::CodeCompletionKind)p_type; completion_option.display = p_display_text; completion_option.insert_text = p_insert_text; completion_option.font_color = p_text_color; @@ -2702,7 +2702,7 @@ void CodeEdit::_filter_code_completion_candidates_impl() { TypedArray<Dictionary> completion_options_sources; completion_options_sources.resize(code_completion_option_sources.size()); int i = 0; - for (const ScriptCodeCompletionOption &E : code_completion_option_sources) { + for (const ScriptLanguage::CodeCompletionOption &E : code_completion_option_sources) { Dictionary option; option["kind"] = E.kind; option["display_text"] = E.display; @@ -2727,8 +2727,8 @@ void CodeEdit::_filter_code_completion_candidates_impl() { /* Convert back into options. */ int max_width = 0; for (i = 0; i < completion_options.size(); i++) { - ScriptCodeCompletionOption option; - option.kind = (ScriptCodeCompletionOption::Kind)(int)completion_options[i].get("kind"); + ScriptLanguage::CodeCompletionOption option; + option.kind = (ScriptLanguage::CodeCompletionKind)(int)completion_options[i].get("kind"); option.display = completion_options[i].get("display_text"); option.insert_text = completion_options[i].get("insert_text"); option.font_color = completion_options[i].get("font_color"); @@ -2821,15 +2821,15 @@ void CodeEdit::_filter_code_completion_candidates_impl() { code_completion_options.clear(); code_completion_base = string_to_complete; - Vector<ScriptCodeCompletionOption> completion_options_casei; - Vector<ScriptCodeCompletionOption> completion_options_substr; - Vector<ScriptCodeCompletionOption> completion_options_substr_casei; - Vector<ScriptCodeCompletionOption> completion_options_subseq; - Vector<ScriptCodeCompletionOption> completion_options_subseq_casei; + Vector<ScriptLanguage::CodeCompletionOption> completion_options_casei; + Vector<ScriptLanguage::CodeCompletionOption> completion_options_substr; + Vector<ScriptLanguage::CodeCompletionOption> completion_options_substr_casei; + Vector<ScriptLanguage::CodeCompletionOption> completion_options_subseq; + Vector<ScriptLanguage::CodeCompletionOption> completion_options_subseq_casei; int max_width = 0; String string_to_complete_lower = string_to_complete.to_lower(); - for (ScriptCodeCompletionOption &option : code_completion_option_sources) { + for (ScriptLanguage::CodeCompletionOption &option : code_completion_option_sources) { if (single_quote && option.display.is_quoted()) { option.display = option.display.unquote().quote("'"); } diff --git a/scene/gui/code_edit.h b/scene/gui/code_edit.h index cb1309ced3..596a065f12 100644 --- a/scene/gui/code_edit.h +++ b/scene/gui/code_edit.h @@ -38,7 +38,7 @@ class CodeEdit : public TextEdit { public: /* Keep enum in sync with: */ - /* /core/object/script_language.h - ScriptCodeCompletionOption::Kind */ + /* /core/object/script_language.h - ScriptLanguage::CodeCompletionKind */ enum CodeCompletionKind { KIND_CLASS, KIND_FUNCTION, @@ -208,15 +208,15 @@ private: Color code_completion_existing_color = Color(0, 0, 0, 0); bool code_completion_active = false; - Vector<ScriptCodeCompletionOption> code_completion_options; + Vector<ScriptLanguage::CodeCompletionOption> code_completion_options; int code_completion_line_ofs = 0; int code_completion_current_selected = 0; int code_completion_longest_line = 0; Rect2i code_completion_rect; Set<char32_t> code_completion_prefixes; - List<ScriptCodeCompletionOption> code_completion_option_submitted; - List<ScriptCodeCompletionOption> code_completion_option_sources; + List<ScriptLanguage::CodeCompletionOption> code_completion_option_submitted; + List<ScriptLanguage::CodeCompletionOption> code_completion_option_sources; String code_completion_base; void _filter_code_completion_candidates_impl(); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index d2d1b5e9b7..ee35eee35d 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2937,9 +2937,9 @@ Control::MouseFilter Control::get_mouse_filter() const { return data.mouse_filter; } -void Control::warp_mouse(const Point2 &p_to_pos) { +void Control::warp_mouse(const Point2 &p_position) { ERR_FAIL_COND(!is_inside_tree()); - get_viewport()->warp_mouse(get_global_transform().xform(p_to_pos)); + get_viewport()->warp_mouse(get_global_transform().xform(p_position)); } bool Control::is_text_field() const { @@ -3331,7 +3331,7 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("set_drag_preview", "control"), &Control::set_drag_preview); ClassDB::bind_method(D_METHOD("is_drag_successful"), &Control::is_drag_successful); - ClassDB::bind_method(D_METHOD("warp_mouse", "to_position"), &Control::warp_mouse); + ClassDB::bind_method(D_METHOD("warp_mouse", "position"), &Control::warp_mouse); ClassDB::bind_method(D_METHOD("update_minimum_size"), &Control::update_minimum_size); diff --git a/scene/gui/control.h b/scene/gui/control.h index 299cdd673f..4240d52b65 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -547,7 +547,7 @@ public: void grab_click_focus(); - void warp_mouse(const Point2 &p_to_pos); + void warp_mouse(const Point2 &p_position); virtual bool is_text_field() const; diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp index 2fb6452a97..2eb41f1631 100644 --- a/scene/gui/range.cpp +++ b/scene/gui/range.cpp @@ -282,7 +282,7 @@ void Range::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_greater"), "set_allow_greater", "is_greater_allowed"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_lesser"), "set_allow_lesser", "is_lesser_allowed"); - GDVIRTUAL_BIND(_value_changed); + GDVIRTUAL_BIND(_value_changed, "new_value"); ADD_LINKED_PROPERTY("min_value", "value"); ADD_LINKED_PROPERTY("min_value", "max_value"); diff --git a/scene/gui/subviewport_container.cpp b/scene/gui/subviewport_container.cpp index c66e145bc4..799eea7eac 100644 --- a/scene/gui/subviewport_container.cpp +++ b/scene/gui/subviewport_container.cpp @@ -223,6 +223,23 @@ void SubViewportContainer::unhandled_input(const Ref<InputEvent> &p_event) { } } +TypedArray<String> SubViewportContainer::get_configuration_warnings() const { + TypedArray<String> warnings = Node::get_configuration_warnings(); + + bool has_viewport = false; + for (int i = 0; i < get_child_count(); i++) { + if (Object::cast_to<SubViewport>(get_child(i))) { + has_viewport = true; + break; + } + } + if (!has_viewport) { + warnings.push_back(TTR("This node doesn't have a SubViewport as child, so it can't display its intended content.\nConsider adding a SubViewport as a child to provide something displayable.")); + } + + return warnings; +} + void SubViewportContainer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_stretch", "enable"), &SubViewportContainer::set_stretch); ClassDB::bind_method(D_METHOD("is_stretch_enabled"), &SubViewportContainer::is_stretch_enabled); diff --git a/scene/gui/subviewport_container.h b/scene/gui/subviewport_container.h index f52f01e4e2..55b7802aa4 100644 --- a/scene/gui/subviewport_container.h +++ b/scene/gui/subviewport_container.h @@ -58,6 +58,8 @@ public: virtual Vector<int> get_allowed_size_flags_horizontal() const override; virtual Vector<int> get_allowed_size_flags_vertical() const override; + TypedArray<String> get_configuration_warnings() const override; + SubViewportContainer(); }; diff --git a/scene/gui/tab_bar.cpp b/scene/gui/tab_bar.cpp index 8128bbd11d..ce2dca0ea3 100644 --- a/scene/gui/tab_bar.cpp +++ b/scene/gui/tab_bar.cpp @@ -35,6 +35,7 @@ #include "scene/gui/box_container.h" #include "scene/gui/label.h" #include "scene/gui/texture_rect.h" +#include "scene/main/viewport.h" Size2 TabBar::get_minimum_size() const { Size2 ms; @@ -158,7 +159,13 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) { } } + if (get_viewport()->gui_is_dragging() && can_drop_data(pos, get_viewport()->gui_get_drag_data())) { + dragging_valid_tab = true; + update(); + } + _update_hover(); + return; } @@ -333,6 +340,13 @@ void TabBar::_notification(int p_what) { } } break; + case NOTIFICATION_DRAG_END: { + if (dragging_valid_tab) { + dragging_valid_tab = false; + update(); + } + } break; + case NOTIFICATION_DRAW: { if (tabs.is_empty()) { return; @@ -346,8 +360,6 @@ void TabBar::_notification(int p_what) { Color font_disabled_color = get_theme_color(SNAME("font_disabled_color")); Ref<Texture2D> incr = get_theme_icon(SNAME("increment")); Ref<Texture2D> decr = get_theme_icon(SNAME("decrement")); - Ref<Texture2D> incr_hl = get_theme_icon(SNAME("increment_highlight")); - Ref<Texture2D> decr_hl = get_theme_icon(SNAME("decrement_highlight")); bool rtl = is_layout_rtl(); Vector2 size = get_size(); @@ -391,7 +403,10 @@ void TabBar::_notification(int p_what) { } if (buttons_visible) { - int vofs = (get_size().height - incr->get_size().height) / 2; + Ref<Texture2D> incr_hl = get_theme_icon(SNAME("increment_highlight")); + Ref<Texture2D> decr_hl = get_theme_icon(SNAME("decrement_highlight")); + + int vofs = (size.height - incr->get_size().height) / 2; if (rtl) { if (missing_right) { @@ -419,6 +434,39 @@ void TabBar::_notification(int p_what) { } } } + + if (dragging_valid_tab) { + int x; + + int tab_hover = get_hovered_tab(); + if (tab_hover != -1) { + Rect2 tab_rect = get_tab_rect(tab_hover); + + x = tab_rect.position.x; + if (get_local_mouse_position().x > x + tab_rect.size.width / 2) { + x += tab_rect.size.width; + } + } else { + if (rtl ^ (get_local_mouse_position().x < get_tab_rect(0).position.x)) { + x = get_tab_rect(0).position.x; + if (rtl) { + x += get_tab_rect(0).size.width; + } + } else { + Rect2 tab_rect = get_tab_rect(get_tab_count() - 1); + + x = tab_rect.position.x; + if (!rtl) { + x += tab_rect.size.width; + } + } + } + + Ref<Texture2D> drop_mark = get_theme_icon(SNAME("drop_mark")); + Color drop_mark_color = get_theme_color(SNAME("drop_mark_color")); + + drop_mark->draw(get_canvas_item(), Point2(x - drop_mark->get_width() / 2, (size.height - drop_mark->get_height()) / 2), drop_mark_color); + } } break; } } @@ -906,6 +954,8 @@ void TabBar::_on_mouse_exited() { cb_hover = -1; hover = -1; highlight_arrow = -1; + dragging_valid_tab = false; + update(); } @@ -1057,13 +1107,29 @@ void TabBar::drop_data(const Point2 &p_point, const Variant &p_data) { NodePath to_path = get_path(); if (from_path == to_path) { - if (hover_now < 0) { - hover_now = get_tab_count() - 1; + if (tab_from_id == hover_now) { + return; + } + + // Drop the new tab to the left or right depending on where the target tab is being hovered. + if (hover_now != -1) { + Rect2 tab_rect = get_tab_rect(hover_now); + if (is_layout_rtl() ^ (p_point.x <= tab_rect.position.x + tab_rect.size.width / 2)) { + if (hover_now > tab_from_id) { + hover_now -= 1; + } + } else if (tab_from_id > hover_now) { + hover_now += 1; + } + } else { + hover_now = is_layout_rtl() ^ (p_point.x < get_tab_rect(0).position.x) ? 0 : get_tab_count() - 1; } move_tab(tab_from_id, hover_now); - emit_signal(SNAME("active_tab_rearranged"), hover_now); - set_current_tab(hover_now); + if (!is_tab_disabled(hover_now)) { + emit_signal(SNAME("active_tab_rearranged"), hover_now); + set_current_tab(hover_now); + } } else if (get_tabs_rearrange_group() != -1) { // Drag and drop between Tabs. @@ -1075,11 +1141,17 @@ void TabBar::drop_data(const Point2 &p_point, const Variant &p_data) { return; } - Tab moving_tab = from_tabs->tabs[tab_from_id]; - if (hover_now < 0) { - hover_now = get_tab_count(); + // Drop the new tab to the left or right depending on where the target tab is being hovered. + if (hover_now != -1) { + Rect2 tab_rect = get_tab_rect(hover_now); + if (is_layout_rtl() ^ (p_point.x > tab_rect.position.x + tab_rect.size.width / 2)) { + hover_now += 1; + } + } else { + hover_now = is_layout_rtl() ^ (p_point.x < get_tab_rect(0).position.x) ? 0 : get_tab_count(); } + Tab moving_tab = from_tabs->tabs[tab_from_id]; from_tabs->remove_tab(tab_from_id); tabs.insert(hover_now, moving_tab); @@ -1092,7 +1164,13 @@ void TabBar::drop_data(const Point2 &p_point, const Variant &p_data) { } } - set_current_tab(hover_now); + if (!is_tab_disabled(hover_now)) { + set_current_tab(hover_now); + } else { + _update_cache(); + update(); + } + update_minimum_size(); if (tabs.size() == 1) { diff --git a/scene/gui/tab_bar.h b/scene/gui/tab_bar.h index e0c4ba85ef..548a2e62af 100644 --- a/scene/gui/tab_bar.h +++ b/scene/gui/tab_bar.h @@ -101,6 +101,7 @@ private: int max_width = 0; bool scrolling_enabled = true; bool drag_to_rearrange_enabled = false; + bool dragging_valid_tab = false; bool scroll_to_selected = true; int tabs_rearrange_group = -1; diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index ee61c862b7..1697e743be 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -173,9 +173,9 @@ void TabContainer::_notification(int p_what) { int x = is_layout_rtl() ? 0 : get_size().width - menu->get_width(); if (menu_hovered) { - menu_hl->draw(get_canvas_item(), Size2(x, (header_height - menu_hl->get_height()) / 2)); + menu_hl->draw(get_canvas_item(), Point2(x, (header_height - menu_hl->get_height()) / 2)); } else { - menu->draw(get_canvas_item(), Size2(x, (header_height - menu->get_height()) / 2)); + menu->draw(get_canvas_item(), Point2(x, (header_height - menu->get_height()) / 2)); } } } break; @@ -201,6 +201,8 @@ void TabContainer::_on_theme_changed() { tab_bar->add_theme_icon_override(SNAME("increment_highlight"), get_theme_icon(SNAME("increment_highlight"))); tab_bar->add_theme_icon_override(SNAME("decrement"), get_theme_icon(SNAME("decrement"))); tab_bar->add_theme_icon_override(SNAME("decrement_highlight"), get_theme_icon(SNAME("decrement_highlight"))); + tab_bar->add_theme_icon_override(SNAME("drop_mark"), get_theme_icon(SNAME("drop_mark"))); + tab_bar->add_theme_color_override(SNAME("drop_mark_color"), get_theme_color(SNAME("drop_mark_color"))); tab_bar->add_theme_color_override(SNAME("font_selected_color"), get_theme_color(SNAME("font_selected_color"))); tab_bar->add_theme_color_override(SNAME("font_unselected_color"), get_theme_color(SNAME("font_unselected_color"))); tab_bar->add_theme_color_override(SNAME("font_disabled_color"), get_theme_color(SNAME("font_disabled_color"))); @@ -384,8 +386,6 @@ void TabContainer::_drop_data_fw(const Point2 &p_point, const Variant &p_data, C return; } - int hover_now = get_tab_idx_at_point(p_point); - Dictionary d = p_data; if (!d.has("type")) { return; @@ -393,11 +393,27 @@ void TabContainer::_drop_data_fw(const Point2 &p_point, const Variant &p_data, C if (String(d["type"]) == "tabc_element") { int tab_from_id = d["tabc_element"]; + int hover_now = get_tab_idx_at_point(p_point); NodePath from_path = d["from_path"]; NodePath to_path = get_path(); + if (from_path == to_path) { - if (hover_now < 0) { - hover_now = get_tab_count() - 1; + if (tab_from_id == hover_now) { + return; + } + + // Drop the new tab to the left or right depending on where the target tab is being hovered. + if (hover_now != -1) { + Rect2 tab_rect = tab_bar->get_tab_rect(hover_now); + if (is_layout_rtl() ^ (p_point.x <= tab_rect.position.x + tab_rect.size.width / 2)) { + if (hover_now > tab_from_id) { + hover_now -= 1; + } + } else if (tab_from_id > hover_now) { + hover_now += 1; + } + } else { + hover_now = is_layout_rtl() ^ (p_point.x < tab_bar->get_tab_rect(0).position.x) ? 0 : get_tab_count() - 1; } move_child(get_tab_control(tab_from_id), get_tab_control(hover_now)->get_index(false)); @@ -407,16 +423,31 @@ void TabContainer::_drop_data_fw(const Point2 &p_point, const Variant &p_data, C } else if (get_tabs_rearrange_group() != -1) { // Drag and drop between TabContainers. + Node *from_node = get_node(from_path); TabContainer *from_tabc = Object::cast_to<TabContainer>(from_node); + if (from_tabc && from_tabc->get_tabs_rearrange_group() == get_tabs_rearrange_group()) { + // Get the tab properties before they get erased by the child removal. + String tab_title = from_tabc->get_tab_title(tab_from_id); + bool tab_disabled = from_tabc->is_tab_disabled(tab_from_id); + + // Drop the new tab to the left or right depending on where the target tab is being hovered. + if (hover_now != -1) { + Rect2 tab_rect = tab_bar->get_tab_rect(hover_now); + if (is_layout_rtl() ^ (p_point.x > tab_rect.position.x + tab_rect.size.width / 2)) { + hover_now += 1; + } + } else { + hover_now = is_layout_rtl() ^ (p_point.x < tab_bar->get_tab_rect(0).position.x) ? 0 : get_tab_count(); + } + Control *moving_tabc = from_tabc->get_tab_control(tab_from_id); from_tabc->remove_child(moving_tabc); add_child(moving_tabc, true); - if (hover_now < 0) { - hover_now = get_tab_count() - 1; - } + set_tab_title(get_tab_count() - 1, tab_title); + set_tab_disabled(get_tab_count() - 1, tab_disabled); move_child(moving_tabc, get_tab_control(hover_now)->get_index(false)); if (!is_tab_disabled(hover_now)) { diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp index 700ba761f6..ac10c2bad8 100644 --- a/scene/main/http_request.cpp +++ b/scene/main/http_request.cpp @@ -558,12 +558,12 @@ void HTTPRequest::set_https_proxy(const String &p_host, int p_port) { client->set_https_proxy(p_host, p_port); } -void HTTPRequest::set_timeout(int p_timeout) { +void HTTPRequest::set_timeout(double p_timeout) { ERR_FAIL_COND(p_timeout < 0); timeout = p_timeout; } -int HTTPRequest::get_timeout() { +double HTTPRequest::get_timeout() { return timeout; } @@ -615,7 +615,7 @@ void HTTPRequest::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "accept_gzip"), "set_accept_gzip", "is_accepting_gzip"); ADD_PROPERTY(PropertyInfo(Variant::INT, "body_size_limit", PROPERTY_HINT_RANGE, "-1,2000000000"), "set_body_size_limit", "get_body_size_limit"); ADD_PROPERTY(PropertyInfo(Variant::INT, "max_redirects", PROPERTY_HINT_RANGE, "-1,64"), "set_max_redirects", "get_max_redirects"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "timeout", PROPERTY_HINT_RANGE, "0,86400"), "set_timeout", "get_timeout"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "timeout", PROPERTY_HINT_RANGE, "0,3600,0.1,or_greater"), "set_timeout", "get_timeout"); ADD_SIGNAL(MethodInfo("request_completed", PropertyInfo(Variant::INT, "result"), PropertyInfo(Variant::INT, "response_code"), PropertyInfo(Variant::PACKED_STRING_ARRAY, "headers"), PropertyInfo(Variant::PACKED_BYTE_ARRAY, "body"))); diff --git a/scene/main/http_request.h b/scene/main/http_request.h index 62880fa282..26d648458f 100644 --- a/scene/main/http_request.h +++ b/scene/main/http_request.h @@ -96,7 +96,7 @@ private: int max_redirects = 8; - int timeout = 0; + double timeout = 0; void _redirect_request(const String &p_new_url); @@ -146,8 +146,8 @@ public: Timer *timer; - void set_timeout(int p_timeout); - int get_timeout(); + void set_timeout(double p_timeout); + double get_timeout(); void _timeout(); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index ec33e5752e..0c7a9fda4a 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1124,9 +1124,9 @@ Vector2 Viewport::get_mouse_position() const { return gui.last_mouse_pos; } -void Viewport::warp_mouse(const Vector2 &p_pos) { - Vector2 gpos = (get_final_transform().affine_inverse() * _get_input_pre_xform()).affine_inverse().xform(p_pos); - Input::get_singleton()->warp_mouse_position(gpos); +void Viewport::warp_mouse(const Vector2 &p_position) { + Vector2 gpos = (get_final_transform().affine_inverse() * _get_input_pre_xform()).affine_inverse().xform(p_position); + Input::get_singleton()->warp_mouse(gpos); } void Viewport::_gui_sort_roots() { @@ -2001,30 +2001,58 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { if (from && p_event->is_pressed()) { Control *next = nullptr; - if (p_event->is_action_pressed("ui_focus_next", true, true)) { - next = from->find_next_valid_focus(); - } + Ref<InputEventJoypadMotion> joypadmotion_event = p_event; + if (joypadmotion_event.is_valid()) { + Input *input = Input::get_singleton(); - if (p_event->is_action_pressed("ui_focus_prev", true, true)) { - next = from->find_prev_valid_focus(); - } + if (p_event->is_action_pressed("ui_focus_next") && input->is_action_just_pressed("ui_focus_next")) { + next = from->find_next_valid_focus(); + } - if (p_event->is_action_pressed("ui_up", true, true)) { - next = from->_get_focus_neighbor(SIDE_TOP); - } + if (p_event->is_action_pressed("ui_focus_prev") && input->is_action_just_pressed("ui_focus_prev")) { + next = from->find_prev_valid_focus(); + } - if (p_event->is_action_pressed("ui_left", true, true)) { - next = from->_get_focus_neighbor(SIDE_LEFT); - } + if (p_event->is_action_pressed("ui_up") && input->is_action_just_pressed("ui_up")) { + next = from->_get_focus_neighbor(SIDE_TOP); + } - if (p_event->is_action_pressed("ui_right", true, true)) { - next = from->_get_focus_neighbor(SIDE_RIGHT); - } + if (p_event->is_action_pressed("ui_left") && input->is_action_just_pressed("ui_left")) { + next = from->_get_focus_neighbor(SIDE_LEFT); + } - if (p_event->is_action_pressed("ui_down", true, true)) { - next = from->_get_focus_neighbor(SIDE_BOTTOM); - } + if (p_event->is_action_pressed("ui_right") && input->is_action_just_pressed("ui_right")) { + next = from->_get_focus_neighbor(SIDE_RIGHT); + } + if (p_event->is_action_pressed("ui_down") && input->is_action_just_pressed("ui_down")) { + next = from->_get_focus_neighbor(SIDE_BOTTOM); + } + } else { + if (p_event->is_action_pressed("ui_focus_next", true, true)) { + next = from->find_next_valid_focus(); + } + + if (p_event->is_action_pressed("ui_focus_prev", true, true)) { + next = from->find_prev_valid_focus(); + } + + if (p_event->is_action_pressed("ui_up", true, true)) { + next = from->_get_focus_neighbor(SIDE_TOP); + } + + if (p_event->is_action_pressed("ui_left", true, true)) { + next = from->_get_focus_neighbor(SIDE_LEFT); + } + + if (p_event->is_action_pressed("ui_right", true, true)) { + next = from->_get_focus_neighbor(SIDE_RIGHT); + } + + if (p_event->is_action_pressed("ui_down", true, true)) { + next = from->_get_focus_neighbor(SIDE_BOTTOM); + } + } if (next) { next->grab_focus(); set_input_as_handled(); @@ -2691,7 +2719,7 @@ void Viewport::push_input(const Ref<InputEvent> &p_event, bool p_local_coords) { ev = p_event; } - if (is_embedding_subwindows() && _sub_windows_forward_input(p_event)) { + if (is_embedding_subwindows() && _sub_windows_forward_input(ev)) { set_input_as_handled(); return; } @@ -3614,7 +3642,7 @@ void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("is_audio_listener_2d"), &Viewport::is_audio_listener_2d); ClassDB::bind_method(D_METHOD("get_mouse_position"), &Viewport::get_mouse_position); - ClassDB::bind_method(D_METHOD("warp_mouse", "to_position"), &Viewport::warp_mouse); + ClassDB::bind_method(D_METHOD("warp_mouse", "position"), &Viewport::warp_mouse); ClassDB::bind_method(D_METHOD("gui_get_drag_data"), &Viewport::gui_get_drag_data); ClassDB::bind_method(D_METHOD("gui_is_dragging"), &Viewport::gui_is_dragging); diff --git a/scene/main/viewport.h b/scene/main/viewport.h index e4912f31c5..d5fca1b881 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -547,7 +547,7 @@ public: bool is_input_disabled() const; Vector2 get_mouse_position() const; - void warp_mouse(const Vector2 &p_pos); + void warp_mouse(const Vector2 &p_position); void set_physics_object_picking(bool p_enable); bool get_physics_object_picking(); diff --git a/scene/resources/capsule_shape_2d.cpp b/scene/resources/capsule_shape_2d.cpp index a1ad487bff..c7bd4cb698 100644 --- a/scene/resources/capsule_shape_2d.cpp +++ b/scene/resources/capsule_shape_2d.cpp @@ -109,8 +109,8 @@ void CapsuleShape2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_height", "height"), &CapsuleShape2D::set_height); ClassDB::bind_method(D_METHOD("get_height"), &CapsuleShape2D::get_height); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius"), "set_radius", "get_radius"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height"), "set_height", "get_height"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_radius", "get_radius"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_height", "get_height"); ADD_LINKED_PROPERTY("radius", "height"); ADD_LINKED_PROPERTY("height", "radius"); } diff --git a/scene/resources/capsule_shape_3d.cpp b/scene/resources/capsule_shape_3d.cpp index 2179ce82dd..d708706ff2 100644 --- a/scene/resources/capsule_shape_3d.cpp +++ b/scene/resources/capsule_shape_3d.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "capsule_shape_3d.h" + #include "servers/physics_server_3d.h" Vector<Vector3> CapsuleShape3D::get_debug_mesh_lines() const { @@ -112,8 +113,8 @@ void CapsuleShape3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_height", "height"), &CapsuleShape3D::set_height); ClassDB::bind_method(D_METHOD("get_height"), &CapsuleShape3D::get_height); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.001,4096,0.001"), "set_radius", "get_radius"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_RANGE, "0.001,4096,0.001"), "set_height", "get_height"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), "set_radius", "get_radius"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), "set_height", "get_height"); ADD_LINKED_PROPERTY("radius", "height"); ADD_LINKED_PROPERTY("height", "radius"); } diff --git a/scene/resources/circle_shape_2d.cpp b/scene/resources/circle_shape_2d.cpp index de931fca7e..c287de9ede 100644 --- a/scene/resources/circle_shape_2d.cpp +++ b/scene/resources/circle_shape_2d.cpp @@ -56,7 +56,7 @@ void CircleShape2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_radius", "radius"), &CircleShape2D::set_radius); ClassDB::bind_method(D_METHOD("get_radius"), &CircleShape2D::get_radius); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.01,16384,0.5"), "set_radius", "get_radius"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_radius", "get_radius"); } Rect2 CircleShape2D::get_rect() const { diff --git a/scene/resources/cylinder_shape_3d.cpp b/scene/resources/cylinder_shape_3d.cpp index c4f1cba341..a1fe5c46fb 100644 --- a/scene/resources/cylinder_shape_3d.cpp +++ b/scene/resources/cylinder_shape_3d.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "cylinder_shape_3d.h" + #include "servers/physics_server_3d.h" Vector<Vector3> CylinderShape3D::get_debug_mesh_lines() const { @@ -99,8 +100,8 @@ void CylinderShape3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_height", "height"), &CylinderShape3D::set_height); ClassDB::bind_method(D_METHOD("get_height"), &CylinderShape3D::get_height); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.001,4096,0.001"), "set_radius", "get_radius"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_RANGE, "0.001,4096,0.001"), "set_height", "get_height"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), "set_height", "get_height"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), "set_radius", "get_radius"); } CylinderShape3D::CylinderShape3D() : diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index da37228ed9..eb71401a3a 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -801,6 +801,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_icon("increment_highlight", "TabContainer", icons["scroll_button_right_hl"]); theme->set_icon("decrement", "TabContainer", icons["scroll_button_left"]); theme->set_icon("decrement_highlight", "TabContainer", icons["scroll_button_left_hl"]); + theme->set_icon("drop_mark", "TabContainer", icons["tabs_drop_mark"]); theme->set_icon("menu", "TabContainer", icons["tabs_menu"]); theme->set_icon("menu_highlight", "TabContainer", icons["tabs_menu_hl"]); @@ -811,6 +812,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_color("font_unselected_color", "TabContainer", control_font_low_color); theme->set_color("font_disabled_color", "TabContainer", control_font_disabled_color); theme->set_color("font_outline_color", "TabContainer", Color(1, 1, 1)); + theme->set_color("drop_mark_color", "TabContainer", Color(1, 1, 1)); theme->set_constant("side_margin", "TabContainer", 8 * scale); theme->set_constant("icon_separation", "TabContainer", 4 * scale); @@ -828,6 +830,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_icon("increment_highlight", "TabBar", icons["scroll_button_right_hl"]); theme->set_icon("decrement", "TabBar", icons["scroll_button_left"]); theme->set_icon("decrement_highlight", "TabBar", icons["scroll_button_left_hl"]); + theme->set_icon("drop_mark", "TabBar", icons["tabs_drop_mark"]); theme->set_icon("close", "TabBar", icons["close"]); theme->set_font("font", "TabBar", Ref<Font>()); @@ -837,6 +840,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_color("font_unselected_color", "TabBar", control_font_low_color); theme->set_color("font_disabled_color", "TabBar", control_font_disabled_color); theme->set_color("font_outline_color", "TabBar", Color(1, 1, 1)); + theme->set_color("drop_mark_color", "TabBar", Color(1, 1, 1)); theme->set_constant("hseparation", "TabBar", 4 * scale); theme->set_constant("outline_size", "TabBar", 0); diff --git a/scene/resources/default_theme/tabs_drop_mark.svg b/scene/resources/default_theme/tabs_drop_mark.svg new file mode 100644 index 0000000000..b1415bec45 --- /dev/null +++ b/scene/resources/default_theme/tabs_drop_mark.svg @@ -0,0 +1 @@ +<svg height="32" viewBox="0 0 16 32" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m5 1h6v30h-6z" fill="#d3d3d3"/></svg> diff --git a/scene/resources/height_map_shape_3d.cpp b/scene/resources/height_map_shape_3d.cpp index 121930d86f..824dc4a544 100644 --- a/scene/resources/height_map_shape_3d.cpp +++ b/scene/resources/height_map_shape_3d.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "height_map_shape_3d.h" + #include "servers/physics_server_3d.h" Vector<Vector3> HeightMapShape3D::get_debug_mesh_lines() const { @@ -186,8 +187,8 @@ void HeightMapShape3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_map_data", "data"), &HeightMapShape3D::set_map_data); ClassDB::bind_method(D_METHOD("get_map_data"), &HeightMapShape3D::get_map_data); - ADD_PROPERTY(PropertyInfo(Variant::INT, "map_width", PROPERTY_HINT_RANGE, "1,4096,1"), "set_map_width", "get_map_width"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "map_depth", PROPERTY_HINT_RANGE, "1,4096,1"), "set_map_depth", "get_map_depth"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "map_width", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), "set_map_width", "get_map_width"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "map_depth", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), "set_map_depth", "get_map_depth"); ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT32_ARRAY, "map_data"), "set_map_data", "get_map_data"); } diff --git a/scene/resources/separation_ray_shape_2d.cpp b/scene/resources/separation_ray_shape_2d.cpp index 0406c91b70..df7b0d969a 100644 --- a/scene/resources/separation_ray_shape_2d.cpp +++ b/scene/resources/separation_ray_shape_2d.cpp @@ -89,7 +89,7 @@ void SeparationRayShape2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_slide_on_slope", "active"), &SeparationRayShape2D::set_slide_on_slope); ClassDB::bind_method(D_METHOD("get_slide_on_slope"), &SeparationRayShape2D::get_slide_on_slope); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "length"), "set_length", "get_length"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "length", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_length", "get_length"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "slide_on_slope"), "set_slide_on_slope", "get_slide_on_slope"); } diff --git a/scene/resources/separation_ray_shape_3d.cpp b/scene/resources/separation_ray_shape_3d.cpp index 5aa7616589..736cb60c1c 100644 --- a/scene/resources/separation_ray_shape_3d.cpp +++ b/scene/resources/separation_ray_shape_3d.cpp @@ -80,7 +80,7 @@ void SeparationRayShape3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_slide_on_slope", "active"), &SeparationRayShape3D::set_slide_on_slope); ClassDB::bind_method(D_METHOD("get_slide_on_slope"), &SeparationRayShape3D::get_slide_on_slope); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "length", PROPERTY_HINT_RANGE, "0,4096,0.001"), "set_length", "get_length"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "length", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), "set_length", "get_length"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "slide_on_slope"), "set_slide_on_slope", "get_slide_on_slope"); } diff --git a/scene/resources/sphere_shape_3d.cpp b/scene/resources/sphere_shape_3d.cpp index 8282992401..8de0dc1650 100644 --- a/scene/resources/sphere_shape_3d.cpp +++ b/scene/resources/sphere_shape_3d.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "sphere_shape_3d.h" + #include "servers/physics_server_3d.h" Vector<Vector3> SphereShape3D::get_debug_mesh_lines() const { @@ -77,7 +78,7 @@ void SphereShape3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_radius", "radius"), &SphereShape3D::set_radius); ClassDB::bind_method(D_METHOD("get_radius"), &SphereShape3D::get_radius); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0,4096,0.001"), "set_radius", "get_radius"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), "set_radius", "get_radius"); } SphereShape3D::SphereShape3D() : diff --git a/scene/resources/world_boundary_shape_2d.cpp b/scene/resources/world_boundary_shape_2d.cpp index 9789388c6a..ac5be79d24 100644 --- a/scene/resources/world_boundary_shape_2d.cpp +++ b/scene/resources/world_boundary_shape_2d.cpp @@ -108,7 +108,7 @@ void WorldBoundaryShape2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_distance"), &WorldBoundaryShape2D::get_distance); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "normal"), "set_normal", "get_normal"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "distance"), "set_distance", "get_distance"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "distance", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater"), "set_distance", "get_distance"); } WorldBoundaryShape2D::WorldBoundaryShape2D() : |