Skip to content

Commit

Permalink
Merge pull request godotengine#34314 from YeldhamDev/button_internal_…
Browse files Browse the repository at this point in the history
…margin_clip

Make Button and co. take internal margins into account when clipping text
  • Loading branch information
akien-mga authored Dec 12, 2019
2 parents aab7000 + bd7cf87 commit ec97535
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scene/gui/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ void Button::_notification(int p_what) {

Point2 icon_ofs = !_icon.is_null() ? Point2(icon_region.size.width + get_constant("hseparation"), 0) : Point2();
int text_clip = size.width - style->get_minimum_size().width - icon_ofs.width;
if (_internal_margin[MARGIN_LEFT] > 0) {
text_clip -= _internal_margin[MARGIN_LEFT] + get_constant("hseparation");
}
if (_internal_margin[MARGIN_RIGHT] > 0) {
text_clip -= _internal_margin[MARGIN_RIGHT] + get_constant("hseparation");
}

Point2 text_ofs = (size - style->get_minimum_size() - icon_ofs - font->get_string_size(xl_text) - Point2(_internal_margin[MARGIN_RIGHT] - _internal_margin[MARGIN_LEFT], 0)) / 2.0;

switch (align) {
Expand Down

0 comments on commit ec97535

Please sign in to comment.