summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/animation/animation_tree.cpp2
-rw-r--r--scene/main/scene_tree.cpp40
-rw-r--r--scene/main/scene_tree.h1
-rw-r--r--scene/main/viewport.cpp27
-rw-r--r--scene/main/viewport.h3
-rw-r--r--scene/resources/theme.cpp2
6 files changed, 60 insertions, 15 deletions
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp
index dc022bcd70..c32001dbcd 100644
--- a/scene/animation/animation_tree.cpp
+++ b/scene/animation/animation_tree.cpp
@@ -686,7 +686,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
} break;
default: {
- ERR_PRINT("Animation corrupted (invalid track type");
+ ERR_PRINT("Animation corrupted (invalid track type)");
continue;
}
}
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 5acb157279..f713851090 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -484,6 +484,14 @@ bool SceneTree::iteration(float p_time) {
return _quit;
}
+void SceneTree::_update_font_oversampling(float p_ratio) {
+
+ if (use_font_oversampling) {
+ DynamicFontAtSize::font_oversampling = p_ratio;
+ DynamicFont::update_oversampling();
+ }
+}
+
bool SceneTree::idle(float p_time) {
//print_line("ram: "+itos(OS::get_singleton()->get_static_memory_usage())+" sram: "+itos(OS::get_singleton()->get_dynamic_memory_usage()));
@@ -515,12 +523,6 @@ bool SceneTree::idle(float p_time) {
last_screen_size = win_size;
_update_root_rect();
-
- if (use_font_oversampling) {
- DynamicFontAtSize::font_oversampling = OS::get_singleton()->get_window_size().width / root->get_visible_rect().size.width;
- DynamicFont::update_oversampling();
- }
-
emit_signal("screen_resized");
}
@@ -1133,10 +1135,12 @@ void SceneTree::_update_root_rect() {
if (stretch_mode == STRETCH_MODE_DISABLED) {
+ _update_font_oversampling(1.0);
root->set_size((last_screen_size / stretch_shrink).floor());
root->set_attach_to_screen_rect(Rect2(Point2(), last_screen_size));
root->set_size_override_stretch(false);
root->set_size_override(false, Size2());
+ root->update_canvas_items();
return; //user will take care
}
@@ -1154,6 +1158,9 @@ void SceneTree::_update_root_rect() {
//same aspect or ignore aspect
viewport_size = desired_res;
screen_size = video_mode;
+ if (use_font_oversampling) {
+ WARN_PRINT("Font oversampling only works with the following resize modes 'Keep Width', 'Keep Height', and 'Expand'.")
+ }
} else if (viewport_aspect < video_mode_aspect) {
// screen ratio is smaller vertically
@@ -1208,21 +1215,30 @@ void SceneTree::_update_root_rect() {
switch (stretch_mode) {
case STRETCH_MODE_DISABLED: {
// Already handled above
+ _update_font_oversampling(1.0);
} break;
case STRETCH_MODE_2D: {
+ _update_font_oversampling(screen_size.x / viewport_size.x); //screen / viewport radio drives oversampling
root->set_size((screen_size / stretch_shrink).floor());
root->set_attach_to_screen_rect(Rect2(margin, screen_size));
root->set_size_override_stretch(true);
root->set_size_override(true, (viewport_size / stretch_shrink).floor());
+ root->update_canvas_items(); //force them to update just in case
} break;
case STRETCH_MODE_VIEWPORT: {
+ _update_font_oversampling(1.0);
root->set_size((viewport_size / stretch_shrink).floor());
root->set_attach_to_screen_rect(Rect2(margin, screen_size));
root->set_size_override_stretch(false);
root->set_size_override(false, Size2());
+ root->update_canvas_items(); //force them to update just in case
+
+ if (use_font_oversampling) {
+ WARN_PRINT("Font oversampling does not work in 'Viewport' stretch mode, only '2D'.")
+ }
} break;
}
@@ -1925,12 +1941,11 @@ void SceneTree::add_idle_callback(IdleCallback p_callback) {
void SceneTree::set_use_font_oversampling(bool p_oversampling) {
+ if (use_font_oversampling == p_oversampling)
+ return;
+
use_font_oversampling = p_oversampling;
- if (use_font_oversampling) {
- DynamicFontAtSize::font_oversampling = OS::get_singleton()->get_window_size().width / root->get_visible_rect().size.width;
- } else {
- DynamicFontAtSize::font_oversampling = 1.0;
- }
+ _update_root_rect();
}
bool SceneTree::is_using_font_oversampling() const {
@@ -1944,6 +1959,7 @@ SceneTree::SceneTree() {
accept_quit = true;
quit_on_go_back = true;
initialized = false;
+ use_font_oversampling = false;
#ifdef DEBUG_ENABLED
debug_collisions_hint = false;
debug_navigation_hint = false;
@@ -2079,8 +2095,6 @@ SceneTree::SceneTree() {
live_edit_root = NodePath("/root");
#endif
-
- use_font_oversampling = false;
}
SceneTree::~SceneTree() {
diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h
index d6ab8c37b2..3a1ff5cb06 100644
--- a/scene/main/scene_tree.h
+++ b/scene/main/scene_tree.h
@@ -153,6 +153,7 @@ private:
Size2i stretch_min;
real_t stretch_shrink;
+ void _update_font_oversampling(float p_ratio);
void _update_root_rect();
List<ObjectID> delete_queue;
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 8df007dcc7..61d6fc7401 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -693,6 +693,13 @@ bool Viewport::use_arvr() {
return arvr;
}
+void Viewport::update_canvas_items() {
+ if (!is_inside_tree())
+ return;
+
+ _update_canvas_items(this);
+}
+
void Viewport::set_size(const Size2 &p_size) {
if (size == p_size.floor())
@@ -1128,6 +1135,26 @@ Transform2D Viewport::get_final_transform() const {
return stretch_transform * global_canvas_transform;
}
+void Viewport::_update_canvas_items(Node *p_node) {
+ if (p_node != this) {
+
+ Viewport *vp = Object::cast_to<Viewport>(p_node);
+ if (vp)
+ return;
+
+ CanvasItem *ci = Object::cast_to<CanvasItem>(p_node);
+ if (ci) {
+ ci->update();
+ }
+ }
+
+ int cc = p_node->get_child_count();
+
+ for (int i = 0; i < cc; i++) {
+ _update_canvas_items(p_node->get_child(i));
+ }
+}
+
void Viewport::set_size_override(bool p_enable, const Size2 &p_size, const Vector2 &p_margin) {
if (size_override == p_enable && p_size == size_override_size)
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index cdb9d4afb5..4d0a4e8c87 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -385,6 +385,8 @@ private:
void _drop_mouse_focus();
+ void _update_canvas_items(Node *p_node);
+
protected:
void _notification(int p_what);
static void _bind_methods();
@@ -403,6 +405,7 @@ public:
bool is_audio_listener_2d() const;
void set_size(const Size2 &p_size);
+ void update_canvas_items();
Size2 get_size() const;
Rect2 get_visible_rect() const;
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index 87b40d5447..8d1a24dbf8 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -756,7 +756,7 @@ void Theme::_bind_methods() {
ClassDB::bind_method(D_METHOD("_emit_theme_changed"), &Theme::_emit_theme_changed);
ClassDB::bind_method("copy_default_theme", &Theme::copy_default_theme);
- ClassDB::bind_method("copy_theme", &Theme::copy_theme);
+ ClassDB::bind_method(D_METHOD("copy_theme", "other"), &Theme::copy_theme);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "default_font", PROPERTY_HINT_RESOURCE_TYPE, "Font"), "set_default_font", "get_default_font");
}