summaryrefslogtreecommitdiffstats
path: root/scene/main/window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main/window.cpp')
-rw-r--r--scene/main/window.cpp50
1 files changed, 42 insertions, 8 deletions
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index 5d3173a2a5..0588a116a8 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -146,7 +146,7 @@ bool Window::_get(const StringName &p_name, Variant &r_ret) const {
void Window::_get_property_list(List<PropertyInfo> *p_list) const {
Ref<Theme> default_theme = ThemeDB::get_singleton()->get_default_theme();
- p_list->push_back(PropertyInfo(Variant::NIL, TTRC("Theme Overrides"), PROPERTY_HINT_NONE, "theme_override_", PROPERTY_USAGE_GROUP));
+ p_list->push_back(PropertyInfo(Variant::NIL, GNAME("Theme Overrides", "theme_override_"), PROPERTY_HINT_NONE, "theme_override_", PROPERTY_USAGE_GROUP));
{
List<StringName> names;
@@ -157,7 +157,7 @@ void Window::_get_property_list(List<PropertyInfo> *p_list) const {
usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
}
- p_list->push_back(PropertyInfo(Variant::COLOR, "theme_override_colors/" + E, PROPERTY_HINT_NONE, "", usage));
+ p_list->push_back(PropertyInfo(Variant::COLOR, PNAME("theme_override_colors") + String("/") + E, PROPERTY_HINT_NONE, "", usage));
}
}
{
@@ -169,7 +169,7 @@ void Window::_get_property_list(List<PropertyInfo> *p_list) const {
usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
}
- p_list->push_back(PropertyInfo(Variant::INT, "theme_override_constants/" + E, PROPERTY_HINT_RANGE, "-16384,16384", usage));
+ p_list->push_back(PropertyInfo(Variant::INT, PNAME("theme_override_constants") + String("/") + E, PROPERTY_HINT_RANGE, "-16384,16384", usage));
}
}
{
@@ -181,7 +181,7 @@ void Window::_get_property_list(List<PropertyInfo> *p_list) const {
usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
}
- p_list->push_back(PropertyInfo(Variant::OBJECT, "theme_override_fonts/" + E, PROPERTY_HINT_RESOURCE_TYPE, "Font", usage));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, PNAME("theme_override_fonts") + String("/") + E, PROPERTY_HINT_RESOURCE_TYPE, "Font", usage));
}
}
{
@@ -193,7 +193,7 @@ void Window::_get_property_list(List<PropertyInfo> *p_list) const {
usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
}
- p_list->push_back(PropertyInfo(Variant::INT, "theme_override_font_sizes/" + E, PROPERTY_HINT_RANGE, "1,256,1,or_greater,suffix:px", usage));
+ p_list->push_back(PropertyInfo(Variant::INT, PNAME("theme_override_font_sizes") + String("/") + E, PROPERTY_HINT_RANGE, "1,256,1,or_greater,suffix:px", usage));
}
}
{
@@ -205,7 +205,7 @@ void Window::_get_property_list(List<PropertyInfo> *p_list) const {
usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
}
- p_list->push_back(PropertyInfo(Variant::OBJECT, "theme_override_icons/" + E, PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", usage));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, PNAME("theme_override_icons") + String("/") + E, PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", usage));
}
}
{
@@ -217,7 +217,7 @@ void Window::_get_property_list(List<PropertyInfo> *p_list) const {
usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
}
- p_list->push_back(PropertyInfo(Variant::OBJECT, "theme_override_styles/" + E, PROPERTY_HINT_RESOURCE_TYPE, "StyleBox", usage));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, PNAME("theme_override_styles") + String("/") + E, PROPERTY_HINT_RESOURCE_TYPE, "StyleBox", usage));
}
}
}
@@ -490,7 +490,7 @@ bool Window::is_embedded() const {
bool Window::is_in_edited_scene_root() const {
#ifdef TOOLS_ENABLED
- return (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root()->is_ancestor_of(this) || get_tree()->get_edited_scene_root() == this));
+ return is_part_of_edited_scene();
#else
return false;
#endif
@@ -1138,6 +1138,13 @@ void Window::_notification(int p_what) {
RS::get_singleton()->viewport_set_active(get_viewport_rid(), true);
}
+#ifdef TOOLS_ENABLED
+ if (is_part_of_edited_scene()) {
+ // Don't translate Windows on scene when inside editor.
+ set_message_translation(false);
+ notification(NOTIFICATION_TRANSLATION_CHANGED);
+ }
+#endif
notification(NOTIFICATION_THEME_CHANGED);
} break;
@@ -1557,11 +1564,38 @@ void Window::popup(const Rect2i &p_screen_rect) {
ERR_PRINT(vformat("Window %d spawned at invalid position: %s.", get_window_id(), position));
set_position((parent_rect.size - size) / 2);
}
+ if (parent_rect != Rect2i() && is_clamped_to_embedder() && is_embedded()) {
+ Rect2i new_rect = fit_rect_in_parent(Rect2i(position, size), parent_rect);
+ set_position(new_rect.position);
+ set_size(new_rect.size);
+ }
_post_popup();
notification(NOTIFICATION_POST_POPUP);
}
+Rect2i Window::fit_rect_in_parent(Rect2i p_rect, const Rect2i &p_parent_rect) const {
+ Size2i limit = p_parent_rect.size;
+ if (p_rect.position.x + p_rect.size.x > limit.x) {
+ p_rect.position.x = limit.x - p_rect.size.x;
+ }
+ if (p_rect.position.y + p_rect.size.y > limit.y) {
+ p_rect.position.y = limit.y - p_rect.size.y;
+ }
+
+ if (p_rect.position.x < 0) {
+ p_rect.position.x = 0;
+ }
+
+ int title_height = get_flag(Window::FLAG_BORDERLESS) ? 0 : get_theme_constant(SNAME("title_height"));
+
+ if (p_rect.position.y < title_height) {
+ p_rect.position.y = title_height;
+ }
+
+ return p_rect;
+}
+
Size2 Window::get_contents_minimum_size() const {
return _get_contents_minimum_size();
}