summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/SCsub2
-rw-r--r--scene/gui/base_button.cpp13
-rw-r--r--scene/gui/base_button.h1
-rw-r--r--scene/gui/button.cpp15
-rw-r--r--scene/gui/color_picker.cpp31
-rw-r--r--scene/gui/control.cpp20
-rw-r--r--scene/gui/file_dialog.cpp6
-rw-r--r--scene/gui/gradient_edit.cpp14
-rw-r--r--scene/gui/graph_edit.cpp14
-rw-r--r--scene/gui/graph_edit.h2
-rw-r--r--scene/gui/grid_container.cpp17
-rw-r--r--scene/gui/grid_container.h1
-rw-r--r--scene/gui/item_list.cpp1
-rw-r--r--scene/gui/label.cpp4
-rw-r--r--scene/gui/line_edit.cpp4
-rw-r--r--scene/gui/link_button.cpp1
-rw-r--r--scene/gui/nine_patch_rect.cpp4
-rw-r--r--scene/gui/range.cpp22
-rw-r--r--scene/gui/range.h2
-rw-r--r--scene/gui/rich_text_label.cpp77
-rw-r--r--scene/gui/rich_text_label.h8
-rw-r--r--scene/gui/scroll_container.cpp3
-rw-r--r--scene/gui/spin_box.cpp13
-rw-r--r--scene/gui/spin_box.h3
-rw-r--r--scene/gui/tabs.cpp81
-rw-r--r--scene/gui/tabs.h2
-rw-r--r--scene/gui/text_edit.cpp52
-rw-r--r--scene/gui/text_edit.h2
-rw-r--r--scene/gui/texture_button.cpp4
-rw-r--r--scene/gui/texture_progress.cpp32
-rw-r--r--scene/gui/tree.cpp59
-rw-r--r--scene/gui/tree.h6
-rw-r--r--scene/gui/video_player.cpp4
33 files changed, 320 insertions, 200 deletions
diff --git a/scene/gui/SCsub b/scene/gui/SCsub
index bf9125be7f..b01e2fd54d 100644
--- a/scene/gui/SCsub
+++ b/scene/gui/SCsub
@@ -3,5 +3,3 @@
Import('env')
env.add_source_files(env.scene_sources, "*.cpp")
-
-Export('env')
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 59590ea67b..6dfaacc776 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -315,6 +315,14 @@ void BaseButton::set_disabled(bool p_disabled) {
return;
status.disabled = p_disabled;
+ if (p_disabled) {
+ if (!toggle_mode) {
+ status.pressed = false;
+ }
+ status.press_attempt = false;
+ status.pressing_inside = false;
+ status.pressing_button = 0;
+ }
update();
_change_notify("disabled");
}
@@ -360,7 +368,9 @@ BaseButton::DrawMode BaseButton::get_draw_mode() const {
return DRAW_DISABLED;
};
- if (status.press_attempt == false && status.hovering && !status.pressed) {
+ if (!status.press_attempt && status.hovering) {
+ if (status.pressed)
+ return DRAW_HOVER_PRESSED;
return DRAW_HOVER;
} else {
@@ -536,6 +546,7 @@ void BaseButton::_bind_methods() {
BIND_ENUM_CONSTANT(DRAW_PRESSED);
BIND_ENUM_CONSTANT(DRAW_HOVER);
BIND_ENUM_CONSTANT(DRAW_DISABLED);
+ BIND_ENUM_CONSTANT(DRAW_HOVER_PRESSED);
BIND_ENUM_CONSTANT(ACTION_MODE_BUTTON_PRESS);
BIND_ENUM_CONSTANT(ACTION_MODE_BUTTON_RELEASE);
diff --git a/scene/gui/base_button.h b/scene/gui/base_button.h
index 79638bbcce..176d9fc213 100644
--- a/scene/gui/base_button.h
+++ b/scene/gui/base_button.h
@@ -85,6 +85,7 @@ public:
DRAW_PRESSED,
DRAW_HOVER,
DRAW_DISABLED,
+ DRAW_HOVER_PRESSED,
};
DrawMode get_draw_mode() const;
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp
index dd6d66ac62..2d17fb1391 100644
--- a/scene/gui/button.cpp
+++ b/scene/gui/button.cpp
@@ -88,6 +88,21 @@ void Button::_notification(int p_what) {
if (has_color("icon_color_normal"))
color_icon = get_color("icon_color_normal");
} break;
+ case DRAW_HOVER_PRESSED: {
+ if (has_stylebox("hover_pressed") && has_stylebox_override("hover_pressed")) {
+ style = get_stylebox("hover_pressed");
+ if (!flat)
+ style->draw(ci, Rect2(Point2(0, 0), size));
+ if (has_color("font_color_hover_pressed"))
+ color = get_color("font_color_hover_pressed");
+ else
+ color = get_color("font_color");
+ if (has_color("icon_color_hover_pressed"))
+ color_icon = get_color("icon_color_hover_pressed");
+
+ break;
+ }
+ }
case DRAW_PRESSED: {
style = get_stylebox("pressed");
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 537a16fbc3..c5d3def4c1 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -33,6 +33,11 @@
#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
+
+#ifdef TOOLS_ENABLED
+#include "editor_settings.h"
+#endif
+
#include "scene/gui/separator.h"
#include "scene/main/viewport.h"
@@ -52,6 +57,16 @@ void ColorPicker::_notification(int p_what) {
bt_add_preset->set_icon(get_icon("add_preset"));
_update_color();
+
+#ifdef TOOLS_ENABLED
+ if (Engine::get_singleton()->is_editor_hint()) {
+ PoolColorArray saved_presets = EditorSettings::get_singleton()->get_project_metadata("color_picker", "presets", PoolColorArray());
+
+ for (int i = 0; i < saved_presets.size(); i++) {
+ add_preset(saved_presets[i]);
+ }
+ }
+#endif
} break;
case NOTIFICATION_PARENTED: {
@@ -144,7 +159,10 @@ void ColorPicker::_html_entered(const String &p_html) {
if (updating)
return;
+ float last_alpha = color.a;
color = Color::html(p_html);
+ if (!is_editing_alpha())
+ color.a = last_alpha;
if (!is_inside_tree())
return;
@@ -186,9 +204,22 @@ 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() {
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 12349e0983..e155d0ef86 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -769,7 +769,7 @@ void Control::force_drag(const Variant &p_data, Control *p_control) {
void Control::set_drag_preview(Control *p_control) {
ERR_FAIL_COND(!is_inside_tree());
- ERR_FAIL_COND(get_viewport()->gui_is_dragging());
+ ERR_FAIL_COND(!get_viewport()->gui_is_dragging());
get_viewport()->_gui_set_drag_preview(this, p_control);
}
@@ -1079,7 +1079,7 @@ bool Control::has_constant_override(const StringName &p_name) const {
bool Control::has_icon(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == "") {
- if (has_icon_override(p_name) == true)
+ if (has_icon_override(p_name))
return true;
}
@@ -1113,7 +1113,7 @@ bool Control::has_icon(const StringName &p_name, const StringName &p_type) const
bool Control::has_shader(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == "") {
- if (has_shader_override(p_name) == true)
+ if (has_shader_override(p_name))
return true;
}
@@ -1146,7 +1146,7 @@ bool Control::has_shader(const StringName &p_name, const StringName &p_type) con
bool Control::has_stylebox(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == "") {
- if (has_stylebox_override(p_name) == true)
+ if (has_stylebox_override(p_name))
return true;
}
@@ -1179,7 +1179,7 @@ bool Control::has_stylebox(const StringName &p_name, const StringName &p_type) c
bool Control::has_font(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == "") {
- if (has_font_override(p_name) == true)
+ if (has_font_override(p_name))
return true;
}
@@ -1213,7 +1213,7 @@ bool Control::has_font(const StringName &p_name, const StringName &p_type) const
bool Control::has_color(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == "") {
- if (has_color_override(p_name) == true)
+ if (has_color_override(p_name))
return true;
}
@@ -1247,7 +1247,7 @@ bool Control::has_color(const StringName &p_name, const StringName &p_type) cons
bool Control::has_constant(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == "") {
- if (has_constant_override(p_name) == true)
+ if (has_constant_override(p_name))
return true;
}
@@ -1993,7 +1993,7 @@ Control *Control::find_prev_valid_focus() const {
if (!from) {
- ERR_EXPLAIN("Prev focus node is not a control: " + n->get_name());
+ ERR_EXPLAIN("Previous focus node is not a control: " + n->get_name());
ERR_FAIL_V(NULL);
}
} else {
@@ -2235,13 +2235,13 @@ String Control::_get_tooltip() const {
void Control::set_focus_neighbour(Margin p_margin, const NodePath &p_neighbour) {
- ERR_FAIL_INDEX(p_margin, 4);
+ ERR_FAIL_INDEX((int)p_margin, 4);
data.focus_neighbour[p_margin] = p_neighbour;
}
NodePath Control::get_focus_neighbour(Margin p_margin) const {
- ERR_FAIL_INDEX_V(p_margin, 4, NodePath());
+ ERR_FAIL_INDEX_V((int)p_margin, 4, NodePath());
return data.focus_neighbour[p_margin];
}
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 5f162a3652..1e9f4df4a3 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -330,6 +330,10 @@ void FileDialog::deselect_items() {
case MODE_OPEN_DIR:
get_ok()->set_text(RTR("Select Current Folder"));
break;
+ case MODE_OPEN_ANY:
+ case MODE_SAVE_FILE:
+ // FIXME: Implement, or refactor to avoid duplication with set_mode
+ break;
}
}
}
@@ -349,7 +353,7 @@ void FileDialog::_tree_selected() {
file->set_text(d["name"]);
} else if (mode == MODE_OPEN_DIR) {
- get_ok()->set_text(RTR("Select this Folder"));
+ get_ok()->set_text(RTR("Select This Folder"));
}
get_ok()->set_disabled(_is_open_should_be_disabled());
diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp
index 19ffe681ef..c13964d196 100644
--- a/scene/gui/gradient_edit.cpp
+++ b/scene/gui/gradient_edit.cpp
@@ -236,23 +236,23 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) {
//Snap to nearest point if holding shift
if (mm->get_shift()) {
- float snap_treshhold = 0.03;
- float smallest_ofs = snap_treshhold;
- bool founded = false;
- int nearest_point;
+ float snap_threshold = 0.03;
+ float smallest_ofs = snap_threshold;
+ bool found = false;
+ int nearest_point = 0;
for (int i = 0; i < points.size(); ++i) {
if (i != grabbed) {
float temp_ofs = ABS(points[i].offset - newofs);
if (temp_ofs < smallest_ofs) {
smallest_ofs = temp_ofs;
nearest_point = i;
- if (founded)
+ if (found)
break;
- founded = true;
+ found = true;
}
}
}
- if (founded) {
+ if (found) {
if (points[nearest_point].offset < newofs)
newofs = points[nearest_point].offset + 0.00001;
else
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 0ffaac20f6..b3bebc88ec 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -406,7 +406,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
connecting_color = Object::cast_to<GraphNode>(to)->get_connection_input_color(E->get().to_port);
connecting_target = false;
connecting_to = pos;
- just_disconected = true;
+ just_disconnected = true;
emit_signal("disconnection_request", E->get().from, E->get().from_port, E->get().to, E->get().to_port);
to = get_node(String(connecting_from)); //maybe it was erased
@@ -427,7 +427,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
connecting_color = gn->get_connection_output_color(j);
connecting_target = false;
connecting_to = pos;
- just_disconected = false;
+ just_disconnected = false;
return;
}
}
@@ -453,7 +453,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
connecting_color = Object::cast_to<GraphNode>(fr)->get_connection_output_color(E->get().from_port);
connecting_target = false;
connecting_to = pos;
- just_disconected = true;
+ just_disconnected = true;
emit_signal("disconnection_request", E->get().from, E->get().from_port, E->get().to, E->get().to_port);
fr = get_node(String(connecting_from)); //maybe it was erased
@@ -474,7 +474,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
connecting_color = gn->get_connection_input_color(j);
connecting_target = false;
connecting_to = pos;
- just_disconected = true;
+ just_disconnected = true;
return;
}
@@ -544,7 +544,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
}
emit_signal("connection_request", from, from_slot, to, to_slot);
- } else if (!just_disconected) {
+ } else if (!just_disconnected) {
String from = connecting_from;
int from_slot = connecting_index;
Vector2 ofs = Vector2(mb->get_position().x, mb->get_position().y);
@@ -1042,7 +1042,7 @@ void GraphEdit::set_connection_activity(const StringName &p_from, int p_from_por
if (E->get().from == p_from && E->get().from_port == p_from_port && E->get().to == p_to && E->get().to_port == p_to_port) {
- if (ABS(E->get().activity != p_activity)) {
+ if (ABS(E->get().activity - p_activity) < CMP_EPSILON) {
//update only if changed
top_layer->update();
connections_layer->update();
@@ -1368,6 +1368,6 @@ GraphEdit::GraphEdit() {
zoom_hb->add_child(snap_amount);
setting_scroll_ofs = false;
- just_disconected = false;
+ just_disconnected = false;
set_clip_contents(true);
}
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h
index 31a449eb59..71165e3dc9 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -94,7 +94,7 @@ private:
Vector2 connecting_to;
String connecting_target_to;
int connecting_target_index;
- bool just_disconected;
+ bool just_disconnected;
bool dragging;
bool just_selected;
diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp
index 278e4123d7..bb1d1d7695 100644
--- a/scene/gui/grid_container.cpp
+++ b/scene/gui/grid_container.cpp
@@ -184,8 +184,6 @@ void GridContainer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_columns", "columns"), &GridContainer::set_columns);
ClassDB::bind_method(D_METHOD("get_columns"), &GridContainer::get_columns);
- ClassDB::bind_method(D_METHOD("get_child_control_at_cell", "row", "column"),
- &GridContainer::get_child_control_at_cell);
ADD_PROPERTY(PropertyInfo(Variant::INT, "columns", PROPERTY_HINT_RANGE, "1,1024,1"), "set_columns", "get_columns");
}
@@ -241,21 +239,6 @@ Size2 GridContainer::get_minimum_size() const {
return ms;
}
-Control *GridContainer::get_child_control_at_cell(int row, int column) {
- Control *c;
- int grid_index = row * columns + column;
- for (int i = 0; i < get_child_count(); i++) {
- c = Object::cast_to<Control>(get_child(i));
- if (!c || !c->is_visible_in_tree())
- continue;
-
- if (grid_index == i) {
- break;
- }
- }
- return c;
-}
-
GridContainer::GridContainer() {
set_mouse_filter(MOUSE_FILTER_PASS);
diff --git a/scene/gui/grid_container.h b/scene/gui/grid_container.h
index 7e3470dc89..243d06f034 100644
--- a/scene/gui/grid_container.h
+++ b/scene/gui/grid_container.h
@@ -47,7 +47,6 @@ public:
void set_columns(int p_columns);
int get_columns() const;
virtual Size2 get_minimum_size() const;
- Control *get_child_control_at_cell(int row, int column);
GridContainer();
};
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 0d5fbee9ee..494995fb85 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -1524,6 +1524,7 @@ void ItemList::_bind_methods() {
ADD_SIGNAL(MethodInfo("nothing_selected"));
GLOBAL_DEF("gui/timers/incremental_search_max_interval_msec", 2000);
+ ProjectSettings::get_singleton()->set_custom_property_info("gui/timers/incremental_search_max_interval_msec", PropertyInfo(Variant::INT, "gui/timers/incremental_search_max_interval_msec", PROPERTY_HINT_RANGE, "0,10000,1,or_greater")); // No negative numbers
}
ItemList::ItemList() {
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index 91dab27930..6ff2d232f0 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -511,7 +511,7 @@ void Label::regenerate_word_cache() {
void Label::set_align(Align p_align) {
- ERR_FAIL_INDEX(p_align, 4);
+ ERR_FAIL_INDEX((int)p_align, 4);
align = p_align;
update();
}
@@ -523,7 +523,7 @@ Label::Align Label::get_align() const {
void Label::set_valign(VAlign p_align) {
- ERR_FAIL_INDEX(p_align, 4);
+ ERR_FAIL_INDEX((int)p_align, 4);
valign = p_align;
update();
}
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 9c43d5b308..c4373876b1 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -527,7 +527,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
void LineEdit::set_align(Align p_align) {
- ERR_FAIL_INDEX(p_align, 4);
+ ERR_FAIL_INDEX((int)p_align, 4);
align = p_align;
update();
}
@@ -1608,6 +1608,8 @@ LineEdit::LineEdit() {
text_changed_dirty = false;
placeholder_alpha = 0.6;
clear_button_enabled = false;
+ clear_button_status.press_attempt = false;
+ clear_button_status.pressing_inside = false;
deselect();
set_focus_mode(FOCUS_ALL);
diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp
index 8560efdde5..c1561e97ba 100644
--- a/scene/gui/link_button.cpp
+++ b/scene/gui/link_button.cpp
@@ -75,6 +75,7 @@ void LinkButton::_notification(int p_what) {
color = get_color("font_color");
do_underline = underline_mode == UNDERLINE_MODE_ALWAYS;
} break;
+ case DRAW_HOVER_PRESSED:
case DRAW_PRESSED: {
if (has_color("font_color_pressed"))
diff --git a/scene/gui/nine_patch_rect.cpp b/scene/gui/nine_patch_rect.cpp
index b8f6ffe6d2..c6a34921c7 100644
--- a/scene/gui/nine_patch_rect.cpp
+++ b/scene/gui/nine_patch_rect.cpp
@@ -110,7 +110,7 @@ Ref<Texture> NinePatchRect::get_texture() const {
void NinePatchRect::set_patch_margin(Margin p_margin, int p_size) {
- ERR_FAIL_INDEX(p_margin, 4);
+ ERR_FAIL_INDEX((int)p_margin, 4);
margin[p_margin] = p_size;
update();
minimum_size_changed();
@@ -132,7 +132,7 @@ void NinePatchRect::set_patch_margin(Margin p_margin, int p_size) {
int NinePatchRect::get_patch_margin(Margin p_margin) const {
- ERR_FAIL_INDEX_V(p_margin, 4, 0);
+ ERR_FAIL_INDEX_V((int)p_margin, 4, 0);
return margin[p_margin];
}
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp
index 09d8664240..e862743934 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -30,6 +30,19 @@
#include "range.h"
+String Range::get_configuration_warning() const {
+ String warning = Control::get_configuration_warning();
+
+ if (shared->exp_ratio && shared->min <= 0) {
+ if (warning != String()) {
+ warning += "\n";
+ }
+ warning += TTR("If exp_edit is true min_value must be > 0.");
+ }
+
+ return warning;
+}
+
void Range::_value_changed_notify() {
_value_changed(shared->val);
@@ -66,10 +79,11 @@ void Range::Shared::emit_changed(const char *p_what) {
}
void Range::set_value(double p_val) {
+ if (shared->step > 0)
+ p_val = Math::round(p_val / shared->step) * shared->step;
- if (_rounded_values) {
+ if (_rounded_values)
p_val = Math::round(p_val);
- }
if (!shared->allow_greater && p_val > shared->max - shared->page)
p_val = shared->max - shared->page;
@@ -90,6 +104,8 @@ void Range::set_min(double p_min) {
set_value(shared->val);
shared->emit_changed("min");
+
+ update_configuration_warning();
}
void Range::set_max(double p_max) {
@@ -277,6 +293,8 @@ bool Range::is_using_rounded_values() const {
void Range::set_exp_ratio(bool p_enable) {
shared->exp_ratio = p_enable;
+
+ update_configuration_warning();
}
bool Range::is_ratio_exp() const {
diff --git a/scene/gui/range.h b/scene/gui/range.h
index 125f559248..58f15c8aa8 100644
--- a/scene/gui/range.h
+++ b/scene/gui/range.h
@@ -97,6 +97,8 @@ public:
void share(Range *p_range);
void unshare();
+ virtual String get_configuration_warning() const;
+
Range();
~Range();
};
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index fa5019a6f7..9f1687262f 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -220,13 +220,14 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
case ALIGN_LEFT: l.offset_caches.push_back(0); break; \
case ALIGN_CENTER: l.offset_caches.push_back(((p_width - margin) - used) / 2); break; \
case ALIGN_RIGHT: l.offset_caches.push_back(((p_width - margin) - used)); break; \
- case ALIGN_FILL: l.offset_caches.push_back((p_width - margin) - used /*+spaces_size*/); break; \
+ case ALIGN_FILL: l.offset_caches.push_back(line_wrapped ? ((p_width - margin) - used) : 0); break; \
} \
l.height_caches.push_back(line_height); \
l.ascent_caches.push_back(line_ascent); \
l.descent_caches.push_back(line_descent); \
l.space_caches.push_back(spaces); \
} \
+ line_wrapped = false; \
y += line_height + get_constant(SceneStringNames::get_singleton()->line_separation); \
line_height = 0; \
line_ascent = 0; \
@@ -254,6 +255,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
l.minimum_width = MAX(l.minimum_width, m_width); \
} \
if (wofs + m_width > p_width) { \
+ line_wrapped = true; \
if (p_mode == PROCESS_CACHE) { \
if (spaces > 0) \
spaces -= 1; \
@@ -298,6 +300,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
int rchar = 0;
int lh = 0;
bool line_is_blank = true;
+ bool line_wrapped = false;
int fh = 0;
while (it) {
@@ -320,14 +323,17 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
Color color;
Color font_color_shadow;
bool underline = false;
+ bool strikethrough = false;
if (p_mode == PROCESS_DRAW) {
color = _find_color(text, p_base_color);
font_color_shadow = _find_color(text, p_font_color_shadow);
- underline = _find_underline(text);
- if (_find_meta(text, &meta) && underline_meta) {
+ if (_find_underline(text) || (_find_meta(text, &meta) && underline_meta)) {
underline = true;
+ } else if (_find_strikethrough(text)) {
+
+ strikethrough = true;
}
} else if (p_mode == PROCESS_CACHE) {
@@ -418,7 +424,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
int cw = 0;
- bool visible = visible_characters < 0 || p_char_count < visible_characters && YRANGE_VISIBLE(y + lh - line_descent - line_ascent, line_ascent + line_descent);
+ bool visible = visible_characters < 0 || (p_char_count < visible_characters && YRANGE_VISIBLE(y + lh - line_descent - line_ascent, line_ascent + line_descent));
if (visible)
line_is_blank = false;
@@ -469,6 +475,15 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
underline_width *= EDSCALE;
#endif
VS::get_singleton()->canvas_item_add_line(ci, p_ofs + Point2(align_ofs + wofs, uy), p_ofs + Point2(align_ofs + wofs + w, uy), uc, underline_width);
+ } else if (strikethrough) {
+ Color uc = color;
+ uc.a *= 0.5;
+ int uy = y + lh / 2 - line_descent + 2;
+ float strikethrough_width = 1.0;
+#ifdef TOOLS_ENABLED
+ strikethrough_width *= EDSCALE;
+#endif
+ VS::get_singleton()->canvas_item_add_line(ci, p_ofs + Point2(align_ofs + wofs, uy), p_ofs + Point2(align_ofs + wofs + w, uy), uc, strikethrough_width);
}
}
@@ -497,7 +512,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
ENSURE_WIDTH(img->image->get_width());
- bool visible = visible_characters < 0 || p_char_count < visible_characters && YRANGE_VISIBLE(y + lh - font->get_descent() - img->image->get_height(), img->image->get_height());
+ bool visible = visible_characters < 0 || (p_char_count < visible_characters && YRANGE_VISIBLE(y + lh - font->get_descent() - img->image->get_height(), img->image->get_height()));
if (visible)
line_is_blank = false;
@@ -835,8 +850,6 @@ void RichTextLabel::_notification(int p_what) {
bool use_outline = get_constant("shadow_as_outline");
Point2 shadow_ofs(get_constant("shadow_offset_x"), get_constant("shadow_offset_y"));
- float x_ofs = 0;
-
visible_line_count = 0;
while (y < size.height && from_line < main->lines.size()) {
@@ -854,7 +867,6 @@ void RichTextLabel::_find_click(ItemFrame *p_frame, const Point2i &p_click, Item
if (r_click_item)
*r_click_item = NULL;
- Size2 size = get_size();
Rect2 text_rect = _get_text_rect();
int ofs = vscroll->get_value();
Color font_color_shadow = get_color("font_color_shadow");
@@ -1227,6 +1239,23 @@ bool RichTextLabel::_find_underline(Item *p_item) {
return false;
}
+bool RichTextLabel::_find_strikethrough(Item *p_item) {
+
+ Item *item = p_item;
+
+ while (item) {
+
+ if (item->type == ITEM_STRIKETHROUGH) {
+
+ return true;
+ }
+
+ item = item->parent;
+ }
+
+ return false;
+}
+
bool RichTextLabel::_find_meta(Item *p_item, Variant *r_meta) {
Item *item = p_item;
@@ -1458,6 +1487,7 @@ void RichTextLabel::push_font(const Ref<Font> &p_font) {
item->font = p_font;
_add_item(item, true);
}
+
void RichTextLabel::push_color(const Color &p_color) {
ERR_FAIL_COND(current->type == ITEM_TABLE);
@@ -1466,6 +1496,7 @@ void RichTextLabel::push_color(const Color &p_color) {
item->color = p_color;
_add_item(item, true);
}
+
void RichTextLabel::push_underline() {
ERR_FAIL_COND(current->type == ITEM_TABLE);
@@ -1474,6 +1505,14 @@ void RichTextLabel::push_underline() {
_add_item(item, true);
}
+void RichTextLabel::push_strikethrough() {
+
+ ERR_FAIL_COND(current->type == ITEM_TABLE);
+ ItemStrikethrough *item = memnew(ItemStrikethrough);
+
+ _add_item(item, true);
+}
+
void RichTextLabel::push_align(Align p_align) {
ERR_FAIL_COND(current->type == ITEM_TABLE);
@@ -1683,7 +1722,7 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
}
if (brk_pos == p_bbcode.length())
- break; //nothing else o add
+ break; //nothing else to add
int brk_end = p_bbcode.find("]", brk_pos + 1);
@@ -1749,7 +1788,7 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
int columns = tag.substr(6, tag.length()).to_int();
if (columns < 1)
columns = 1;
- //use monospace font
+
push_table(columns);
pos = brk_end + 1;
tag_stack.push_front("table");
@@ -1763,7 +1802,7 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
int ratio = tag.substr(5, tag.length()).to_int();
if (ratio < 1)
ratio = 1;
- //use monospace font
+
set_table_column_expand(get_current_table_column(), true, ratio);
push_cell();
pos = brk_end + 1;
@@ -1776,43 +1815,37 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
tag_stack.push_front(tag);
} else if (tag == "s") {
- //use strikethrough (not supported underline instead)
- push_underline();
+ //use strikethrough
+ push_strikethrough();
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "center") {
- //use underline
push_align(ALIGN_CENTER);
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "fill") {
- //use underline
push_align(ALIGN_FILL);
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "right") {
- //use underline
push_align(ALIGN_RIGHT);
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "ul") {
- //use underline
push_list(LIST_DOTS);
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "ol") {
- //use underline
push_list(LIST_NUMBERS);
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "indent") {
- //use underline
indent_level++;
push_indent(indent_level);
pos = brk_end + 1;
@@ -1820,7 +1853,6 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
} else if (tag == "url") {
- //use strikethrough (not supported underline instead)
int end = p_bbcode.find("[", brk_end);
if (end == -1)
end = p_bbcode.length();
@@ -1838,7 +1870,6 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
tag_stack.push_front("url");
} else if (tag == "img") {
- //use strikethrough (not supported underline instead)
int end = p_bbcode.find("[", brk_end);
if (end == -1)
end = p_bbcode.length();
@@ -2145,6 +2176,7 @@ void RichTextLabel::_bind_methods() {
ClassDB::bind_method(D_METHOD("push_list", "type"), &RichTextLabel::push_list);
ClassDB::bind_method(D_METHOD("push_meta", "data"), &RichTextLabel::push_meta);
ClassDB::bind_method(D_METHOD("push_underline"), &RichTextLabel::push_underline);
+ ClassDB::bind_method(D_METHOD("push_strikethrough"), &RichTextLabel::push_strikethrough);
ClassDB::bind_method(D_METHOD("push_table", "columns"), &RichTextLabel::push_table);
ClassDB::bind_method(D_METHOD("set_table_column_expand", "column", "expand", "ratio"), &RichTextLabel::set_table_column_expand);
ClassDB::bind_method(D_METHOD("push_cell"), &RichTextLabel::push_cell);
@@ -2205,7 +2237,7 @@ void RichTextLabel::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "meta_underlined"), "set_meta_underline", "is_meta_underlined");
ADD_PROPERTY(PropertyInfo(Variant::INT, "tab_size", PROPERTY_HINT_RANGE, "0,24,1"), "set_tab_size", "get_tab_size");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "text"), "set_text", "get_text");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "text", PROPERTY_HINT_MULTILINE_TEXT), "set_text", "get_text");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_active"), "set_scroll_active", "is_scroll_active");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_following"), "set_scroll_follow", "is_scroll_following");
@@ -2233,6 +2265,7 @@ void RichTextLabel::_bind_methods() {
BIND_ENUM_CONSTANT(ITEM_FONT);
BIND_ENUM_CONSTANT(ITEM_COLOR);
BIND_ENUM_CONSTANT(ITEM_UNDERLINE);
+ BIND_ENUM_CONSTANT(ITEM_STRIKETHROUGH);
BIND_ENUM_CONSTANT(ITEM_ALIGN);
BIND_ENUM_CONSTANT(ITEM_INDENT);
BIND_ENUM_CONSTANT(ITEM_LIST);
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index 06e9b8efe3..c2e5712b9d 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -62,6 +62,7 @@ public:
ITEM_FONT,
ITEM_COLOR,
ITEM_UNDERLINE,
+ ITEM_STRIKETHROUGH,
ITEM_ALIGN,
ITEM_INDENT,
ITEM_LIST,
@@ -164,6 +165,11 @@ private:
ItemUnderline() { type = ITEM_UNDERLINE; }
};
+ struct ItemStrikethrough : public Item {
+
+ ItemStrikethrough() { type = ITEM_STRIKETHROUGH; }
+ };
+
struct ItemMeta : public Item {
Variant meta;
@@ -277,6 +283,7 @@ private:
Align _find_align(Item *p_item);
Color _find_color(Item *p_item, const Color &p_default_color);
bool _find_underline(Item *p_item);
+ bool _find_strikethrough(Item *p_item);
bool _find_meta(Item *p_item, Variant *r_meta);
void _update_scroll();
@@ -307,6 +314,7 @@ public:
void push_font(const Ref<Font> &p_font);
void push_color(const Color &p_color);
void push_underline();
+ void push_strikethrough();
void push_align(Align p_align);
void push_indent(int p_level);
void push_list(ListType p_list);
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index e3fb602065..26da16569a 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -30,6 +30,7 @@
#include "scroll_container.h"
#include "core/os/os.h"
+
bool ScrollContainer::clips_input() const {
return true;
@@ -170,7 +171,7 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) {
Vector2 motion = Vector2(mm->get_relative().x, mm->get_relative().y);
drag_accum -= motion;
- if (beyond_deadzone || scroll_h && Math::abs(drag_accum.x) > deadzone || scroll_v && Math::abs(drag_accum.y) > deadzone) {
+ if (beyond_deadzone || (scroll_h && Math::abs(drag_accum.x) > deadzone) || (scroll_v && Math::abs(drag_accum.y) > deadzone)) {
if (!beyond_deadzone) {
propagate_notification(NOTIFICATION_SCROLL_BEGIN);
emit_signal("scroll_started");
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index 2221923093..f766c0722d 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -217,6 +217,16 @@ void SpinBox::_notification(int p_what) {
}
}
+void SpinBox::set_align(LineEdit::Align p_align) {
+
+ line_edit->set_align(p_align);
+}
+
+LineEdit::Align SpinBox::get_align() const {
+
+ return line_edit->get_align();
+}
+
void SpinBox::set_suffix(const String &p_suffix) {
suffix = p_suffix;
@@ -253,6 +263,8 @@ void SpinBox::_bind_methods() {
//ClassDB::bind_method(D_METHOD("_value_changed"),&SpinBox::_value_changed);
ClassDB::bind_method(D_METHOD("_gui_input"), &SpinBox::_gui_input);
ClassDB::bind_method(D_METHOD("_text_entered"), &SpinBox::_text_entered);
+ ClassDB::bind_method(D_METHOD("set_align", "align"), &SpinBox::set_align);
+ ClassDB::bind_method(D_METHOD("get_align"), &SpinBox::get_align);
ClassDB::bind_method(D_METHOD("set_suffix", "suffix"), &SpinBox::set_suffix);
ClassDB::bind_method(D_METHOD("get_suffix"), &SpinBox::get_suffix);
ClassDB::bind_method(D_METHOD("set_prefix", "prefix"), &SpinBox::set_prefix);
@@ -264,6 +276,7 @@ void SpinBox::_bind_methods() {
ClassDB::bind_method(D_METHOD("_line_edit_input"), &SpinBox::_line_edit_input);
ClassDB::bind_method(D_METHOD("_range_click_timeout"), &SpinBox::_range_click_timeout);
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "align", PROPERTY_HINT_ENUM, "Left,Center,Right,Fill"), "set_align", "get_align");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editable"), "set_editable", "is_editable");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "prefix"), "set_prefix", "get_prefix");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "suffix"), "set_suffix", "get_suffix");
diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h
index 8863f44bef..f1ee26d9f3 100644
--- a/scene/gui/spin_box.h
+++ b/scene/gui/spin_box.h
@@ -76,6 +76,9 @@ public:
virtual Size2 get_minimum_size() const;
+ void set_align(LineEdit::Align p_align);
+ LineEdit::Align get_align() const;
+
void set_editable(bool p_editable);
bool is_editable() const;
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index c56b7d0f26..b7f8c74046 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -106,41 +106,8 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) {
}
}
- // 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;
-
- Rect2 rect = get_tab_rect(i);
- if (rect.has_point(pos)) {
- hover_now = i;
- }
- if (tabs[i].rb_rect.has_point(pos)) {
- rb_hover = i;
- cb_hover = -1;
- hover_buttons = i;
- break;
- } else if (!tabs[i].disabled && tabs[i].cb_rect.has_point(pos)) {
- cb_hover = i;
- rb_hover = -1;
- hover_buttons = i;
- break;
- }
- }
- if (hover != hover_now) {
- hover = hover_now;
- emit_signal("tab_hover", hover);
- }
-
- if (hover_buttons == -1) { // no hover
- rb_hover = hover_buttons;
- cb_hover = hover_buttons;
- }
+ _update_hover();
update();
-
return;
}
@@ -522,6 +489,48 @@ Ref<Texture> Tabs::get_tab_right_button(int p_tab) const {
return tabs[p_tab].right_button;
}
+void Tabs::_update_hover() {
+
+ if (!is_inside_tree()) {
+ return;
+ }
+
+ const Point2 &pos = get_local_mouse_position();
+ // 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;
+
+ Rect2 rect = get_tab_rect(i);
+ if (rect.has_point(pos)) {
+ hover_now = i;
+ }
+ if (tabs[i].rb_rect.has_point(pos)) {
+ rb_hover = i;
+ cb_hover = -1;
+ hover_buttons = i;
+ break;
+ } else if (!tabs[i].disabled && tabs[i].cb_rect.has_point(pos)) {
+ cb_hover = i;
+ rb_hover = -1;
+ hover_buttons = i;
+ break;
+ }
+ }
+ if (hover != hover_now) {
+ hover = hover_now;
+ emit_signal("tab_hover", hover);
+ }
+
+ if (hover_buttons == -1) { // no hover
+ rb_hover = hover_buttons;
+ cb_hover = hover_buttons;
+ }
+}
+
void Tabs::_update_cache() {
Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");
Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
@@ -597,6 +606,7 @@ void Tabs::add_tab(const String &p_str, const Ref<Texture> &p_icon) {
tabs.push_back(t);
_update_cache();
+ call_deferred("_update_hover");
update();
minimum_size_changed();
}
@@ -604,6 +614,7 @@ void Tabs::add_tab(const String &p_str, const Ref<Texture> &p_icon) {
void Tabs::clear_tabs() {
tabs.clear();
current = 0;
+ call_deferred("_update_hover");
update();
}
@@ -614,6 +625,7 @@ void Tabs::remove_tab(int p_idx) {
if (current >= p_idx)
current--;
_update_cache();
+ call_deferred("_update_hover");
update();
minimum_size_changed();
@@ -931,6 +943,7 @@ bool Tabs::get_select_with_rmb() const {
void Tabs::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"), &Tabs::_gui_input);
+ ClassDB::bind_method(D_METHOD("_update_hover"), &Tabs::_update_hover);
ClassDB::bind_method(D_METHOD("get_tab_count"), &Tabs::get_tab_count);
ClassDB::bind_method(D_METHOD("set_current_tab", "tab_idx"), &Tabs::set_current_tab);
ClassDB::bind_method(D_METHOD("get_current_tab"), &Tabs::get_current_tab);
diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h
index e204f4364b..a98744b804 100644
--- a/scene/gui/tabs.h
+++ b/scene/gui/tabs.h
@@ -97,6 +97,8 @@ private:
int get_tab_width(int p_idx) const;
void _ensure_no_over_offset();
+
+ void _update_hover();
void _update_cache();
protected:
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index a9566d9387..d996132960 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -334,15 +334,12 @@ void TextEdit::_update_scrollbars() {
h_scroll->set_begin(Point2(0, size.height - hmin.height));
h_scroll->set_end(Point2(size.width - vmin.width, size.height));
- int hscroll_rows = ((hmin.height - 1) / get_row_height()) + 1;
int visible_rows = get_visible_rows();
-
int total_rows = get_total_visible_rows();
if (scroll_past_end_of_file_enabled) {
total_rows += visible_rows - 1;
}
- int vscroll_pixels = v_scroll->get_combined_minimum_size().width;
int visible_width = size.width - cache.style_normal->get_minimum_size().width;
int total_width = text.get_max_width(true) + vmin.x;
@@ -367,12 +364,12 @@ void TextEdit::_update_scrollbars() {
} else {
- if (total_rows > visible_rows && total_width <= visible_width - vscroll_pixels) {
+ if (total_rows > visible_rows && total_width <= visible_width) {
//thanks yessopie for this clever bit of logic
use_hscroll = false;
}
- if (total_rows <= visible_rows - hscroll_rows && total_width > visible_width) {
+ if (total_rows <= visible_rows && total_width > visible_width) {
//thanks yessopie for this clever bit of logic
use_vscroll = false;
}
@@ -650,8 +647,6 @@ void TextEdit::_notification(int p_what) {
int visible_rows = get_visible_rows() + 1;
- int tab_w = cache.font->get_char_size(' ').width * indent_size;
-
Color color = cache.font_color;
color.a *= readonly_alpha;
@@ -1434,9 +1429,6 @@ void TextEdit::_notification(int p_what) {
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->show_virtual_keyboard(get_text(), get_global_rect());
- if (raised_from_completion) {
- VisualServer::get_singleton()->canvas_item_set_z_index(get_canvas_item(), 1);
- }
} break;
case NOTIFICATION_FOCUS_EXIT: {
@@ -1448,9 +1440,6 @@ void TextEdit::_notification(int p_what) {
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->hide_virtual_keyboard();
- if (raised_from_completion) {
- VisualServer::get_singleton()->canvas_item_set_z_index(get_canvas_item(), 0);
- }
} break;
}
}
@@ -2336,9 +2325,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
// no need to indent if we are going upwards.
if (auto_indent && !(k->get_command() && k->get_shift())) {
- // indent once again if previous line will end with ':' or '{'
+ // indent once again if previous line will end with ':' or '{' and the line is not a comment
// (i.e. colon/brace precedes current cursor position)
- if (cursor.column > 0 && (text[cursor.line][cursor.column - 1] == ':' || text[cursor.line][cursor.column - 1] == '{')) {
+ if (cursor.column > 0 && (text[cursor.line][cursor.column - 1] == ':' || text[cursor.line][cursor.column - 1] == '{') && !is_line_comment(cursor.line)) {
if (indent_using_spaces) {
ins += space_indent;
} else {
@@ -3262,7 +3251,7 @@ void TextEdit::_scroll_down(real_t p_delta) {
}
if (smooth_scroll_enabled) {
- int max_v_scroll = v_scroll->get_max() - v_scroll->get_page();
+ int max_v_scroll = round(v_scroll->get_max() - v_scroll->get_page());
if (target_v_scroll > max_v_scroll) {
target_v_scroll = max_v_scroll;
v_scroll->set_value(target_v_scroll);
@@ -3796,7 +3785,7 @@ Vector<String> TextEdit::get_wrap_rows_text(int p_line) const {
int tab_offset_px = get_indent_level(p_line) * cache.font->get_char_size(' ').width;
while (col < line_text.length()) {
- char c = line_text[col];
+ CharType c = line_text[col];
int w = text.get_char_width(c, line_text[col + 1], px + word_px);
int indent_ofs = (cur_wrap_index != 0 ? tab_offset_px : 0);
@@ -4402,7 +4391,7 @@ int TextEdit::_is_line_in_region(int p_line) {
// if not find the closest line we have
int previous_line = p_line - 1;
- for (previous_line; previous_line > -1; previous_line--) {
+ for (; previous_line > -1; previous_line--) {
if (color_region_cache.has(p_line)) {
break;
}
@@ -4547,9 +4536,13 @@ void TextEdit::cut() {
void TextEdit::copy() {
if (!selection.active) {
- String clipboard = _base_get_text(cursor.line, 0, cursor.line, text[cursor.line].length());
- OS::get_singleton()->set_clipboard(clipboard);
- cut_copy_line = clipboard;
+
+ if (text[cursor.line].length() != 0) {
+
+ String clipboard = _base_get_text(cursor.line, 0, cursor.line, text[cursor.line].length());
+ OS::get_singleton()->set_clipboard(clipboard);
+ cut_copy_line = clipboard;
+ }
} else {
String clipboard = _base_get_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
OS::get_singleton()->set_clipboard(clipboard);
@@ -5152,7 +5145,7 @@ bool TextEdit::can_fold(int p_line) const {
return false;
if (p_line + 1 >= text.size())
return false;
- if (text[p_line].size() == 0)
+ if (text[p_line].strip_edges().size() == 0)
return false;
if (is_folded(p_line))
return false;
@@ -5164,7 +5157,7 @@ bool TextEdit::can_fold(int p_line) const {
int start_indent = get_indent_level(p_line);
for (int i = p_line + 1; i < text.size(); i++) {
- if (text[i].size() == 0)
+ if (text[i].strip_edges().size() == 0)
continue;
int next_indent = get_indent_level(i);
if (is_line_comment(i)) {
@@ -5667,16 +5660,12 @@ void TextEdit::_confirm_completion() {
void TextEdit::_cancel_code_hint() {
- VisualServer::get_singleton()->canvas_item_set_z_index(get_canvas_item(), 0);
- raised_from_completion = false;
completion_hint = "";
update();
}
void TextEdit::_cancel_completion() {
- VisualServer::get_singleton()->canvas_item_set_z_index(get_canvas_item(), 0);
- raised_from_completion = false;
if (!completion_active)
return;
@@ -5834,8 +5823,6 @@ void TextEdit::query_code_comple() {
void TextEdit::set_code_hint(const String &p_hint) {
- VisualServer::get_singleton()->canvas_item_set_z_index(get_canvas_item(), 1);
- raised_from_completion = true;
completion_hint = p_hint;
completion_hint_offset = -0xFFFF;
update();
@@ -5843,8 +5830,6 @@ void TextEdit::set_code_hint(const String &p_hint) {
void TextEdit::code_complete(const Vector<String> &p_strings, bool p_forced) {
- VisualServer::get_singleton()->canvas_item_set_z_index(get_canvas_item(), 1);
- raised_from_completion = true;
completion_strings = p_strings;
completion_active = true;
completion_forced = p_forced;
@@ -5866,7 +5851,7 @@ String TextEdit::get_word_at_pos(const Vector2 &p_pos) const {
if (select_word(s, col, beg, end)) {
bool inside_quotes = false;
- char selected_quote = '\0';
+ CharType selected_quote = '\0';
int qbegin = 0, qend = 0;
for (int i = 0; i < s.length(); i++) {
if (s[i] == '"' || s[i] == '\'') {
@@ -6233,6 +6218,7 @@ void TextEdit::_bind_methods() {
BIND_ENUM_CONSTANT(MENU_MAX);
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::REAL, "gui/timers/text_edit_idle_detect_sec", PROPERTY_HINT_RANGE, "0,10,0.01,or_greater")); // No negative numbers
}
TextEdit::TextEdit() {
@@ -6346,8 +6332,6 @@ TextEdit::TextEdit() {
target_v_scroll = 0;
v_scroll_speed = 80;
- raised_from_completion = false;
-
context_menu_enabled = true;
menu = memnew(PopupMenu);
add_child(menu);
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index f0c18ad047..8a508a8738 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -306,8 +306,6 @@ private:
float target_v_scroll;
float v_scroll_speed;
- bool raised_from_completion;
-
String highlighted_word;
uint64_t last_dblclk;
diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp
index 6bd3b26280..1940bbfa98 100644
--- a/scene/gui/texture_button.cpp
+++ b/scene/gui/texture_button.cpp
@@ -88,6 +88,9 @@ bool TextureButton::has_point(const Point2 &p_point) const {
scale.y = min;
ofs -= _texture_region.position / min;
} break;
+ default: {
+ // FIXME: Why a switch if we only handle one enum value?
+ }
}
// offset and scale the new point position to adjust it to the bitmask size
@@ -125,6 +128,7 @@ void TextureButton::_notification(int p_what) {
if (normal.is_valid())
texdraw = normal;
} break;
+ case DRAW_HOVER_PRESSED:
case DRAW_PRESSED: {
if (pressed.is_null()) {
diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp
index 8188d1dcf8..75f88dc4e6 100644
--- a/scene/gui/texture_progress.cpp
+++ b/scene/gui/texture_progress.cpp
@@ -59,14 +59,14 @@ Ref<Texture> TextureProgress::get_over_texture() const {
}
void TextureProgress::set_stretch_margin(Margin p_margin, int p_size) {
- ERR_FAIL_INDEX(p_margin, 4);
+ ERR_FAIL_INDEX((int)p_margin, 4);
stretch_margin[p_margin] = p_size;
update();
minimum_size_changed();
}
int TextureProgress::get_stretch_margin(Margin p_margin) const {
- ERR_FAIL_INDEX_V(p_margin, 4, 0);
+ ERR_FAIL_INDEX_V((int)p_margin, 4, 0);
return stretch_margin[p_margin];
}
@@ -148,9 +148,9 @@ Point2 TextureProgress::unit_val_to_uv(float val) {
float angle = (val * Math_TAU) - Math_PI * 0.5;
Point2 dir = Vector2(Math::cos(angle), Math::sin(angle));
float t1 = 1.0;
- float cp;
- float cq;
- float cr;
+ float cp = 0;
+ float cq = 0;
+ float cr = 0;
float edgeLeft = 0.0;
float edgeRight = 1.0;
float edgeBottom = 0.0;
@@ -229,6 +229,17 @@ void TextureProgress::draw_nine_patch_stretched(const Ref<Texture> &p_texture, F
first_section_size = topleft.y;
last_section_size = bottomright.y;
} break;
+ case FILL_BILINEAR_LEFT_AND_RIGHT: {
+ // TODO: Implement
+ } break;
+ case FILL_BILINEAR_TOP_AND_BOTTOM: {
+ // TODO: Implement
+ } break;
+ case FILL_CLOCKWISE:
+ case FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE:
+ case FILL_COUNTER_CLOCKWISE: {
+ // Those modes are circular, not relevant for nine patch
+ } break;
}
double width_filled = width_total * p_ratio;
@@ -263,6 +274,17 @@ void TextureProgress::draw_nine_patch_stretched(const Ref<Texture> &p_texture, F
dst_rect.size.y = width_filled;
topleft.y = last_section_size;
} break;
+ case FILL_BILINEAR_LEFT_AND_RIGHT: {
+ // TODO: Implement
+ } break;
+ case FILL_BILINEAR_TOP_AND_BOTTOM: {
+ // TODO: Implement
+ } break;
+ case FILL_CLOCKWISE:
+ case FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE:
+ case FILL_COUNTER_CLOCKWISE: {
+ // Those modes are circular, not relevant for nine patch
+ } break;
}
}
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 24b9083964..0c11181f98 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -159,7 +159,7 @@ void TreeItem::set_text(int p_column, String p_text) {
ERR_FAIL_INDEX(p_column, cells.size());
cells.write[p_column].text = p_text;
- if (cells[p_column].mode == TreeItem::CELL_MODE_RANGE || cells[p_column].mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) {
+ if (cells[p_column].mode == TreeItem::CELL_MODE_RANGE) {
Vector<String> strings = p_text.split(",");
cells.write[p_column].min = INT_MAX;
@@ -791,7 +791,6 @@ void TreeItem::_bind_methods() {
BIND_ENUM_CONSTANT(CELL_MODE_STRING);
BIND_ENUM_CONSTANT(CELL_MODE_CHECK);
BIND_ENUM_CONSTANT(CELL_MODE_RANGE);
- BIND_ENUM_CONSTANT(CELL_MODE_RANGE_EXPRESSION);
BIND_ENUM_CONSTANT(CELL_MODE_ICON);
BIND_ENUM_CONSTANT(CELL_MODE_CUSTOM);
@@ -1245,9 +1244,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
//font->draw( ci, text_pos, p_item->cells[i].text, col,item_rect.size.x-check_w );
} break;
- case TreeItem::CELL_MODE_RANGE:
- case TreeItem::CELL_MODE_RANGE_EXPRESSION: {
-
+ case TreeItem::CELL_MODE_RANGE: {
if (p_item->cells[i].text != "") {
if (!p_item->cells[i].editable)
@@ -1257,13 +1254,13 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
String s = RTR("(Other)");
Vector<String> strings = p_item->cells[i].text.split(",");
- for (int i = 0; i < strings.size(); i++) {
- int value = i;
- if (!strings[i].get_slicec(':', 1).empty()) {
- value = strings[i].get_slicec(':', 1).to_int();
+ for (int j = 0; j < strings.size(); j++) {
+ int value = j;
+ if (!strings[j].get_slicec(':', 1).empty()) {
+ value = strings[j].get_slicec(':', 1).to_int();
}
if (option == value) {
- s = strings[i].get_slicec(':', 0);
+ s = strings[j].get_slicec(':', 0);
break;
}
}
@@ -1419,7 +1416,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
while (c) {
- if (cache.draw_relationship_lines == 1 && (c->get_parent() != root || c->get_parent() == root && !hide_root)) {
+ if (cache.draw_relationship_lines == 1 && (c->get_parent() != root || !hide_root)) {
int root_ofs = children_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin);
int parent_ofs = p_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin);
Point2i root_pos = Point2i(root_ofs, children_pos.y + label_h / 2) - cache.offset + p_draw_ofs;
@@ -1821,9 +1818,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
//p_item->edited_signal.call(col);
} break;
- case TreeItem::CELL_MODE_RANGE:
- case TreeItem::CELL_MODE_RANGE_EXPRESSION: {
-
+ case TreeItem::CELL_MODE_RANGE: {
if (c.text != "") {
//if (x >= (get_column_width(col)-item_h/2)) {
@@ -2010,21 +2005,6 @@ void Tree::text_editor_enter(String p_text) {
//popup_edited_item->edited_signal.call( popup_edited_item_col );
} break;
- case TreeItem::CELL_MODE_RANGE_EXPRESSION: {
-
- if (evaluator)
- c.val = evaluator->eval(p_text);
- else
- c.val = p_text.to_double();
-
- if (c.step > 0)
- c.val = Math::stepify(c.val, c.step);
- if (c.val < c.min)
- c.val = c.min;
- else if (c.val > c.max)
- c.val = c.max;
-
- } break;
default: { ERR_FAIL(); }
}
@@ -2203,6 +2183,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
Ref<InputEventKey> k = p_event;
+ bool is_command = k.is_valid() && k->get_command();
if (p_event->is_action("ui_right") && p_event->is_pressed()) {
if (!cursor_can_exit_tree) accept_event();
@@ -2239,13 +2220,13 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
_go_left();
}
- } else if (p_event->is_action("ui_up") && p_event->is_pressed() && !k->get_command()) {
+ } else if (p_event->is_action("ui_up") && p_event->is_pressed() && !is_command) {
if (!cursor_can_exit_tree) accept_event();
_go_up();
- } else if (p_event->is_action("ui_down") && p_event->is_pressed() && !k->get_command()) {
+ } else if (p_event->is_action("ui_down") && p_event->is_pressed() && !is_command) {
if (!cursor_can_exit_tree) accept_event();
@@ -2453,7 +2434,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
update();
}
- if (pressing_for_editor && popup_edited_item && (popup_edited_item->get_cell_mode(popup_edited_item_col) == TreeItem::CELL_MODE_RANGE || popup_edited_item->get_cell_mode(popup_edited_item_col) == TreeItem::CELL_MODE_RANGE_EXPRESSION)) {
+ if (pressing_for_editor && popup_edited_item && (popup_edited_item->get_cell_mode(popup_edited_item_col) == TreeItem::CELL_MODE_RANGE)) {
//range drag
if (!range_drag_enabled) {
@@ -2697,7 +2678,7 @@ bool Tree::edit_selected() {
item_edited(col, s);
return true;
- } else if ((c.mode == TreeItem::CELL_MODE_RANGE || c.mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) && c.text != "") {
+ } else if (c.mode == TreeItem::CELL_MODE_RANGE && c.text != "") {
popup_menu->clear();
for (int i = 0; i < c.text.get_slice_count(","); i++) {
@@ -2713,7 +2694,7 @@ bool Tree::edit_selected() {
popup_edited_item_col = col;
return true;
- } else if (c.mode == TreeItem::CELL_MODE_STRING || c.mode == TreeItem::CELL_MODE_RANGE || c.mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) {
+ } else if (c.mode == TreeItem::CELL_MODE_STRING || c.mode == TreeItem::CELL_MODE_RANGE) {
Vector2 ofs(0, (text_editor->get_size().height - rect.size.height) / 2);
Point2i textedpos = get_global_position() + rect.position - ofs;
@@ -2723,7 +2704,7 @@ bool Tree::edit_selected() {
text_editor->set_text(c.mode == TreeItem::CELL_MODE_STRING ? c.text : String::num(c.val, Math::step_decimals(c.step)));
text_editor->select_all();
- if (c.mode == TreeItem::CELL_MODE_RANGE || c.mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) {
+ if (c.mode == TreeItem::CELL_MODE_RANGE) {
value_editor->set_position(textedpos + Point2i(0, text_editor->get_size().height));
value_editor->set_size(Size2(rect.size.width, 1));
@@ -2953,7 +2934,7 @@ void Tree::_notification(int p_what) {
if (show_column_titles) {
- //title butons
+ //title buttons
int ofs = cache.bg->get_margin(MARGIN_LEFT);
for (int i = 0; i < columns.size(); i++) {
@@ -3713,10 +3694,6 @@ bool Tree::is_folding_hidden() const {
return hide_folding;
}
-void Tree::set_value_evaluator(ValueEvaluator *p_evaluator) {
- evaluator = p_evaluator;
-}
-
void Tree::set_drop_mode_flags(int p_flags) {
if (drop_mode_flags == p_flags)
return;
@@ -3934,8 +3911,6 @@ Tree::Tree() {
hide_folding = false;
- evaluator = NULL;
-
drop_mode_flags = 0;
drop_mode_over = NULL;
drop_mode_section = 0;
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 205cdbfb7e..34138acb85 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -31,7 +31,6 @@
#ifndef TREE_H
#define TREE_H
-#include "core/helper/value_evaluator.h"
#include "scene/gui/control.h"
#include "scene/gui/line_edit.h"
#include "scene/gui/popup_menu.h"
@@ -54,7 +53,6 @@ public:
CELL_MODE_STRING, ///< just a string
CELL_MODE_CHECK, ///< string + check
CELL_MODE_RANGE, ///< Contains a range
- CELL_MODE_RANGE_EXPRESSION, ///< Contains a range
CELL_MODE_ICON, ///< Contains an icon, not editable
CELL_MODE_CUSTOM, ///< Contains a custom value, show a string, and an edit button
};
@@ -504,8 +502,6 @@ private:
bool hide_folding;
- ValueEvaluator *evaluator;
-
int _count_selected_items(TreeItem *p_from) const;
void _go_left();
void _go_right();
@@ -601,8 +597,6 @@ public:
void set_allow_reselect(bool p_allow);
bool get_allow_reselect() const;
- void set_value_evaluator(ValueEvaluator *p_evaluator);
-
Tree();
~Tree();
};
diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp
index 17ab234551..39e7c73390 100644
--- a/scene/gui/video_player.cpp
+++ b/scene/gui/video_player.cpp
@@ -102,6 +102,10 @@ void VideoPlayer::_mix_audio() {
}
} break;
+ case AudioServer::SPEAKER_SURROUND_31: {
+
+ // FIXME: Implement
+ } break;
case AudioServer::SPEAKER_SURROUND_51: {
AudioFrame *targets[2] = {