summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/physics_body_2d.cpp14
-rw-r--r--scene/2d/physics_body_2d.h4
-rw-r--r--scene/3d/physics_body_3d.cpp20
-rw-r--r--scene/3d/physics_body_3d.h6
-rw-r--r--scene/3d/vehicle_body_3d.cpp9
-rw-r--r--scene/animation/animation_player.cpp4
-rw-r--r--scene/gui/base_button.cpp5
-rw-r--r--scene/gui/control.cpp10
-rw-r--r--scene/gui/graph_node.cpp4
-rw-r--r--scene/gui/rich_text_label.cpp2
-rw-r--r--scene/gui/tree.cpp49
-rw-r--r--scene/gui/tree.h5
-rw-r--r--scene/main/canvas_item.cpp2
-rw-r--r--scene/main/canvas_item.h2
-rw-r--r--scene/main/scene_tree.cpp5
-rw-r--r--scene/main/scene_tree.h2
-rw-r--r--scene/main/viewport.cpp29
-rw-r--r--scene/main/viewport.h5
-rw-r--r--scene/main/window.cpp20
-rw-r--r--scene/main/window.h5
-rw-r--r--scene/resources/animation.cpp5
-rw-r--r--scene/resources/sky.cpp2
22 files changed, 144 insertions, 65 deletions
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 84560b843b..0a9de20664 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -631,8 +631,8 @@ void RigidBody2D::apply_central_impulse(const Vector2 &p_impulse) {
PhysicsServer2D::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse);
}
-void RigidBody2D::apply_impulse(const Vector2 &p_offset, const Vector2 &p_impulse) {
- PhysicsServer2D::get_singleton()->body_apply_impulse(get_rid(), p_offset, p_impulse);
+void RigidBody2D::apply_impulse(const Vector2 &p_impulse, const Vector2 &p_position) {
+ PhysicsServer2D::get_singleton()->body_apply_impulse(get_rid(), p_impulse, p_position);
}
void RigidBody2D::apply_torque_impulse(float p_torque) {
@@ -659,8 +659,8 @@ void RigidBody2D::add_central_force(const Vector2 &p_force) {
PhysicsServer2D::get_singleton()->body_add_central_force(get_rid(), p_force);
}
-void RigidBody2D::add_force(const Vector2 &p_offset, const Vector2 &p_force) {
- PhysicsServer2D::get_singleton()->body_add_force(get_rid(), p_offset, p_force);
+void RigidBody2D::add_force(const Vector2 &p_force, const Vector2 &p_position) {
+ PhysicsServer2D::get_singleton()->body_add_force(get_rid(), p_force, p_position);
}
void RigidBody2D::add_torque(const float p_torque) {
@@ -801,8 +801,8 @@ void RigidBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_continuous_collision_detection_mode"), &RigidBody2D::get_continuous_collision_detection_mode);
ClassDB::bind_method(D_METHOD("set_axis_velocity", "axis_velocity"), &RigidBody2D::set_axis_velocity);
- ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &RigidBody2D::apply_central_impulse);
- ClassDB::bind_method(D_METHOD("apply_impulse", "offset", "impulse"), &RigidBody2D::apply_impulse);
+ ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &RigidBody2D::apply_central_impulse, Vector2());
+ ClassDB::bind_method(D_METHOD("apply_impulse", "impulse", "position"), &RigidBody2D::apply_impulse, Vector2());
ClassDB::bind_method(D_METHOD("apply_torque_impulse", "torque"), &RigidBody2D::apply_torque_impulse);
ClassDB::bind_method(D_METHOD("set_applied_force", "force"), &RigidBody2D::set_applied_force);
@@ -812,7 +812,7 @@ void RigidBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_applied_torque"), &RigidBody2D::get_applied_torque);
ClassDB::bind_method(D_METHOD("add_central_force", "force"), &RigidBody2D::add_central_force);
- ClassDB::bind_method(D_METHOD("add_force", "offset", "force"), &RigidBody2D::add_force);
+ ClassDB::bind_method(D_METHOD("add_force", "force", "position"), &RigidBody2D::add_force, Vector2());
ClassDB::bind_method(D_METHOD("add_torque", "torque"), &RigidBody2D::add_torque);
ClassDB::bind_method(D_METHOD("set_sleeping", "sleeping"), &RigidBody2D::set_sleeping);
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index cde4398ad3..936cc9b7ac 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -237,7 +237,7 @@ public:
CCDMode get_continuous_collision_detection_mode() const;
void apply_central_impulse(const Vector2 &p_impulse);
- void apply_impulse(const Vector2 &p_offset, const Vector2 &p_impulse);
+ void apply_impulse(const Vector2 &p_impulse, const Vector2 &p_position = Vector2());
void apply_torque_impulse(float p_torque);
void set_applied_force(const Vector2 &p_force);
@@ -247,7 +247,7 @@ public:
float get_applied_torque() const;
void add_central_force(const Vector2 &p_force);
- void add_force(const Vector2 &p_offset, const Vector2 &p_force);
+ void add_force(const Vector2 &p_force, const Vector2 &p_position = Vector2());
void add_torque(float p_torque);
TypedArray<Node2D> get_colliding_bodies() const; //function for script
diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp
index 6320af21eb..fda072e233 100644
--- a/scene/3d/physics_body_3d.cpp
+++ b/scene/3d/physics_body_3d.cpp
@@ -638,8 +638,9 @@ void RigidBody3D::add_central_force(const Vector3 &p_force) {
PhysicsServer3D::get_singleton()->body_add_central_force(get_rid(), p_force);
}
-void RigidBody3D::add_force(const Vector3 &p_force, const Vector3 &p_pos) {
- PhysicsServer3D::get_singleton()->body_add_force(get_rid(), p_force, p_pos);
+void RigidBody3D::add_force(const Vector3 &p_force, const Vector3 &p_position) {
+ PhysicsServer3D *singleton = PhysicsServer3D::get_singleton();
+ singleton->body_add_force(get_rid(), p_force, p_position);
}
void RigidBody3D::add_torque(const Vector3 &p_torque) {
@@ -650,8 +651,9 @@ void RigidBody3D::apply_central_impulse(const Vector3 &p_impulse) {
PhysicsServer3D::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse);
}
-void RigidBody3D::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse) {
- PhysicsServer3D::get_singleton()->body_apply_impulse(get_rid(), p_pos, p_impulse);
+void RigidBody3D::apply_impulse(const Vector3 &p_impulse, const Vector3 &p_position) {
+ PhysicsServer3D *singleton = PhysicsServer3D::get_singleton();
+ singleton->body_apply_impulse(get_rid(), p_impulse, p_position);
}
void RigidBody3D::apply_torque_impulse(const Vector3 &p_impulse) {
@@ -782,11 +784,11 @@ void RigidBody3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_axis_velocity", "axis_velocity"), &RigidBody3D::set_axis_velocity);
ClassDB::bind_method(D_METHOD("add_central_force", "force"), &RigidBody3D::add_central_force);
- ClassDB::bind_method(D_METHOD("add_force", "force", "position"), &RigidBody3D::add_force);
+ ClassDB::bind_method(D_METHOD("add_force", "force", "position"), &RigidBody3D::add_force, Vector3());
ClassDB::bind_method(D_METHOD("add_torque", "torque"), &RigidBody3D::add_torque);
ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &RigidBody3D::apply_central_impulse);
- ClassDB::bind_method(D_METHOD("apply_impulse", "position", "impulse"), &RigidBody3D::apply_impulse);
+ ClassDB::bind_method(D_METHOD("apply_impulse", "impulse", "position"), &RigidBody3D::apply_impulse, Vector3());
ClassDB::bind_method(D_METHOD("apply_torque_impulse", "impulse"), &RigidBody3D::apply_torque_impulse);
ClassDB::bind_method(D_METHOD("set_sleeping", "sleeping"), &RigidBody3D::set_sleeping);
@@ -1372,8 +1374,8 @@ void PhysicalBone3D::apply_central_impulse(const Vector3 &p_impulse) {
PhysicsServer3D::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse);
}
-void PhysicalBone3D::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse) {
- PhysicsServer3D::get_singleton()->body_apply_impulse(get_rid(), p_pos, p_impulse);
+void PhysicalBone3D::apply_impulse(const Vector3 &p_impulse, const Vector3 &p_position) {
+ PhysicsServer3D::get_singleton()->body_apply_impulse(get_rid(), p_impulse, p_position);
}
void PhysicalBone3D::reset_physics_simulation_state() {
@@ -2099,7 +2101,7 @@ void PhysicalBone3D::_direct_state_changed(Object *p_state) {
void PhysicalBone3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &PhysicalBone3D::apply_central_impulse);
- ClassDB::bind_method(D_METHOD("apply_impulse", "position", "impulse"), &PhysicalBone3D::apply_impulse);
+ ClassDB::bind_method(D_METHOD("apply_impulse", "impulse", "position"), &PhysicalBone3D::apply_impulse, Vector3());
ClassDB::bind_method(D_METHOD("_direct_state_changed"), &PhysicalBone3D::_direct_state_changed);
diff --git a/scene/3d/physics_body_3d.h b/scene/3d/physics_body_3d.h
index 4c58c73942..e846b7a7f8 100644
--- a/scene/3d/physics_body_3d.h
+++ b/scene/3d/physics_body_3d.h
@@ -234,11 +234,11 @@ public:
Array get_colliding_bodies() const;
void add_central_force(const Vector3 &p_force);
- void add_force(const Vector3 &p_force, const Vector3 &p_pos);
+ void add_force(const Vector3 &p_force, const Vector3 &p_position = Vector3());
void add_torque(const Vector3 &p_torque);
void apply_central_impulse(const Vector3 &p_impulse);
- void apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse);
+ void apply_impulse(const Vector3 &p_impulse, const Vector3 &p_position = Vector3());
void apply_torque_impulse(const Vector3 &p_impulse);
virtual String get_configuration_warning() const;
@@ -597,7 +597,7 @@ public:
bool get_axis_lock(PhysicsServer3D::BodyAxis p_axis) const;
void apply_central_impulse(const Vector3 &p_impulse);
- void apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse);
+ void apply_impulse(const Vector3 &p_impulse, const Vector3 &p_position = Vector3());
void reset_physics_simulation_state();
void reset_to_rest_position();
diff --git a/scene/3d/vehicle_body_3d.cpp b/scene/3d/vehicle_body_3d.cpp
index 9c6b940b00..4c71ab470b 100644
--- a/scene/3d/vehicle_body_3d.cpp
+++ b/scene/3d/vehicle_body_3d.cpp
@@ -794,7 +794,7 @@ void VehicleBody3D::_update_friction(PhysicsDirectBodyState3D *s) {
s->get_transform().origin;
if (m_forwardImpulse[wheel] != real_t(0.)) {
- s->apply_impulse(rel_pos, m_forwardWS[wheel] * (m_forwardImpulse[wheel]));
+ s->apply_impulse(m_forwardWS[wheel] * (m_forwardImpulse[wheel]), rel_pos);
}
if (m_sideImpulse[wheel] != real_t(0.)) {
PhysicsBody3D *groundObject = wheelInfo.m_raycastInfo.m_groundObject;
@@ -812,7 +812,7 @@ void VehicleBody3D::_update_friction(PhysicsDirectBodyState3D *s) {
#else
rel_pos[1] *= wheelInfo.m_rollInfluence; //?
#endif
- s->apply_impulse(rel_pos, sideImp);
+ s->apply_impulse(sideImp, rel_pos);
//apply friction impulse on the ground
//todo
@@ -850,10 +850,9 @@ void VehicleBody3D::_direct_state_changed(Object *p_state) {
suspensionForce = wheel.m_maxSuspensionForce;
}
Vector3 impulse = wheel.m_raycastInfo.m_contactNormalWS * suspensionForce * step;
- Vector3 relpos = wheel.m_raycastInfo.m_contactPointWS - state->get_transform().origin;
+ Vector3 relative_position = wheel.m_raycastInfo.m_contactPointWS - state->get_transform().origin;
- state->apply_impulse(relpos, impulse);
- //getRigidBody()->applyImpulse(impulse, relpos);
+ state->apply_impulse(impulse, relative_position);
}
_update_friction(state);
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 319d0171b3..66c587e2d4 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -1055,6 +1055,8 @@ void AnimationPlayer::get_animation_list(List<StringName> *p_animations) const {
}
void AnimationPlayer::set_blend_time(const StringName &p_animation1, const StringName &p_animation2, float p_time) {
+ ERR_FAIL_COND(!animation_set.has(p_animation1));
+ ERR_FAIL_COND(!animation_set.has(p_animation2));
ERR_FAIL_COND_MSG(p_time < 0, "Blend time cannot be smaller than 0.");
BlendKey bk;
@@ -1462,7 +1464,7 @@ void AnimationPlayer::get_argument_options(const StringName &p_function, int p_i
#endif
String pf = p_function;
- if (p_function == "play" || p_function == "play_backwards" || p_function == "remove_animation" || p_function == "has_animation" || p_function == "queue") {
+ if (p_idx == 0 && (p_function == "play" || p_function == "play_backwards" || p_function == "remove_animation" || p_function == "has_animation" || p_function == "queue")) {
List<StringName> al;
get_animation_list(&al);
for (List<StringName>::Element *E = al.front(); E; E = E->next()) {
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index d8229b5f43..6fef44481a 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -271,6 +271,11 @@ BaseButton::DrawMode BaseButton::get_draw_mode() const {
}
void BaseButton::set_toggle_mode(bool p_on) {
+ // Make sure to set 'pressed' to false if we are not in toggle mode
+ if (!p_on) {
+ set_pressed(false);
+ }
+
toggle_mode = p_on;
}
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 97daeceda9..2cdee4641e 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -1173,7 +1173,17 @@ Rect2 Control::get_parent_anchorable_rect() const {
if (data.parent_canvas_item) {
parent_rect = data.parent_canvas_item->get_anchorable_rect();
} else {
+#ifdef TOOLS_ENABLED
+ Node *edited_root = get_tree()->get_edited_scene_root();
+ if (edited_root && (this == edited_root || edited_root->is_a_parent_of(this))) {
+ parent_rect.size = Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height"));
+ } else {
+ parent_rect = get_viewport()->get_visible_rect();
+ }
+
+#else
parent_rect = get_viewport()->get_visible_rect();
+#endif
}
return parent_rect;
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index b6a96238dc..01b54ddaa8 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -503,9 +503,7 @@ void GraphNode::_connpos_update() {
}
}
- if (vofs > 0) {
- vofs += sep;
- }
+ vofs += sep;
vofs += size.y;
idx++;
}
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 5ae27081ea..22e5bd55f3 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -256,7 +256,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
lh = line < l.height_caches.size() ? l.height_caches[line] : 1; \
line_ascent = line < l.ascent_caches.size() ? l.ascent_caches[line] : 1; \
line_descent = line < l.descent_caches.size() ? l.descent_caches[line] : 1; \
- if (p_mode == PROCESS_DRAW) { \
+ if ((p_mode == PROCESS_DRAW) && (align != ALIGN_FILL)) { \
if (line < l.offset_caches.size()) { \
wofs = l.offset_caches[line]; \
} \
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 34161a9e80..47761d724e 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1786,7 +1786,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
case TreeItem::CELL_MODE_STRING: {
//nothing in particular
- if (select_mode == SELECT_MULTI && (get_tree()->get_event_count() == focus_in_id || !already_cursor)) {
+ if (select_mode == SELECT_MULTI && (get_viewport()->get_processed_events_count() == focus_in_id || !already_cursor)) {
bring_up_editor = false;
}
@@ -1861,7 +1861,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
} else {
editor_text = String::num(p_item->cells[col].val, Math::range_step_decimals(p_item->cells[col].step));
- if (select_mode == SELECT_MULTI && get_tree()->get_event_count() == focus_in_id) {
+ if (select_mode == SELECT_MULTI && get_viewport()->get_processed_events_count() == focus_in_id) {
bring_up_editor = false;
}
}
@@ -2787,7 +2787,7 @@ int Tree::_get_title_button_height() const {
void Tree::_notification(int p_what) {
if (p_what == NOTIFICATION_FOCUS_ENTER) {
- focus_in_id = get_tree()->get_event_count();
+ focus_in_id = get_viewport()->get_processed_events_count();
}
if (p_what == NOTIFICATION_MOUSE_EXIT) {
if (cache.hover_type != Cache::CLICK_NONE) {
@@ -3623,6 +3623,47 @@ TreeItem *Tree::get_item_at_position(const Point2 &p_pos) const {
return nullptr;
}
+int Tree::get_button_id_at_position(const Point2 &p_pos) const {
+ if (root) {
+ Point2 pos = p_pos;
+ pos -= cache.bg->get_offset();
+ pos.y -= _get_title_button_height();
+ if (pos.y < 0) {
+ return -1;
+ }
+
+ if (h_scroll->is_visible_in_tree()) {
+ pos.x += h_scroll->get_value();
+ }
+ if (v_scroll->is_visible_in_tree()) {
+ pos.y += v_scroll->get_value();
+ }
+
+ int col, h, section;
+ TreeItem *it = _find_item_at_pos(root, pos, col, h, section);
+
+ if (it) {
+ const TreeItem::Cell &c = it->cells[col];
+ int col_width = get_column_width(col);
+
+ for (int i = 0; i < col; i++) {
+ pos.x -= get_column_width(i);
+ }
+
+ for (int j = c.buttons.size() - 1; j >= 0; j--) {
+ Ref<Texture2D> b = c.buttons[j].texture;
+ Size2 size = b->get_size() + cache.button_pressed->get_minimum_size();
+ if (pos.x > col_width - size.width) {
+ return c.buttons[j].id;
+ }
+ col_width -= size.width;
+ }
+ }
+ }
+
+ return -1;
+}
+
String Tree::get_tooltip(const Point2 &p_pos) const {
if (root) {
Point2 pos = p_pos;
@@ -3839,7 +3880,7 @@ Tree::Tree() {
add_child(popup_menu);
// popup_menu->set_as_toplevel(true);
- popup_editor = memnew(PopupPanel);
+ popup_editor = memnew(Popup);
popup_editor->set_wrap_controls(true);
add_child(popup_editor);
popup_editor_vb = memnew(VBoxContainer);
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 46842e78a0..cfdc307d03 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -359,11 +359,11 @@ private:
VBoxContainer *popup_editor_vb;
- PopupPanel *popup_editor;
+ Popup *popup_editor;
LineEdit *text_editor;
HSlider *value_editor;
bool updating_value_editor;
- int64_t focus_in_id;
+ uint64_t focus_in_id;
PopupMenu *popup_menu;
Vector<ColumnInfo> columns;
@@ -535,6 +535,7 @@ public:
TreeItem *get_item_at_position(const Point2 &p_pos) const;
int get_column_at_position(const Point2 &p_pos) const;
int get_drop_section_at_position(const Point2 &p_pos) const;
+ int get_button_id_at_position(const Point2 &p_pos) const;
void clear();
diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp
index 721f573f39..d1bf038b8d 100644
--- a/scene/main/canvas_item.cpp
+++ b/scene/main/canvas_item.cpp
@@ -1174,7 +1174,7 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("draw_mesh", "mesh", "texture", "normal_map", "specular_map", "specular_shininess", "transform", "modulate", "texture_filter", "texture_repeat"), &CanvasItem::draw_mesh, DEFVAL(Ref<Texture2D>()), DEFVAL(Ref<Texture2D>()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(TEXTURE_FILTER_PARENT_NODE), DEFVAL(TEXTURE_REPEAT_PARENT_NODE));
ClassDB::bind_method(D_METHOD("draw_multimesh", "multimesh", "texture", "normal_map", "specular_map", "specular_shininess", "texture_filter", "texture_repeat"), &CanvasItem::draw_multimesh, DEFVAL(Ref<Texture2D>()), DEFVAL(Ref<Texture2D>()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(TEXTURE_FILTER_PARENT_NODE), DEFVAL(TEXTURE_REPEAT_PARENT_NODE));
- ClassDB::bind_method(D_METHOD("draw_set_transform", "position", "rotation", "scale"), &CanvasItem::draw_set_transform);
+ ClassDB::bind_method(D_METHOD("draw_set_transform", "position", "rotation", "scale"), &CanvasItem::draw_set_transform, DEFVAL(0.0), DEFVAL(Size2(1.0, 1.0)));
ClassDB::bind_method(D_METHOD("draw_set_transform_matrix", "xform"), &CanvasItem::draw_set_transform_matrix);
ClassDB::bind_method(D_METHOD("get_transform"), &CanvasItem::get_transform);
ClassDB::bind_method(D_METHOD("get_global_transform"), &CanvasItem::get_global_transform);
diff --git a/scene/main/canvas_item.h b/scene/main/canvas_item.h
index 31edd424a1..918610ac1e 100644
--- a/scene/main/canvas_item.h
+++ b/scene/main/canvas_item.h
@@ -348,7 +348,7 @@ public:
void draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, const Color &p_modulate = Color(1, 1, 1), int p_clip_w = -1);
float draw_char(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_char, const String &p_next = "", const Color &p_modulate = Color(1, 1, 1));
- void draw_set_transform(const Point2 &p_offset, float p_rot, const Size2 &p_scale);
+ void draw_set_transform(const Point2 &p_offset, float p_rot = 0.0, const Size2 &p_scale = Size2(1.0, 1.0));
void draw_set_transform_matrix(const Transform2D &p_matrix);
static CanvasItem *get_current_item_drawn();
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index a418883506..d6159e089b 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -939,10 +939,6 @@ int64_t SceneTree::get_frame() const {
return current_frame;
}
-int64_t SceneTree::get_event_count() const {
- return current_event;
-}
-
Array SceneTree::_get_nodes_in_group(const StringName &p_group) {
Array ret;
Map<StringName, Group>::Element *E = group_map.find(p_group);
@@ -1362,7 +1358,6 @@ SceneTree::SceneTree() {
root = nullptr;
pause = false;
current_frame = 0;
- current_event = 0;
tree_changed_name = "tree_changed";
node_added_name = "node_added";
node_removed_name = "node_removed";
diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h
index 57b6b4dcfa..bea29c7605 100644
--- a/scene/main/scene_tree.h
+++ b/scene/main/scene_tree.h
@@ -110,7 +110,6 @@ private:
StringName node_renamed_name;
int64_t current_frame;
- int64_t current_event;
int node_count;
#ifdef TOOLS_ENABLED
@@ -300,7 +299,6 @@ public:
int get_collision_debug_contact_count() { return collision_debug_contacts; }
int64_t get_frame() const;
- int64_t get_event_count() const;
int get_node_count() const;
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index f272cfb7ca..1c259b7d32 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -2083,7 +2083,11 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
Control *c = over;
Vector2 cpos = pos;
while (c) {
- cursor_shape = c->get_cursor_shape(cpos);
+ if (gui.mouse_focus_mask != 0 || c->has_point(cpos)) {
+ cursor_shape = c->get_cursor_shape(cpos);
+ } else {
+ cursor_shape = Control::CURSOR_ARROW;
+ }
cpos = c->get_transform().xform(cpos);
if (cursor_shape != Control::CURSOR_ARROW) {
break;
@@ -2450,6 +2454,22 @@ void Viewport::_gui_remove_control(Control *p_control) {
}
}
+Window *Viewport::get_base_window() const {
+ Viewport *v = const_cast<Viewport *>(this);
+ Window *w = Object::cast_to<Window>(v);
+ while (!w) {
+ v = v->get_parent_viewport();
+ w = Object::cast_to<Window>(v);
+ }
+
+ return w;
+}
+void Viewport::_gui_remove_focus_for_window(Node *p_window) {
+ if (get_base_window() == p_window) {
+ _gui_remove_focus();
+ }
+}
+
void Viewport::_gui_remove_focus() {
if (gui.key_focus) {
Node *f = gui.key_focus;
@@ -2467,7 +2487,7 @@ void Viewport::_gui_control_grab_focus(Control *p_control) {
if (gui.key_focus && gui.key_focus == p_control) {
return;
}
- get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, "_viewports", "_gui_remove_focus");
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, "_viewports", "_gui_remove_focus_for_window", (Node *)get_base_window());
gui.key_focus = p_control;
emit_signal("gui_focus_changed", p_control);
p_control->notification(Control::NOTIFICATION_FOCUS_ENTER);
@@ -2945,6 +2965,8 @@ void Viewport::input(const Ref<InputEvent> &p_event, bool p_local_coords) {
if (!is_input_handled()) {
_gui_input_event(ev);
}
+
+ event_count++;
//get_tree()->call_group(SceneTree::GROUP_CALL_REVERSE|SceneTree::GROUP_CALL_REALTIME|SceneTree::GROUP_CALL_MULIILEVEL,gui_input_group,"_gui_input",ev); //special one for GUI, as controls use their own process check
}
@@ -3326,8 +3348,7 @@ void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_disable_input", "disable"), &Viewport::set_disable_input);
ClassDB::bind_method(D_METHOD("is_input_disabled"), &Viewport::is_input_disabled);
- ClassDB::bind_method(D_METHOD("_gui_show_tooltip"), &Viewport::_gui_show_tooltip);
- ClassDB::bind_method(D_METHOD("_gui_remove_focus"), &Viewport::_gui_remove_focus);
+ ClassDB::bind_method(D_METHOD("_gui_remove_focus_for_window"), &Viewport::_gui_remove_focus_for_window);
ClassDB::bind_method(D_METHOD("_post_gui_grab_click_focus"), &Viewport::_post_gui_grab_click_focus);
ClassDB::bind_method(D_METHOD("set_shadow_atlas_size", "size"), &Viewport::set_shadow_atlas_size);
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index d45b321f73..09ef4354c5 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -392,6 +392,7 @@ private:
void _gui_force_drag(Control *p_base, const Variant &p_data, Control *p_control);
void _gui_set_drag_preview(Control *p_base, Control *p_control);
+ void _gui_remove_focus_for_window(Node *p_window);
void _gui_remove_focus();
void _gui_unfocus_control(Control *p_control);
bool _gui_control_has_focus(const Control *p_control);
@@ -442,6 +443,7 @@ private:
SubWindowResize _sub_window_get_resize_margin(Window *p_subwindow, const Point2 &p_point);
virtual bool _can_consume_input_events() const { return true; }
+ uint64_t event_count = 0;
protected:
void _set_size(const Size2i &p_size, const Size2i &p_size_2d_override, const Rect2i &p_to_screen_rect, const Transform2D &p_stretch_transform, bool p_allocated);
@@ -455,6 +457,8 @@ protected:
virtual void _validate_property(PropertyInfo &property) const;
public:
+ uint64_t get_processed_events_count() const { return event_count; }
+
Listener3D *get_listener() const;
Camera3D *get_camera() const;
@@ -572,6 +576,7 @@ public:
bool is_embedding_subwindows() const;
Viewport *get_parent_viewport() const;
+ Window *get_base_window() const;
void pass_mouse_focus_to(Viewport *p_viewport, Control *p_control);
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index 0463615d4d..48540b7bc9 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -309,6 +309,7 @@ void Window::_event_callback(DisplayServer::WindowEvent p_event) {
case DisplayServer::WINDOW_EVENT_MOUSE_ENTER: {
_propagate_window_notification(this, NOTIFICATION_WM_MOUSE_ENTER);
emit_signal("mouse_entered");
+ DisplayServer::get_singleton()->cursor_set_shape(DisplayServer::CURSOR_ARROW); //restore cursor shape
} break;
case DisplayServer::WINDOW_EVENT_MOUSE_EXIT: {
_propagate_window_notification(this, NOTIFICATION_WM_MOUSE_EXIT);
@@ -624,26 +625,25 @@ void Window::_update_viewport_size() {
// Already handled above
//_update_font_oversampling(1.0);
} break;
- case CONTENT_SCALE_MODE_OBJECTS: {
+ case CONTENT_SCALE_MODE_CANVAS_ITEMS: {
final_size = screen_size;
final_size_override = viewport_size;
attach_to_screen_rect = Rect2(margin, screen_size);
font_oversampling = screen_size.x / viewport_size.x;
+
+ Size2 scale = Vector2(screen_size) / Vector2(final_size_override);
+ stretch_transform.scale(scale);
+
} break;
- case CONTENT_SCALE_MODE_PIXELS: {
+ case CONTENT_SCALE_MODE_VIEWPORT: {
final_size = viewport_size;
attach_to_screen_rect = Rect2(margin, screen_size);
} break;
}
-
- Size2 scale = size / (Vector2(final_size) + margin * 2);
- stretch_transform.scale(scale);
- stretch_transform.elements[2] = margin * scale;
}
bool allocate = is_inside_tree() && visible && (window_id != DisplayServer::INVALID_WINDOW_ID || embedder != nullptr);
-
_set_size(final_size, final_size_override, attach_to_screen_rect, stretch_transform, allocate);
if (window_id != DisplayServer::INVALID_WINDOW_ID) {
@@ -1372,7 +1372,7 @@ void Window::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "max_size"), "set_max_size", "get_max_size");
ADD_GROUP("Content Scale", "content_scale_");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "content_scale_size"), "set_content_scale_size", "get_content_scale_size");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "content_scale_mode", PROPERTY_HINT_ENUM, "Disabled,Object,Pixels"), "set_content_scale_mode", "get_content_scale_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "content_scale_mode", PROPERTY_HINT_ENUM, "Disabled,CanvasItems,Viewport"), "set_content_scale_mode", "get_content_scale_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "content_scale_aspect", PROPERTY_HINT_ENUM, "Ignore,Keep,KeepWidth,KeepHeight,Expand"), "set_content_scale_aspect", "get_content_scale_aspect");
ADD_GROUP("Theme", "");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "theme", PROPERTY_HINT_RESOURCE_TYPE, "Theme"), "set_theme", "get_theme");
@@ -1403,8 +1403,8 @@ void Window::_bind_methods() {
BIND_ENUM_CONSTANT(FLAG_MAX);
BIND_ENUM_CONSTANT(CONTENT_SCALE_MODE_DISABLED);
- BIND_ENUM_CONSTANT(CONTENT_SCALE_MODE_OBJECTS);
- BIND_ENUM_CONSTANT(CONTENT_SCALE_MODE_PIXELS);
+ BIND_ENUM_CONSTANT(CONTENT_SCALE_MODE_CANVAS_ITEMS);
+ BIND_ENUM_CONSTANT(CONTENT_SCALE_MODE_VIEWPORT);
BIND_ENUM_CONSTANT(CONTENT_SCALE_ASPECT_IGNORE);
BIND_ENUM_CONSTANT(CONTENT_SCALE_ASPECT_KEEP);
diff --git a/scene/main/window.h b/scene/main/window.h
index 8191fc7219..c8c02b8984 100644
--- a/scene/main/window.h
+++ b/scene/main/window.h
@@ -57,8 +57,8 @@ public:
enum ContentScaleMode {
CONTENT_SCALE_MODE_DISABLED,
- CONTENT_SCALE_MODE_OBJECTS,
- CONTENT_SCALE_MODE_PIXELS,
+ CONTENT_SCALE_MODE_CANVAS_ITEMS,
+ CONTENT_SCALE_MODE_VIEWPORT,
};
enum ContentScaleAspect {
@@ -135,7 +135,6 @@ private:
protected:
Viewport *_get_embedder() const;
-
virtual Rect2i _popup_adjust_rect() const { return Rect2i(); }
virtual void _post_popup() {}
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index 014b773298..479d97aadc 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -2577,7 +2577,10 @@ void Animation::copy_track(int p_track, Ref<Animation> p_to_animation) {
p_to_animation->track_set_enabled(dst_track, track_is_enabled(p_track));
p_to_animation->track_set_interpolation_type(dst_track, track_get_interpolation_type(p_track));
p_to_animation->track_set_interpolation_loop_wrap(dst_track, track_get_interpolation_loop_wrap(p_track));
- p_to_animation->value_track_set_update_mode(dst_track, value_track_get_update_mode(p_track));
+ if (track_get_type(p_track) == TYPE_VALUE) {
+ p_to_animation->value_track_set_update_mode(dst_track, value_track_get_update_mode(p_track));
+ }
+
for (int i = 0; i < track_get_key_count(p_track); i++) {
p_to_animation->track_insert_key(dst_track, track_get_key_time(p_track, i), track_get_key_value(p_track, i), track_get_key_transition(p_track, i));
}
diff --git a/scene/resources/sky.cpp b/scene/resources/sky.cpp
index 54b6cde8bd..38d1346541 100644
--- a/scene/resources/sky.cpp
+++ b/scene/resources/sky.cpp
@@ -107,4 +107,4 @@ Sky::Sky() {
Sky::~Sky() {
RS::get_singleton()->free(sky);
-} \ No newline at end of file
+}