vcl: set toolbox size correctly when using 32px icons
Change-Id: Ifacff75f80bc8401ccff2a4d4dc90e56e3b4aa84
Reviewed-on: https://gerrit.libreoffice.org/31801
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
(cherry picked from commit 99fd3b2a2759864caf519dfd89173e301b74c24e)
Reviewed-on: https://gerrit.libreoffice.org/31802
Tested-by: Jenkins <ci@libreoffice.org>
diff --git a/framework/source/fwe/classes/addonsoptions.cxx b/framework/source/fwe/classes/addonsoptions.cxx
index c3013e4..fc11b4e 100644
--- a/framework/source/fwe/classes/addonsoptions.cxx
+++ b/framework/source/fwe/classes/addonsoptions.cxx
@@ -475,7 +475,7 @@ bool AddonsOptions_Impl::GetMergeToolbarInstructions(
static Image ScaleImage( const Image &rImage, bool bBig )
{
Size aSize = ToolBox::GetDefaultImageSize(bBig);
Size aSize = ToolBox::GetDefaultImageSize(bBig ? ToolBoxButtonSize::Large : ToolBoxButtonSize::Small);
BitmapEx aScaleBmp(rImage.GetBitmapEx());
SAL_INFO("fwk", "Addons: expensive scale image from "
<< aScaleBmp.GetSizePixel() << " to " << aSize);
diff --git a/include/vcl/toolbox.hxx b/include/vcl/toolbox.hxx
index 66bd8cf..be81106 100644
--- a/include/vcl/toolbox.hxx
+++ b/include/vcl/toolbox.hxx
@@ -502,7 +502,7 @@ public:
// if an index is found the corresponding item id is filled in (else 0)
long GetIndexForPoint( const Point& rPoint, sal_uInt16& rItemID ) const;
static Size GetDefaultImageSize(bool bLarge);
static Size GetDefaultImageSize(ToolBoxButtonSize eToolBoxButtonSize);
Size GetDefaultImageSize() const;
void ChangeHighlight( sal_uInt16 nPos );
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 2fe5869..14579fa 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -1671,9 +1671,8 @@ bool ToolBox::ImplCalcItem()
long nDropDownArrowWidth = TB_DROPDOWNARROWWIDTH;
// set defaults if image or text is needed but empty
float fDPIScaleFactor = GetDPIScaleFactor();
nDefWidth = GetDefaultImageSize().Width() * fDPIScaleFactor;
nDefHeight = GetDefaultImageSize().Height() * fDPIScaleFactor;
nDefWidth = GetDefaultImageSize().Width();
nDefHeight = GetDefaultImageSize().Height();
mnWinHeight = 0;
// determine minimum size necessary in NWF
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index 04ba01c..37f809c 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -633,20 +633,28 @@ ToolBoxButtonSize ToolBox::GetToolboxButtonSize() const
return mpData->meButtonSize;
}
/*static*/ Size ToolBox::GetDefaultImageSize(bool bLarge)
/*static*/ Size ToolBox::GetDefaultImageSize(ToolBoxButtonSize eToolBoxButtonSize)
{
const long TB_SMALLIMAGESIZE = 16;
if (!bLarge) {
return Size(TB_SMALLIMAGESIZE, TB_SMALLIMAGESIZE);
}
float fScaleFactor = Application::GetDefaultDevice()->GetDPIScaleFactor();
OUString iconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme();
return vcl::IconThemeInfo::SizeByThemeName(iconTheme);
Size aUnscaledSize = Size(16, 16);
if (eToolBoxButtonSize == ToolBoxButtonSize::Large)
{
OUString iconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme();
aUnscaledSize = vcl::IconThemeInfo::SizeByThemeName(iconTheme);
}
else if (eToolBoxButtonSize == ToolBoxButtonSize::Size32)
{
aUnscaledSize = Size(32, 32);
}
return Size(aUnscaledSize.Width() * fScaleFactor,
aUnscaledSize.Height() * fScaleFactor);
}
Size ToolBox::GetDefaultImageSize() const
{
return GetDefaultImageSize( GetToolboxButtonSize() == ToolBoxButtonSize::Large );
return GetDefaultImageSize(GetToolboxButtonSize());
}
void ToolBox::SetAlign( WindowAlign eNewAlign )