diff options
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/base_button.cpp | 11 | ||||
-rw-r--r-- | scene/gui/base_button.h | 1 | ||||
-rw-r--r-- | scene/gui/color_picker.cpp | 59 | ||||
-rw-r--r-- | scene/gui/color_picker.h | 3 | ||||
-rw-r--r-- | scene/gui/control.cpp | 18 | ||||
-rw-r--r-- | scene/gui/graph_edit.cpp | 4 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 16 | ||||
-rw-r--r-- | scene/gui/line_edit.h | 1 | ||||
-rw-r--r-- | scene/gui/menu_button.cpp | 19 | ||||
-rw-r--r-- | scene/gui/menu_button.h | 3 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 39 | ||||
-rw-r--r-- | scene/gui/rich_text_label.h | 1 | ||||
-rw-r--r-- | scene/gui/spin_box.cpp | 34 | ||||
-rw-r--r-- | scene/gui/spin_box.h | 4 | ||||
-rw-r--r-- | scene/gui/split_container.cpp | 15 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 28 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 3 |
17 files changed, 163 insertions, 96 deletions
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 1ac19774f7..dc85c8e641 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -595,6 +595,16 @@ void ButtonGroup::get_buttons(List<BaseButton *> *r_buttons) { } } +Array ButtonGroup::_get_buttons() { + + Array btns; + for (Set<BaseButton *>::Element *E = buttons.front(); E; E = E->next()) { + btns.push_back(E->get()); + } + + return btns; +} + BaseButton *ButtonGroup::get_pressed_button() { for (Set<BaseButton *>::Element *E = buttons.front(); E; E = E->next()) { @@ -608,6 +618,7 @@ BaseButton *ButtonGroup::get_pressed_button() { void ButtonGroup::_bind_methods() { ClassDB::bind_method(D_METHOD("get_pressed_button"), &ButtonGroup::get_pressed_button); + ClassDB::bind_method(D_METHOD("get_buttons"), &ButtonGroup::_get_buttons); } ButtonGroup::ButtonGroup() { diff --git a/scene/gui/base_button.h b/scene/gui/base_button.h index a131e719ad..272c07f68a 100644 --- a/scene/gui/base_button.h +++ b/scene/gui/base_button.h @@ -143,6 +143,7 @@ protected: public: BaseButton *get_pressed_button(); void get_buttons(List<BaseButton *> *r_buttons); + Array _get_buttons(); ButtonGroup(); }; diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index c5d3def4c1..523e07087b 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -204,22 +204,9 @@ void ColorPicker::_update_presets() { preset->draw_texture_rect(get_icon("preset_bg", "ColorPicker"), Rect2(Point2(), preset_size), true); -#ifdef TOOLS_ENABLED - if (Engine::get_singleton()->is_editor_hint()) { - PoolColorArray arr_to_save = PoolColorArray(); - - for (int i = 0; i < presets.size(); i++) { - preset->draw_rect(Rect2(Point2(size.width * i, 0), size), presets[i]); - arr_to_save.insert(i, presets[i]); - } - - EditorSettings::get_singleton()->set_project_metadata("color_picker", "presets", arr_to_save); - } -#else for (int i = 0; i < presets.size(); i++) { preset->draw_rect(Rect2(Point2(size.width * i, 0), size), presets[i]); } -#endif } void ColorPicker::_text_type_toggled() { @@ -251,6 +238,38 @@ void ColorPicker::add_preset(const Color &p_color) { preset->update(); if (presets.size() == 10) bt_add_preset->hide(); + +#ifdef TOOLS_ENABLED + if (Engine::get_singleton()->is_editor_hint()) { + PoolColorArray arr_to_save = get_presets(); + EditorSettings::get_singleton()->set_project_metadata("color_picker", "presets", arr_to_save); + } +#endif +} + +void ColorPicker::erase_preset(const Color &p_color) { + + if (presets.find(p_color)) { + presets.erase(presets.find(p_color)); + preset->update(); + +#ifdef TOOLS_ENABLED + if (Engine::get_singleton()->is_editor_hint()) { + PoolColorArray arr_to_save = get_presets(); + EditorSettings::get_singleton()->set_project_metadata("color_picker", "presets", arr_to_save); + } +#endif + } +} + +PoolColorArray ColorPicker::get_presets() const { + + PoolColorArray arr; + arr.resize(presets.size()); + for (int i = 0; i < presets.size(); i++) { + arr.set(i, presets[i]); + } + return arr; } void ColorPicker::set_raw_mode(bool p_enabled) { @@ -444,14 +463,15 @@ void ColorPicker::_preset_input(const Ref<InputEvent> &p_event) { if (bev->is_pressed() && bev->get_button_index() == BUTTON_LEFT) { int index = bev->get_position().x / (preset->get_size().x / presets.size()); set_pick_color(presets[index]); + _update_color(); + emit_signal("color_changed", color); } else if (bev->is_pressed() && bev->get_button_index() == BUTTON_RIGHT) { int index = bev->get_position().x / (preset->get_size().x / presets.size()); - presets.erase(presets[index]); - preset->update(); + Color clicked_preset = presets[index]; + erase_preset(clicked_preset); + emit_signal("preset_removed", clicked_preset); bt_add_preset->show(); } - _update_color(); - emit_signal("color_changed", color); } Ref<InputEventMouseMotion> mev = p_event; @@ -501,6 +521,7 @@ void ColorPicker::_screen_input(const Ref<InputEvent> &p_event) { void ColorPicker::_add_preset_pressed() { add_preset(color); + emit_signal("preset_added", color); } void ColorPicker::_screen_pick_pressed() { @@ -553,6 +574,8 @@ void ColorPicker::_bind_methods() { ClassDB::bind_method(D_METHOD("set_edit_alpha", "show"), &ColorPicker::set_edit_alpha); ClassDB::bind_method(D_METHOD("is_editing_alpha"), &ColorPicker::is_editing_alpha); ClassDB::bind_method(D_METHOD("add_preset", "color"), &ColorPicker::add_preset); + ClassDB::bind_method(D_METHOD("erase_preset", "color"), &ColorPicker::erase_preset); + ClassDB::bind_method(D_METHOD("get_presets"), &ColorPicker::get_presets); ClassDB::bind_method(D_METHOD("_value_changed"), &ColorPicker::_value_changed); ClassDB::bind_method(D_METHOD("_html_entered"), &ColorPicker::_html_entered); ClassDB::bind_method(D_METHOD("_text_type_toggled"), &ColorPicker::_text_type_toggled); @@ -575,6 +598,8 @@ void ColorPicker::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "deferred_mode"), "set_deferred_mode", "is_deferred_mode"); ADD_SIGNAL(MethodInfo("color_changed", PropertyInfo(Variant::COLOR, "color"))); + ADD_SIGNAL(MethodInfo("preset_added", PropertyInfo(Variant::COLOR, "color"))); + ADD_SIGNAL(MethodInfo("preset_removed", PropertyInfo(Variant::COLOR, "color"))); } ColorPicker::ColorPicker() : diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h index 0166da7118..e32c830434 100644 --- a/scene/gui/color_picker.h +++ b/scene/gui/color_picker.h @@ -105,6 +105,9 @@ public: Color get_pick_color() const; void add_preset(const Color &p_color); + void erase_preset(const Color &p_color); + PoolColorArray get_presets() const; + void set_raw_mode(bool p_enabled); bool is_raw_mode() const; diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 79e1d35b94..a580d89439 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -451,6 +451,11 @@ 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); } @@ -1336,11 +1341,6 @@ void Control::_size_changed() { new_size_cache.height = minimum_size.height; } - // 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()) { - new_size_cache = new_size_cache.round(); - new_pos_cache = new_pos_cache.round(); - } bool pos_changed = new_pos_cache != data.pos_cache; bool size_changed = new_size_cache != data.size_cache; @@ -1740,10 +1740,10 @@ Rect2 Control::_compute_child_rect(const float p_anchors[4], const float p_margi void Control::_compute_margins(Rect2 p_rect, const float p_anchors[4], float (&r_margins)[4]) { Size2 parent_rect_size = get_parent_anchorable_rect().size; - r_margins[0] = Math::floor(p_rect.position.x - (p_anchors[0] * parent_rect_size.x)); - r_margins[1] = Math::floor(p_rect.position.y - (p_anchors[1] * parent_rect_size.y)); - r_margins[2] = Math::floor(p_rect.position.x + p_rect.size.x - (p_anchors[2] * parent_rect_size.x)); - r_margins[3] = Math::floor(p_rect.position.y + p_rect.size.y - (p_anchors[3] * parent_rect_size.y)); + r_margins[0] = p_rect.position.x - (p_anchors[0] * parent_rect_size.x); + r_margins[1] = p_rect.position.y - (p_anchors[1] * parent_rect_size.y); + r_margins[2] = p_rect.position.x + p_rect.size.x - (p_anchors[2] * parent_rect_size.x); + r_margins[3] = p_rect.position.y + p_rect.size.y - (p_anchors[3] * parent_rect_size.y); } void Control::set_position(const Size2 &p_point) { diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index b3bebc88ec..eee3213fe7 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -1339,21 +1339,25 @@ GraphEdit::GraphEdit() { zoom_minus = memnew(ToolButton); zoom_hb->add_child(zoom_minus); + zoom_minus->set_tooltip(RTR("Zoom Out")); zoom_minus->connect("pressed", this, "_zoom_minus"); zoom_minus->set_focus_mode(FOCUS_NONE); zoom_reset = memnew(ToolButton); zoom_hb->add_child(zoom_reset); + zoom_reset->set_tooltip(RTR("Zoom Reset")); zoom_reset->connect("pressed", this, "_zoom_reset"); zoom_reset->set_focus_mode(FOCUS_NONE); zoom_plus = memnew(ToolButton); zoom_hb->add_child(zoom_plus); + zoom_plus->set_tooltip(RTR("Zoom In")); zoom_plus->connect("pressed", this, "_zoom_plus"); zoom_plus->set_focus_mode(FOCUS_NONE); snap_button = memnew(ToolButton); snap_button->set_toggle_mode(true); + snap_button->set_tooltip(RTR("Enable snap and show grid.")); snap_button->connect("pressed", this, "_snap_toggled"); snap_button->set_pressed(true); snap_button->set_focus_mode(FOCUS_NONE); diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 299c304c5f..42d7f1b080 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -831,7 +831,6 @@ void LineEdit::_notification(int p_what) { OS::get_singleton()->set_ime_active(true); OS::get_singleton()->set_ime_position(get_global_position() + Point2(using_placeholder ? 0 : x_ofs, y_ofs + caret_height)); - OS::get_singleton()->set_ime_intermediate_text_callback(_ime_text_callback, this); } } break; case NOTIFICATION_FOCUS_ENTER: { @@ -843,7 +842,6 @@ void LineEdit::_notification(int p_what) { OS::get_singleton()->set_ime_active(true); Point2 cursor_pos = Point2(get_cursor_position(), 1) * get_minimum_size().height; OS::get_singleton()->set_ime_position(get_global_position() + cursor_pos); - OS::get_singleton()->set_ime_intermediate_text_callback(_ime_text_callback, this); if (OS::get_singleton()->has_virtual_keyboard()) OS::get_singleton()->show_virtual_keyboard(text, get_global_rect()); @@ -852,7 +850,6 @@ void LineEdit::_notification(int p_what) { case NOTIFICATION_FOCUS_EXIT: { OS::get_singleton()->set_ime_position(Point2()); - OS::get_singleton()->set_ime_intermediate_text_callback(NULL, NULL); OS::get_singleton()->set_ime_active(false); ime_text = ""; ime_selection = Point2(); @@ -861,6 +858,12 @@ void LineEdit::_notification(int p_what) { OS::get_singleton()->hide_virtual_keyboard(); } break; + case MainLoop::NOTIFICATION_OS_IME_UPDATE: { + + ime_text = OS::get_singleton()->get_ime_text(); + ime_selection = OS::get_singleton()->get_ime_selection(); + update(); + } break; } } @@ -1461,13 +1464,6 @@ void LineEdit::set_right_icon(const Ref<Texture> &p_icon) { update(); } -void LineEdit::_ime_text_callback(void *p_self, String p_text, Point2 p_selection) { - LineEdit *self = (LineEdit *)p_self; - self->ime_text = p_text; - self->ime_selection = p_selection; - self->update(); -} - void LineEdit::_text_changed() { if (expand_to_text_length) diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index 5294d99da0..ddcdeda8c0 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -122,7 +122,6 @@ private: Timer *caret_blink_timer; - static void _ime_text_callback(void *p_self, String p_text, Point2 p_selection); void _text_changed(); void _emit_text_change(); bool expand_to_text_length; diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp index 95ec618c3b..b4cb297900 100644 --- a/scene/gui/menu_button.cpp +++ b/scene/gui/menu_button.cpp @@ -71,13 +71,24 @@ PopupMenu *MenuButton::get_popup() const { return popup; } +void MenuButton::_set_items(const Array &p_items) { + + popup->set("items", p_items); +} + Array MenuButton::_get_items() const { return popup->get("items"); } -void MenuButton::_set_items(const Array &p_items) { - popup->set("items", p_items); +void MenuButton::set_switch_on_hover(bool p_enabled) { + + switch_on_hover = p_enabled; +} + +bool MenuButton::is_switch_on_hover() { + + return switch_on_hover; } void MenuButton::_bind_methods() { @@ -86,9 +97,12 @@ void MenuButton::_bind_methods() { ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &MenuButton::_unhandled_key_input); ClassDB::bind_method(D_METHOD("_set_items"), &MenuButton::_set_items); ClassDB::bind_method(D_METHOD("_get_items"), &MenuButton::_get_items); + ClassDB::bind_method(D_METHOD("set_switch_on_hover", "enable"), &MenuButton::set_switch_on_hover); + ClassDB::bind_method(D_METHOD("is_switch_on_hover"), &MenuButton::is_switch_on_hover); ClassDB::bind_method(D_METHOD("set_disable_shortcuts", "disabled"), &MenuButton::set_disable_shortcuts); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "items", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_items", "_get_items"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "switch_on_hover"), "set_switch_on_hover", "is_switch_on_hover"); ADD_SIGNAL(MethodInfo("about_to_show")); } @@ -100,6 +114,7 @@ void MenuButton::set_disable_shortcuts(bool p_disabled) { MenuButton::MenuButton() { + switch_on_hover = false; set_flat(true); set_disable_shortcuts(false); set_enabled_focus_mode(FOCUS_NONE); diff --git a/scene/gui/menu_button.h b/scene/gui/menu_button.h index 0636accfee..abc49f4988 100644 --- a/scene/gui/menu_button.h +++ b/scene/gui/menu_button.h @@ -41,6 +41,7 @@ class MenuButton : public Button { GDCLASS(MenuButton, Button); bool clicked; + bool switch_on_hover; bool disable_shortcuts; PopupMenu *popup; @@ -57,6 +58,8 @@ public: virtual void pressed(); PopupMenu *get_popup() const; + void set_switch_on_hover(bool p_enabled); + bool is_switch_on_hover(); void set_disable_shortcuts(bool p_disabled); MenuButton(); diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 17de346f51..db890bf1c8 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -765,20 +765,19 @@ void RichTextLabel::_update_scroll() { if (exceeds) { scroll_visible = true; - main->first_invalid_line = 0; scroll_w = vscroll->get_combined_minimum_size().width; vscroll->show(); vscroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -scroll_w); - _validate_line_caches(main); - } else { - scroll_visible = false; - vscroll->hide(); scroll_w = 0; - _validate_line_caches(main); + vscroll->hide(); } + + main->first_invalid_line = 0; //invalidate ALL + _validate_line_caches(main); } + scroll_updated = true; } void RichTextLabel::_notification(int p_what) { @@ -931,6 +930,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { if (true) { if (b->is_pressed() && !b->is_doubleclick()) { + scroll_updated = false; int line = 0; Item *item = NULL; @@ -939,12 +939,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { if (item) { - Variant meta; - if (!outside && _find_meta(item, &meta)) { - //meta clicked - - emit_signal("meta_clicked", meta); - } else if (selection.enabled) { + if (selection.enabled) { selection.click = item; selection.click_char = line; @@ -993,6 +988,24 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { } else if (!b->is_pressed()) { selection.click = NULL; + + if (!b->is_doubleclick() && !scroll_updated) { + int line = 0; + Item *item = NULL; + + bool outside; + _find_click(main, b->get_position(), &item, &line, &outside); + + if (item) { + + Variant meta; + if (!outside && _find_meta(item, &meta)) { + //meta clicked + + emit_signal("meta_clicked", meta); + } + } + } } } } @@ -1616,7 +1629,6 @@ void RichTextLabel::clear() { main->lines.clear(); main->lines.resize(1); main->first_invalid_line = 0; - scroll_w = 0; update(); selection.click = NULL; selection.active = false; @@ -2327,6 +2339,7 @@ RichTextLabel::RichTextLabel() { updating_scroll = false; scroll_active = true; scroll_w = 0; + scroll_updated = false; vscroll = memnew(VScrollBar); add_child(vscroll); diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index c2e5712b9d..7c30738e2d 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -225,6 +225,7 @@ private: bool scroll_following; bool scroll_active; int scroll_w; + bool scroll_updated; bool updating_scroll; int current_idx; int visible_line_count; diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index ace22dddff..4f43bb0581 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -110,6 +110,9 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) { range_click_timer->start(); line_edit->grab_focus(); + + drag.allowed = true; + drag.capture_pos = mb->get_position(); } break; case BUTTON_RIGHT: { @@ -133,14 +136,7 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) { } } - if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == 1) { - - //set_default_cursor_shape(CURSOR_VSIZE); - Vector2 cpos = Vector2(mb->get_position().x, mb->get_position().y); - drag.mouse_pos = cpos; - } - - if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == 1) { + if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { //set_default_cursor_shape(CURSOR_ARROW); range_click_timer->stop(); @@ -150,32 +146,24 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) { Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE); warp_mouse(drag.capture_pos); } + drag.allowed = false; } Ref<InputEventMouseMotion> mm = p_event; - if (mm.is_valid() && mm->get_button_mask() & 1) { - - Vector2 cpos = mm->get_position(); + if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) { if (drag.enabled) { - float diff_y = drag.mouse_pos.y - cpos.y; - diff_y = Math::pow(ABS(diff_y), 1.8f) * SGN(diff_y); - diff_y *= 0.1; - - drag.mouse_pos = cpos; - drag.base_val = CLAMP(drag.base_val + get_step() * diff_y, get_min(), get_max()); - - set_value(drag.base_val); - - } else if (drag.mouse_pos.distance_to(cpos) > 2) { + drag.diff_y += mm->get_relative().y; + float diff_y = -0.01 * Math::pow(ABS(drag.diff_y), 1.8f) * SGN(drag.diff_y); + set_value(CLAMP(drag.base_val + get_step() * diff_y, get_min(), get_max())); + } else if (drag.allowed && drag.capture_pos.distance_to(mm->get_position()) > 2) { Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED); drag.enabled = true; drag.base_val = get_value(); - drag.mouse_pos = cpos; - drag.capture_pos = cpos; + drag.diff_y = 0; } } } diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h index f1ee26d9f3..6425af7158 100644 --- a/scene/gui/spin_box.h +++ b/scene/gui/spin_box.h @@ -54,10 +54,10 @@ class SpinBox : public Range { struct Drag { float base_val; + bool allowed; bool enabled; - Vector2 from; - Vector2 mouse_pos; Vector2 capture_pos; + float diff_y; } drag; void _line_edit_focus_exit(); diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp index 3554f04cc0..c3265d3ed5 100644 --- a/scene/gui/split_container.cpp +++ b/scene/gui/split_container.cpp @@ -94,12 +94,15 @@ void SplitContainer::_resort() { } // Compute the final middle separation - int clamped_split_offset = CLAMP(split_offset, ms_first[axis] - no_offset_middle_sep, (get_size()[axis] - ms_second[axis] - sep) - no_offset_middle_sep); - middle_sep = no_offset_middle_sep + clamped_split_offset; - if (!collapsed && should_clamp_split_offset) { - split_offset = clamped_split_offset; - _change_notify("split_offset"); - should_clamp_split_offset = false; + middle_sep = no_offset_middle_sep; + if (!collapsed) { + int clamped_split_offset = CLAMP(split_offset, ms_first[axis] - no_offset_middle_sep, (get_size()[axis] - ms_second[axis] - sep) - no_offset_middle_sep); + middle_sep += clamped_split_offset; + if (should_clamp_split_offset) { + split_offset = clamped_split_offset; + _change_notify("split_offset"); + should_clamp_split_offset = false; + } } if (vertical) { diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 5fe6fcdfac..fef29b7e6c 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1412,7 +1412,6 @@ void TextEdit::_notification(int p_what) { if (has_focus()) { OS::get_singleton()->set_ime_active(true); OS::get_singleton()->set_ime_position(get_global_position() + cursor_pos + Point2(0, get_row_height())); - OS::get_singleton()->set_ime_intermediate_text_callback(_ime_text_callback, this); } } break; @@ -1425,7 +1424,6 @@ void TextEdit::_notification(int p_what) { OS::get_singleton()->set_ime_active(true); Point2 cursor_pos = Point2(cursor_get_column(), cursor_get_line()) * get_row_height(); OS::get_singleton()->set_ime_position(get_global_position() + cursor_pos); - OS::get_singleton()->set_ime_intermediate_text_callback(_ime_text_callback, this); if (OS::get_singleton()->has_virtual_keyboard()) OS::get_singleton()->show_virtual_keyboard(get_text(), get_global_rect()); @@ -1433,7 +1431,6 @@ void TextEdit::_notification(int p_what) { case NOTIFICATION_FOCUS_EXIT: { OS::get_singleton()->set_ime_position(Point2()); - OS::get_singleton()->set_ime_intermediate_text_callback(NULL, NULL); OS::get_singleton()->set_ime_active(false); ime_text = ""; ime_selection = Point2(); @@ -1441,14 +1438,13 @@ void TextEdit::_notification(int p_what) { if (OS::get_singleton()->has_virtual_keyboard()) OS::get_singleton()->hide_virtual_keyboard(); } break; - } -} + case MainLoop::NOTIFICATION_OS_IME_UPDATE: { -void TextEdit::_ime_text_callback(void *p_self, String p_text, Point2 p_selection) { - TextEdit *self = (TextEdit *)p_self; - self->ime_text = p_text; - self->ime_selection = p_selection; - self->update(); + ime_text = OS::get_singleton()->get_ime_text(); + ime_selection = OS::get_singleton()->get_ime_selection(); + update(); + } break; + } } void TextEdit::_consume_pair_symbol(CharType ch) { @@ -5758,6 +5754,7 @@ void TextEdit::_update_completion_candidates() { completion_base = s; Vector<float> sim_cache; bool single_quote = s.begins_with("'"); + Vector<String> completion_options_casei; for (int i = 0; i < completion_strings.size(); i++) { if (single_quote && completion_strings[i].is_quoted()) { @@ -5766,9 +5763,13 @@ void TextEdit::_update_completion_candidates() { if (completion_strings[i].begins_with(s)) { completion_options.push_back(completion_strings[i]); + } else if (completion_strings[i].to_lower().begins_with(s.to_lower())) { + completion_options_casei.push_back(completion_strings[i]); } } + completion_options.append_array(completion_options_casei); + if (completion_options.size() == 0) { for (int i = 0; i < completion_strings.size(); i++) { if (s.is_subsequence_of(completion_strings[i])) { @@ -6040,7 +6041,10 @@ void TextEdit::menu_option(int p_option) { case MENU_UNDO: { undo(); } break; - }; + case MENU_REDO: { + redo(); + } + } } void TextEdit::set_select_identifiers_on_hover(bool p_enable) { @@ -6216,6 +6220,7 @@ void TextEdit::_bind_methods() { BIND_ENUM_CONSTANT(MENU_CLEAR); BIND_ENUM_CONSTANT(MENU_SELECT_ALL); BIND_ENUM_CONSTANT(MENU_UNDO); + BIND_ENUM_CONSTANT(MENU_REDO); BIND_ENUM_CONSTANT(MENU_MAX); GLOBAL_DEF("gui/timers/text_edit_idle_detect_sec", 3); @@ -6344,6 +6349,7 @@ TextEdit::TextEdit() { menu->add_item(RTR("Clear"), MENU_CLEAR); menu->add_separator(); menu->add_item(RTR("Undo"), MENU_UNDO, KEY_MASK_CMD | KEY_Z); + menu->add_item(RTR("Redo"), MENU_REDO, KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_Z); menu->connect("id_pressed", this, "menu_option"); } diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 8a508a8738..f069ffc167 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -380,8 +380,6 @@ private: void _scroll_lines_up(); void _scroll_lines_down(); - static void _ime_text_callback(void *p_self, String p_text, Point2 p_selection); - //void mouse_motion(const Point& p_pos, const Point& p_rel, int p_button_mask); Size2 get_minimum_size() const; @@ -444,6 +442,7 @@ public: MENU_CLEAR, MENU_SELECT_ALL, MENU_UNDO, + MENU_REDO, MENU_MAX }; |