summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-05-18 16:34:22 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-05-18 20:17:15 +0200
commitc66de7079f5ad92889a28b4a3f18adc4c4cf019f (patch)
treeec9a2bfac513d93f8244638ef35582ab7e3834ee
parentffc59e2b524029adbc775c0a01acc53faaf7c4d4 (diff)
tdf#142337 Button::GetOptimalSize only considered image beside text case
not image above/below text Change-Id: I5a8e9bfb36cee1460d43478a100e574a3bf1930e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115758 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/source/control/button.cxx17
1 files changed, 15 insertions, 2 deletions
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 42d3da20c2a2..1e47b8fbba35 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -1629,8 +1629,21 @@ Size PushButton::CalcMinimumSize() const
{
Size textSize = GetTextRect( tools::Rectangle( Point(), Size( 0x7fffffff, 0x7fffffff ) ),
PushButton::GetText(), ImplGetTextStyle( DrawFlags::NONE ) ).GetSize();
- aSize.AdjustWidth(textSize.Width() );
- aSize.setHeight( std::max( aSize.Height(), tools::Long( textSize.Height() * 1.15 ) ) );
+
+ tools::Long nTextHeight = textSize.Height() * 1.15;
+
+ ImageAlign eImageAlign = GetImageAlign();
+ // tdf#142337 only considering the simple top/bottom/left/right possibilities
+ if (eImageAlign == ImageAlign::Top || eImageAlign == ImageAlign::Bottom)
+ {
+ aSize.AdjustHeight(nTextHeight);
+ aSize.setWidth(std::max(aSize.Width(), textSize.Width()));
+ }
+ else
+ {
+ aSize.AdjustWidth(textSize.Width());
+ aSize.setHeight(std::max(aSize.Height(), nTextHeight));
+ }
}
// cf. ImplDrawPushButton ...