diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2020-06-29 07:01:26 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2020-07-07 14:14:07 +0200 |
commit | eee6441bc9eea847ba4b338baf99ab47913fcd61 (patch) | |
tree | cdd2fb1e22d38f1501c3be0c03bd9c1e5ca50e27 /vcl | |
parent | c0971961cf11097c787c67b5892d6209f89662e7 (diff) |
tdf#134054 toolbox: respect drop-down arrow rect
When centering the text and icon on the button, the code didn't
take the drop-down arrow rect width into account, resulting in an
overlapped arrow. This is especially visible, if the drop-down
is shown and the button is wrongly highlighted.
There is supposed to be some vertical mode, which I couldn't find
in the GUI, so this just adapts the width in horizontal mode.
Change-Id: I194780dc32db610041ad0ee45a425e1026c7c4e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97358
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
(cherry picked from commit 8565546ce6a04f6f243f4f60d2693b148dca5a77)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97688
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/window/toolbox.cxx | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index 77df4fddcacb..df5aadf89243 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -2641,13 +2641,11 @@ void ToolBox::ImplDrawItem(vcl::RenderContext& rRenderContext, ImplToolItems::si long nBtnWidth = aBtnSize.Width()-SMALLBUTTON_HSIZE; long nBtnHeight = aBtnSize.Height()-SMALLBUTTON_VSIZE; Size aImageSize; - Size aTxtSize; - if ( bText ) - { - aTxtSize.setWidth( GetCtrlTextWidth( pItem->maText ) ); - aTxtSize.setHeight( GetTextHeight() ); - } + const bool bDropDown = (pItem->mnBits & ToolBoxItemBits::DROPDOWN) == ToolBoxItemBits::DROPDOWN; + tools::Rectangle aDropDownRect; + if (bDropDown) + aDropDownRect = pItem->GetDropDownRect(mbHorz); if ( bImage ) { @@ -2678,7 +2676,7 @@ void ToolBox::ImplDrawItem(vcl::RenderContext& rRenderContext, ImplToolItems::si } else { - nImageOffX += (nBtnWidth-aImageSize.Width())/2; + nImageOffX += (nBtnWidth-(bDropDown ? aDropDownRect.getWidth() : 0)+SMALLBUTTON_OFF_NORMAL_X-aImageSize.Width())/2; if ( meTextPosition == ToolBoxTextPosition::Right ) nImageOffY += (nBtnHeight-aImageSize.Height())/2; } @@ -2705,6 +2703,7 @@ void ToolBox::ImplDrawItem(vcl::RenderContext& rRenderContext, ImplToolItems::si bool bRotate = false; if ( bText ) { + const Size aTxtSize(GetCtrlTextWidth(pItem->maText), GetTextHeight()); long nTextOffX = nOffX; long nTextOffY = nOffY; @@ -2742,7 +2741,7 @@ void ToolBox::ImplDrawItem(vcl::RenderContext& rRenderContext, ImplToolItems::si else { // center horizontally - nTextOffX += (nBtnWidth-aTxtSize.Width() - TB_IMAGETEXTOFFSET)/2; + nTextOffX += (nBtnWidth-(bDropDown ? aDropDownRect.getWidth() : 0)+SMALLBUTTON_OFF_NORMAL_X-aTxtSize.Width() - TB_IMAGETEXTOFFSET)/2; // set vertical position nTextOffY += nBtnHeight - aTxtSize.Height(); } @@ -2768,9 +2767,8 @@ void ToolBox::ImplDrawItem(vcl::RenderContext& rRenderContext, ImplToolItems::si } // paint optional drop down arrow - if ( pItem->mnBits & ToolBoxItemBits::DROPDOWN ) + if (bDropDown) { - tools::Rectangle aDropDownRect( pItem->GetDropDownRect( mbHorz ) ); bool bSetColor = true; if ( !pItem->mbEnabled || !IsEnabled() ) { |