summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/color_picker.cpp2
-rw-r--r--scene/gui/control.cpp12
-rw-r--r--scene/gui/dialogs.cpp1
-rw-r--r--scene/gui/file_dialog.cpp66
-rw-r--r--scene/gui/file_dialog.h22
-rw-r--r--scene/gui/gradient_edit.cpp2
-rw-r--r--scene/gui/graph_edit.cpp51
-rw-r--r--scene/gui/graph_edit.h2
-rw-r--r--scene/gui/link_button.cpp4
-rw-r--r--scene/gui/option_button.cpp4
-rw-r--r--scene/gui/popup_menu.cpp10
-rw-r--r--scene/gui/popup_menu.h1
-rw-r--r--scene/gui/rich_text_label.cpp79
-rw-r--r--scene/gui/slider.cpp5
-rw-r--r--scene/gui/spin_box.cpp8
-rw-r--r--scene/gui/subviewport_container.cpp (renamed from scene/gui/viewport_container.cpp)36
-rw-r--r--scene/gui/subviewport_container.h (renamed from scene/gui/viewport_container.h)8
-rw-r--r--scene/gui/tab_container.cpp2
-rw-r--r--scene/gui/tabs.cpp30
-rw-r--r--scene/gui/text_edit.cpp23
-rw-r--r--scene/gui/text_edit.h1
-rw-r--r--scene/gui/texture_rect.cpp9
-rw-r--r--scene/gui/tree.cpp28
23 files changed, 177 insertions, 229 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 5e0f4c91e8..63878a0b26 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -30,7 +30,7 @@
#include "color_picker.h"
-#include "core/input/input_filter.h"
+#include "core/input/input.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index de6233f359..b710ba4803 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -561,12 +561,6 @@ void Control::_notification(int p_notification) {
data.parent = nullptr;
data.parent_canvas_item = nullptr;
- /*
- if (data.theme_owner && data.theme.is_null()) {
- data.theme_owner=NULL;
- notification(NOTIFICATION_THEME_CHANGED);
- }
- */
} break;
case NOTIFICATION_MOVED_IN_PARENT: {
@@ -1899,7 +1893,7 @@ static Control *_next_control(Control *p_from) {
return nullptr;
}
- int next = p_from->get_position_in_parent();
+ int next = p_from->get_index();
ERR_FAIL_INDEX_V(next, parent->get_child_count(), nullptr);
for (int i = (next + 1); i < parent->get_child_count(); i++) {
@@ -2038,7 +2032,7 @@ Control *Control::find_prev_valid_focus() const {
} else {
- for (int i = (from->get_position_in_parent() - 1); i >= 0; i--) {
+ for (int i = (from->get_index() - 1); i >= 0; i--) {
Control *c = Object::cast_to<Control>(from->get_parent()->get_child(i));
@@ -2902,7 +2896,7 @@ void Control::_bind_methods() {
ADD_GROUP("Size Flags", "size_flags_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "size_flags_horizontal", PROPERTY_HINT_FLAGS, "Fill,Expand,Shrink Center,Shrink End"), "set_h_size_flags", "get_h_size_flags");
ADD_PROPERTY(PropertyInfo(Variant::INT, "size_flags_vertical", PROPERTY_HINT_FLAGS, "Fill,Expand,Shrink Center,Shrink End"), "set_v_size_flags", "get_v_size_flags");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "size_flags_stretch_ratio", PROPERTY_HINT_RANGE, "0,128,0.01"), "set_stretch_ratio", "get_stretch_ratio");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "size_flags_stretch_ratio", PROPERTY_HINT_RANGE, "0,20,0.01,or_greater"), "set_stretch_ratio", "get_stretch_ratio");
ADD_GROUP("Theme", "");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "theme", PROPERTY_HINT_RESOURCE_TYPE, "Theme"), "set_theme", "get_theme");
ADD_GROUP("", "");
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index 2e87a92969..5654219a3e 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -322,7 +322,6 @@ AcceptDialog::AcceptDialog() {
label->set_end(Point2(-margin, -button_margin - 10));
add_child(label);
- hbc = memnew(HBoxContainer);
add_child(hbc);
hbc->add_spacer();
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 6be74d8d29..89d13ecd7f 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -46,9 +46,9 @@ VBoxContainer *FileDialog::get_vbox() {
void FileDialog::_theme_changed() {
- Color font_color = vbc->get_theme_color("font_color", "ToolButton");
- Color font_color_hover = vbc->get_theme_color("font_color_hover", "ToolButton");
- Color font_color_pressed = vbc->get_theme_color("font_color_pressed", "ToolButton");
+ Color font_color = vbox->get_theme_color("font_color", "ToolButton");
+ Color font_color_hover = vbox->get_theme_color("font_color_hover", "ToolButton");
+ Color font_color_pressed = vbox->get_theme_color("font_color_pressed", "ToolButton");
dir_up->add_theme_color_override("icon_color_normal", font_color);
dir_up->add_theme_color_override("icon_color_hover", font_color_hover);
@@ -73,9 +73,9 @@ void FileDialog::_notification(int p_what) {
}
if (p_what == NOTIFICATION_ENTER_TREE) {
- dir_up->set_icon(vbc->get_theme_icon("parent_folder"));
- refresh->set_icon(vbc->get_theme_icon("reload"));
- show_hidden->set_icon(vbc->get_theme_icon("toggle_hidden"));
+ dir_up->set_icon(vbox->get_theme_icon("parent_folder", "FileDialog"));
+ refresh->set_icon(vbox->get_theme_icon("reload", "FileDialog"));
+ show_hidden->set_icon(vbox->get_theme_icon("toggle_hidden", "FileDialog"));
_theme_changed();
}
}
@@ -429,8 +429,8 @@ void FileDialog::update_file_list() {
dir_access->list_dir_begin();
TreeItem *root = tree->create_item();
- Ref<Texture2D> folder = vbc->get_theme_icon("folder");
- const Color folder_color = vbc->get_theme_color("folder_icon_modulate");
+ Ref<Texture2D> folder = vbox->get_theme_icon("folder", "FileDialog");
+ const Color folder_color = vbox->get_theme_color("folder_icon_modulate", "FileDialog");
List<String> files;
List<String> dirs;
@@ -528,7 +528,7 @@ void FileDialog::update_file_list() {
}
if (mode == FILE_MODE_OPEN_DIR) {
- ti->set_custom_color(0, vbc->get_theme_color("files_disabled"));
+ ti->set_custom_color(0, vbox->get_theme_color("files_disabled", "FileDialog"));
ti->set_selectable(0, false);
}
Dictionary d;
@@ -888,9 +888,9 @@ FileDialog::FileDialog() {
mode_overrides_title = true;
- vbc = memnew(VBoxContainer);
- add_child(vbc);
- vbc->connect("theme_changed", callable_mp(this, &FileDialog::_theme_changed));
+ vbox = memnew(VBoxContainer);
+ add_child(vbox);
+ vbox->connect("theme_changed", callable_mp(this, &FileDialog::_theme_changed));
mode = FILE_MODE_SAVE_FILE;
set_title(RTR("Save a File"));
@@ -909,6 +909,7 @@ FileDialog::FileDialog() {
drives = memnew(OptionButton);
drives->connect("item_selected", callable_mp(this, &FileDialog::_select_drive));
+ hbc->add_child(drives);
dir = memnew(LineEdit);
hbc->add_child(dir);
@@ -933,11 +934,11 @@ FileDialog::FileDialog() {
makedir->set_text(RTR("Create Folder"));
makedir->connect("pressed", callable_mp(this, &FileDialog::_make_dir));
hbc->add_child(makedir);
- vbc->add_child(hbc);
+ vbox->add_child(hbc);
tree = memnew(Tree);
tree->set_hide_root(true);
- vbc->add_margin_child(RTR("Directories & Files:"), tree, true);
+ vbox->add_margin_child(RTR("Directories & Files:"), tree, true);
file_box = memnew(HBoxContainer);
file_box->add_child(memnew(Label(RTR("File:"))));
@@ -950,7 +951,7 @@ FileDialog::FileDialog() {
filter->set_h_size_flags(Control::SIZE_EXPAND_FILL);
filter->set_clip_text(true); // too many extensions overflows it
file_box->add_child(filter);
- vbc->add_child(file_box);
+ vbox->add_child(file_box);
dir_access = DirAccess::create(DirAccess::ACCESS_RESOURCES);
access = ACCESS_RESOURCES;
@@ -993,7 +994,6 @@ FileDialog::FileDialog() {
update_dir();
set_hide_on_ok(false);
- vbox = vbc;
invalidated = true;
if (register_func)
@@ -1006,37 +1006,3 @@ FileDialog::~FileDialog() {
unregister_func(this);
memdelete(dir_access);
}
-
-void LineEditFileChooser::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("get_button"), &LineEditFileChooser::get_button);
- ClassDB::bind_method(D_METHOD("get_line_edit"), &LineEditFileChooser::get_line_edit);
- ClassDB::bind_method(D_METHOD("get_file_dialog"), &LineEditFileChooser::get_file_dialog);
-}
-
-void LineEditFileChooser::_chosen(const String &p_text) {
-
- line_edit->set_text(p_text);
- line_edit->emit_signal("text_entered", p_text);
-}
-
-void LineEditFileChooser::_browse() {
-
- dialog->popup_centered_ratio();
-}
-
-LineEditFileChooser::LineEditFileChooser() {
-
- line_edit = memnew(LineEdit);
- add_child(line_edit);
- line_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- button = memnew(Button);
- button->set_text(" .. ");
- add_child(button);
- button->connect("pressed", callable_mp(this, &LineEditFileChooser::_browse));
- dialog = memnew(FileDialog);
- add_child(dialog);
- dialog->connect("file_selected", callable_mp(this, &LineEditFileChooser::_chosen));
- dialog->connect("dir_selected", callable_mp(this, &LineEditFileChooser::_chosen));
- dialog->connect("files_selected", callable_mp(this, &LineEditFileChooser::_chosen));
-}
diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h
index 295ae023d1..ac0e733abc 100644
--- a/scene/gui/file_dialog.h
+++ b/scene/gui/file_dialog.h
@@ -70,7 +70,6 @@ private:
ConfirmationDialog *makedialog;
LineEdit *makedirname;
- VBoxContainer *vbc;
Button *makedir;
Access access;
//Button *action;
@@ -178,27 +177,6 @@ public:
~FileDialog();
};
-class LineEditFileChooser : public HBoxContainer {
-
- GDCLASS(LineEditFileChooser, HBoxContainer);
- Button *button;
- LineEdit *line_edit;
- FileDialog *dialog;
-
- void _chosen(const String &p_text);
- void _browse();
-
-protected:
- static void _bind_methods();
-
-public:
- Button *get_button() { return button; }
- LineEdit *get_line_edit() { return line_edit; }
- FileDialog *get_file_dialog() { return dialog; }
-
- LineEditFileChooser();
-};
-
VARIANT_ENUM_CAST(FileDialog::FileMode);
VARIANT_ENUM_CAST(FileDialog::Access);
diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp
index 88107f754c..a6ed3d8de9 100644
--- a/scene/gui/gradient_edit.cpp
+++ b/scene/gui/gradient_edit.cpp
@@ -207,7 +207,7 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) {
prev = points[pos];
}
- newPoint.color = prev.color.linear_interpolate(next.color, (newPoint.offset - prev.offset) / (next.offset - prev.offset));
+ newPoint.color = prev.color.lerp(next.color, (newPoint.offset - prev.offset) / (next.offset - prev.offset));
points.push_back(newPoint);
points.sort();
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index e37e93e2a9..0bf67df9b4 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -30,7 +30,7 @@
#include "graph_edit.h"
-#include "core/input/input_filter.h"
+#include "core/input/input.h"
#include "core/os/keyboard.h"
#include "scene/gui/box_container.h"
@@ -653,7 +653,7 @@ void GraphEdit::_bake_segment2d(Vector<Vector2> &points, Vector<Color> &colors,
if (p_depth >= p_min_depth && (dp < p_tol || p_depth >= p_max_depth)) {
points.push_back((beg + end) * 0.5);
- colors.push_back(p_color.linear_interpolate(p_to_color, mp));
+ colors.push_back(p_color.lerp(p_to_color, mp));
lines++;
} else {
_bake_segment2d(points, colors, p_begin, mp, p_a, p_out, p_b, p_in, p_depth + 1, p_min_depth, p_max_depth, p_tol, p_color, p_to_color, lines);
@@ -737,8 +737,8 @@ void GraphEdit::_connections_layer_draw() {
Color tocolor = gto->get_connection_input_color(E->get().to_port);
if (E->get().activity > 0) {
- color = color.linear_interpolate(activity_color, E->get().activity);
- tocolor = tocolor.linear_interpolate(activity_color, E->get().activity);
+ color = color.lerp(activity_color, E->get().activity);
+ tocolor = tocolor.lerp(activity_color, E->get().activity);
}
_draw_cos_line(connections_layer, frompos, topos, color, tocolor);
}
@@ -804,7 +804,7 @@ void GraphEdit::set_selected(Node *p_child) {
void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
Ref<InputEventMouseMotion> mm = p_ev;
- if (mm.is_valid() && (mm->get_button_mask() & BUTTON_MASK_MIDDLE || (mm->get_button_mask() & BUTTON_MASK_LEFT && InputFilter::get_singleton()->is_key_pressed(KEY_SPACE)))) {
+ if (mm.is_valid() && (mm->get_button_mask() & BUTTON_MASK_MIDDLE || (mm->get_button_mask() & BUTTON_MASK_LEFT && Input::get_singleton()->is_key_pressed(KEY_SPACE)))) {
h_scroll->set_value(h_scroll->get_value() - mm->get_relative().x);
v_scroll->set_value(v_scroll->get_value() - mm->get_relative().y);
}
@@ -823,7 +823,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
// Snapping can be toggled temporarily by holding down Ctrl.
// This is done here as to not toggle the grid when holding down Ctrl.
- if (is_using_snap() ^ InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL)) {
+ if (is_using_snap() ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
const int snap = get_snap();
pos = pos.snapped(Vector2(snap, snap));
}
@@ -852,7 +852,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
bool in_box = r.intersects(box_selecting_rect);
if (in_box)
- gn->set_selected(box_selection_mode_aditive);
+ gn->set_selected(box_selection_mode_additive);
else
gn->set_selected(previus_selected.find(gn) != nullptr);
}
@@ -886,7 +886,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
}
if (b->get_button_index() == BUTTON_LEFT && !b->is_pressed() && dragging) {
- if (!just_selected && drag_accum == Vector2() && InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL)) {
+ if (!just_selected && drag_accum == Vector2() && Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
//deselect current node
for (int i = get_child_count() - 1; i >= 0; i--) {
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
@@ -948,11 +948,19 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
drag_accum = Vector2();
drag_origin = get_local_mouse_position();
just_selected = !gn->is_selected();
- if (!gn->is_selected() && !InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL)) {
+ if (!gn->is_selected() && !Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
for (int i = 0; i < get_child_count(); i++) {
GraphNode *o_gn = Object::cast_to<GraphNode>(get_child(i));
- if (o_gn)
- o_gn->set_selected(o_gn == gn);
+ if (o_gn) {
+ if (o_gn == gn) {
+ o_gn->set_selected(true);
+ } else {
+ if (o_gn->is_selected()) {
+ emit_signal("node_unselected", o_gn);
+ }
+ o_gn->set_selected(false);
+ }
+ }
}
}
@@ -968,13 +976,13 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
} else {
if (_filter_input(b->get_position()))
return;
- if (InputFilter::get_singleton()->is_key_pressed(KEY_SPACE))
+ if (Input::get_singleton()->is_key_pressed(KEY_SPACE))
return;
box_selecting = true;
box_selecting_from = get_local_mouse_position();
if (b->get_control()) {
- box_selection_mode_aditive = true;
+ box_selection_mode_additive = true;
previus_selected.clear();
for (int i = get_child_count() - 1; i >= 0; i--) {
@@ -985,7 +993,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
previus_selected.push_back(gn2);
}
} else if (b->get_shift()) {
- box_selection_mode_aditive = false;
+ box_selection_mode_additive = false;
previus_selected.clear();
for (int i = get_child_count() - 1; i >= 0; i--) {
@@ -996,14 +1004,16 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
previus_selected.push_back(gn2);
}
} else {
- box_selection_mode_aditive = true;
+ box_selection_mode_additive = true;
previus_selected.clear();
for (int i = get_child_count() - 1; i >= 0; i--) {
GraphNode *gn2 = Object::cast_to<GraphNode>(get_child(i));
if (!gn2)
continue;
-
+ if (gn2->is_selected()) {
+ emit_signal("node_unselected", gn2);
+ }
gn2->set_selected(false);
}
}
@@ -1025,16 +1035,16 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
//too difficult to get right
//set_zoom(zoom/ZOOM_SCALE);
}
- if (b->get_button_index() == BUTTON_WHEEL_UP && !InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ if (b->get_button_index() == BUTTON_WHEEL_UP && !Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
v_scroll->set_value(v_scroll->get_value() - v_scroll->get_page() * b->get_factor() / 8);
}
- if (b->get_button_index() == BUTTON_WHEEL_DOWN && !InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ if (b->get_button_index() == BUTTON_WHEEL_DOWN && !Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * b->get_factor() / 8);
}
- if (b->get_button_index() == BUTTON_WHEEL_RIGHT || (b->get_button_index() == BUTTON_WHEEL_DOWN && InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT))) {
+ if (b->get_button_index() == BUTTON_WHEEL_RIGHT || (b->get_button_index() == BUTTON_WHEEL_DOWN && Input::get_singleton()->is_key_pressed(KEY_SHIFT))) {
h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * b->get_factor() / 8);
}
- if (b->get_button_index() == BUTTON_WHEEL_LEFT || (b->get_button_index() == BUTTON_WHEEL_UP && InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT))) {
+ if (b->get_button_index() == BUTTON_WHEEL_LEFT || (b->get_button_index() == BUTTON_WHEEL_UP && Input::get_singleton()->is_key_pressed(KEY_SHIFT))) {
h_scroll->set_value(h_scroll->get_value() - h_scroll->get_page() * b->get_factor() / 8);
}
}
@@ -1311,6 +1321,7 @@ void GraphEdit::_bind_methods() {
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("node_unselected", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("connection_to_empty", PropertyInfo(Variant::STRING_NAME, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::VECTOR2, "release_position")));
ADD_SIGNAL(MethodInfo("connection_from_empty", PropertyInfo(Variant::STRING_NAME, "to"), PropertyInfo(Variant::INT, "to_slot"), PropertyInfo(Variant::VECTOR2, "release_position")));
ADD_SIGNAL(MethodInfo("delete_nodes_request"));
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h
index 7f1d2699ba..f675f8c7f3 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -104,7 +104,7 @@ private:
float zoom;
bool box_selecting;
- bool box_selection_mode_aditive;
+ bool box_selection_mode_additive;
Point2 box_selecting_from;
Point2 box_selecting_to;
Rect2 box_selecting_rect;
diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp
index 3dffa06b49..098e8297ad 100644
--- a/scene/gui/link_button.cpp
+++ b/scene/gui/link_button.cpp
@@ -111,11 +111,11 @@ void LinkButton::_notification(int p_what) {
draw_string(font, Vector2(0, font->get_ascent()), text, color);
if (do_underline) {
- int underline_spacing = get_theme_constant("underline_spacing");
+ int underline_spacing = get_theme_constant("underline_spacing") + font->get_underline_position();
int width = font->get_string_size(text).width;
int y = font->get_ascent() + underline_spacing;
- draw_line(Vector2(0, y), Vector2(width, y), color);
+ draw_line(Vector2(0, y), Vector2(width, y), color, font->get_underline_thickness());
}
} break;
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index 30ecd651b1..a03d6d0cdc 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -340,8 +340,8 @@ void OptionButton::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "items", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_items", "_get_items");
// "selected" property must come after "items", otherwise GH-10213 occurs.
ADD_PROPERTY(PropertyInfo(Variant::INT, "selected"), "_select_int", "get_selected");
- ADD_SIGNAL(MethodInfo("item_selected", PropertyInfo(Variant::INT, "id")));
- ADD_SIGNAL(MethodInfo("item_focused", PropertyInfo(Variant::INT, "id")));
+ ADD_SIGNAL(MethodInfo("item_selected", PropertyInfo(Variant::INT, "index")));
+ ADD_SIGNAL(MethodInfo("item_focused", PropertyInfo(Variant::INT, "index")));
}
OptionButton::OptionButton() {
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 1e933c9aa1..9c48801ec1 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -30,7 +30,7 @@
#include "popup_menu.h"
-#include "core/input/input_filter.h"
+#include "core/input/input.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "core/print_string.h"
@@ -594,7 +594,7 @@ void PopupMenu::_notification(int p_what) {
} break;
case NOTIFICATION_POST_POPUP: {
- initial_button_mask = InputFilter::get_singleton()->get_mouse_button_mask();
+ initial_button_mask = Input::get_singleton()->get_mouse_button_mask();
during_grabbed_click = (bool)initial_button_mask;
} break;
case NOTIFICATION_WM_SIZE_CHANGED: {
@@ -1079,6 +1079,11 @@ bool PopupMenu::is_item_shortcut_disabled(int p_idx) const {
return items[p_idx].shortcut_is_disabled;
}
+int PopupMenu::get_current_index() const {
+
+ return mouse_over;
+}
+
int PopupMenu::get_item_count() const {
return items.size();
@@ -1457,6 +1462,7 @@ void PopupMenu::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_item_tooltip", "idx"), &PopupMenu::get_item_tooltip);
ClassDB::bind_method(D_METHOD("get_item_shortcut", "idx"), &PopupMenu::get_item_shortcut);
+ ClassDB::bind_method(D_METHOD("get_current_index"), &PopupMenu::get_current_index);
ClassDB::bind_method(D_METHOD("get_item_count"), &PopupMenu::get_item_count);
ClassDB::bind_method(D_METHOD("remove_item", "idx"), &PopupMenu::remove_item);
diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h
index 2eef1f009d..d5c1015863 100644
--- a/scene/gui/popup_menu.h
+++ b/scene/gui/popup_menu.h
@@ -178,6 +178,7 @@ public:
Ref<ShortCut> get_item_shortcut(int p_idx) const;
int get_item_state(int p_idx) const;
+ int get_current_index() const;
int get_item_count() const;
bool activate_item_by_event(const Ref<InputEvent> &p_event, bool p_for_global_only = false);
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 5fb2243aff..84097eb6a1 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -407,17 +407,16 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
cw = tab_size * font->get_char_size(' ').width;
}
- if (end > 0 && w + cw + begin > p_width) {
+ if (end > 0 && fw + cw + begin > p_width) {
break; //don't allow lines longer than assigned width
}
- w += cw;
fw += cw;
end++;
}
CHECK_HEIGHT(fh);
- ENSURE_WIDTH(w);
+ ENSURE_WIDTH(fw);
line_ascent = MAX(line_ascent, ascent);
line_descent = MAX(line_descent, descent);
@@ -552,8 +551,10 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
}
}
- if (visible)
+ if (visible) {
line_is_blank = false;
+ w += font->get_char_size(c[i], c[i + 1]).x;
+ }
if (c[i] == '\t')
visible = false;
@@ -582,13 +583,14 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
} else {
cw = drawer.draw_char(ci, p_ofs + Point2(align_ofs + pofs, y + lh - line_descent) + fx_offset, fx_char, c[i + 1], fx_color);
}
- } else if (previously_visible) {
+ } else if (previously_visible && c[i] != '\t') {
backtrack += font->get_char_size(fx_char, c[i + 1]).x;
}
p_char_count++;
if (c[i] == '\t') {
cw = tab_size * font->get_char_size(' ').width;
+ backtrack = MAX(0, backtrack - cw);
}
ofs += cw;
@@ -598,8 +600,8 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
if (underline) {
Color uc = color;
uc.a *= 0.5;
- int uy = y + lh - line_descent + 2;
- float underline_width = 1.0;
+ int uy = y + lh - line_descent + font->get_underline_position();
+ float underline_width = font->get_underline_thickness();
#ifdef TOOLS_ENABLED
underline_width *= EDSCALE;
#endif
@@ -607,8 +609,8 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
} else if (strikethrough) {
Color uc = color;
uc.a *= 0.5;
- int uy = y + lh / 2 - line_descent + 2;
- float strikethrough_width = 1.0;
+ int uy = y + lh - (line_ascent + line_descent) / 2;
+ float strikethrough_width = font->get_underline_thickness();
#ifdef TOOLS_ENABLED
strikethrough_width *= EDSCALE;
#endif
@@ -2091,6 +2093,8 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
}
String tag = p_bbcode.substr(brk_pos + 1, brk_end - brk_pos - 1);
+ Vector<String> split_tag_block = tag.split(" ", false);
+ String bbcode = !split_tag_block.empty() ? split_tag_block[0] : "";
if (tag.begins_with("/") && tag_stack.size()) {
bool tag_ok = tag_stack.size() && tag_stack.front()->get() == tag.substr(1, tag.length());
@@ -2323,15 +2327,14 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
pos = brk_end + 1;
tag_stack.push_front("font");
- } else if (tag.begins_with("fade")) {
- Vector<String> tags = tag.split(" ", false);
+ } else if (bbcode == "fade") {
int startIndex = 0;
int length = 10;
- if (tags.size() > 1) {
- tags.remove(0);
- for (int i = 0; i < tags.size(); i++) {
- String expr = tags[i];
+ if (split_tag_block.size() > 1) {
+ split_tag_block.remove(0);
+ for (int i = 0; i < split_tag_block.size(); i++) {
+ String expr = split_tag_block[i];
if (expr.begins_with("start=")) {
String start_str = expr.substr(6, expr.length());
startIndex = start_str.to_int();
@@ -2345,15 +2348,14 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
push_fade(startIndex, length);
pos = brk_end + 1;
tag_stack.push_front("fade");
- } else if (tag.begins_with("shake")) {
- Vector<String> tags = tag.split(" ", false);
+ } else if (bbcode == "shake") {
int strength = 5;
float rate = 20.0f;
- if (tags.size() > 1) {
- tags.remove(0);
- for (int i = 0; i < tags.size(); i++) {
- String expr = tags[i];
+ if (split_tag_block.size() > 1) {
+ split_tag_block.remove(0);
+ for (int i = 0; i < split_tag_block.size(); i++) {
+ String expr = split_tag_block[i];
if (expr.begins_with("level=")) {
String str_str = expr.substr(6, expr.length());
strength = str_str.to_int();
@@ -2368,15 +2370,14 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
pos = brk_end + 1;
tag_stack.push_front("shake");
set_process_internal(true);
- } else if (tag.begins_with("wave")) {
- Vector<String> tags = tag.split(" ", false);
+ } else if (bbcode == "wave") {
float amplitude = 20.0f;
float period = 5.0f;
- if (tags.size() > 1) {
- tags.remove(0);
- for (int i = 0; i < tags.size(); i++) {
- String expr = tags[i];
+ if (split_tag_block.size() > 1) {
+ split_tag_block.remove(0);
+ for (int i = 0; i < split_tag_block.size(); i++) {
+ String expr = split_tag_block[i];
if (expr.begins_with("amp=")) {
String amp_str = expr.substr(4, expr.length());
amplitude = amp_str.to_float();
@@ -2391,15 +2392,14 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
pos = brk_end + 1;
tag_stack.push_front("wave");
set_process_internal(true);
- } else if (tag.begins_with("tornado")) {
- Vector<String> tags = tag.split(" ", false);
+ } else if (bbcode == "tornado") {
float radius = 10.0f;
float frequency = 1.0f;
- if (tags.size() > 1) {
- tags.remove(0);
- for (int i = 0; i < tags.size(); i++) {
- String expr = tags[i];
+ if (split_tag_block.size() > 1) {
+ split_tag_block.remove(0);
+ for (int i = 0; i < split_tag_block.size(); i++) {
+ String expr = split_tag_block[i];
if (expr.begins_with("radius=")) {
String amp_str = expr.substr(7, expr.length());
radius = amp_str.to_float();
@@ -2414,16 +2414,15 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
pos = brk_end + 1;
tag_stack.push_front("tornado");
set_process_internal(true);
- } else if (tag.begins_with("rainbow")) {
- Vector<String> tags = tag.split(" ", false);
+ } else if (bbcode == "rainbow") {
float saturation = 0.8f;
float value = 0.8f;
float frequency = 1.0f;
- if (tags.size() > 1) {
- tags.remove(0);
- for (int i = 0; i < tags.size(); i++) {
- String expr = tags[i];
+ if (split_tag_block.size() > 1) {
+ split_tag_block.remove(0);
+ for (int i = 0; i < split_tag_block.size(); i++) {
+ String expr = split_tag_block[i];
if (expr.begins_with("sat=")) {
String sat_str = expr.substr(4, expr.length());
saturation = sat_str.to_float();
@@ -2442,7 +2441,7 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
tag_stack.push_front("rainbow");
set_process_internal(true);
} else {
- Vector<String> expr = tag.split(" ", false);
+ Vector<String> &expr = split_tag_block;
if (expr.size() < 1) {
add_text("[");
pos = brk_pos + 1;
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp
index e47e2b869d..1f135163d4 100644
--- a/scene/gui/slider.cpp
+++ b/scene/gui/slider.cpp
@@ -166,8 +166,9 @@ void Slider::_notification(int p_what) {
RID ci = get_canvas_item();
Size2i size = get_size();
Ref<StyleBox> style = get_theme_stylebox("slider");
- Ref<StyleBox> grabber_area = get_theme_stylebox("grabber_area");
- Ref<Texture2D> grabber = get_theme_icon(editable ? ((mouse_inside || has_focus()) ? "grabber_highlight" : "grabber") : "grabber_disabled");
+ bool highlighted = mouse_inside || has_focus();
+ Ref<StyleBox> grabber_area = get_theme_stylebox(highlighted ? "grabber_area_highlight" : "grabber_area");
+ Ref<Texture2D> grabber = get_theme_icon(editable ? (highlighted ? "grabber_highlight" : "grabber") : "grabber_disabled");
Ref<Texture2D> tick = get_theme_icon("tick");
double ratio = Math::is_nan(get_as_ratio()) ? 0 : get_as_ratio();
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index 8572d570fb..94628f7cea 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -30,7 +30,7 @@
#include "spin_box.h"
-#include "core/input/input_filter.h"
+#include "core/input/input.h"
#include "core/math/expression.h"
Size2 SpinBox::get_minimum_size() const {
@@ -77,7 +77,7 @@ void SpinBox::_line_edit_input(const Ref<InputEvent> &p_event) {
void SpinBox::_range_click_timeout() {
- if (!drag.enabled && InputFilter::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
+ if (!drag.enabled && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
bool up = get_local_mouse_position().y < (get_size().height / 2);
set_value(get_value() + (up ? get_step() : -get_step()));
@@ -149,7 +149,7 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) {
if (drag.enabled) {
drag.enabled = false;
- InputFilter::get_singleton()->set_mouse_mode(InputFilter::MOUSE_MODE_VISIBLE);
+ Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
warp_mouse(drag.capture_pos);
}
drag.allowed = false;
@@ -166,7 +166,7 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) {
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) {
- InputFilter::get_singleton()->set_mouse_mode(InputFilter::MOUSE_MODE_CAPTURED);
+ Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
drag.enabled = true;
drag.base_val = get_value();
drag.diff_y = 0;
diff --git a/scene/gui/viewport_container.cpp b/scene/gui/subviewport_container.cpp
index 7ce1d9e551..50f468741d 100644
--- a/scene/gui/viewport_container.cpp
+++ b/scene/gui/subviewport_container.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* viewport_container.cpp */
+/* subviewport_container.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,12 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "viewport_container.h"
+#include "subviewport_container.h"
#include "core/engine.h"
#include "scene/main/viewport.h"
-Size2 ViewportContainer::get_minimum_size() const {
+Size2 SubViewportContainer::get_minimum_size() const {
if (stretch)
return Size2();
@@ -52,19 +52,19 @@ Size2 ViewportContainer::get_minimum_size() const {
return ms;
}
-void ViewportContainer::set_stretch(bool p_enable) {
+void SubViewportContainer::set_stretch(bool p_enable) {
stretch = p_enable;
queue_sort();
update();
}
-bool ViewportContainer::is_stretch_enabled() const {
+bool SubViewportContainer::is_stretch_enabled() const {
return stretch;
}
-void ViewportContainer::set_stretch_shrink(int p_shrink) {
+void SubViewportContainer::set_stretch_shrink(int p_shrink) {
ERR_FAIL_COND(p_shrink < 1);
if (shrink == p_shrink)
@@ -87,12 +87,12 @@ void ViewportContainer::set_stretch_shrink(int p_shrink) {
update();
}
-int ViewportContainer::get_stretch_shrink() const {
+int SubViewportContainer::get_stretch_shrink() const {
return shrink;
}
-void ViewportContainer::_notification(int p_what) {
+void SubViewportContainer::_notification(int p_what) {
if (p_what == NOTIFICATION_RESIZED) {
@@ -142,7 +142,7 @@ void ViewportContainer::_notification(int p_what) {
}
}
-void ViewportContainer::_input(const Ref<InputEvent> &p_event) {
+void SubViewportContainer::_input(const Ref<InputEvent> &p_event) {
if (Engine::get_singleton()->is_editor_hint())
return;
@@ -167,7 +167,7 @@ void ViewportContainer::_input(const Ref<InputEvent> &p_event) {
}
}
-void ViewportContainer::_unhandled_input(const Ref<InputEvent> &p_event) {
+void SubViewportContainer::_unhandled_input(const Ref<InputEvent> &p_event) {
if (Engine::get_singleton()->is_editor_hint())
return;
@@ -192,21 +192,21 @@ void ViewportContainer::_unhandled_input(const Ref<InputEvent> &p_event) {
}
}
-void ViewportContainer::_bind_methods() {
+void SubViewportContainer::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_unhandled_input", "event"), &ViewportContainer::_unhandled_input);
- ClassDB::bind_method(D_METHOD("_input", "event"), &ViewportContainer::_input);
- ClassDB::bind_method(D_METHOD("set_stretch", "enable"), &ViewportContainer::set_stretch);
- ClassDB::bind_method(D_METHOD("is_stretch_enabled"), &ViewportContainer::is_stretch_enabled);
+ ClassDB::bind_method(D_METHOD("_unhandled_input", "event"), &SubViewportContainer::_unhandled_input);
+ ClassDB::bind_method(D_METHOD("_input", "event"), &SubViewportContainer::_input);
+ ClassDB::bind_method(D_METHOD("set_stretch", "enable"), &SubViewportContainer::set_stretch);
+ ClassDB::bind_method(D_METHOD("is_stretch_enabled"), &SubViewportContainer::is_stretch_enabled);
- ClassDB::bind_method(D_METHOD("set_stretch_shrink", "amount"), &ViewportContainer::set_stretch_shrink);
- ClassDB::bind_method(D_METHOD("get_stretch_shrink"), &ViewportContainer::get_stretch_shrink);
+ ClassDB::bind_method(D_METHOD("set_stretch_shrink", "amount"), &SubViewportContainer::set_stretch_shrink);
+ ClassDB::bind_method(D_METHOD("get_stretch_shrink"), &SubViewportContainer::get_stretch_shrink);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stretch"), "set_stretch", "is_stretch_enabled");
ADD_PROPERTY(PropertyInfo(Variant::INT, "stretch_shrink"), "set_stretch_shrink", "get_stretch_shrink");
}
-ViewportContainer::ViewportContainer() {
+SubViewportContainer::SubViewportContainer() {
stretch = false;
shrink = 1;
diff --git a/scene/gui/viewport_container.h b/scene/gui/subviewport_container.h
index 8597444426..6ff3d188e2 100644
--- a/scene/gui/viewport_container.h
+++ b/scene/gui/subviewport_container.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* viewport_container.h */
+/* subviewport_container.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -33,9 +33,9 @@
#include "scene/gui/container.h"
-class ViewportContainer : public Container {
+class SubViewportContainer : public Container {
- GDCLASS(ViewportContainer, Container);
+ GDCLASS(SubViewportContainer, Container);
bool stretch;
int shrink;
@@ -55,7 +55,7 @@ public:
virtual Size2 get_minimum_size() const;
- ViewportContainer();
+ SubViewportContainer();
};
#endif // VIEWPORTCONTAINER_H
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index de80049862..3a128cf8e6 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -990,7 +990,7 @@ void TabContainer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_current_tab"), &TabContainer::get_current_tab);
ClassDB::bind_method(D_METHOD("get_previous_tab"), &TabContainer::get_previous_tab);
ClassDB::bind_method(D_METHOD("get_current_tab_control"), &TabContainer::get_current_tab_control);
- ClassDB::bind_method(D_METHOD("get_tab_control", "idx"), &TabContainer::get_tab_control);
+ ClassDB::bind_method(D_METHOD("get_tab_control", "tab_idx"), &TabContainer::get_tab_control);
ClassDB::bind_method(D_METHOD("set_tab_align", "align"), &TabContainer::set_tab_align);
ClassDB::bind_method(D_METHOD("get_tab_align"), &TabContainer::get_tab_align);
ClassDB::bind_method(D_METHOD("set_tabs_visible", "visible"), &TabContainer::set_tabs_visible);
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index ea6d44e3a7..1a3b53f489 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -184,10 +184,7 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) {
}
int found = -1;
- for (int i = 0; i < tabs.size(); i++) {
-
- if (i < offset)
- continue;
+ for (int i = offset; i < tabs.size(); i++) {
if (tabs[i].rb_rect.has_point(pos)) {
rb_pressing = true;
@@ -276,10 +273,7 @@ void Tabs::_notification(int p_what) {
missing_right = false;
- for (int i = 0; i < tabs.size(); i++) {
-
- if (i < offset)
- continue;
+ for (int i = offset; i < tabs.size(); i++) {
tabs.write[i].ofs_cache = w;
@@ -499,10 +493,7 @@ void Tabs::_update_hover() {
// test hovering to display right or close button
int hover_now = -1;
int hover_buttons = -1;
- for (int i = 0; i < tabs.size(); i++) {
-
- if (i < offset)
- continue;
+ for (int i = offset; i < tabs.size(); i++) {
Rect2 rect = get_tab_rect(i);
if (rect.has_point(pos)) {
@@ -559,9 +550,8 @@ void Tabs::_update_cache() {
if (count_resize > 0) {
m_width = MAX((limit - size_fixed) / count_resize, min_width);
}
- for (int i = 0; i < tabs.size(); i++) {
- if (i < offset)
- continue;
+ for (int i = offset; i < tabs.size(); i++) {
+
Ref<StyleBox> sb;
if (tabs[i].disabled) {
sb = tab_disabled;
@@ -753,10 +743,7 @@ void Tabs::drop_data(const Point2 &p_point, const Variant &p_data) {
int Tabs::get_tab_idx_at_point(const Point2 &p_point) const {
int hover_now = -1;
- for (int i = 0; i < tabs.size(); i++) {
-
- if (i < offset)
- continue;
+ for (int i = offset; i < tabs.size(); i++) {
Rect2 rect = get_tab_rect(i);
if (rect.has_point(p_point)) {
@@ -850,10 +837,7 @@ void Tabs::_ensure_no_over_offset() {
while (offset > 0) {
int total_w = 0;
- for (int i = 0; i < tabs.size(); i++) {
-
- if (i < offset - 1)
- continue;
+ for (int i = offset - 1; i < tabs.size(); i++) {
total_w += tabs[i].size_cache;
}
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 36e35897d1..aa518fbb7d 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -30,7 +30,7 @@
#include "text_edit.h"
-#include "core/input/input_filter.h"
+#include "core/input/input.h"
#include "core/message_queue.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
@@ -446,7 +446,7 @@ void TextEdit::_click_selection_held() {
// Warning: is_mouse_button_pressed(BUTTON_LEFT) returns false for double+ clicks, so this doesn't work for MODE_WORD
// and MODE_LINE. However, moving the mouse triggers _gui_input, which calls these functions too, so that's not a huge problem.
// I'm unsure if there's an actual fix that doesn't have a ton of side effects.
- if (InputFilter::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT) && selection.selecting_mode != Selection::MODE_NONE) {
+ if (Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT) && selection.selecting_mode != Selection::MODE_NONE) {
switch (selection.selecting_mode) {
case Selection::MODE_POINTER: {
_update_selection_mode_pointer();
@@ -1064,11 +1064,6 @@ void TextEdit::_notification(int p_what) {
break;
}
- // re-adjust if we went backwards.
- if (color != previous_color && !is_whitespace) {
- characters++;
- }
-
if (str[j] == '\t') {
tabs += minimap_tab_size;
}
@@ -1158,7 +1153,7 @@ void TextEdit::_notification(int p_what) {
highlighted_text_col = _get_column_pos_of_word(highlighted_text, str, SEARCH_MATCH_CASE | SEARCH_WHOLE_WORDS, 0);
if (select_identifiers_enabled && highlighted_word.length() != 0) {
- if (_is_char(highlighted_word[0])) {
+ if (_is_char(highlighted_word[0]) || highlighted_word[0] == '.') {
highlighted_word_col = _get_column_pos_of_word(highlighted_word, fullstr, SEARCH_MATCH_CASE | SEARCH_WHOLE_WORDS, 0);
}
}
@@ -1492,12 +1487,12 @@ void TextEdit::_notification(int p_what) {
int yofs = ofs_y + (get_row_height() - cache.font->get_height()) / 2;
int w = drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), str[j], str[j + 1], in_selection && override_selected_font_color ? cache.font_color_selected : color);
if (underlined) {
- float line_width = 1.0;
+ float line_width = cache.font->get_underline_thickness();
#ifdef TOOLS_ENABLED
line_width *= EDSCALE;
#endif
- draw_rect(Rect2(char_ofs + char_margin + ofs_x, yofs + ascent + 2, w, line_width), in_selection && override_selected_font_color ? cache.font_color_selected : color);
+ draw_rect(Rect2(char_ofs + char_margin + ofs_x, yofs + ascent + cache.font->get_underline_position(), w, line_width), in_selection && override_selected_font_color ? cache.font_color_selected : color);
}
} else if (draw_tabs && str[j] == '\t') {
int yofs = (get_row_height() - cache.tab_icon->get_height()) / 2;
@@ -6220,6 +6215,10 @@ void TextEdit::_push_current_op() {
current_op.type = TextOperation::TYPE_NONE;
current_op.text = "";
current_op.chain_forward = false;
+
+ if (undo_stack.size() > undo_stack_max_size) {
+ undo_stack.pop_front();
+ }
}
void TextEdit::set_indent_using_spaces(const bool p_use_spaces) {
@@ -7084,6 +7083,7 @@ void TextEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_line_count"), &TextEdit::get_line_count);
ClassDB::bind_method(D_METHOD("get_text"), &TextEdit::get_text);
ClassDB::bind_method(D_METHOD("get_line", "line"), &TextEdit::get_line);
+ ClassDB::bind_method(D_METHOD("set_line", "line", "new_text"), &TextEdit::set_line);
ClassDB::bind_method(D_METHOD("center_viewport_to_cursor"), &TextEdit::center_viewport_to_cursor);
ClassDB::bind_method(D_METHOD("cursor_set_column", "column", "adjust_viewport"), &TextEdit::cursor_set_column, DEFVAL(true));
@@ -7244,6 +7244,8 @@ void TextEdit::_bind_methods() {
GLOBAL_DEF("gui/timers/text_edit_idle_detect_sec", 3);
ProjectSettings::get_singleton()->set_custom_property_info("gui/timers/text_edit_idle_detect_sec", PropertyInfo(Variant::FLOAT, "gui/timers/text_edit_idle_detect_sec", PROPERTY_HINT_RANGE, "0,10,0.01,or_greater")); // No negative numbers.
+ GLOBAL_DEF("gui/common/text_edit_undo_stack_max_size", 1024);
+ ProjectSettings::get_singleton()->set_custom_property_info("gui/common/text_edit_undo_stack_max_size", PropertyInfo(Variant::INT, "gui/common/text_edit_undo_stack_max_size", PROPERTY_HINT_RANGE, "0,10000,1,or_greater")); // No negative numbers.
}
TextEdit::TextEdit() {
@@ -7323,6 +7325,7 @@ TextEdit::TextEdit() {
current_op.type = TextOperation::TYPE_NONE;
undo_enabled = true;
+ undo_stack_max_size = GLOBAL_GET("gui/common/text_edit_undo_stack_max_size");
undo_stack_pos = nullptr;
setting_text = false;
last_dblclk = 0;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index ef8c39d32f..ac8eb5da1d 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -306,6 +306,7 @@ private:
List<TextOperation> undo_stack;
List<TextOperation>::Element *undo_stack_pos;
+ int undo_stack_max_size;
void _clear_redo();
void _do_text_op(const TextOperation &p_op, bool p_reverse);
diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp
index baa138847f..92f3c5b5d9 100644
--- a/scene/gui/texture_rect.cpp
+++ b/scene/gui/texture_rect.cpp
@@ -95,6 +95,15 @@ void TextureRect::_notification(int p_what) {
} break;
}
+ Ref<AtlasTexture> p_atlas = texture;
+
+ if (p_atlas.is_valid() && region.has_no_area()) {
+ Size2 scale_size(size.width / texture->get_width(), size.height / texture->get_height());
+
+ offset.width += hflip ? p_atlas->get_margin().get_position().width * scale_size.width * 2 : 0;
+ offset.height += vflip ? p_atlas->get_margin().get_position().height * scale_size.height * 2 : 0;
+ }
+
size.width *= hflip ? -1.0f : 1.0f;
size.height *= vflip ? -1.0f : 1.0f;
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index a7acaae8df..329c1085df 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -30,7 +30,7 @@
#include "tree.h"
-#include "core/input/input_filter.h"
+#include "core/input/input.h"
#include "core/math/math_funcs.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
@@ -779,6 +779,9 @@ void TreeItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_text", "column", "text"), &TreeItem::set_text);
ClassDB::bind_method(D_METHOD("get_text", "column"), &TreeItem::get_text);
+ ClassDB::bind_method(D_METHOD("set_suffix", "column", "text"), &TreeItem::set_suffix);
+ ClassDB::bind_method(D_METHOD("get_suffix", "column"), &TreeItem::get_suffix);
+
ClassDB::bind_method(D_METHOD("set_icon", "column", "texture"), &TreeItem::set_icon);
ClassDB::bind_method(D_METHOD("get_icon", "column"), &TreeItem::get_icon);
@@ -1425,7 +1428,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
if (p_item->cells[i].custom_button) {
if (cache.hover_item == p_item && cache.hover_cell == i) {
- if (InputFilter::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
+ if (Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
draw_style_box(cache.custom_button_pressed, ir);
} else {
draw_style_box(cache.custom_button_hover, ir);
@@ -1661,7 +1664,7 @@ Rect2 Tree::search_item_rect(TreeItem *p_from, TreeItem *p_item) {
void Tree::_range_click_timeout() {
- if (range_item_last && !range_drag_enabled && InputFilter::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
+ if (range_item_last && !range_drag_enabled && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
Point2 pos = get_local_mouse_position() - cache.bg->get_offset();
if (show_column_titles) {
@@ -2048,9 +2051,9 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
void Tree::_text_editor_modal_close() {
- if (InputFilter::get_singleton()->is_key_pressed(KEY_ESCAPE) ||
- InputFilter::get_singleton()->is_key_pressed(KEY_KP_ENTER) ||
- InputFilter::get_singleton()->is_key_pressed(KEY_ENTER)) {
+ if (Input::get_singleton()->is_key_pressed(KEY_ESCAPE) ||
+ Input::get_singleton()->is_key_pressed(KEY_KP_ENTER) ||
+ Input::get_singleton()->is_key_pressed(KEY_ENTER)) {
return;
}
@@ -2532,7 +2535,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
range_drag_enabled = true;
range_drag_capture_pos = cpos;
range_drag_base = popup_edited_item->get_range(popup_edited_item_col);
- InputFilter::get_singleton()->set_mouse_mode(InputFilter::MOUSE_MODE_CAPTURED);
+ Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
}
} else {
@@ -2594,7 +2597,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
if (range_drag_enabled) {
range_drag_enabled = false;
- InputFilter::get_singleton()->set_mouse_mode(InputFilter::MOUSE_MODE_VISIBLE);
+ Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
warp_mouse(range_drag_capture_pos);
} else {
Rect2 rect = get_selected()->get_meta("__focus_rect");
@@ -3045,13 +3048,6 @@ void Tree::_notification(int p_what) {
draw_item(Point2(), draw_ofs, draw_size, root);
}
- int ofs = 0;
-
- for (int i = 0; i < (columns.size() - 1 - 1); i++) {
-
- ofs += get_column_width(i);
- }
-
if (show_column_titles) {
//title buttons
@@ -3245,7 +3241,7 @@ void Tree::clear() {
if (pressing_for_editor) {
if (range_drag_enabled) {
range_drag_enabled = false;
- InputFilter::get_singleton()->set_mouse_mode(InputFilter::MOUSE_MODE_VISIBLE);
+ Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
warp_mouse(range_drag_capture_pos);
}
pressing_for_editor = false;