summaryrefslogtreecommitdiff
path: root/scene/gui/popup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/popup.cpp')
-rw-r--r--scene/gui/popup.cpp26
1 files changed, 10 insertions, 16 deletions
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp
index 8979e0f111..f2ba6bfbc4 100644
--- a/scene/gui/popup.cpp
+++ b/scene/gui/popup.cpp
@@ -108,13 +108,10 @@ void Popup::set_as_minsize() {
float margin_begin = c->get_margin(m_beg);
float margin_end = c->get_margin(m_end);
- AnchorType anchor_begin = c->get_anchor(m_beg);
- AnchorType anchor_end = c->get_anchor(m_end);
+ float anchor_begin = c->get_anchor(m_beg);
+ float anchor_end = c->get_anchor(m_end);
- if (anchor_begin == ANCHOR_BEGIN)
- minsize[j] += margin_begin;
- if (anchor_end == ANCHOR_END)
- minsize[j] += margin_end;
+ minsize[j] += margin_begin * (ANCHOR_END - anchor_begin) + margin_end * anchor_end;
}
total_minsize.width = MAX(total_minsize.width, minsize.width);
@@ -145,13 +142,10 @@ void Popup::popup_centered_minsize(const Size2 &p_minsize) {
float margin_begin = c->get_margin(m_beg);
float margin_end = c->get_margin(m_end);
- AnchorType anchor_begin = c->get_anchor(m_beg);
- AnchorType anchor_end = c->get_anchor(m_end);
+ float anchor_begin = c->get_anchor(m_beg);
+ float anchor_end = c->get_anchor(m_end);
- if (anchor_begin == ANCHOR_BEGIN)
- minsize[j] += margin_begin;
- if (anchor_end == ANCHOR_END)
- minsize[j] += margin_end;
+ minsize[j] += margin_begin * (ANCHOR_END - anchor_begin) + margin_end * anchor_end;
}
total_minsize.width = MAX(total_minsize.width, minsize.width);
@@ -209,15 +203,15 @@ void Popup::popup_centered_ratio(float p_screen_ratio) {
popped_up = true;
}
-void Popup::popup(const Rect2 &bounds) {
+void Popup::popup(const Rect2 &p_bounds) {
emit_signal("about_to_show");
show_modal(exclusive);
// Fit the popup into the optionally provided bounds.
- if (!bounds.has_no_area()) {
- set_position(bounds.position);
- set_size(bounds.size);
+ if (!p_bounds.has_no_area()) {
+ set_position(p_bounds.position);
+ set_size(p_bounds.size);
}
_fix_size();