diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2020-01-29 16:41:02 +0100 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2020-02-04 22:17:05 +0100 |
commit | a1f07a57e548763c6afd546938caa131a2a22427 (patch) | |
tree | 6b6e9b7375736719189bc9a948096c71a562c8f5 /vcl | |
parent | bf0baf83fe1ff3e0b46f18294729ad0dd4598104 (diff) |
Place button text in tooltip if it doesn't fit into the button
Seen this happening in custom sidebars (from extensions).
When the text is too long for the button, it will get cut off
and there is no way to view the button text.
Change-Id: I86ce72154e0371bdf24480be41517855dc3ce050
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87692
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
(cherry picked from commit dabb6176407067ef8d46bdde863b087457805c6a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87948
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/control/button.cxx | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 53eaa3ff6b0c..7d235e6bd4c8 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -216,6 +216,11 @@ void Button::ImplDrawAlignedImage(OutputDevice* pDev, Point& rPos, else if (bDrawText && !bDrawImage && !bHasSymbol) { aOutRect = DrawControlText(*pDev, aOutRect, aText, nTextStyle, nullptr, nullptr); + tools::Rectangle textRect = GetTextRect( + tools::Rectangle(Point(), Size(0x7fffffff, 0x7fffffff)), aText, nTextStyle); + // If the button text doesn't fit into it, put it into a tooltip (might happen in sidebar) + if (GetQuickHelpText().isEmpty() && textRect.getWidth() > rSize.getWidth()) + SetQuickHelpText(aText); ImplSetFocusRect(aOutRect); rSize = aOutRect.GetSize(); |