vcl/source/window/toolbox.cxx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
New commits: commit 8565546ce6a04f6f243f4f60d2693b148dca5a77 Author: Jan-Marek Glogowski <glo...@fbihome.de> AuthorDate: Mon Jun 29 07:01:26 2020 +0200 Commit: Jan-Marek Glogowski <glo...@fbihome.de> CommitDate: Mon Jun 29 15:24:27 2020 +0200 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 <glo...@fbihome.de> diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index 8ddb536f7bb4..543e1b507c50 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -2642,13 +2642,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; } @@ -2703,6 +2701,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; @@ -2740,7 +2739,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(); } @@ -2766,9 +2765,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() ) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits