diff options
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/base_button.cpp | 2 | ||||
-rw-r--r-- | scene/gui/button.cpp | 3 | ||||
-rw-r--r-- | scene/gui/control.cpp | 3 | ||||
-rw-r--r-- | scene/gui/file_dialog.cpp | 16 | ||||
-rw-r--r-- | scene/gui/file_dialog.h | 1 | ||||
-rw-r--r-- | scene/gui/item_list.cpp | 2 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 5 | ||||
-rw-r--r-- | scene/gui/link_button.cpp | 2 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 1 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 57 | ||||
-rw-r--r-- | scene/gui/texture_progress.cpp | 2 |
11 files changed, 43 insertions, 51 deletions
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index acdbd9de08..d17ae1d84c 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -31,7 +31,6 @@ #include "base_button.h" #include "os/keyboard.h" -#include "print_string.h" #include "scene/main/viewport.h" #include "scene/scene_string_names.h" @@ -361,7 +360,6 @@ BaseButton::DrawMode BaseButton::get_draw_mode() const { return DRAW_DISABLED; }; - //print_line("press attempt: "+itos(status.press_attempt)+" hover: "+itos(status.hovering)+" pressed: "+itos(status.pressed)); if (status.press_attempt == false && status.hovering && !status.pressed) { return DRAW_HOVER; diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index 03b25a138f..a34f2f1ad5 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -29,7 +29,6 @@ /*************************************************************************/ #include "button.h" -#include "print_string.h" #include "servers/visual_server.h" #include "translation.h" @@ -76,8 +75,6 @@ void Button::_notification(int p_what) { Color color; Color color_icon(1, 1, 1, 1); - //print_line(get_text()+": "+itos(is_flat())+" hover "+itos(get_draw_mode())); - Ref<StyleBox> style = get_stylebox("normal"); switch (get_draw_mode()) { diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 18f06eca31..e094a063be 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -357,7 +357,7 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const { if (data.shader_override.has(E->get())) hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; - p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_shaders/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "CanvasItemShader,CanvasItemShaderGraph", hint)); + p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_shaders/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "Shader,VisualShader", hint)); } } { @@ -769,6 +769,7 @@ void Control::force_drag(const Variant &p_data, Control *p_control) { void Control::set_drag_preview(Control *p_control) { ERR_FAIL_COND(!is_inside_tree()); + ERR_FAIL_COND(get_viewport()->gui_is_dragging()); get_viewport()->_gui_set_drag_preview(this, p_control); } diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 635f812805..9bddaa7d29 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -284,7 +284,13 @@ bool FileDialog::_is_open_should_be_disabled() { if (mode == MODE_OPEN_ANY || mode == MODE_SAVE_FILE) return false; - TreeItem *ti = tree->get_selected(); + TreeItem *ti = tree->get_next_selected(tree->get_root()); + while (ti) { + TreeItem *prev_ti = ti; + ti = tree->get_next_selected(tree->get_root()); + if (ti == prev_ti) + break; + } // We have something that we can't select? if (!ti) return mode != MODE_OPEN_DIR; // In "Open folder" mode, having nothing selected picks the current folder. @@ -328,6 +334,10 @@ void FileDialog::deselect_items() { } } +void FileDialog::_tree_multi_selected(Object *p_object, int p_cell, bool p_selected) { + _tree_selected(); +} + void FileDialog::_tree_selected() { TreeItem *ti = tree->get_selected(); @@ -754,6 +764,7 @@ void FileDialog::_bind_methods() { ClassDB::bind_method(D_METHOD("_unhandled_input"), &FileDialog::_unhandled_input); + ClassDB::bind_method(D_METHOD("_tree_multi_selected"), &FileDialog::_tree_multi_selected); ClassDB::bind_method(D_METHOD("_tree_selected"), &FileDialog::_tree_selected); ClassDB::bind_method(D_METHOD("_tree_item_activated"), &FileDialog::_tree_item_activated); ClassDB::bind_method(D_METHOD("_dir_entered"), &FileDialog::_dir_entered); @@ -794,7 +805,7 @@ void FileDialog::_bind_methods() { ClassDB::bind_method(D_METHOD("invalidate"), &FileDialog::invalidate); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "mode_overrides_title"), "set_mode_overrides_title", "is_mode_overriding_title"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Open one,Open many,Open folder,Open any,Save"), "set_mode", "get_mode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Open File,Open Files,Open Folder,Open Any,Save"), "set_mode", "get_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "access", PROPERTY_HINT_ENUM, "Resources,User data,File system"), "set_access", "get_access"); ADD_PROPERTY(PropertyInfo(Variant::POOL_STRING_ARRAY, "filters"), "set_filters", "get_filters"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_hidden_files"), "set_show_hidden_files", "is_showing_hidden_files"); @@ -890,6 +901,7 @@ FileDialog::FileDialog() { _update_drives(); connect("confirmed", this, "_action_pressed"); + tree->connect("multi_selected", this, "_tree_multi_selected", varray(), CONNECT_DEFERRED); tree->connect("cell_selected", this, "_tree_selected", varray(), CONNECT_DEFERRED); tree->connect("item_activated", this, "_tree_item_activated", varray()); tree->connect("nothing_selected", this, "deselect_items"); diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h index ad483d5dab..3227f1c3a8 100644 --- a/scene/gui/file_dialog.h +++ b/scene/gui/file_dialog.h @@ -104,6 +104,7 @@ private: void update_file_list(); void update_filters(); + void _tree_multi_selected(Object *p_object, int p_cell, bool p_selected); void _tree_selected(); void _select_drive(int p_idx); diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index d61bd97c2a..9f5c12e87f 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -502,7 +502,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { bool selected = !items[j].selected; select(j, false); if (selected) - emit_signal("multi_selected", i, true); + emit_signal("multi_selected", j, true); } if (mb->get_button_index() == BUTTON_RIGHT) { diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 549daecdae..1f3d5e6e13 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -866,15 +866,14 @@ void LineEdit::_notification(int p_what) { void LineEdit::copy_text() { - if (selection.enabled) { - + if (selection.enabled && !pass) { OS::get_singleton()->set_clipboard(text.substr(selection.begin, selection.end - selection.begin)); } } void LineEdit::cut_text() { - if (selection.enabled) { + if (selection.enabled && !pass) { OS::get_singleton()->set_clipboard(text.substr(selection.begin, selection.end - selection.begin)); selection_delete(); } diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp index d862e8669c..8560efdde5 100644 --- a/scene/gui/link_button.cpp +++ b/scene/gui/link_button.cpp @@ -68,8 +68,6 @@ void LinkButton::_notification(int p_what) { Color color; bool do_underline = false; - //print_line(get_text()+": "+itos(is_flat())+" hover "+itos(get_draw_mode())); - switch (get_draw_mode()) { case DRAW_NORMAL: { diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index a3748bf14c..a5f9bea1b1 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -2034,7 +2034,6 @@ void RichTextLabel::selection_copy() { if (text != "") { OS::get_singleton()->set_clipboard(text); - //print_line("COPY: "+text); } } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 9a8dc62e4e..ec98b01ced 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -5640,6 +5640,10 @@ void TextEdit::_confirm_completion() { end_complex_operation(); _cancel_completion(); + + if (last_completion_char == '(') { + query_code_comple(); + } } void TextEdit::_cancel_code_hint() { @@ -5692,15 +5696,12 @@ void TextEdit::_update_completion_candidates() { bool pre_keyword = false; bool cancel = false; - //print_line("inquote: "+itos(inquote)+"first quote "+itos(first_quote)+" cofs-1 "+itos(cofs-1)); if (!inquote && first_quote == cofs - 1) { //no completion here - //print_line("cancel!"); cancel = true; } else if (inquote && first_quote != -1) { s = l.substr(first_quote, cofs - first_quote); - //print_line("s: 1"+s); } else if (cofs > 0 && l[cofs - 1] == ' ') { int kofs = cofs - 1; String kw; @@ -5713,7 +5714,6 @@ void TextEdit::_update_completion_candidates() { } pre_keyword = keywords.has(kw); - //print_line("KW "+kw+"? "+itos(pre_keyword)); } else { @@ -5755,43 +5755,23 @@ void TextEdit::_update_completion_candidates() { completion_strings.write[i] = completion_strings[i].unquote().quote("'"); } - if (s == completion_strings[i]) { - // A perfect match, stop completion - _cancel_completion(); - return; + if (completion_strings[i].begins_with(s)) { + completion_options.push_back(completion_strings[i]); } + } - if (s.is_subsequence_ofi(completion_strings[i])) { - // don't remove duplicates if no input is provided - if (s != "" && completion_options.find(completion_strings[i]) != -1) { - continue; - } - // Calculate the similarity to keep completions in good order - float similarity; - if (completion_strings[i].begins_with(s)) { - // Substrings (same case) are the best candidates - similarity = 1.2; - } else if (completion_strings[i].to_lower().begins_with(s.to_lower())) { - // then any substrings - similarity = 1.1; - } else { - // Otherwise compute the similarity - similarity = s.to_lower().similarity(completion_strings[i].to_lower()); + if (completion_options.size() == 0) { + for (int i = 0; i < completion_strings.size(); i++) { + if (s.is_subsequence_of(completion_strings[i])) { + completion_options.push_back(completion_strings[i]); } + } + } - int comp_size = completion_options.size(); - if (comp_size == 0) { + if (completion_options.size() == 0) { + for (int i = 0; i < completion_strings.size(); i++) { + if (s.is_subsequence_ofi(completion_strings[i])) { completion_options.push_back(completion_strings[i]); - sim_cache.push_back(similarity); - } else { - float comp_sim; - int pos = 0; - do { - comp_sim = sim_cache[pos++]; - } while (pos < comp_size && similarity < comp_sim); - pos = similarity > comp_sim ? pos - 1 : pos; // Pos will be off by one - completion_options.insert(pos, completion_strings[i]); - sim_cache.insert(pos, similarity); } } } @@ -5799,7 +5779,12 @@ void TextEdit::_update_completion_candidates() { if (completion_options.size() == 0) { //no options to complete, cancel _cancel_completion(); + return; + } + if (completion_options.size() == 1 && s == completion_options[0]) { + // A perfect match, stop completion + _cancel_completion(); return; } diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp index 6e4fe88dbf..ff90576c1b 100644 --- a/scene/gui/texture_progress.cpp +++ b/scene/gui/texture_progress.cpp @@ -266,6 +266,8 @@ void TextureProgress::draw_nine_patch_stretched(const Ref<Texture> &p_texture, F } } + p_texture->get_rect_region(dst_rect, src_rect, dst_rect, src_rect); + RID ci = get_canvas_item(); VS::get_singleton()->canvas_item_add_nine_patch(ci, dst_rect, src_rect, p_texture->get_rid(), topleft, bottomright, VS::NINE_PATCH_STRETCH, VS::NINE_PATCH_STRETCH, true, p_modulate); } |