Allow automatically calculating both the width and height of a text label

This fixes welcome dialog links triggering when you hit OK in the right place
This commit is contained in:
2020-12-19 18:10:25 -05:00
parent 99ac7531a8
commit 81c2a084e3
2 changed files with 12 additions and 10 deletions

View File

@@ -123,10 +123,11 @@ void cTextMsg::recalcRect() {
if(!fixedHeight) {
// Fix the width and calculate the height
calc_rect.height() = lines * style.lineHeight * 10;
} else if(!fixedWidth) {
}
if(!fixedWidth) {
// Fix the height and calculate the width
calc_rect.width() = 100 * max_line_chars;
} else return; // This case should be impossible, but just in case...
}
sf::RenderTexture temp;
temp.create(frame.width(), frame.height());
rectangle test_rect = calc_rect;
@@ -140,8 +141,9 @@ void cTextMsg::recalcRect() {
}
if(!fixedHeight) {
calc_rect.height() = combo.height() + 8;
} else if(!fixedWidth) {
calc_rect.width() = combo.width() + 8;
}
if(!fixedWidth) {
calc_rect.width() = combo.width() + 16;
}
frame = calc_rect;
}