diff options
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/box_container.cpp | 2 | ||||
-rw-r--r-- | scene/gui/container.cpp | 2 | ||||
-rw-r--r-- | scene/gui/control.cpp | 5 | ||||
-rw-r--r-- | scene/gui/graph_edit.cpp | 1 | ||||
-rw-r--r-- | scene/gui/grid_container.cpp | 2 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 39 | ||||
-rw-r--r-- | scene/gui/line_edit.h | 1 | ||||
-rw-r--r-- | scene/gui/option_button.cpp | 9 | ||||
-rw-r--r-- | scene/gui/panel.cpp | 2 | ||||
-rw-r--r-- | scene/gui/panel_container.cpp | 2 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 9 | ||||
-rw-r--r-- | scene/gui/split_container.cpp | 6 | ||||
-rw-r--r-- | scene/gui/tab_container.cpp | 16 | ||||
-rw-r--r-- | scene/gui/tab_container.h | 2 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 2 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 13 | ||||
-rw-r--r-- | scene/gui/tree.h | 3 |
17 files changed, 73 insertions, 43 deletions
diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp index 24312af1b5..e0bfeac9f7 100644 --- a/scene/gui/box_container.cpp +++ b/scene/gui/box_container.cpp @@ -289,8 +289,6 @@ BoxContainer::BoxContainer(bool p_vertical) { vertical = p_vertical; align = ALIGN_BEGIN; - //set_ignore_mouse(true); - set_mouse_filter(MOUSE_FILTER_PASS); } void BoxContainer::_bind_methods() { diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp index b07fec90c2..b411f563b8 100644 --- a/scene/gui/container.cpp +++ b/scene/gui/container.cpp @@ -197,4 +197,6 @@ void Container::_bind_methods() { Container::Container() { pending_sort = false; + // All containers should let mouse events pass by default. + set_mouse_filter(MOUSE_FILTER_PASS); } diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index ae48a1356e..4c70bd1d39 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -462,11 +462,6 @@ void Control::_update_canvas_item_transform() { Transform2D xform = _get_internal_transform(); xform[2] += get_position(); - // We use a little workaround to avoid flickering when moving the pivot with _edit_set_pivot() - if (is_inside_tree() && Math::abs(Math::sin(data.rotation * 4.0f)) < 0.00001f && get_viewport()->is_snap_controls_to_pixels_enabled()) { - xform[2] = xform[2].round(); - } - VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), xform); } diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 00ce57eb04..c09b2414b2 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -1342,7 +1342,6 @@ GraphEdit::GraphEdit() { top_layer->set_mouse_filter(MOUSE_FILTER_PASS); top_layer->set_anchors_and_margins_preset(Control::PRESET_WIDE); top_layer->connect("draw", this, "_top_layer_draw"); - top_layer->set_mouse_filter(MOUSE_FILTER_PASS); top_layer->connect("gui_input", this, "_top_layer_input"); connections_layer = memnew(Control); diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp index 04aed532d4..0028093a95 100644 --- a/scene/gui/grid_container.cpp +++ b/scene/gui/grid_container.cpp @@ -247,7 +247,5 @@ Size2 GridContainer::get_minimum_size() const { } GridContainer::GridContainer() { - - set_mouse_filter(MOUSE_FILTER_PASS); columns = 1; } diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 7afc3b0d00..2504989d2c 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -184,6 +184,12 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { case KEY_H: { remap_key = KEY_BACKSPACE; } break; + case KEY_A: { + remap_key = KEY_HOME; + } break; + case KEY_E: { + remap_key = KEY_END; + } break; } if (remap_key != KEY_UNKNOWN) { @@ -240,15 +246,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { deselect(); text = text.substr(cursor_pos, text.length() - cursor_pos); - - Ref<Font> font = get_font("font"); - - cached_width = 0; - if (font != NULL) { - for (int i = 0; i < text.length(); i++) - cached_width += font->get_char_size(text[i]).width; - } - + update_cached_width(); set_cursor_position(0); _text_changed(); } @@ -1358,18 +1356,10 @@ void LineEdit::set_window_pos(int p_pos) { void LineEdit::append_at_cursor(String p_text) { if ((max_length <= 0) || (text.length() + p_text.length() <= max_length)) { - - Ref<Font> font = get_font("font"); - if (font != NULL) { - for (int i = 0; i < p_text.length(); i++) - cached_width += font->get_char_size(p_text[i]).width; - } else { - cached_width = 0; - } - String pre = text.substr(0, cursor_pos); String post = text.substr(cursor_pos, text.length() - cursor_pos); text = pre + p_text + post; + update_cached_width(); set_cursor_position(cursor_pos + p_text.length()); } else { emit_signal("text_change_rejected"); @@ -1499,6 +1489,7 @@ bool LineEdit::is_editable() const { void LineEdit::set_secret(bool p_secret) { pass = p_secret; + update_cached_width(); update(); } @@ -1514,6 +1505,7 @@ void LineEdit::set_secret_character(const String &p_string) { ERR_FAIL_COND_MSG(p_string.length() != 1, "Secret character must be exactly one character long (" + itos(p_string.length()) + " characters given)."); secret_character = p_string; + update_cached_width(); update(); } @@ -1685,6 +1677,17 @@ void LineEdit::_emit_text_change() { text_changed_dirty = false; } +void LineEdit::update_cached_width() { + Ref<Font> font = get_font("font"); + cached_width = 0; + if (font != NULL) { + String text = get_text(); + for (int i = 0; i < text.length(); i++) { + cached_width += font->get_char_size(pass ? secret_character[0] : text[i]).width; + } + } +} + void LineEdit::update_placeholder_width() { if ((max_length <= 0) || (placeholder_translated.length() <= max_length)) { Ref<Font> font = get_font("font"); diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index cf597d11b6..037238d682 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -132,6 +132,7 @@ private: void _emit_text_change(); bool expand_to_text_length; + void update_cached_width(); void update_placeholder_width(); bool caret_blink_enabled; diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index 8598a953b4..3f46afa8e8 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -36,7 +36,14 @@ Size2 OptionButton::get_minimum_size() const { Size2 minsize = Button::get_minimum_size(); if (has_icon("arrow")) { - minsize.width += Control::get_icon("arrow")->get_width() + get_constant("hseparation"); + const Size2 padding = get_stylebox("normal")->get_minimum_size(); + const Size2 arrow_size = Control::get_icon("arrow")->get_size(); + + Size2 content_size = minsize - padding; + content_size.width += arrow_size.width + get_constant("hseparation"); + content_size.height = MAX(content_size.height, arrow_size.height); + + minsize = content_size + padding; } return minsize; diff --git a/scene/gui/panel.cpp b/scene/gui/panel.cpp index aa1a381934..0356607071 100644 --- a/scene/gui/panel.cpp +++ b/scene/gui/panel.cpp @@ -42,7 +42,7 @@ void Panel::_notification(int p_what) { } Panel::Panel() { - + // Has visible stylebox, so stop by default. set_mouse_filter(MOUSE_FILTER_STOP); } diff --git a/scene/gui/panel_container.cpp b/scene/gui/panel_container.cpp index 74663c33e3..6cf23b8a32 100644 --- a/scene/gui/panel_container.cpp +++ b/scene/gui/panel_container.cpp @@ -103,4 +103,6 @@ void PanelContainer::_notification(int p_what) { } PanelContainer::PanelContainer() { + // Has visible stylebox, so stop by default. + set_mouse_filter(MOUSE_FILTER_STOP); } diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index a9b9aa4a4a..b19e1d8362 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -33,8 +33,13 @@ #include "core/math/math_defs.h" #include "core/os/keyboard.h" #include "core/os/os.h" -#include "modules/regex/regex.h" #include "scene/scene_string_names.h" + +#include "modules/modules_enabled.gen.h" +#ifdef MODULE_REGEX_ENABLED +#include "modules/regex/regex.h" +#endif + #ifdef TOOLS_ENABLED #include "editor/editor_scale.h" #endif @@ -2873,6 +2878,7 @@ Dictionary RichTextLabel::parse_expressions_for_values(Vector<String> p_expressi Vector<String> values = parts[1].split(",", false); +#ifdef MODULE_REGEX_ENABLED RegEx color = RegEx(); color.compile("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$"); RegEx nodepath = RegEx(); @@ -2906,6 +2912,7 @@ Dictionary RichTextLabel::parse_expressions_for_values(Vector<String> p_expressi a.append(values[j]); } } +#endif if (values.size() > 1) { d[key] = a; diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp index bb5260b15e..079907db07 100644 --- a/scene/gui/split_container.cpp +++ b/scene/gui/split_container.cpp @@ -266,7 +266,7 @@ void SplitContainer::_gui_input(const Ref<InputEvent> &p_event) { Control::CursorShape SplitContainer::get_cursor_shape(const Point2 &p_pos) const { if (dragging) - return (vertical ? CURSOR_VSIZE : CURSOR_HSIZE); + return (vertical ? CURSOR_VSPLIT : CURSOR_HSPLIT); if (!collapsed && _getch(0) && _getch(1) && dragger_visibility == DRAGGER_VISIBLE) { @@ -275,11 +275,11 @@ Control::CursorShape SplitContainer::get_cursor_shape(const Point2 &p_pos) const if (vertical) { if (p_pos.y > middle_sep && p_pos.y < middle_sep + sep) - return CURSOR_VSIZE; + return CURSOR_VSPLIT; } else { if (p_pos.x > middle_sep && p_pos.x < middle_sep + sep) - return CURSOR_HSIZE; + return CURSOR_HSPLIT; } } diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index c3ddc41813..b045ff4fe1 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -785,23 +785,25 @@ TabContainer::TabAlign TabContainer::get_tab_align() const { return align; } -void TabContainer::set_tabs_visible(bool p_visibe) { +void TabContainer::set_tabs_visible(bool p_visible) { - if (p_visibe == tabs_visible) + if (p_visible == tabs_visible) return; - tabs_visible = p_visibe; + tabs_visible = p_visible; Vector<Control *> tabs = _get_tabs(); for (int i = 0; i < tabs.size(); i++) { Control *c = tabs[i]; - if (p_visibe) + if (p_visible) c->set_margin(MARGIN_TOP, _get_top_margin()); else c->set_margin(MARGIN_TOP, 0); } + update(); + minimum_size_changed(); } bool TabContainer::are_tabs_visible() const { @@ -936,8 +938,10 @@ Size2 TabContainer::get_minimum_size() const { Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled"); Ref<Font> font = get_font("font"); - ms.y += MAX(MAX(tab_bg->get_minimum_size().y, tab_fg->get_minimum_size().y), tab_disabled->get_minimum_size().y); - ms.y += font->get_height(); + if (tabs_visible) { + ms.y += MAX(MAX(tab_bg->get_minimum_size().y, tab_fg->get_minimum_size().y), tab_disabled->get_minimum_size().y); + ms.y += font->get_height(); + } Ref<StyleBox> sb = get_stylebox("panel"); ms += sb->get_minimum_size(); diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h index e69c2ae289..c5a9045ca6 100644 --- a/scene/gui/tab_container.h +++ b/scene/gui/tab_container.h @@ -87,7 +87,7 @@ public: void set_tab_align(TabAlign p_align); TabAlign get_tab_align() const; - void set_tabs_visible(bool p_visibe); + void set_tabs_visible(bool p_visible); bool are_tabs_visible() const; void set_tab_title(int p_tab, const String &p_title); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 6de2f0b570..93d0ae080b 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -4480,7 +4480,7 @@ void TextEdit::cursor_set_line(int p_row, bool p_adjust_viewport, bool p_can_be_ if (p_row - move_up > 0 && !is_line_hidden(p_row - move_up)) { p_row -= move_up; } else { - WARN_PRINTS(("Cursor set to hidden line " + itos(p_row) + " and there are no nonhidden lines.")); + WARN_PRINT(("Cursor set to hidden line " + itos(p_row) + " and there are no nonhidden lines.")); } } } diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 964f376dbd..790e1d5f4f 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1121,7 +1121,7 @@ void Tree::draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, co } rect.position.y += Math::floor((rect.size.y - font->get_height()) / 2.0) + font->get_ascent(); - font->draw(ci, rect.position, text, p_color, rect.size.x); + font->draw(ci, rect.position, text, p_color, MAX(0, rect.size.width)); } int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item) { @@ -3630,6 +3630,17 @@ TreeItem *Tree::search_item_text(const String &p_find, int *r_col, bool p_select return _search_item_text(from->get_next_visible(true), p_find, r_col, p_selectable); } +TreeItem *Tree::get_item_with_text(const String &p_find) const { + for (TreeItem *current = root; current; current = current->get_next_visible()) { + for (int i = 0; i < columns.size(); i++) { + if (current->get_text(i) == p_find) { + return current; + } + } + } + return NULL; +} + void Tree::_do_incr_search(const String &p_add) { uint64_t time = OS::get_singleton()->get_ticks_usec() / 1000; // convert to msec diff --git a/scene/gui/tree.h b/scene/gui/tree.h index d87de6e773..f3c88eb5ac 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -577,7 +577,10 @@ public: Rect2 get_item_rect(TreeItem *p_item, int p_column = -1) const; bool edit_selected(); + // First item that starts with the text, from the current focused item down and wraps around. TreeItem *search_item_text(const String &p_find, int *r_col = NULL, bool p_selectable = false); + // First item that matches the whole text, from the first item down. + TreeItem *get_item_with_text(const String &p_find) const; Point2 get_scroll() const; void scroll_to_item(TreeItem *p_item); |