summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/sprite.cpp3
-rw-r--r--scene/3d/mesh_instance.cpp7
-rw-r--r--scene/3d/mesh_instance.h1
-rw-r--r--scene/gui/control.cpp18
-rw-r--r--scene/gui/scroll_container.cpp28
-rw-r--r--scene/gui/scroll_container.h1
-rw-r--r--scene/gui/slider.cpp10
-rw-r--r--scene/gui/text_edit.cpp11
-rw-r--r--scene/main/viewport.cpp6
-rw-r--r--scene/resources/default_theme/default_theme.cpp6
-rw-r--r--scene/resources/style_box.cpp4
11 files changed, 62 insertions, 33 deletions
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp
index 8cdfceea52..a595f6714b 100644
--- a/scene/2d/sprite.cpp
+++ b/scene/2d/sprite.cpp
@@ -315,6 +315,9 @@ bool Sprite::is_pixel_opaque(const Point2 &p_point) const {
if (texture.is_null())
return false;
+ if (texture->get_size().width == 0 || texture->get_size().height == 0)
+ return false;
+
Rect2 src_rect, dst_rect;
bool filter_clip;
_get_rects(src_rect, dst_rect, filter_clip);
diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp
index 50ca466df3..493806fc78 100644
--- a/scene/3d/mesh_instance.cpp
+++ b/scene/3d/mesh_instance.cpp
@@ -154,10 +154,10 @@ void MeshInstance::_resolve_skeleton_path() {
if (!skeleton_path.is_empty()) {
Skeleton *skeleton = Object::cast_to<Skeleton>(get_node(skeleton_path));
if (skeleton) {
- new_skin_reference = skeleton->register_skin(skin);
- if (skin.is_null()) {
+ new_skin_reference = skeleton->register_skin(skin_internal);
+ if (skin_internal.is_null()) {
//a skin was created for us
- skin = new_skin_reference->get_skin();
+ skin_internal = new_skin_reference->get_skin();
_change_notify();
}
}
@@ -173,6 +173,7 @@ void MeshInstance::_resolve_skeleton_path() {
}
void MeshInstance::set_skin(const Ref<Skin> &p_skin) {
+ skin_internal = p_skin;
skin = p_skin;
if (!is_inside_tree())
return;
diff --git a/scene/3d/mesh_instance.h b/scene/3d/mesh_instance.h
index 77ead75dd3..91617341ba 100644
--- a/scene/3d/mesh_instance.h
+++ b/scene/3d/mesh_instance.h
@@ -43,6 +43,7 @@ class MeshInstance : public GeometryInstance {
protected:
Ref<Mesh> mesh;
Ref<Skin> skin;
+ Ref<Skin> skin_internal;
Ref<SkinReference> skin_ref;
NodePath skeleton_path;
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 8b4d5d4980..ccc658b0aa 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -2012,14 +2012,15 @@ Control *Control::find_next_valid_focus() const {
if (!data.focus_next.is_empty()) {
Node *n = get_node(data.focus_next);
+ Control *c;
if (n) {
- from = Object::cast_to<Control>(n);
- ERR_FAIL_COND_V_MSG(!from, NULL, "Next focus node is not a control: " + n->get_name() + ".");
+ c = Object::cast_to<Control>(n);
+ ERR_FAIL_COND_V_MSG(!c, NULL, "Next focus node is not a control: " + n->get_name() + ".");
} else {
return NULL;
}
- if (from->is_visible() && from->get_focus_mode() != FOCUS_NONE)
- return from;
+ if (c->is_visible() && c->get_focus_mode() != FOCUS_NONE)
+ return c;
}
// find next child
@@ -2102,14 +2103,15 @@ Control *Control::find_prev_valid_focus() const {
if (!data.focus_prev.is_empty()) {
Node *n = get_node(data.focus_prev);
+ Control *c;
if (n) {
- from = Object::cast_to<Control>(n);
- ERR_FAIL_COND_V_MSG(!from, NULL, "Previous focus node is not a control: " + n->get_name() + ".");
+ c = Object::cast_to<Control>(n);
+ ERR_FAIL_COND_V_MSG(!c, NULL, "Previous focus node is not a control: " + n->get_name() + ".");
} else {
return NULL;
}
- if (from->is_visible() && from->get_focus_mode() != FOCUS_NONE)
- return from;
+ if (c->is_visible() && c->get_focus_mode() != FOCUS_NONE)
+ return c;
}
// find prev child
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index fa23bf91dd..cb9ae875b7 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"
+#include "scene/main/viewport.h"
bool ScrollContainer::clips_input() const {
@@ -232,6 +233,27 @@ void ScrollContainer::_update_scrollbar_position() {
v_scroll->raise();
}
+void ScrollContainer::_ensure_focused_visible(Control *p_control) {
+
+ if (is_a_parent_of(p_control)) {
+ Rect2 global_rect = get_global_rect();
+ Rect2 other_rect = p_control->get_global_rect();
+ float right_margin = 0;
+ if (v_scroll->is_visible()) {
+ right_margin += v_scroll->get_size().x;
+ }
+ float bottom_margin = 0;
+ if (h_scroll->is_visible()) {
+ bottom_margin += h_scroll->get_size().y;
+ }
+
+ float diff = MAX(MIN(other_rect.position.y, global_rect.position.y), other_rect.position.y + other_rect.size.y - global_rect.size.y + bottom_margin);
+ set_v_scroll(get_v_scroll() + (diff - global_rect.position.y));
+ diff = MAX(MIN(other_rect.position.x, global_rect.position.x), other_rect.position.x + other_rect.size.x - global_rect.size.x + right_margin);
+ set_h_scroll(get_h_scroll() + (diff - global_rect.position.x));
+ }
+}
+
void ScrollContainer::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
@@ -239,6 +261,11 @@ void ScrollContainer::_notification(int p_what) {
call_deferred("_update_scrollbar_position");
};
+ if (p_what == NOTIFICATION_READY) {
+
+ get_viewport()->connect("gui_focus_changed", this, "_ensure_focused_visible");
+ }
+
if (p_what == NOTIFICATION_SORT_CHILDREN) {
child_max_size = Size2(0, 0);
@@ -521,6 +548,7 @@ void ScrollContainer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_enable_v_scroll", "enable"), &ScrollContainer::set_enable_v_scroll);
ClassDB::bind_method(D_METHOD("is_v_scroll_enabled"), &ScrollContainer::is_v_scroll_enabled);
ClassDB::bind_method(D_METHOD("_update_scrollbar_position"), &ScrollContainer::_update_scrollbar_position);
+ ClassDB::bind_method(D_METHOD("_ensure_focused_visible"), &ScrollContainer::_ensure_focused_visible);
ClassDB::bind_method(D_METHOD("set_h_scroll", "value"), &ScrollContainer::set_h_scroll);
ClassDB::bind_method(D_METHOD("get_h_scroll"), &ScrollContainer::get_h_scroll);
ClassDB::bind_method(D_METHOD("set_v_scroll", "value"), &ScrollContainer::set_v_scroll);
diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h
index 2ab169f4d0..1d247f14c6 100644
--- a/scene/gui/scroll_container.h
+++ b/scene/gui/scroll_container.h
@@ -75,6 +75,7 @@ protected:
static void _bind_methods();
void _update_scrollbar_position();
+ void _ensure_focused_visible(Control *p_node);
public:
int get_v_scroll() const;
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp
index ba57be1686..cbb2db7788 100644
--- a/scene/gui/slider.cpp
+++ b/scene/gui/slider.cpp
@@ -166,7 +166,6 @@ void Slider::_notification(int p_what) {
RID ci = get_canvas_item();
Size2i size = get_size();
Ref<StyleBox> style = get_stylebox("slider");
- Ref<StyleBox> focus = get_stylebox("focus");
Ref<StyleBox> grabber_area = get_stylebox("grabber_area");
Ref<Texture> grabber = get_icon(editable ? ((mouse_inside || has_focus()) ? "grabber_highlight" : "grabber") : "grabber_disabled");
Ref<Texture> tick = get_icon("tick");
@@ -178,10 +177,7 @@ void Slider::_notification(int p_what) {
float areasize = size.height - grabber->get_size().height;
style->draw(ci, Rect2i(Point2i(size.width / 2 - widget_width / 2, 0), Size2i(widget_width, size.height)));
grabber_area->draw(ci, Rect2i(Point2i((size.width - widget_width) / 2, size.height - areasize * ratio - grabber->get_size().height / 2), Size2i(widget_width, areasize * ratio + grabber->get_size().width / 2)));
- /*
- if (mouse_inside||has_focus())
- focus->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height)));
- */
+
if (ticks > 1) {
int grabber_offset = (grabber->get_size().height / 2 - tick->get_height() / 2);
for (int i = 0; i < ticks; i++) {
@@ -198,10 +194,6 @@ void Slider::_notification(int p_what) {
style->draw(ci, Rect2i(Point2i(0, (size.height - widget_height) / 2), Size2i(size.width, widget_height)));
grabber_area->draw(ci, Rect2i(Point2i(0, (size.height - widget_height) / 2), Size2i(areasize * ratio + grabber->get_size().width / 2, widget_height)));
- /*
- if (mouse_inside||has_focus())
- focus->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height)));
- */
if (ticks > 1) {
int grabber_offset = (grabber->get_size().width / 2 - tick->get_width() / 2);
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index bf3ec9b05b..9bcacd6ee3 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -5177,11 +5177,16 @@ void TextEdit::cut() {
OS::get_singleton()->set_clipboard(clipboard);
cursor_set_line(cursor.line);
cursor_set_column(0);
- _remove_text(cursor.line, 0, cursor.line, text[cursor.line].length());
- backspace_at_cursor();
+ if (cursor.line == 0 && get_line_count() > 1) {
+ _remove_text(cursor.line, 0, cursor.line + 1, 0);
+ } else {
+ _remove_text(cursor.line, 0, cursor.line, text[cursor.line].length());
+ backspace_at_cursor();
+ cursor_set_line(cursor.line + 1);
+ }
+
update();
- cursor_set_line(cursor.line + 1);
cut_copy_line = clipboard;
} else {
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 3ad44a4a2e..a7c7322b0e 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -2407,12 +2407,12 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
Input *input = Input::get_singleton();
- if (!mods && p_event->is_action_pressed("ui_focus_next") && input->is_action_just_pressed("ui_focus_next")) {
+ if (p_event->is_action_pressed("ui_focus_next") && input->is_action_just_pressed("ui_focus_next")) {
next = from->find_next_valid_focus();
}
- if (!mods && p_event->is_action_pressed("ui_focus_prev") && input->is_action_just_pressed("ui_focus_prev")) {
+ if (p_event->is_action_pressed("ui_focus_prev") && input->is_action_just_pressed("ui_focus_prev")) {
next = from->find_prev_valid_focus();
}
@@ -2634,6 +2634,7 @@ void Viewport::_gui_control_grab_focus(Control *p_control) {
return;
get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, "_viewports", "_gui_remove_focus");
gui.key_focus = p_control;
+ emit_signal("gui_focus_changed", p_control);
p_control->notification(Control::NOTIFICATION_FOCUS_ENTER);
p_control->update();
}
@@ -3216,6 +3217,7 @@ void Viewport::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "global_canvas_transform", PROPERTY_HINT_NONE, "", 0), "set_global_canvas_transform", "get_global_canvas_transform");
ADD_SIGNAL(MethodInfo("size_changed"));
+ ADD_SIGNAL(MethodInfo("gui_focus_changed", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
BIND_ENUM_CONSTANT(UPDATE_DISABLED);
BIND_ENUM_CONSTANT(UPDATE_ONCE);
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index e82819f270..c67e5a928c 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -496,9 +496,6 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_stylebox("slider", "HSlider", make_stylebox(hslider_bg_png, 4, 4, 4, 4));
theme->set_stylebox("grabber_area", "HSlider", make_stylebox(hslider_bg_png, 4, 4, 4, 4));
- theme->set_stylebox("grabber_highlight", "HSlider", make_stylebox(hslider_grabber_hl_png, 6, 6, 6, 6));
- theme->set_stylebox("grabber_disabled", "HSlider", make_stylebox(hslider_grabber_disabled_png, 6, 6, 6, 6));
- theme->set_stylebox("focus", "HSlider", focus);
theme->set_icon("grabber", "HSlider", make_icon(hslider_grabber_png));
theme->set_icon("grabber_highlight", "HSlider", make_icon(hslider_grabber_hl_png));
@@ -509,9 +506,6 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_stylebox("slider", "VSlider", make_stylebox(vslider_bg_png, 4, 4, 4, 4));
theme->set_stylebox("grabber_area", "VSlider", make_stylebox(vslider_bg_png, 4, 4, 4, 4));
- theme->set_stylebox("grabber_highlight", "VSlider", make_stylebox(vslider_grabber_hl_png, 6, 6, 6, 6));
- theme->set_stylebox("grabber_disabled", "VSlider", make_stylebox(vslider_grabber_disabled_png, 6, 6, 6, 6));
- theme->set_stylebox("focus", "VSlider", focus);
theme->set_icon("grabber", "VSlider", make_icon(vslider_grabber_png));
theme->set_icon("grabber_highlight", "VSlider", make_icon(vslider_grabber_hl_png));
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index f26b57b572..d4da98b8a8 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -554,7 +554,7 @@ int StyleBoxFlat::get_aa_size() const {
}
void StyleBoxFlat::set_corner_detail(const int &p_corner_detail) {
- corner_detail = CLAMP(p_corner_detail, 1, 128);
+ corner_detail = CLAMP(p_corner_detail, 1, 20);
emit_changed();
}
int StyleBoxFlat::get_corner_detail() const {
@@ -931,7 +931,7 @@ void StyleBoxFlat::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::INT, "corner_radius_bottom_right", PROPERTY_HINT_RANGE, "0,1024,1"), "set_corner_radius", "get_corner_radius", CORNER_BOTTOM_RIGHT);
ADD_PROPERTYI(PropertyInfo(Variant::INT, "corner_radius_bottom_left", PROPERTY_HINT_RANGE, "0,1024,1"), "set_corner_radius", "get_corner_radius", CORNER_BOTTOM_LEFT);
- ADD_PROPERTY(PropertyInfo(Variant::INT, "corner_detail", PROPERTY_HINT_RANGE, "1,128,1"), "set_corner_detail", "get_corner_detail");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "corner_detail", PROPERTY_HINT_RANGE, "1,20,1"), "set_corner_detail", "get_corner_detail");
ADD_GROUP("Expand Margin", "expand_margin_");
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin_left", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin", "get_expand_margin", MARGIN_LEFT);