diff options
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/base_button.cpp | 3 | ||||
-rw-r--r-- | scene/gui/container.cpp | 4 | ||||
-rw-r--r-- | scene/gui/control.cpp | 59 | ||||
-rw-r--r-- | scene/gui/file_dialog.cpp | 9 | ||||
-rw-r--r-- | scene/gui/graph_edit.cpp | 30 | ||||
-rw-r--r-- | scene/gui/graph_node.cpp | 4 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 8 | ||||
-rw-r--r-- | scene/gui/option_button.cpp | 62 | ||||
-rw-r--r-- | scene/gui/popup.cpp | 2 | ||||
-rw-r--r-- | scene/gui/progress_bar.cpp | 2 | ||||
-rw-r--r-- | scene/gui/range.cpp | 4 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 38 | ||||
-rw-r--r-- | scene/gui/scroll_container.cpp | 2 | ||||
-rw-r--r-- | scene/gui/spin_box.cpp | 4 | ||||
-rw-r--r-- | scene/gui/spin_box.h | 2 | ||||
-rw-r--r-- | scene/gui/tab_container.cpp | 2 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 42 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 1 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 41 | ||||
-rw-r--r-- | scene/gui/tree.h | 4 |
20 files changed, 178 insertions, 145 deletions
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 52fcea2a71..4f71481280 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -115,9 +115,6 @@ void BaseButton::_notification(int p_what) { } } - if (p_what == NOTIFICATION_ENTER_TREE) { - } - if (p_what == NOTIFICATION_EXIT_TREE || (p_what == NOTIFICATION_VISIBILITY_CHANGED && !is_visible_in_tree())) { if (!toggle_mode) { diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp index c9cf5f8308..449076f863 100644 --- a/scene/gui/container.cpp +++ b/scene/gui/container.cpp @@ -175,9 +175,9 @@ String Container::get_configuration_warning() const { if (get_class() == "Container" && get_script().is_null()) { if (warning != String()) { - warning += "\n"; + warning += "\n\n"; } - warning += TTR("Container by itself serves no purpose unless a script configures its children placement behavior.\nIf you don't intend to add a script, then please use a plain 'Control' node instead."); + warning += TTR("Container by itself serves no purpose unless a script configures its children placement behavior.\nIf you don't intend to add a script, use a plain Control node instead."); } return warning; } diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index eccd42cb9f..5ec6c68163 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -289,7 +289,7 @@ void Control::_update_minimum_size() { Size2 minsize = get_combined_minimum_size(); if (minsize.x > data.size_cache.x || minsize.y > data.size_cache.y) { - set_size(data.size_cache); + _size_changed(); } data.updating_last_minimum_size = false; @@ -850,6 +850,12 @@ Ref<Texture> Control::get_icon(const StringName &p_name, const StringName &p_typ theme_owner = NULL; } + if (Theme::get_project_default().is_valid()) { + if (Theme::get_project_default()->has_icon(p_name, type)) { + return Theme::get_project_default()->get_icon(p_name, type); + } + } + return Theme::get_default()->get_icon(p_name, type); } @@ -886,6 +892,12 @@ Ref<Shader> Control::get_shader(const StringName &p_name, const StringName &p_ty theme_owner = NULL; } + if (Theme::get_project_default().is_valid()) { + if (Theme::get_project_default()->has_shader(p_name, type)) { + return Theme::get_project_default()->get_shader(p_name, type); + } + } + return Theme::get_default()->get_shader(p_name, type); } @@ -925,6 +937,9 @@ Ref<StyleBox> Control::get_stylebox(const StringName &p_name, const StringName & } while (class_name != StringName()) { + if (Theme::get_project_default().is_valid() && Theme::get_project_default()->has_stylebox(p_name, type)) + return Theme::get_project_default()->get_stylebox(p_name, type); + if (Theme::get_default()->has_stylebox(p_name, class_name)) return Theme::get_default()->get_stylebox(p_name, class_name); @@ -1001,6 +1016,11 @@ Color Control::get_color(const StringName &p_name, const StringName &p_type) con theme_owner = NULL; } + if (Theme::get_project_default().is_valid()) { + if (Theme::get_project_default()->has_color(p_name, type)) { + return Theme::get_project_default()->get_color(p_name, type); + } + } return Theme::get_default()->get_color(p_name, type); } @@ -1036,6 +1056,11 @@ int Control::get_constant(const StringName &p_name, const StringName &p_type) co theme_owner = NULL; } + if (Theme::get_project_default().is_valid()) { + if (Theme::get_project_default()->has_constant(p_name, type)) { + return Theme::get_project_default()->get_constant(p_name, type); + } + } return Theme::get_default()->get_constant(p_name, type); } @@ -1106,6 +1131,11 @@ bool Control::has_icon(const StringName &p_name, const StringName &p_type) const theme_owner = NULL; } + if (Theme::get_project_default().is_valid()) { + if (Theme::get_project_default()->has_color(p_name, type)) { + return true; + } + } return Theme::get_default()->has_icon(p_name, type); } @@ -1140,6 +1170,11 @@ bool Control::has_shader(const StringName &p_name, const StringName &p_type) con theme_owner = NULL; } + if (Theme::get_project_default().is_valid()) { + if (Theme::get_project_default()->has_shader(p_name, type)) { + return true; + } + } return Theme::get_default()->has_shader(p_name, type); } bool Control::has_stylebox(const StringName &p_name, const StringName &p_type) const { @@ -1173,6 +1208,11 @@ bool Control::has_stylebox(const StringName &p_name, const StringName &p_type) c theme_owner = NULL; } + if (Theme::get_project_default().is_valid()) { + if (Theme::get_project_default()->has_stylebox(p_name, type)) { + return true; + } + } return Theme::get_default()->has_stylebox(p_name, type); } bool Control::has_font(const StringName &p_name, const StringName &p_type) const { @@ -1206,6 +1246,11 @@ bool Control::has_font(const StringName &p_name, const StringName &p_type) const theme_owner = NULL; } + if (Theme::get_project_default().is_valid()) { + if (Theme::get_project_default()->has_font(p_name, type)) { + return true; + } + } return Theme::get_default()->has_font(p_name, type); } @@ -1240,6 +1285,11 @@ bool Control::has_color(const StringName &p_name, const StringName &p_type) cons theme_owner = NULL; } + if (Theme::get_project_default().is_valid()) { + if (Theme::get_project_default()->has_color(p_name, type)) { + return true; + } + } return Theme::get_default()->has_color(p_name, type); } @@ -1274,6 +1324,11 @@ bool Control::has_constant(const StringName &p_name, const StringName &p_type) c theme_owner = NULL; } + if (Theme::get_project_default().is_valid()) { + if (Theme::get_project_default()->has_constant(p_name, type)) { + return true; + } + } return Theme::get_default()->has_constant(p_name, type); } @@ -2711,7 +2766,7 @@ String Control::get_configuration_warning() const { if (data.mouse_filter == MOUSE_FILTER_IGNORE && data.tooltip != "") { if (warning != String()) { - warning += "\n"; + warning += "\n\n"; } warning += TTR("The Hint Tooltip won't be displayed as the control's Mouse Filter is set to \"Ignore\". To solve this, set the Mouse Filter to \"Stop\" or \"Pass\"."); } diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 04fb991f78..f1bdbb5ff5 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -403,11 +403,10 @@ void FileDialog::update_file_list() { List<String> files; List<String> dirs; - bool is_dir; bool is_hidden; String item; - while ((item = dir_access->get_next(&is_dir)) != "") { + while ((item = dir_access->get_next()) != "") { if (item == "." || item == "..") continue; @@ -415,7 +414,7 @@ void FileDialog::update_file_list() { is_hidden = dir_access->current_is_hidden(); if (show_hidden_files || !is_hidden) { - if (!is_dir) + if (!dir_access->current_is_dir()) files.push_back(item); else dirs.push_back(item); @@ -880,14 +879,14 @@ FileDialog::FileDialog() { dir->set_h_size_flags(SIZE_EXPAND_FILL); refresh = memnew(ToolButton); - refresh->set_tooltip(RTR("Refresh")); + refresh->set_tooltip(RTR("Refresh files.")); refresh->connect("pressed", this, "_update_file_list"); hbc->add_child(refresh); show_hidden = memnew(ToolButton); show_hidden->set_toggle_mode(true); show_hidden->set_pressed(is_showing_hidden_files()); - show_hidden->set_tooltip(RTR("Toggle Hidden Files")); + show_hidden->set_tooltip(RTR("Toggle the visibility of hidden files.")); show_hidden->connect("toggled", this, "set_show_hidden_files"); hbc->add_child(show_hidden); diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index f238aeb392..38005f1322 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -1030,14 +1030,28 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { } Ref<InputEventKey> k = p_ev; - if (k.is_valid() && k->get_scancode() == KEY_D && k->is_pressed() && k->get_command()) { - emit_signal("duplicate_nodes_request"); - accept_event(); - } - if (k.is_valid() && k->get_scancode() == KEY_DELETE && k->is_pressed()) { - emit_signal("delete_nodes_request"); - accept_event(); + if (k.is_valid()) { + + if (k->get_scancode() == KEY_D && k->is_pressed() && k->get_command()) { + emit_signal("duplicate_nodes_request"); + accept_event(); + } + + if (k->get_scancode() == KEY_C && k->is_pressed() && k->get_command()) { + emit_signal("copy_nodes_request"); + accept_event(); + } + + if (k->get_scancode() == KEY_V && k->is_pressed() && k->get_command()) { + emit_signal("paste_nodes_request"); + accept_event(); + } + + if (k->get_scancode() == KEY_DELETE && k->is_pressed()) { + emit_signal("delete_nodes_request"); + accept_event(); + } } Ref<InputEventMagnifyGesture> magnify_gesture = p_ev; @@ -1297,6 +1311,8 @@ void GraphEdit::_bind_methods() { ADD_SIGNAL(MethodInfo("disconnection_request", PropertyInfo(Variant::STRING, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::STRING, "to"), PropertyInfo(Variant::INT, "to_slot"))); ADD_SIGNAL(MethodInfo("popup_request", PropertyInfo(Variant::VECTOR2, "position"))); ADD_SIGNAL(MethodInfo("duplicate_nodes_request")); + ADD_SIGNAL(MethodInfo("copy_nodes_request")); + ADD_SIGNAL(MethodInfo("paste_nodes_request")); ADD_SIGNAL(MethodInfo("node_selected", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"))); ADD_SIGNAL(MethodInfo("connection_to_empty", PropertyInfo(Variant::STRING, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::VECTOR2, "release_position"))); ADD_SIGNAL(MethodInfo("connection_from_empty", PropertyInfo(Variant::STRING, "to"), PropertyInfo(Variant::INT, "to_slot"), PropertyInfo(Variant::VECTOR2, "release_position"))); diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index 6463ee5ad5..222c75b21d 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -599,6 +599,8 @@ void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) { Vector2 mpos = Vector2(mb->get_position().x, mb->get_position().y); if (close_rect.size != Size2() && close_rect.has_point(mpos)) { + //send focus to parent + get_parent_control()->grab_focus(); emit_signal("close_request"); accept_event(); return; @@ -615,9 +617,7 @@ void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) { return; } - //send focus to parent emit_signal("raise_request"); - get_parent_control()->grab_focus(); } if (!mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 3dcbf64e7c..d5347edb87 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -999,6 +999,8 @@ void LineEdit::set_cursor_at_pixel_pos(int p_x) { Ref<StyleBox> style = get_stylebox("normal"); int pixel_ofs = 0; Size2 size = get_size(); + bool display_clear_icon = !text.empty() && is_editable() && clear_button_enabled; + int r_icon_width = Control::get_icon("clear")->get_width(); switch (align) { @@ -1013,10 +1015,16 @@ void LineEdit::set_cursor_at_pixel_pos(int p_x) { pixel_ofs = int(style->get_offset().x); else pixel_ofs = int(size.width - (cached_width)) / 2; + + if (display_clear_icon) + pixel_ofs -= int(r_icon_width / 2 + style->get_margin(MARGIN_RIGHT)); } break; case ALIGN_RIGHT: { pixel_ofs = int(size.width - style->get_margin(MARGIN_RIGHT) - (cached_width)); + + if (display_clear_icon) + pixel_ofs -= int(r_icon_width + style->get_margin(MARGIN_RIGHT)); } break; } diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index 58671655dc..d1840e43a3 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -43,40 +43,42 @@ Size2 OptionButton::get_minimum_size() const { void OptionButton::_notification(int p_what) { - if (p_what == NOTIFICATION_DRAW) { - - if (!has_icon("arrow")) - return; - - RID ci = get_canvas_item(); - Ref<Texture> arrow = Control::get_icon("arrow"); - Ref<StyleBox> normal = get_stylebox("normal"); - Color clr = Color(1, 1, 1); - if (get_constant("modulate_arrow")) { - switch (get_draw_mode()) { - case DRAW_PRESSED: - clr = get_color("font_color_pressed"); - break; - case DRAW_HOVER: - clr = get_color("font_color_hover"); - break; - case DRAW_DISABLED: - clr = get_color("font_color_disabled"); - break; - default: - clr = get_color("font_color"); + switch (p_what) { + case NOTIFICATION_DRAW: { + + if (!has_icon("arrow")) + return; + + RID ci = get_canvas_item(); + Ref<Texture> arrow = Control::get_icon("arrow"); + Color clr = Color(1, 1, 1); + if (get_constant("modulate_arrow")) { + switch (get_draw_mode()) { + case DRAW_PRESSED: + clr = get_color("font_color_pressed"); + break; + case DRAW_HOVER: + clr = get_color("font_color_hover"); + break; + case DRAW_DISABLED: + clr = get_color("font_color_disabled"); + break; + default: + clr = get_color("font_color"); + } } - } - Size2 size = get_size(); + Size2 size = get_size(); - Point2 ofs(size.width - arrow->get_width() - get_constant("arrow_margin"), int(Math::abs((size.height - arrow->get_height()) / 2))); - arrow->draw(ci, ofs, clr); - } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { + Point2 ofs(size.width - arrow->get_width() - get_constant("arrow_margin"), int(Math::abs((size.height - arrow->get_height()) / 2))); + arrow->draw(ci, ofs, clr); + } break; + case NOTIFICATION_VISIBILITY_CHANGED: { - if (!is_visible_in_tree()) { - popup->hide(); - } + if (!is_visible_in_tree()) { + popup->hide(); + } + } break; } } diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp index 9e996e5519..3e003af396 100644 --- a/scene/gui/popup.cpp +++ b/scene/gui/popup.cpp @@ -234,7 +234,7 @@ Popup::Popup() { String Popup::get_configuration_warning() const { if (is_visible_in_tree()) { - return TTR("Popups will hide by default unless you call popup() or any of the popup*() functions. Making them visible for editing is fine though, but they will hide upon running."); + return TTR("Popups will hide by default unless you call popup() or any of the popup*() functions. Making them visible for editing is fine, but they will hide upon running."); } return String(); diff --git a/scene/gui/progress_bar.cpp b/scene/gui/progress_bar.cpp index 264eda4035..0154a452ad 100644 --- a/scene/gui/progress_bar.cpp +++ b/scene/gui/progress_bar.cpp @@ -60,7 +60,7 @@ void ProgressBar::_notification(int p_what) { draw_style_box(bg, Rect2(Point2(), get_size())); float r = get_as_ratio(); int mp = fg->get_minimum_size().width; - int p = r * get_size().width - mp; + int p = r * (get_size().width - mp); if (p > 0) { draw_style_box(fg, Rect2(Point2(), Size2(p + fg->get_minimum_size().width, get_size().height))); diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp index d00acaf08a..e709bac377 100644 --- a/scene/gui/range.cpp +++ b/scene/gui/range.cpp @@ -35,9 +35,9 @@ String Range::get_configuration_warning() const { if (shared->exp_ratio && shared->min <= 0) { if (warning != String()) { - warning += "\n"; + warning += "\n\n"; } - warning += TTR("If exp_edit is true min_value must be > 0."); + warning += TTR("If \"Exp Edit\" is enabled, \"Min Value\" must be greater than 0."); } return warning; diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 5b91299de6..8223ea6d1e 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -821,11 +821,7 @@ void RichTextLabel::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - if (is_inside_tree() && use_bbcode) { - parse_bbcode(bbcode); - //first_invalid_line=0; //invalidate ALL - //update(); - } + update(); } break; case NOTIFICATION_DRAW: { @@ -1942,37 +1938,37 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) { if (col.begins_with("#")) color = Color::html(col); else if (col == "aqua") - color = Color::html("#00FFFF"); + color = Color(0, 1, 1); else if (col == "black") - color = Color::html("#000000"); + color = Color(0, 0, 0); else if (col == "blue") - color = Color::html("#0000FF"); + color = Color(0, 0, 1); else if (col == "fuchsia") - color = Color::html("#FF00FF"); + color = Color(1, 0, 1); else if (col == "gray" || col == "grey") - color = Color::html("#808080"); + color = Color(0.5, 0.5, 0.5); else if (col == "green") - color = Color::html("#008000"); + color = Color(0, 0.5, 0); else if (col == "lime") - color = Color::html("#00FF00"); + color = Color(0, 1, 0); else if (col == "maroon") - color = Color::html("#800000"); + color = Color(0.5, 0, 0); else if (col == "navy") - color = Color::html("#000080"); + color = Color(0, 0, 0.5); else if (col == "olive") - color = Color::html("#808000"); + color = Color(0.5, 0.5, 0); else if (col == "purple") - color = Color::html("#800080"); + color = Color(0.5, 0, 0.5); else if (col == "red") - color = Color::html("#FF0000"); + color = Color(1, 0, 0); else if (col == "silver") - color = Color::html("#C0C0C0"); + color = Color(0.75, 0.75, 0.75); else if (col == "teal") - color = Color::html("#008008"); + color = Color(0, 0.5, 0.5); else if (col == "white") - color = Color::html("#FFFFFF"); + color = Color(1, 1, 1); else if (col == "yellow") - color = Color::html("#FFFF00"); + color = Color(1, 1, 0); else color = base_color; diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index d83ae47671..461281a4ed 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -486,7 +486,7 @@ String ScrollContainer::get_configuration_warning() const { } if (found != 1) - return TTR("ScrollContainer is intended to work with a single child control.\nUse a container as child (VBox,HBox,etc), or a Control and set the custom minimum size manually."); + return TTR("ScrollContainer is intended to work with a single child control.\nUse a container as child (VBox, HBox, etc.), or a Control and set the custom minimum size manually."); else return ""; } diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index e778af3ceb..db277d3705 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -40,7 +40,7 @@ Size2 SpinBox::get_minimum_size() const { void SpinBox::_value_changed(double) { - String value = String::num(get_value(), Math::step_decimals(get_step())); + String value = String::num(get_value(), Math::range_step_decimals(get_step())); if (prefix != "") value = prefix + " " + value; if (suffix != "") @@ -173,7 +173,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<Texture> &icon) { int w = icon->get_width(); if (w != last_w) { diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h index 49dc6d950c..9cf977d2d6 100644 --- a/scene/gui/spin_box.h +++ b/scene/gui/spin_box.h @@ -62,7 +62,7 @@ class SpinBox : public Range { void _line_edit_focus_exit(); - inline void _adjust_width_for_icon(const Ref<Texture> icon); + inline void _adjust_width_for_icon(const Ref<Texture> &icon); protected: void _gui_input(const Ref<InputEvent> &p_event); diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 39c76e6646..be8f1cf36e 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -303,7 +303,7 @@ void TabContainer::_notification(int p_what) { // Draw the tab contents. Control *control = Object::cast_to<Control>(tabs[i + first_tab_cache]); - String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(control->get_name()); + String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(tr(control->get_name())); int x_content = tab_rect.position.x + tab_style->get_margin(MARGIN_LEFT); int top_margin = tab_style->get_margin(MARGIN_TOP); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index a7b4e08553..ff0c723141 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -683,7 +683,7 @@ void TextEdit::_notification(int p_what) { } if (line_length_guideline) { - int x = xmargin_beg + cache.font->get_char_size('0').width * line_length_guideline_col - cursor.x_ofs; + int x = xmargin_beg + (int)cache.font->get_char_size('0').width * line_length_guideline_col - cursor.x_ofs; if (x > xmargin_beg && x < xmargin_end) { VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(x, 0), Point2(x, size.height), cache.line_length_guideline_color); } @@ -3287,28 +3287,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } break; - case KEY_U: { - if (!k->get_command() || k->get_shift()) { - scancode_handled = false; - break; - } else { - if (selection.active) { - int ini = selection.from_line; - int end = selection.to_line; - - for (int i = ini; i <= end; i++) { - _uncomment_line(i); - } - } else { - _uncomment_line(cursor.line); - if (cursor.column >= get_line(cursor.line).length()) { - cursor.column = MAX(0, get_line(cursor.line).length() - 1); - } - } - update(); - } - } break; - default: { scancode_handled = false; @@ -3367,24 +3345,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } } -void TextEdit::_uncomment_line(int p_line) { - String line_text = get_line(p_line); - for (int i = 0; i < line_text.length(); i++) { - if (line_text[i] == '#') { - _remove_text(p_line, i, p_line, i + 1); - if (p_line == selection.to_line && selection.to_column > line_text.length() - 1) { - selection.to_column -= 1; - if (selection.to_column >= selection.from_column) { - selection.active = false; - } - } - return; - } else if (line_text[i] != '\t' && line_text[i] != ' ') { - return; - } - } -} - void TextEdit::_scroll_up(real_t p_delta) { if (scrolling && smooth_scroll_enabled && SGN(target_v_scroll - v_scroll->get_value()) != SGN(-p_delta)) diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 9fb8e03288..b47dac0902 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -395,7 +395,6 @@ private: void _update_selection_mode_word(); void _update_selection_mode_line(); - void _uncomment_line(int p_line); void _scroll_up(real_t p_delta); void _scroll_down(real_t p_delta); diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 8624baa005..81f2f46a80 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -571,21 +571,7 @@ int TreeItem::get_button_by_id(int p_column, int p_id) const { return -1; } -void TreeItem::set_disable_button(int p_column, int p_idx, bool p_disabled) { - ERR_FAIL_INDEX(p_column, cells.size()); - ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size()); - - cells.write[p_column].buttons.write[p_idx].disabled = p_disabled; - _changed_notify(p_column); -} -bool TreeItem::is_button_disabled(int p_column, int p_idx) const { - - ERR_FAIL_INDEX_V(p_column, cells.size(), false); - ERR_FAIL_INDEX_V(p_idx, cells[p_column].buttons.size(), false); - - return cells[p_column].buttons[p_idx].disabled; -} void TreeItem::set_button(int p_column, int p_idx, const Ref<Texture> &p_button) { ERR_FAIL_COND(p_button.is_null()); @@ -603,6 +589,23 @@ void TreeItem::set_button_color(int p_column, int p_idx, const Color &p_color) { _changed_notify(p_column); } +void TreeItem::set_button_disabled(int p_column, int p_idx, bool p_disabled) { + + ERR_FAIL_INDEX(p_column, cells.size()); + ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size()); + + cells.write[p_column].buttons.write[p_idx].disabled = p_disabled; + _changed_notify(p_column); +} + +bool TreeItem::is_button_disabled(int p_column, int p_idx) const { + + ERR_FAIL_INDEX_V(p_column, cells.size(), false); + ERR_FAIL_INDEX_V(p_idx, cells[p_column].buttons.size(), false); + + return cells[p_column].buttons[p_idx].disabled; +} + void TreeItem::set_editable(int p_column, bool p_editable) { ERR_FAIL_INDEX(p_column, cells.size()); @@ -792,8 +795,8 @@ void TreeItem::_bind_methods() { ClassDB::bind_method(D_METHOD("get_button", "column", "button_idx"), &TreeItem::get_button); ClassDB::bind_method(D_METHOD("set_button", "column", "button_idx", "button"), &TreeItem::set_button); ClassDB::bind_method(D_METHOD("erase_button", "column", "button_idx"), &TreeItem::erase_button); + ClassDB::bind_method(D_METHOD("set_button_disabled", "column", "button_idx", "disabled"), &TreeItem::set_button_disabled); ClassDB::bind_method(D_METHOD("is_button_disabled", "column", "button_idx"), &TreeItem::is_button_disabled); - ClassDB::bind_method(D_METHOD("set_disable_button", "column", "button_idx", "disabled"), &TreeItem::set_disable_button); ClassDB::bind_method(D_METHOD("set_expand_right", "column", "enable"), &TreeItem::set_expand_right); ClassDB::bind_method(D_METHOD("get_expand_right", "column"), &TreeItem::get_expand_right); @@ -1312,7 +1315,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 Ref<Texture> updown = cache.updown; - String valtext = String::num(p_item->cells[i].val, Math::step_decimals(p_item->cells[i].step)); + String valtext = String::num(p_item->cells[i].val, Math::range_step_decimals(p_item->cells[i].step)); //String valtext = rtos( p_item->cells[i].val ); if (p_item->cells[i].suffix != String()) @@ -1923,7 +1926,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool } else { - editor_text = String::num(p_item->cells[col].val, Math::step_decimals(p_item->cells[col].step)); + editor_text = String::num(p_item->cells[col].val, Math::range_step_decimals(p_item->cells[col].step)); if (select_mode == SELECT_MULTI && get_tree()->get_event_count() == focus_in_id) bring_up_editor = false; } @@ -2752,7 +2755,7 @@ bool Tree::edit_selected() { text_editor->set_position(textedpos); text_editor->set_size(rect.size); text_editor->clear(); - text_editor->set_text(c.mode == TreeItem::CELL_MODE_STRING ? c.text : String::num(c.val, Math::step_decimals(c.step))); + text_editor->set_text(c.mode == TreeItem::CELL_MODE_STRING ? c.text : String::num(c.val, Math::range_step_decimals(c.step))); text_editor->select_all(); if (c.mode == TreeItem::CELL_MODE_RANGE) { @@ -2918,8 +2921,6 @@ void Tree::_notification(int p_what) { drag_touching = false; drag_touching_deaccel = false; } - - } else { } } diff --git a/scene/gui/tree.h b/scene/gui/tree.h index 6e5e2c1eba..b6cdab766f 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -209,10 +209,10 @@ public: int get_button_id(int p_column, int p_idx) const; void erase_button(int p_column, int p_idx); int get_button_by_id(int p_column, int p_id) const; - bool is_button_disabled(int p_column, int p_idx) const; void set_button(int p_column, int p_idx, const Ref<Texture> &p_button); void set_button_color(int p_column, int p_idx, const Color &p_color); - void set_disable_button(int p_column, int p_idx, bool p_disabled); + void set_button_disabled(int p_column, int p_idx, bool p_disabled); + bool is_button_disabled(int p_column, int p_idx) const; /* range works for mode number or mode combo */ |