Fix Button clipping when internal margins exist
(cherry picked from commit 71430cdd48
)
This commit is contained in:
parent
cd7411c58d
commit
71ba2aca63
|
@ -327,11 +327,8 @@ void Button::_notification(int p_what) {
|
||||||
if (align_rtl_checked == HORIZONTAL_ALIGNMENT_CENTER && icon_align_rtl_checked == HORIZONTAL_ALIGNMENT_CENTER) {
|
if (align_rtl_checked == HORIZONTAL_ALIGNMENT_CENTER && icon_align_rtl_checked == HORIZONTAL_ALIGNMENT_CENTER) {
|
||||||
icon_ofs.x = 0.0;
|
icon_ofs.x = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int text_clip = size.width - style->get_minimum_size().width - icon_ofs.width;
|
int text_clip = size.width - style->get_minimum_size().width - icon_ofs.width;
|
||||||
text_buf->set_width((clip_text || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) ? text_clip : -1);
|
|
||||||
|
|
||||||
int text_width = MAX(1, (clip_text || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) ? MIN(text_clip, text_buf->get_size().x) : text_buf->get_size().x);
|
|
||||||
|
|
||||||
if (_internal_margin[SIDE_LEFT] > 0) {
|
if (_internal_margin[SIDE_LEFT] > 0) {
|
||||||
text_clip -= _internal_margin[SIDE_LEFT] + theme_cache.h_separation;
|
text_clip -= _internal_margin[SIDE_LEFT] + theme_cache.h_separation;
|
||||||
}
|
}
|
||||||
|
@ -339,6 +336,10 @@ void Button::_notification(int p_what) {
|
||||||
text_clip -= _internal_margin[SIDE_RIGHT] + theme_cache.h_separation;
|
text_clip -= _internal_margin[SIDE_RIGHT] + theme_cache.h_separation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
text_buf->set_width((clip_text || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) ? text_clip : -1);
|
||||||
|
|
||||||
|
int text_width = MAX(1, (clip_text || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) ? MIN(text_clip, text_buf->get_size().x) : text_buf->get_size().x);
|
||||||
|
|
||||||
Point2 text_ofs = (size - style->get_minimum_size() - icon_ofs - text_buf->get_size() - Point2(_internal_margin[SIDE_RIGHT] - _internal_margin[SIDE_LEFT], 0)) / 2.0;
|
Point2 text_ofs = (size - style->get_minimum_size() - icon_ofs - text_buf->get_size() - Point2(_internal_margin[SIDE_RIGHT] - _internal_margin[SIDE_LEFT], 0)) / 2.0;
|
||||||
|
|
||||||
if (vertical_icon_alignment == VERTICAL_ALIGNMENT_TOP) {
|
if (vertical_icon_alignment == VERTICAL_ALIGNMENT_TOP) {
|
||||||
|
|
Loading…
Reference in New Issue