summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/base_button.cpp1
-rw-r--r--scene/gui/code_edit.cpp47
-rw-r--r--scene/gui/code_edit.h1
-rw-r--r--scene/gui/color_picker.cpp94
-rw-r--r--scene/gui/color_picker.h8
-rw-r--r--scene/gui/control.cpp21
-rw-r--r--scene/gui/control.h14
-rw-r--r--scene/gui/dialogs.cpp4
-rw-r--r--scene/gui/item_list.cpp6
-rw-r--r--scene/gui/item_list.h1
-rw-r--r--scene/gui/label.cpp9
-rw-r--r--scene/gui/label.h2
-rw-r--r--scene/gui/line_edit.cpp2
-rw-r--r--scene/gui/menu_bar.cpp8
-rw-r--r--scene/gui/popup.cpp6
-rw-r--r--scene/gui/popup_menu.cpp6
-rw-r--r--scene/gui/rich_text_label.cpp4
-rw-r--r--scene/gui/scroll_bar.cpp6
-rw-r--r--scene/gui/separator.cpp2
-rw-r--r--scene/gui/slider.cpp6
-rw-r--r--scene/gui/tab_container.cpp5
-rw-r--r--scene/gui/text_edit.cpp10
-rw-r--r--scene/gui/text_edit.h2
-rw-r--r--scene/gui/tree.cpp2
24 files changed, 112 insertions, 155 deletions
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index d0326290ac..472299b135 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -385,6 +385,7 @@ void BaseButton::shortcut_input(const Ref<InputEvent> &p_event) {
if (shortcut_feedback) {
if (shortcut_feedback_timer == nullptr) {
shortcut_feedback_timer = memnew(Timer);
+ shortcut_feedback_timer->set_one_shot(true);
add_child(shortcut_feedback_timer);
shortcut_feedback_timer->set_wait_time(GLOBAL_GET("gui/timers/button_shortcut_feedback_highlight_time"));
shortcut_feedback_timer->connect("timeout", callable_mp(this, &BaseButton::_shortcut_feedback_timeout));
diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp
index 4356e91e41..c977d9d2fb 100644
--- a/scene/gui/code_edit.cpp
+++ b/scene/gui/code_edit.cpp
@@ -548,7 +548,7 @@ void CodeEdit::gui_input(const Ref<InputEvent> &p_gui_input) {
}
if (k->is_action("ui_text_dedent", true)) {
- do_unindent();
+ unindent_lines();
accept_event();
return;
}
@@ -898,50 +898,6 @@ void CodeEdit::indent_lines() {
end_complex_operation();
}
-void CodeEdit::do_unindent() {
- if (!is_editable()) {
- return;
- }
-
- int cc = get_caret_column();
-
- if (has_selection() || cc <= 0) {
- unindent_lines();
- return;
- }
-
- begin_complex_operation();
- Vector<int> caret_edit_order = get_caret_index_edit_order();
- for (const int &c : caret_edit_order) {
- int cl = get_caret_line(c);
- const String &line = get_line(cl);
-
- if (line[cc - 1] == '\t') {
- remove_text(cl, cc - 1, cl, cc);
- set_caret_column(MAX(0, cc - 1), c == 0, c);
- adjust_carets_after_edit(c, cl, cc, cl, cc - 1);
- continue;
- }
-
- if (line[cc - 1] != ' ') {
- continue;
- }
-
- int spaces_to_remove = _calculate_spaces_till_next_left_indent(cc);
- if (spaces_to_remove > 0) {
- for (int i = 1; i <= spaces_to_remove; i++) {
- if (line[cc - i] != ' ') {
- spaces_to_remove = i - 1;
- break;
- }
- }
- remove_text(cl, cc - spaces_to_remove, cl, cc);
- set_caret_column(MAX(0, cc - spaces_to_remove), c == 0, c);
- }
- }
- end_complex_operation();
-}
-
void CodeEdit::unindent_lines() {
if (!is_editable()) {
return;
@@ -2204,7 +2160,6 @@ void CodeEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_auto_indent_prefixes"), &CodeEdit::get_auto_indent_prefixes);
ClassDB::bind_method(D_METHOD("do_indent"), &CodeEdit::do_indent);
- ClassDB::bind_method(D_METHOD("do_unindent"), &CodeEdit::do_unindent);
ClassDB::bind_method(D_METHOD("indent_lines"), &CodeEdit::indent_lines);
ClassDB::bind_method(D_METHOD("unindent_lines"), &CodeEdit::unindent_lines);
diff --git a/scene/gui/code_edit.h b/scene/gui/code_edit.h
index c050b2266f..55fc5aa2ae 100644
--- a/scene/gui/code_edit.h
+++ b/scene/gui/code_edit.h
@@ -289,7 +289,6 @@ public:
TypedArray<String> get_auto_indent_prefixes() const;
void do_indent();
- void do_unindent();
void indent_lines();
void unindent_lines();
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index b5846cb692..da29bc823f 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -35,11 +35,6 @@
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "scene/gui/color_mode.h"
-
-#ifdef TOOLS_ENABLED
-#include "editor/editor_settings.h"
-#endif
-
#include "thirdparty/misc/ok_color.h"
#include "thirdparty/misc/ok_color_shader.h"
@@ -50,31 +45,6 @@ void ColorPicker::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
_update_color();
-#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint()) {
- if (preset_cache.is_empty()) {
- PackedColorArray saved_presets = EditorSettings::get_singleton()->get_project_metadata("color_picker", "presets", PackedColorArray());
- for (int i = 0; i < saved_presets.size(); i++) {
- preset_cache.push_back(saved_presets[i]);
- }
- }
-
- for (int i = 0; i < preset_cache.size(); i++) {
- presets.push_back(preset_cache[i]);
- }
-
- if (recent_preset_cache.is_empty()) {
- PackedColorArray saved_recent_presets = EditorSettings::get_singleton()->get_project_metadata("color_picker", "recent_presets", PackedColorArray());
- for (int i = 0; i < saved_recent_presets.size(); i++) {
- recent_preset_cache.push_back(saved_recent_presets[i]);
- }
- }
-
- for (int i = 0; i < recent_preset_cache.size(); i++) {
- recent_presets.push_back(recent_preset_cache[i]);
- }
- }
-#endif
[[fallthrough]];
}
case NOTIFICATION_THEME_CHANGED: {
@@ -404,6 +374,40 @@ void ColorPicker::create_slider(GridContainer *gc, int idx) {
}
}
+#ifdef TOOLS_ENABLED
+void ColorPicker::set_editor_settings(Object *p_editor_settings) {
+ if (editor_settings) {
+ return;
+ }
+ editor_settings = p_editor_settings;
+
+ if (preset_cache.is_empty()) {
+ PackedColorArray saved_presets = editor_settings->call(SNAME("get_project_metadata"), "color_picker", "presets", PackedColorArray());
+ for (int i = 0; i < saved_presets.size(); i++) {
+ preset_cache.push_back(saved_presets[i]);
+ }
+ }
+
+ for (int i = 0; i < preset_cache.size(); i++) {
+ presets.push_back(preset_cache[i]);
+ }
+
+ if (recent_preset_cache.is_empty()) {
+ PackedColorArray saved_recent_presets = editor_settings->call(SNAME("get_project_metadata"), "color_picker", "recent_presets", PackedColorArray());
+ for (int i = 0; i < saved_recent_presets.size(); i++) {
+ recent_preset_cache.push_back(saved_recent_presets[i]);
+ }
+ }
+
+ for (int i = 0; i < recent_preset_cache.size(); i++) {
+ recent_presets.push_back(recent_preset_cache[i]);
+ }
+
+ _update_presets();
+ _update_recent_presets();
+}
+#endif
+
HSlider *ColorPicker::get_slider(int p_idx) {
if (p_idx < SLIDER_COUNT) {
return sliders[p_idx];
@@ -471,7 +475,7 @@ ColorPicker::PickerShapeType ColorPicker::_get_actual_shape() const {
void ColorPicker::_reset_theme() {
Ref<StyleBoxFlat> style_box_flat(memnew(StyleBoxFlat));
- style_box_flat->set_default_margin(SIDE_TOP, 16 * get_theme_default_base_scale());
+ style_box_flat->set_content_margin(SIDE_TOP, 16 * get_theme_default_base_scale());
style_box_flat->set_bg_color(Color(0.2, 0.23, 0.31).lerp(Color(0, 0, 0, 1), 0.3).clamp());
for (int i = 0; i < SLIDER_COUNT; i++) {
sliders[i]->add_theme_icon_override("grabber", get_theme_icon(SNAME("bar_arrow"), SNAME("ColorPicker")));
@@ -553,7 +557,7 @@ void ColorPicker::_update_presets() {
}
#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint()) {
+ if (editor_settings) {
// Only load preset buttons when the only child is the add-preset button.
if (preset_container->get_child_count() == 1) {
for (int i = 0; i < preset_cache.size(); i++) {
@@ -567,7 +571,7 @@ void ColorPicker::_update_presets() {
void ColorPicker::_update_recent_presets() {
#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint()) {
+ if (editor_settings) {
int recent_preset_count = recent_preset_hbc->get_child_count();
for (int i = 0; i < recent_preset_count; i++) {
memdelete(recent_preset_hbc->get_child(0));
@@ -642,7 +646,7 @@ inline int ColorPicker::_get_preset_size() {
void ColorPicker::_add_preset_button(int p_size, const Color &p_color) {
ColorPresetButton *btn_preset_new = memnew(ColorPresetButton(p_color, p_size));
btn_preset_new->set_tooltip_text(vformat(RTR("Color: #%s\nLMB: Apply color\nRMB: Remove preset"), p_color.to_html(p_color.a < 1)));
- btn_preset_new->set_drag_forwarding_compat(this);
+ SET_DRAG_FORWARDING_GCDU(btn_preset_new, ColorPicker);
btn_preset_new->set_button_group(preset_group);
preset_container->add_child(btn_preset_new);
btn_preset_new->set_pressed(true);
@@ -743,9 +747,9 @@ void ColorPicker::add_preset(const Color &p_color) {
}
#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint()) {
+ if (editor_settings) {
PackedColorArray arr_to_save = get_presets();
- EditorSettings::get_singleton()->set_project_metadata("color_picker", "presets", arr_to_save);
+ editor_settings->call(SNAME("set_project_metadata"), "color_picker", "presets", arr_to_save);
}
#endif
}
@@ -764,9 +768,9 @@ void ColorPicker::add_recent_preset(const Color &p_color) {
_select_from_preset_container(p_color);
#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint()) {
+ if (editor_settings) {
PackedColorArray arr_to_save = get_recent_presets();
- EditorSettings::get_singleton()->set_project_metadata("color_picker", "recent_presets", arr_to_save);
+ editor_settings->call(SNAME("set_project_metadata"), "color_picker", "recent_presets", arr_to_save);
}
#endif
}
@@ -787,9 +791,9 @@ void ColorPicker::erase_preset(const Color &p_color) {
}
#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint()) {
+ if (editor_settings) {
PackedColorArray arr_to_save = get_presets();
- EditorSettings::get_singleton()->set_project_metadata("color_picker", "presets", arr_to_save);
+ editor_settings->call(SNAME("set_project_metadata"), "color_picker", "presets", arr_to_save);
}
#endif
}
@@ -811,9 +815,9 @@ void ColorPicker::erase_recent_preset(const Color &p_color) {
}
#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint()) {
+ if (editor_settings) {
PackedColorArray arr_to_save = get_recent_presets();
- EditorSettings::get_singleton()->set_project_metadata("color_picker", "recent_presets", arr_to_save);
+ editor_settings->call(SNAME("set_project_metadata"), "color_picker", "recent_presets", arr_to_save);
}
#endif
}
@@ -890,7 +894,7 @@ void ColorPicker::set_colorize_sliders(bool p_colorize_sliders) {
alpha_slider->add_theme_style_override("slider", style_box_empty);
} else {
Ref<StyleBoxFlat> style_box_flat(memnew(StyleBoxFlat));
- style_box_flat->set_default_margin(SIDE_TOP, 16 * get_theme_default_base_scale());
+ style_box_flat->set_content_margin(SIDE_TOP, 16 * get_theme_default_base_scale());
style_box_flat->set_bg_color(Color(0.2, 0.23, 0.31).lerp(Color(0, 0, 0, 1), 0.3).clamp());
if (!slider_theme_modified) {
@@ -1544,10 +1548,6 @@ void ColorPicker::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_picker_shape", "shape"), &ColorPicker::set_picker_shape);
ClassDB::bind_method(D_METHOD("get_picker_shape"), &ColorPicker::get_picker_shape);
- ClassDB::bind_method(D_METHOD("_get_drag_data_fw"), &ColorPicker::_get_drag_data_fw);
- ClassDB::bind_method(D_METHOD("_can_drop_data_fw"), &ColorPicker::_can_drop_data_fw);
- ClassDB::bind_method(D_METHOD("_drop_data_fw"), &ColorPicker::_drop_data_fw);
-
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_pick_color", "get_pick_color");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "edit_alpha"), "set_edit_alpha", "is_editing_alpha");
ADD_PROPERTY(PropertyInfo(Variant::INT, "color_mode", PROPERTY_HINT_ENUM, "RGB,HSV,RAW,OKHSL"), "set_color_mode", "get_color_mode");
diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h
index 5eaeecca2a..f7578612cd 100644
--- a/scene/gui/color_picker.h
+++ b/scene/gui/color_picker.h
@@ -100,6 +100,10 @@ private:
static List<Color> preset_cache;
static List<Color> recent_preset_cache;
+#ifdef TOOLS_ENABLED
+ Object *editor_settings = nullptr;
+#endif
+
int current_slider_count = SLIDER_COUNT;
static const int MODE_BUTTON_COUNT = 3;
@@ -231,6 +235,10 @@ protected:
static void _bind_methods();
public:
+#ifdef TOOLS_ENABLED
+ void set_editor_settings(Object *p_editor_settings);
+#endif
+
HSlider *get_slider(int idx);
Vector<float> get_active_slider_values();
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 10dbad232a..fead0878fb 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -1582,10 +1582,6 @@ void Control::set_block_minimum_size_adjust(bool p_block) {
data.block_minimum_size_adjust = p_block;
}
-bool Control::is_minimum_size_adjust_blocked() const {
- return data.block_minimum_size_adjust;
-}
-
Size2 Control::get_minimum_size() const {
Vector2 ms;
GDVIRTUAL_CALL(_get_minimum_size, ms);
@@ -1823,19 +1819,6 @@ bool Control::is_focus_owner_in_shortcut_context() const {
// Drag and drop handling.
-void Control::set_drag_forwarding_compat(Object *p_base) {
- if (p_base != nullptr) {
- data.forward_drag = Callable(p_base, "_get_drag_data_fw").bind(this);
- data.forward_can_drop = Callable(p_base, "_can_drop_data_fw").bind(this);
- data.forward_drop = Callable(p_base, "_drop_data_fw").bind(this);
-
- } else {
- data.forward_drag = Callable();
- data.forward_can_drop = Callable();
- data.forward_drop = Callable();
- }
-}
-
void Control::set_drag_forwarding(const Callable &p_drag, const Callable &p_can_drop, const Callable &p_drop) {
data.forward_drag = p_drag;
data.forward_can_drop = p_can_drop;
@@ -2782,9 +2765,9 @@ void Control::end_bulk_theme_override() {
// Internationalization.
-TypedArray<Vector2i> Control::structured_text_parser(TextServer::StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const {
+TypedArray<Vector3i> Control::structured_text_parser(TextServer::StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const {
if (p_parser_type == TextServer::STRUCTURED_TEXT_CUSTOM) {
- TypedArray<Vector2i> ret;
+ TypedArray<Vector3i> ret;
GDVIRTUAL_CALL(_structured_text_parser, p_args, p_text, ret);
return ret;
} else {
diff --git a/scene/gui/control.h b/scene/gui/control.h
index 22a37dd89e..a93a88e5b4 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -145,7 +145,7 @@ public:
TEXT_DIRECTION_AUTO = TextServer::DIRECTION_AUTO,
TEXT_DIRECTION_LTR = TextServer::DIRECTION_LTR,
TEXT_DIRECTION_RTL = TextServer::DIRECTION_RTL,
- TEXT_DIRECTION_INHERITED,
+ TEXT_DIRECTION_INHERITED = TextServer::DIRECTION_INHERITED,
};
private:
@@ -330,7 +330,7 @@ protected:
// Internationalization.
- virtual TypedArray<Vector2i> structured_text_parser(TextServer::StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const;
+ virtual TypedArray<Vector3i> structured_text_parser(TextServer::StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const;
// Base object overrides.
@@ -340,7 +340,7 @@ protected:
// Exposed virtual methods.
GDVIRTUAL1RC(bool, _has_point, Vector2)
- GDVIRTUAL2RC(TypedArray<Vector2i>, _structured_text_parser, Array, String)
+ GDVIRTUAL2RC(TypedArray<Vector3i>, _structured_text_parser, Array, String)
GDVIRTUAL0RC(Vector2, _get_minimum_size)
GDVIRTUAL1RC(Variant, _get_drag_data, Vector2)
@@ -464,7 +464,6 @@ public:
void update_minimum_size();
void set_block_minimum_size_adjust(bool p_block);
- bool is_minimum_size_adjust_blocked() const;
virtual Size2 get_minimum_size() const;
virtual Size2 get_combined_minimum_size() const;
@@ -503,7 +502,6 @@ public:
// Drag and drop handling.
virtual void set_drag_forwarding(const Callable &p_drag, const Callable &p_can_drop, const Callable &p_drop);
- virtual void set_drag_forwarding_compat(Object *p_base);
virtual Variant get_drag_data(const Point2 &p_point);
virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const;
virtual void drop_data(const Point2 &p_point, const Variant &p_data);
@@ -634,4 +632,10 @@ VARIANT_ENUM_CAST(Control::LayoutMode);
VARIANT_ENUM_CAST(Control::LayoutDirection);
VARIANT_ENUM_CAST(Control::TextDirection);
+// G = get_drag_data_fw, C = can_drop_data_fw, D = drop_data_fw, U = underscore
+#define SET_DRAG_FORWARDING_CD(from, to) from->set_drag_forwarding(Callable(), callable_mp(this, &to::can_drop_data_fw).bind(from), callable_mp(this, &to::drop_data_fw).bind(from));
+#define SET_DRAG_FORWARDING_CDU(from, to) from->set_drag_forwarding(Callable(), callable_mp(this, &to::_can_drop_data_fw).bind(from), callable_mp(this, &to::_drop_data_fw).bind(from));
+#define SET_DRAG_FORWARDING_GCD(from, to) from->set_drag_forwarding(callable_mp(this, &to::get_drag_data_fw).bind(from), callable_mp(this, &to::can_drop_data_fw).bind(from), callable_mp(this, &to::drop_data_fw).bind(from));
+#define SET_DRAG_FORWARDING_GCDU(from, to) from->set_drag_forwarding(callable_mp(this, &to::_get_drag_data_fw).bind(from), callable_mp(this, &to::_can_drop_data_fw).bind(from), callable_mp(this, &to::_drop_data_fw).bind(from));
+
#endif // CONTROL_H
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index 4365db2ea2..dfe9ea3b08 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -136,7 +136,7 @@ void AcceptDialog::_cancel_pressed() {
call_deferred(SNAME("hide"));
- emit_signal(SNAME("cancelled"));
+ emit_signal(SNAME("canceled"));
cancel_pressed();
@@ -372,7 +372,7 @@ void AcceptDialog::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_ok_button_text"), &AcceptDialog::get_ok_button_text);
ADD_SIGNAL(MethodInfo("confirmed"));
- ADD_SIGNAL(MethodInfo("cancelled"));
+ ADD_SIGNAL(MethodInfo("canceled"));
ADD_SIGNAL(MethodInfo("custom_action", PropertyInfo(Variant::STRING_NAME, "action")));
ADD_PROPERTY(PropertyInfo(Variant::STRING, "ok_button_text"), "set_ok_button_text", "get_ok_button_text");
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 372baeadae..25a27d5e1a 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -309,12 +309,6 @@ void ItemList::set_item_tag_icon(int p_idx, const Ref<Texture2D> &p_tag_icon) {
shape_changed = true;
}
-Ref<Texture2D> ItemList::get_item_tag_icon(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture2D>());
-
- return items[p_idx].tag_icon;
-}
-
void ItemList::set_item_selectable(int p_idx, bool p_selectable) {
if (p_idx < 0) {
p_idx += get_item_count();
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index 848f9a2ba9..934318dbb4 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -191,7 +191,6 @@ public:
Variant get_item_metadata(int p_idx) const;
void set_item_tag_icon(int p_idx, const Ref<Texture2D> &p_tag_icon);
- Ref<Texture2D> get_item_tag_icon(int p_idx) const;
void set_item_tooltip_enabled(int p_idx, const bool p_enabled);
bool is_item_tooltip_enabled(int p_idx) const;
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index cafea83f16..f59702835c 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -222,6 +222,7 @@ void Label::_shape() {
}
}
lines_dirty = false;
+ lines_shaped_last_width = get_size().width;
}
_update_visible();
@@ -596,7 +597,13 @@ void Label::_notification(int p_what) {
} break;
case NOTIFICATION_RESIZED: {
- lines_dirty = true;
+ // It may happen that the reshaping due to this size change triggers a cascade of re-layout
+ // across the hierarchy where this label belongs to in a way that its size changes multiple
+ // times, but ending up with the original size it was already shaped for.
+ // This check prevents the catastrophic, freezing infinite cascade of re-layout.
+ if (lines_shaped_last_width != get_size().width) {
+ lines_dirty = true;
+ }
} break;
}
}
diff --git a/scene/gui/label.h b/scene/gui/label.h
index 2350525236..b80646810b 100644
--- a/scene/gui/label.h
+++ b/scene/gui/label.h
@@ -49,6 +49,8 @@ private:
bool uppercase = false;
bool lines_dirty = true;
+ int lines_shaped_last_width = -1;
+
bool dirty = true;
bool font_dirty = true;
RID text_rid;
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index e5bb64b225..ad4e667278 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -2576,7 +2576,7 @@ LineEdit::LineEdit(const String &p_placeholder) {
set_placeholder(p_placeholder);
- set_editable(true); // Initialise to opposite first, so we get past the early-out in set_editable.
+ set_editable(true); // Initialize to opposite first, so we get past the early-out in set_editable.
}
LineEdit::~LineEdit() {
diff --git a/scene/gui/menu_bar.cpp b/scene/gui/menu_bar.cpp
index 224e405d41..5b27983851 100644
--- a/scene/gui/menu_bar.cpp
+++ b/scene/gui/menu_bar.cpp
@@ -214,10 +214,10 @@ void MenuBar::_update_submenu(const String &p_menu_name, PopupMenu *p_child) {
PopupMenu *pm = Object::cast_to<PopupMenu>(n);
ERR_FAIL_COND_MSG(!pm, "Item subnode is not a PopupMenu: " + p_child->get_item_submenu(i) + ".");
- DisplayServer::get_singleton()->global_menu_add_submenu_item(p_menu_name, p_child->get_item_text(i), p_menu_name + "/" + itos(i));
+ DisplayServer::get_singleton()->global_menu_add_submenu_item(p_menu_name, atr(p_child->get_item_text(i)), p_menu_name + "/" + itos(i));
_update_submenu(p_menu_name + "/" + itos(i), pm);
} else {
- int index = DisplayServer::get_singleton()->global_menu_add_item(p_menu_name, p_child->get_item_text(i), callable_mp(p_child, &PopupMenu::activate_item), Callable(), i);
+ int index = DisplayServer::get_singleton()->global_menu_add_item(p_menu_name, atr(p_child->get_item_text(i)), callable_mp(p_child, &PopupMenu::activate_item), Callable(), i);
if (p_child->is_item_checkable(i)) {
DisplayServer::get_singleton()->global_menu_set_item_checkable(p_menu_name, index, true);
@@ -290,7 +290,7 @@ void MenuBar::_update_menu() {
if (menu_cache[i].hidden) {
continue;
}
- String menu_name = String(popups[i]->get_meta("_menu_name", popups[i]->get_name()));
+ String menu_name = atr(String(popups[i]->get_meta("_menu_name", popups[i]->get_name())));
index = DisplayServer::get_singleton()->global_menu_add_submenu_item("_main", menu_name, root_name + "/" + itos(i), index);
if (menu_cache[i].disabled) {
@@ -525,7 +525,7 @@ void MenuBar::shape(Menu &p_menu) {
} else {
p_menu.text_buf->set_direction((TextServer::Direction)text_direction);
}
- p_menu.text_buf->add_string(p_menu.name, theme_cache.font, theme_cache.font_size, language);
+ p_menu.text_buf->add_string(atr(p_menu.name), theme_cache.font, theme_cache.font_size, language);
}
void MenuBar::_refresh_menu_names() {
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp
index c939e7a48a..2ea1b93810 100644
--- a/scene/gui/popup.cpp
+++ b/scene/gui/popup.cpp
@@ -59,9 +59,9 @@ void Popup::_initialize_visible_parents() {
void Popup::_deinitialize_visible_parents() {
if (is_embedded()) {
- for (uint32_t i = 0; i < visible_parents.size(); ++i) {
- visible_parents[i]->disconnect("focus_entered", callable_mp(this, &Popup::_parent_focused));
- visible_parents[i]->disconnect("tree_exited", callable_mp(this, &Popup::_deinitialize_visible_parents));
+ for (Window *parent_window : visible_parents) {
+ parent_window->disconnect("focus_entered", callable_mp(this, &Popup::_parent_focused));
+ parent_window->disconnect("tree_exited", callable_mp(this, &Popup::_deinitialize_visible_parents));
}
visible_parents.clear();
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 4e8a44dd63..ddc11d97b9 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -594,17 +594,17 @@ void PopupMenu::_draw_items() {
int content_left = content_center - content_size / 2;
int content_right = content_center + content_size / 2;
if (content_left > item_ofs.x) {
- int sep_h = theme_cache.labeled_separator_left->get_center_size().height + theme_cache.labeled_separator_left->get_minimum_size().height;
+ int sep_h = theme_cache.labeled_separator_left->get_minimum_size().height;
int sep_ofs = Math::floor((h - sep_h) / 2.0);
theme_cache.labeled_separator_left->draw(ci, Rect2(item_ofs + Point2(0, sep_ofs), Size2(MAX(0, content_left - item_ofs.x), sep_h)));
}
if (content_right < display_width) {
- int sep_h = theme_cache.labeled_separator_right->get_center_size().height + theme_cache.labeled_separator_right->get_minimum_size().height;
+ int sep_h = theme_cache.labeled_separator_right->get_minimum_size().height;
int sep_ofs = Math::floor((h - sep_h) / 2.0);
theme_cache.labeled_separator_right->draw(ci, Rect2(Point2(content_right, item_ofs.y + sep_ofs), Size2(MAX(0, display_width - content_right), sep_h)));
}
} else {
- int sep_h = theme_cache.separator_style->get_center_size().height + theme_cache.separator_style->get_minimum_size().height;
+ int sep_h = theme_cache.separator_style->get_minimum_size().height;
int sep_ofs = Math::floor((h - sep_h) / 2.0);
theme_cache.separator_style->draw(ci, Rect2(item_ofs + Point2(0, sep_ofs), Size2(display_width, sep_h)));
}
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 5ab64b35fd..a7e50a765e 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -4074,8 +4074,8 @@ void RichTextLabel::append_text(const String &p_bbcode) {
st_parser_type = TextServer::STRUCTURED_TEXT_EMAIL;
} else if (subtag_a[1] == "l" || subtag_a[1] == "list") {
st_parser_type = TextServer::STRUCTURED_TEXT_LIST;
- } else if (subtag_a[1] == "n" || subtag_a[1] == "none") {
- st_parser_type = TextServer::STRUCTURED_TEXT_NONE;
+ } else if (subtag_a[1] == "n" || subtag_a[1] == "gdscript") {
+ st_parser_type = TextServer::STRUCTURED_TEXT_GDSCRIPT;
} else if (subtag_a[1] == "c" || subtag_a[1] == "custom") {
st_parser_type = TextServer::STRUCTURED_TEXT_CUSTOM;
}
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index e617b2ca77..b8faf22a59 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -433,7 +433,7 @@ void ScrollBar::_notification(int p_what) {
double ScrollBar::get_grabber_min_size() const {
Ref<StyleBox> grabber = theme_cache.grabber_style;
- Size2 gminsize = grabber->get_minimum_size() + grabber->get_center_size();
+ Size2 gminsize = grabber->get_minimum_size();
return (orientation == VERTICAL) ? gminsize.height : gminsize.width;
}
@@ -500,7 +500,7 @@ Size2 ScrollBar::get_minimum_size() const {
Size2 minsize;
if (orientation == VERTICAL) {
- minsize.width = MAX(incr->get_size().width, (bg->get_minimum_size() + bg->get_center_size()).width);
+ minsize.width = MAX(incr->get_size().width, bg->get_minimum_size().width);
minsize.height += incr->get_size().height;
minsize.height += decr->get_size().height;
minsize.height += bg->get_minimum_size().height;
@@ -508,7 +508,7 @@ Size2 ScrollBar::get_minimum_size() const {
}
if (orientation == HORIZONTAL) {
- minsize.height = MAX(incr->get_size().height, (bg->get_center_size() + bg->get_minimum_size()).height);
+ minsize.height = MAX(incr->get_size().height, bg->get_minimum_size().height);
minsize.width += incr->get_size().width;
minsize.width += decr->get_size().width;
minsize.width += bg->get_minimum_size().width;
diff --git a/scene/gui/separator.cpp b/scene/gui/separator.cpp
index 45185de698..b0879c1931 100644
--- a/scene/gui/separator.cpp
+++ b/scene/gui/separator.cpp
@@ -51,7 +51,7 @@ void Separator::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_DRAW: {
Size2i size = get_size();
- Size2i ssize = theme_cache.separator_style->get_minimum_size() + theme_cache.separator_style->get_center_size();
+ Size2i ssize = theme_cache.separator_style->get_minimum_size();
if (orientation == VERTICAL) {
theme_cache.separator_style->draw(get_canvas_item(), Rect2((size.x - ssize.x) / 2, 0, ssize.x, size.y));
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp
index 040559dab8..292a4cfea2 100644
--- a/scene/gui/slider.cpp
+++ b/scene/gui/slider.cpp
@@ -33,7 +33,7 @@
#include "core/os/keyboard.h"
Size2 Slider::get_minimum_size() const {
- Size2i ss = theme_cache.slider_style->get_minimum_size() + theme_cache.slider_style->get_center_size();
+ Size2i ss = theme_cache.slider_style->get_minimum_size();
Size2i rs = theme_cache.grabber_icon->get_size();
if (orientation == HORIZONTAL) {
@@ -212,7 +212,7 @@ void Slider::_notification(int p_what) {
}
if (orientation == VERTICAL) {
- int widget_width = style->get_minimum_size().width + style->get_center_size().width;
+ int widget_width = style->get_minimum_size().width;
double areasize = size.height - grabber->get_size().height;
style->draw(ci, Rect2i(Point2i(size.width / 2 - widget_width / 2, 0), Size2i(widget_width, size.height)));
grabber_area->draw(ci, Rect2i(Point2i((size.width - widget_width) / 2, size.height - areasize * ratio - grabber->get_size().height / 2), Size2i(widget_width, areasize * ratio + grabber->get_size().height / 2)));
@@ -229,7 +229,7 @@ void Slider::_notification(int p_what) {
}
grabber->draw(ci, Point2i(size.width / 2 - grabber->get_size().width / 2 + get_theme_constant(SNAME("grabber_offset")), size.height - ratio * areasize - grabber->get_size().height));
} else {
- int widget_height = style->get_minimum_size().height + style->get_center_size().height;
+ int widget_height = style->get_minimum_size().height;
double areasize = size.width - grabber->get_size().width;
style->draw(ci, Rect2i(Point2i(0, (size.height - widget_height) / 2), Size2i(size.width, widget_height)));
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 3457cfa94f..208cb29772 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -954,9 +954,6 @@ void TabContainer::_bind_methods() {
ClassDB::bind_method(D_METHOD("_repaint"), &TabContainer::_repaint);
ClassDB::bind_method(D_METHOD("_on_theme_changed"), &TabContainer::_on_theme_changed);
- ClassDB::bind_method(D_METHOD("_get_drag_data_fw"), &TabContainer::_get_drag_data_fw);
- ClassDB::bind_method(D_METHOD("_can_drop_data_fw"), &TabContainer::_can_drop_data_fw);
- ClassDB::bind_method(D_METHOD("_drop_data_fw"), &TabContainer::_drop_data_fw);
ADD_SIGNAL(MethodInfo("tab_changed", PropertyInfo(Variant::INT, "tab")));
ADD_SIGNAL(MethodInfo("tab_selected", PropertyInfo(Variant::INT, "tab")));
@@ -975,7 +972,7 @@ void TabContainer::_bind_methods() {
TabContainer::TabContainer() {
tab_bar = memnew(TabBar);
- tab_bar->set_drag_forwarding_compat(this);
+ SET_DRAG_FORWARDING_GCDU(tab_bar, TabContainer);
add_child(tab_bar, false, INTERNAL_MODE_FRONT);
tab_bar->set_anchors_and_offsets_preset(Control::PRESET_TOP_WIDE);
tab_bar->connect("tab_changed", callable_mp(this, &TabContainer::_on_tab_changed));
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 108a533a74..8ffaa9e81f 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1208,7 +1208,15 @@ void TextEdit::_notification(int p_what) {
char_ofs = 0;
}
for (int j = 0; j < gl_size; j++) {
- const Variant *color_data = color_map.getptr(glyphs[j].start);
+ int64_t color_start = -1;
+ for (const Variant *key = color_map.next(nullptr); key; key = color_map.next(key)) {
+ if (int64_t(*key) <= glyphs[j].start) {
+ color_start = *key;
+ } else {
+ break;
+ }
+ }
+ const Variant *color_data = (color_start >= 0) ? color_map.getptr(color_start) : nullptr;
if (color_data != nullptr) {
current_color = (color_data->operator Dictionary()).get("color", font_color);
if (!editable && current_color.a > font_readonly_color.a) {
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 426acc4996..2ec2f39409 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -274,7 +274,7 @@ private:
void _update_placeholder();
- /* Initialise to opposite first, so we get past the early-out in set_editable. */
+ /* Initialize to opposite first, so we get past the early-out in set_editable. */
bool editable = false;
TextDirection text_direction = TEXT_DIRECTION_AUTO;
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 2138f10ad0..2d985c2324 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -332,7 +332,7 @@ void TreeItem::set_structured_text_bidi_override(int p_column, TextServer::Struc
}
TextServer::StructuredTextParser TreeItem::get_structured_text_bidi_override(int p_column) const {
- ERR_FAIL_INDEX_V(p_column, cells.size(), TextServer::STRUCTURED_TEXT_NONE);
+ ERR_FAIL_INDEX_V(p_column, cells.size(), TextServer::STRUCTURED_TEXT_DEFAULT);
return cells[p_column].st_parser;
}