summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2020-03-25 11:16:19 -0300
committerJuan Linietsky <reduzio@gmail.com>2020-03-26 15:50:00 +0100
commit197cb4e7718034aba35832a547477dfc858a7280 (patch)
tree402336f7eafedcc3b1af2f9cc290c7040383a005 /scene
parentf387b9b4f4ef3ae6eba5199b4089ef591f2d7ba2 (diff)
Fixes to X11, still pretty broken
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/menu_button.cpp7
-rw-r--r--scene/main/window.cpp26
-rw-r--r--scene/main/window.h8
3 files changed, 24 insertions, 17 deletions
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index ba1f651b5c..a7d1f64e93 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -53,10 +53,17 @@ void MenuButton::_unhandled_key_input(Ref<InputEvent> p_event) {
void MenuButton::pressed() {
+ {
+ Window *w = Object::cast_to<Window>(get_viewport());
+ if (w && !w->is_embedding_subwindows()) {
+ print_line("windowpos: " + w->get_position());
+ }
+ }
Size2 size = get_size();
Point2 gp = get_screen_position();
+ print_line("screenpos: " + gp);
gp.y += get_size().y;
popup->set_position(gp);
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index 6c2e2f1d31..5054e18a7a 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -932,7 +932,7 @@ Window *Window::get_parent_visible_window() const {
return window;
}
-void Window::popup_on_parent(const Rect2 &p_parent_rect) {
+void Window::popup_on_parent(const Rect2i &p_parent_rect) {
ERR_FAIL_COND(!is_inside_tree());
ERR_FAIL_COND_MSG(window_id == DisplayServer::MAIN_WINDOW_ID, "Can't popup the main window.");
@@ -943,14 +943,14 @@ void Window::popup_on_parent(const Rect2 &p_parent_rect) {
if (!window) {
popup(p_parent_rect);
} else {
- popup(Rect2(window->get_position() + p_parent_rect.position, p_parent_rect.size));
+ popup(Rect2i(window->get_position() + p_parent_rect.position, p_parent_rect.size));
}
} else {
popup(p_parent_rect);
}
}
-void Window::popup_centered_clamped(const Size2 &p_size, float p_fallback_ratio) {
+void Window::popup_centered_clamped(const Size2i &p_size, float p_fallback_ratio) {
ERR_FAIL_COND(!is_inside_tree());
ERR_FAIL_COND_MSG(window_id == DisplayServer::MAIN_WINDOW_ID, "Can't popup the main window.");
@@ -966,16 +966,16 @@ void Window::popup_centered_clamped(const Size2 &p_size, float p_fallback_ratio)
parent_rect.size = DisplayServer::get_singleton()->screen_get_size(parent_screen);
}
- Vector2 size_ratio = parent_rect.size * p_fallback_ratio;
+ Vector2i size_ratio = parent_rect.size * p_fallback_ratio;
- Rect2 popup_rect;
- popup_rect.size = Vector2(MIN(size_ratio.x, p_size.x), MIN(size_ratio.y, p_size.y));
+ Rect2i popup_rect;
+ popup_rect.size = Vector2i(MIN(size_ratio.x, p_size.x), MIN(size_ratio.y, p_size.y));
popup_rect.position = (parent_rect.size - popup_rect.size) / 2;
popup(popup_rect);
}
-void Window::popup_centered(const Size2 &p_minsize) {
+void Window::popup_centered(const Size2i &p_minsize) {
ERR_FAIL_COND(!is_inside_tree());
ERR_FAIL_COND_MSG(window_id == DisplayServer::MAIN_WINDOW_ID, "Can't popup the main window.");
@@ -990,8 +990,8 @@ void Window::popup_centered(const Size2 &p_minsize) {
parent_rect.size = DisplayServer::get_singleton()->screen_get_size(parent_screen);
}
- Rect2 popup_rect;
- if (p_minsize == Size2()) {
+ Rect2i popup_rect;
+ if (p_minsize == Size2i()) {
popup_rect.size = _get_contents_minimum_size();
} else {
popup_rect.size = p_minsize;
@@ -1006,7 +1006,7 @@ void Window::popup_centered_ratio(float p_ratio) {
ERR_FAIL_COND(!is_inside_tree());
ERR_FAIL_COND_MSG(window_id == DisplayServer::MAIN_WINDOW_ID, "Can't popup the main window.");
- Rect2 parent_rect;
+ Rect2i parent_rect;
if (is_embedded()) {
parent_rect = get_parent_viewport()->get_visible_rect();
@@ -1017,18 +1017,18 @@ void Window::popup_centered_ratio(float p_ratio) {
parent_rect.size = DisplayServer::get_singleton()->screen_get_size(parent_screen);
}
- Rect2 popup_rect;
+ Rect2i popup_rect;
popup_rect.size = parent_rect.size * p_ratio;
popup_rect.position = (parent_rect.size - popup_rect.size) / 2;
popup(popup_rect);
}
-void Window::popup(const Rect2 &p_screen_rect) {
+void Window::popup(const Rect2i &p_screen_rect) {
emit_signal("about_to_popup");
- if (p_screen_rect != Rect2()) {
+ if (p_screen_rect != Rect2i()) {
set_position(p_screen_rect.position);
set_size(p_screen_rect.size);
}
diff --git a/scene/main/window.h b/scene/main/window.h
index df67cabeaa..be07762f20 100644
--- a/scene/main/window.h
+++ b/scene/main/window.h
@@ -221,11 +221,11 @@ public:
Window *get_parent_visible_window() const;
Viewport *get_parent_viewport() const;
- void popup(const Rect2 &p_rect = Rect2());
- void popup_on_parent(const Rect2 &p_parent_rect);
+ void popup(const Rect2i &p_rect = Rect2i());
+ void popup_on_parent(const Rect2i &p_parent_rect);
void popup_centered_ratio(float p_ratio = 0.8);
- void popup_centered(const Size2 &p_minsize = Size2());
- void popup_centered_clamped(const Size2 &p_size = Size2(), float p_fallback_ratio = 0.75);
+ void popup_centered(const Size2i &p_minsize = Size2i());
+ void popup_centered_clamped(const Size2i &p_size = Size2i(), float p_fallback_ratio = 0.75);
void set_theme(const Ref<Theme> &p_theme);
Ref<Theme> get_theme() const;