summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/animation/animation_tree_player.cpp10
-rw-r--r--scene/animation/animation_tree_player.h2
-rw-r--r--scene/gui/control.cpp18
-rw-r--r--scene/gui/menu_button.cpp19
-rw-r--r--scene/gui/menu_button.h3
-rw-r--r--scene/gui/text_edit.cpp41
-rw-r--r--scene/gui/text_edit.h4
-rw-r--r--scene/main/viewport.cpp7
-rw-r--r--scene/resources/tile_set.cpp2
9 files changed, 88 insertions, 18 deletions
diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp
index 524784df53..6adfb94695 100644
--- a/scene/animation/animation_tree_player.cpp
+++ b/scene/animation/animation_tree_player.cpp
@@ -401,6 +401,9 @@ void AnimationTreePlayer::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
+ ERR_EXPLAIN("AnimationTreePlayer has been deprecated. Use AnimationTree instead.");
+ WARN_DEPRECATED
+
if (!processing) {
//make sure that a previous process state was not saved
//only process if "processing" is set
@@ -409,12 +412,14 @@ void AnimationTreePlayer::_notification(int p_what) {
}
} break;
case NOTIFICATION_READY: {
+
dirty_caches = true;
if (master != NodePath()) {
_update_sources();
}
} break;
case NOTIFICATION_INTERNAL_PROCESS: {
+
if (animation_process_mode == ANIMATION_PROCESS_PHYSICS)
break;
@@ -1715,6 +1720,11 @@ Error AnimationTreePlayer::node_rename(const StringName &p_node, const StringNam
return OK;
}
+String AnimationTreePlayer::get_configuration_warning() const {
+
+ return TTR("This node has been deprecated. Use AnimationTree instead.");
+}
+
void AnimationTreePlayer::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_node", "type", "id"), &AnimationTreePlayer::add_node);
diff --git a/scene/animation/animation_tree_player.h b/scene/animation/animation_tree_player.h
index d2d7b1c9ec..4e4c876e87 100644
--- a/scene/animation/animation_tree_player.h
+++ b/scene/animation/animation_tree_player.h
@@ -343,6 +343,8 @@ public:
int node_get_input_count(const StringName &p_node) const;
StringName node_get_input_source(const StringName &p_node, int p_input) const;
+ String get_configuration_warning() const;
+
/* ANIMATION NODE */
void animation_node_set_animation(const StringName &p_node, const Ref<Animation> &p_animation);
Ref<Animation> animation_node_get_animation(const StringName &p_node) const;
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 79e1d35b94..a580d89439 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -451,6 +451,11 @@ void Control::_update_canvas_item_transform() {
Transform2D xform = _get_internal_transform();
xform[2] += get_position();
+ // We use a little workaround to avoid flickering when moving the pivot with _edit_set_pivot()
+ if (is_inside_tree() && Math::abs(Math::sin(data.rotation * 4.0f)) < 0.00001f && get_viewport()->is_snap_controls_to_pixels_enabled()) {
+ xform[2] = xform[2].round();
+ }
+
VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), xform);
}
@@ -1336,11 +1341,6 @@ void Control::_size_changed() {
new_size_cache.height = minimum_size.height;
}
- // We use a little workaround to avoid flickering when moving the pivot with _edit_set_pivot()
- if (is_inside_tree() && Math::abs(Math::sin(data.rotation * 4.0f)) < 0.00001f && get_viewport()->is_snap_controls_to_pixels_enabled()) {
- new_size_cache = new_size_cache.round();
- new_pos_cache = new_pos_cache.round();
- }
bool pos_changed = new_pos_cache != data.pos_cache;
bool size_changed = new_size_cache != data.size_cache;
@@ -1740,10 +1740,10 @@ Rect2 Control::_compute_child_rect(const float p_anchors[4], const float p_margi
void Control::_compute_margins(Rect2 p_rect, const float p_anchors[4], float (&r_margins)[4]) {
Size2 parent_rect_size = get_parent_anchorable_rect().size;
- r_margins[0] = Math::floor(p_rect.position.x - (p_anchors[0] * parent_rect_size.x));
- r_margins[1] = Math::floor(p_rect.position.y - (p_anchors[1] * parent_rect_size.y));
- r_margins[2] = Math::floor(p_rect.position.x + p_rect.size.x - (p_anchors[2] * parent_rect_size.x));
- r_margins[3] = Math::floor(p_rect.position.y + p_rect.size.y - (p_anchors[3] * parent_rect_size.y));
+ r_margins[0] = p_rect.position.x - (p_anchors[0] * parent_rect_size.x);
+ r_margins[1] = p_rect.position.y - (p_anchors[1] * parent_rect_size.y);
+ r_margins[2] = p_rect.position.x + p_rect.size.x - (p_anchors[2] * parent_rect_size.x);
+ r_margins[3] = p_rect.position.y + p_rect.size.y - (p_anchors[3] * parent_rect_size.y);
}
void Control::set_position(const Size2 &p_point) {
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index 95ec618c3b..b4cb297900 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -71,13 +71,24 @@ PopupMenu *MenuButton::get_popup() const {
return popup;
}
+void MenuButton::_set_items(const Array &p_items) {
+
+ popup->set("items", p_items);
+}
+
Array MenuButton::_get_items() const {
return popup->get("items");
}
-void MenuButton::_set_items(const Array &p_items) {
- popup->set("items", p_items);
+void MenuButton::set_switch_on_hover(bool p_enabled) {
+
+ switch_on_hover = p_enabled;
+}
+
+bool MenuButton::is_switch_on_hover() {
+
+ return switch_on_hover;
}
void MenuButton::_bind_methods() {
@@ -86,9 +97,12 @@ void MenuButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &MenuButton::_unhandled_key_input);
ClassDB::bind_method(D_METHOD("_set_items"), &MenuButton::_set_items);
ClassDB::bind_method(D_METHOD("_get_items"), &MenuButton::_get_items);
+ ClassDB::bind_method(D_METHOD("set_switch_on_hover", "enable"), &MenuButton::set_switch_on_hover);
+ ClassDB::bind_method(D_METHOD("is_switch_on_hover"), &MenuButton::is_switch_on_hover);
ClassDB::bind_method(D_METHOD("set_disable_shortcuts", "disabled"), &MenuButton::set_disable_shortcuts);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "items", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_items", "_get_items");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "switch_on_hover"), "set_switch_on_hover", "is_switch_on_hover");
ADD_SIGNAL(MethodInfo("about_to_show"));
}
@@ -100,6 +114,7 @@ void MenuButton::set_disable_shortcuts(bool p_disabled) {
MenuButton::MenuButton() {
+ switch_on_hover = false;
set_flat(true);
set_disable_shortcuts(false);
set_enabled_focus_mode(FOCUS_NONE);
diff --git a/scene/gui/menu_button.h b/scene/gui/menu_button.h
index 0636accfee..abc49f4988 100644
--- a/scene/gui/menu_button.h
+++ b/scene/gui/menu_button.h
@@ -41,6 +41,7 @@ class MenuButton : public Button {
GDCLASS(MenuButton, Button);
bool clicked;
+ bool switch_on_hover;
bool disable_shortcuts;
PopupMenu *popup;
@@ -57,6 +58,8 @@ public:
virtual void pressed();
PopupMenu *get_popup() const;
+ void set_switch_on_hover(bool p_enabled);
+ bool is_switch_on_hover();
void set_disable_shortcuts(bool p_disabled);
MenuButton();
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index c339cf6374..18c80ba9a3 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -39,6 +39,7 @@
#ifdef TOOLS_ENABLED
#include "editor/editor_scale.h"
+#include "editor_settings.h"
#endif
#define TAB_PIXELS
@@ -918,6 +919,26 @@ void TextEdit::_notification(int p_what) {
}
}
+ int indent_level = get_indent_level(i);
+ if (draw_indent_guides && indent_level > 0) {
+#ifdef TOOLS_ENABLED
+ int indent_size = EditorSettings::get_singleton()->get("text_editor/indent/size");
+ float line_width = Math::round(EDSCALE);
+#else
+ int indent_size = 4;
+ float line_width = 1.0;
+#endif
+ int guides = 1 + (indent_level - 1) / indent_size;
+
+ for (int guide = 0; guide < guides; guide++) {
+ draw_line(
+ Point2(guide * indent_size * cache.font->get_char_size(' ').width + char_margin, ofs_y),
+ Point2(guide * indent_size * cache.font->get_char_size(' ').width + char_margin, ofs_y + get_row_height()),
+ cache.indent_guide_color,
+ line_width);
+ }
+ }
+
if (line_wrap_index == 0) {
// only do these if we are on the first wrapped part of a line
@@ -1179,9 +1200,14 @@ void TextEdit::_notification(int p_what) {
draw_rect(Rect2(char_ofs + char_margin + ofs_x, yofs + ascent + 2, w, line_width), in_selection && override_selected_font_color ? cache.font_selected_color : color);
}
- } else if (draw_tabs && str[j] == '\t') {
+ } else if (draw_tabs && (j > get_indent_level(i) || !draw_indent_guides) && str[j] == '\t') {
+ // If indent guides are enabled, only draw trailing or alignment tabs
+ // Otherwise, draw all tabs (including those used for indentation)
int yofs = (get_row_height() - cache.tab_icon->get_height()) / 2;
- cache.tab_icon->draw(ci, Point2(char_ofs + char_margin + ofs_x, ofs_y + yofs), in_selection && override_selected_font_color ? cache.font_selected_color : color);
+ cache.tab_icon->draw(
+ ci,
+ Point2(char_ofs + char_margin + ofs_x, ofs_y + yofs),
+ in_selection && override_selected_font_color ? cache.font_selected_color : color);
}
char_ofs += char_w;
@@ -4333,6 +4359,7 @@ void TextEdit::_update_caches() {
cache.font = get_font("font");
cache.caret_color = get_color("caret_color");
cache.caret_background_color = get_color("caret_background_color");
+ cache.indent_guide_color = get_color("indent_guide_color");
cache.line_number_color = get_color("line_number_color");
cache.safe_line_number_color = get_color("safe_line_number_color");
cache.font_color = get_color("font_color");
@@ -5446,6 +5473,16 @@ int TextEdit::get_indent_size() {
return indent_size;
}
+void TextEdit::set_draw_indent_guides(bool p_draw) {
+
+ draw_indent_guides = p_draw;
+}
+
+bool TextEdit::is_drawing_indent_guides() const {
+
+ return draw_indent_guides;
+}
+
void TextEdit::set_draw_tabs(bool p_draw) {
draw_tabs = p_draw;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index b1a0b60442..4d398f56b6 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -167,6 +167,7 @@ private:
Color completion_font_color;
Color caret_color;
Color caret_background_color;
+ Color indent_guide_color;
Color line_number_color;
Color safe_line_number_color;
Color font_color;
@@ -276,6 +277,7 @@ private:
int wrap_right_offset;
bool setting_row;
+ bool draw_indent_guides;
bool draw_tabs;
bool override_selected_font_color;
bool cursor_changed_dirty;
@@ -590,6 +592,8 @@ public:
bool is_indent_using_spaces() const;
void set_indent_size(const int p_size);
int get_indent_size();
+ void set_draw_indent_guides(bool p_draw);
+ bool is_drawing_indent_guides() const;
void set_draw_tabs(bool p_draw);
bool is_drawing_tabs() const;
void set_override_selected_font_color(bool p_override_selected_font_color);
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 3e27c86c67..5b1c2d8020 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1955,10 +1955,9 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
// If the mouse is over a menu button, this menu will open automatically
// if there is already a pop-up menu open at the same hierarchical level.
- if (popup_menu_parent && menu_button &&
- popup_menu_parent->get_icon().is_null() &&
- menu_button->get_icon().is_null() &&
- (popup_menu->get_parent()->get_parent()->is_a_parent_of(menu_button) ||
+ if (popup_menu_parent && menu_button && popup_menu_parent->is_switch_on_hover() &&
+ !menu_button->is_disabled() && menu_button->is_switch_on_hover() &&
+ (popup_menu_parent->get_parent()->is_a_parent_of(menu_button) ||
menu_button->get_parent()->is_a_parent_of(popup_menu))) {
popup_menu->notification(Control::NOTIFICATION_MODAL_CLOSE);
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index 88dbc67e01..c2c2c0ff32 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -137,7 +137,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
int z_index;
while (p.size() > 0) {
val = p[0];
- if (val.z > 1) {
+ if (val.z != 0) {
v.x = val.x;
v.y = val.y;
z_index = (int)val.z;