summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormenip <menip.git@gmail.com>2021-08-30 08:42:33 -0700
committermenip <menip.git@gmail.com>2021-08-30 08:42:33 -0700
commit4f4c9a5f570bcaf8017cb86f22f45e885a226d07 (patch)
treecc25437922436d85922277820ad229c6bf9277c5
parent4d08a737fb868b4c2f47946aea7c9ec4ee97894d (diff)
Make Color Picker, Menu Button, Option Button consider camera position scale for popup position.
-rw-r--r--scene/gui/color_picker.cpp6
-rw-r--r--scene/gui/menu_button.cpp6
-rw-r--r--scene/gui/option_button.cpp2
3 files changed, 8 insertions, 6 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 0dddb2b09a..5c33a08934 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -1308,6 +1308,8 @@ void ColorPickerButton::_modal_closed() {
void ColorPickerButton::pressed() {
_update_picker();
+ Size2 size = get_size() * get_viewport()->get_canvas_transform().get_scale();
+
popup->set_as_minsize();
picker->_update_presets();
@@ -1319,13 +1321,13 @@ void ColorPickerButton::pressed() {
if (i > 1) {
cp_rect.position.y = get_screen_position().y - cp_rect.size.y;
} else {
- cp_rect.position.y = get_screen_position().y + get_size().height;
+ cp_rect.position.y = get_screen_position().y + size.height;
}
if (i & 1) {
cp_rect.position.x = get_screen_position().x;
} else {
- cp_rect.position.x = get_screen_position().x - MAX(0, (cp_rect.size.x - get_size().x));
+ cp_rect.position.x = get_screen_position().x - MAX(0, (cp_rect.size.x - size.x));
}
if (usable_rect.encloses(cp_rect)) {
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index e312aaed57..38f319b823 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -87,15 +87,15 @@ void MenuButton::_popup_visibility_changed(bool p_visible) {
void MenuButton::pressed() {
emit_signal(SNAME("about_to_popup"));
- Size2 size = get_size();
+ Size2 size = get_size() * get_viewport()->get_canvas_transform().get_scale();
Point2 gp = get_screen_position();
- gp.y += get_size().y;
+ gp.y += size.y;
popup->set_position(gp);
popup->set_size(Size2(size.width, 0));
- popup->set_parent_rect(Rect2(Point2(gp - popup->get_position()), get_size()));
+ popup->set_parent_rect(Rect2(Point2(gp - popup->get_position()), size));
popup->take_mouse_focus();
popup->popup();
}
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index cd55f258b3..5062e87ded 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -115,7 +115,7 @@ void OptionButton::_selected(int p_which) {
}
void OptionButton::pressed() {
- Size2 size = get_size();
+ Size2 size = get_size() * get_viewport()->get_canvas_transform().get_scale();
popup->set_position(get_screen_position() + Size2(0, size.height * get_global_transform().get_scale().y));
popup->set_size(Size2(size.width, 0));
popup->popup();