diff options
author | volzhs <volzhs@gmail.com> | 2017-12-11 14:03:32 +0900 |
---|---|---|
committer | volzhs <volzhs@gmail.com> | 2017-12-11 14:52:32 +0900 |
commit | 3c04d7798c7d7e510f8dadf5b305b534c0bce452 (patch) | |
tree | 786c095574a234b232d5144c536a3e34731bf590 /scene/gui/button.cpp | |
parent | c05c66ee01bcf285d5b4d952fb24c15af281803d (diff) |
Fix CheckButton minimum size
Diffstat (limited to 'scene/gui/button.cpp')
-rw-r--r-- | scene/gui/button.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index 1fa03f81f4..d2bf4b7b40 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -55,6 +55,10 @@ Size2 Button::get_minimum_size() const { return get_stylebox("normal")->get_minimum_size() + minsize; } +void Button::_set_internal_margin(Margin p_margin, float p_value) { + _internal_margin[p_margin] = p_value; +} + void Button::_notification(int p_what) { if (p_what == NOTIFICATION_TRANSLATION_CHANGED) { @@ -136,7 +140,7 @@ void Button::_notification(int p_what) { Point2 icon_ofs = (!_icon.is_null()) ? Point2(_icon->get_width() + get_constant("hseparation"), 0) : Point2(); int text_clip = size.width - style->get_minimum_size().width - icon_ofs.width; - Point2 text_ofs = (size - style->get_minimum_size() - icon_ofs - font->get_string_size(xl_text)) / 2.0; + Point2 text_ofs = (size - style->get_minimum_size() - icon_ofs - font->get_string_size(xl_text) - Point2(_internal_margin[MARGIN_RIGHT], 0)) / 2.0; switch (align) { case ALIGN_LEFT: { @@ -150,7 +154,7 @@ void Button::_notification(int p_what) { text_ofs += style->get_offset(); } break; case ALIGN_RIGHT: { - text_ofs.x = size.x - style->get_margin(MARGIN_RIGHT) - font->get_string_size(xl_text).x; + text_ofs.x = size.x - style->get_margin(MARGIN_RIGHT) - font->get_string_size(xl_text).x - _internal_margin[MARGIN_RIGHT]; text_ofs.y += style->get_offset().y; } break; } @@ -263,6 +267,10 @@ Button::Button(const String &p_text) { set_mouse_filter(MOUSE_FILTER_STOP); set_text(p_text); align = ALIGN_CENTER; + + for (int i = 0; i < 4; i++) { + _internal_margin[i] = 0; + } } Button::~Button() { |