summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/scene_tree.cpp27
-rw-r--r--scene/main/scene_tree.h5
-rw-r--r--scene/main/viewport.cpp26
3 files changed, 53 insertions, 5 deletions
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index deb40800bc..7c31b72bb5 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -38,6 +38,7 @@
#include "os/os.h"
#include "print_string.h"
#include "project_settings.h"
+#include "scene/resources/dynamic_font.h"
#include "scene/resources/material.h"
#include "scene/resources/mesh.h"
#include "scene/resources/packed_scene.h"
@@ -495,6 +496,11 @@ bool SceneTree::idle(float p_time) {
Size2 win_size = Size2(OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height);
if (win_size != last_screen_size) {
+ if (use_font_oversampling) {
+ DynamicFontAtSize::font_oversampling = OS::get_singleton()->get_window_size().width / root->get_visible_rect().size.width;
+ DynamicFont::update_oversampling();
+ }
+
last_screen_size = win_size;
_update_root_rect();
@@ -2195,6 +2201,9 @@ void SceneTree::_bind_methods() {
ClassDB::bind_method(D_METHOD("_connection_failed"), &SceneTree::_connection_failed);
ClassDB::bind_method(D_METHOD("_server_disconnected"), &SceneTree::_server_disconnected);
+ ClassDB::bind_method(D_METHOD("set_use_font_oversampling", "enable"), &SceneTree::set_use_font_oversampling);
+ ClassDB::bind_method(D_METHOD("is_using_font_oversampling"), &SceneTree::is_using_font_oversampling);
+
ADD_SIGNAL(MethodInfo("tree_changed"));
ADD_SIGNAL(MethodInfo("node_added", PropertyInfo(Variant::OBJECT, "node")));
ADD_SIGNAL(MethodInfo("node_removed", PropertyInfo(Variant::OBJECT, "node")));
@@ -2244,6 +2253,20 @@ void SceneTree::add_idle_callback(IdleCallback p_callback) {
idle_callbacks[idle_callback_count++] = p_callback;
}
+void SceneTree::set_use_font_oversampling(bool p_oversampling) {
+
+ 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;
+ }
+}
+
+bool SceneTree::is_using_font_oversampling() const {
+ return use_font_oversampling;
+}
+
SceneTree::SceneTree() {
singleton = this;
@@ -2327,7 +2350,7 @@ SceneTree::SceneTree() {
ProjectSettings::get_singleton()->set("rendering/environment/default_environment", "");
} else {
//file was erased, notify user.
- ERR_PRINTS(RTR("Default Environment as specified in Project Setings (Rendering -> Viewport -> Default Environment) could not be loaded."));
+ ERR_PRINTS(RTR("Default Environment as specified in Project Setings (Rendering -> Environment -> Default Environment) could not be loaded."));
}
}
}
@@ -2380,6 +2403,8 @@ SceneTree::SceneTree() {
last_send_cache_id = 1;
#endif
+
+ use_font_oversampling = false;
}
SceneTree::~SceneTree() {
diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h
index 244fc8da62..9c5b0f69cb 100644
--- a/scene/main/scene_tree.h
+++ b/scene/main/scene_tree.h
@@ -122,11 +122,13 @@ private:
bool _quit;
bool initialized;
bool input_handled;
+
Size2 last_screen_size;
StringName tree_changed_name;
StringName node_added_name;
StringName node_removed_name;
+ bool use_font_oversampling;
int64_t current_frame;
int node_count;
@@ -420,6 +422,9 @@ public:
void set_screen_stretch(StretchMode p_mode, StretchAspect p_aspect, const Size2 p_minsize, real_t p_shrink = 1);
+ void set_use_font_oversampling(bool p_oversampling);
+ bool is_using_font_oversampling() const;
+
//void change_scene(const String& p_path);
//Node *get_loaded_scene();
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index f5d7043a40..8f431389d8 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1659,6 +1659,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
//cancel event, sorry, modal exclusive EATS UP ALL
//alternative, you can't pop out a window the same frame it was made modal (fixes many issues)
get_tree()->set_input_as_handled();
+
return; // no one gets the event if exclusive NO ONE
}
@@ -1807,15 +1808,18 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
pos = gui.focus_inv_xform.xform(pos);
mb->set_position(pos);
- if (gui.mouse_focus->can_process()) {
- _gui_call_input(gui.mouse_focus, mb);
- }
+ Control *mouse_focus = gui.mouse_focus;
+ //disable mouse focus if needed before calling input, this makes popups on mouse press event work better, as the release will never be received otherwise
if (mb->get_button_index() == gui.mouse_focus_button) {
gui.mouse_focus = NULL;
gui.mouse_focus_button = -1;
}
+ if (mouse_focus->can_process()) {
+ _gui_call_input(mouse_focus, mb);
+ }
+
/*if (gui.drag_data.get_type()!=Variant::NIL && mb->get_button_index()==BUTTON_LEFT) {
_propagate_viewport_notification(this,NOTIFICATION_DRAG_END);
gui.drag_data=Variant(); //always clear
@@ -2348,7 +2352,6 @@ void Viewport::_gui_control_grab_focus(Control *p_control) {
//no need for change
if (gui.key_focus && gui.key_focus == p_control)
return;
-
get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, "_viewports", "_gui_remove_focus");
gui.key_focus = p_control;
p_control->notification(Control::NOTIFICATION_FOCUS_ENTER);
@@ -2370,6 +2373,21 @@ List<Control *>::Element *Viewport::_gui_show_modal(Control *p_control) {
else
p_control->_modal_set_prev_focus_owner(0);
+ if (gui.mouse_focus && !p_control->is_a_parent_of(gui.mouse_focus)) {
+ Ref<InputEventMouseButton> mb;
+ mb.instance();
+ mb->set_position(gui.mouse_focus->get_local_mouse_position());
+ mb->set_global_position(gui.mouse_focus->get_local_mouse_position());
+ mb->set_button_index(gui.mouse_focus_button);
+ mb->set_pressed(false);
+ gui.mouse_focus->call_multilevel(SceneStringNames::get_singleton()->_gui_input, mb);
+
+ //if (gui.mouse_over == gui.mouse_focus) {
+ // gui.mouse_focus->notification(Control::NOTIFICATION_MOUSE_EXIT);
+ //}
+ gui.mouse_focus = NULL;
+ }
+
return gui.modal_stack.back();
}