summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-03-02 20:57:32 +0900
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-03-05 09:46:49 +0900
commitb8f21298288890d52c06fef6c84441634c56c986 (patch)
tree3c295b87962a894fff700c31a2cb1b5f014ebdb4
parent2c40b082b585d0d4429f3f6915cf96a8f7914448 (diff)
toolbox - preserve the orig. image + use it in menu & color update
In toolbox the images are scaled for HiDPI, which causes various problems. This change preserves the original image and uses that when adding images into the menu and also uses that when updating the color related toolbox-es. Change-Id: Ib7e7d82ccb1cd774e0e14dd6bab5626eaefea097
-rw-r--r--include/vcl/toolbox.hxx1
-rw-r--r--svx/source/tbxctrls/tbxcolorupdate.cxx7
-rw-r--r--vcl/inc/toolbox.h1
-rw-r--r--vcl/source/window/toolbox2.cxx59
4 files changed, 38 insertions, 30 deletions
diff --git a/include/vcl/toolbox.hxx b/include/vcl/toolbox.hxx
index 44b4b8c046a7..c72c59f25862 100644
--- a/include/vcl/toolbox.hxx
+++ b/include/vcl/toolbox.hxx
@@ -401,6 +401,7 @@ public:
void* GetItemData( sal_uInt16 nItemId ) const;
void SetItemImage( sal_uInt16 nItemId, const Image& rImage );
Image GetItemImage( sal_uInt16 nItemId ) const;
+ Image GetItemImageOriginal( sal_uInt16 nItemId ) const;
void SetItemImageAngle( sal_uInt16 nItemId, long nAngle10 );
void SetItemImageMirrorMode( sal_uInt16 nItemId, bool bMirror );
void SetItemText( sal_uInt16 nItemId, const OUString& rText );
diff --git a/svx/source/tbxctrls/tbxcolorupdate.cxx b/svx/source/tbxctrls/tbxcolorupdate.cxx
index 3c9a1efc21ed..27f9de9fedb2 100644
--- a/svx/source/tbxctrls/tbxcolorupdate.cxx
+++ b/svx/source/tbxctrls/tbxcolorupdate.cxx
@@ -78,8 +78,9 @@ namespace svx
void ToolboxButtonColorUpdater::Update(const Color& rColor)
{
- Image aImage(mpTbx->GetItemImage(mnBtnId));
- Size aItemSize(mpTbx->GetItemContentSize(mnBtnId));
+ Image aImage(mpTbx->GetItemImageOriginal(mnBtnId));
+ BitmapEx aSource(aImage.GetBitmapEx());
+ Size aItemSize = aSource.GetSizePixel();
const bool bSizeChanged = (maBmpSize != aItemSize);
const bool bDisplayModeChanged = (mbWasHiContrastMode != mpTbx->GetSettings().GetStyleSettings().GetHighContrastMode());
@@ -99,7 +100,7 @@ namespace svx
// (so that it grows in case the original bitmap was smaller)
sal_uInt8 nAlpha = 255;
BitmapEx aBmpEx(Bitmap(aItemSize, 24), AlphaMask(aItemSize, &nAlpha));
- BitmapEx aSource(aImage.GetBitmapEx());
+
long nWidth = std::min(aItemSize.Width(), aSource.GetSizePixel().Width());
long nHeight = std::min(aItemSize.Height(), aSource.GetSizePixel().Height());
diff --git a/vcl/inc/toolbox.h b/vcl/inc/toolbox.h
index 2b23c53eddb9..935d1184e81c 100644
--- a/vcl/inc/toolbox.h
+++ b/vcl/inc/toolbox.h
@@ -40,6 +40,7 @@ struct ImplToolItem
vcl::Window* mpWindow;
void* mpUserData;
Image maImage;
+ Image maImageOriginal;
long mnImageAngle;
bool mbMirrorMode;
OUString maText;
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index dd675dc3fa38..17588506d021 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -1125,7 +1125,12 @@ void ToolBox::SetItemImage( sal_uInt16 nItemId, const Image& rImage )
{
Image aImage(rImage);
- if ( GetDPIScaleFactor() > 1)
+ ImplToolItem* pItem = &mpData->m_aItems[nPos];
+ Size aOldSize = pItem->maImage.GetSizePixel();
+
+ pItem->maImageOriginal = aImage;
+
+ if (GetDPIScaleFactor() > 1)
{
BitmapEx aBitmap(aImage.GetBitmapEx());
@@ -1138,19 +1143,16 @@ void ToolBox::SetItemImage( sal_uInt16 nItemId, const Image& rImage )
}
}
- ImplToolItem* pItem = &mpData->m_aItems[nPos];
+ pItem->maImage = aImage;
+
// only once all is calculated, do extra work
- if ( !mbCalc )
+ if (!mbCalc)
{
- Size aOldSize = pItem->maImage.GetSizePixel();
- pItem->maImage = aImage;
- if ( aOldSize != pItem->maImage.GetSizePixel() )
+ if (aOldSize != pItem->maImage.GetSizePixel())
ImplInvalidate( true );
else
ImplUpdateItem( nPos );
}
- else
- pItem->maImage = aImage;
}
}
@@ -1196,14 +1198,15 @@ void ToolBox::SetItemImageAngle( sal_uInt16 nItemId, long nAngle10 )
if( nDeltaAngle && !!pItem->maImage )
{
pItem->maImage = ImplRotImage( pItem->maImage, nDeltaAngle );
+ pItem->maImageOriginal = ImplRotImage( pItem->maImageOriginal, nDeltaAngle );
}
- if ( !mbCalc )
+ if (!mbCalc)
{
- if ( aOldSize != pItem->maImage.GetSizePixel() )
- ImplInvalidate( true );
+ if (aOldSize != pItem->maImage.GetSizePixel())
+ ImplInvalidate(true);
else
- ImplUpdateItem( nPos );
+ ImplUpdateItem(nPos);
}
}
}
@@ -1226,30 +1229,32 @@ void ToolBox::SetItemImageMirrorMode( sal_uInt16 nItemId, bool bMirror )
{
ImplToolItem* pItem = &mpData->m_aItems[nPos];
- if( ( pItem->mbMirrorMode && ! bMirror ) ||
- ( ! pItem->mbMirrorMode && bMirror )
- )
+ if ((pItem->mbMirrorMode && !bMirror) ||
+ (!pItem->mbMirrorMode && bMirror))
{
pItem->mbMirrorMode = bMirror;
- if( !!pItem->maImage )
+ if (!!pItem->maImage)
{
- pItem->maImage = ImplMirrorImage( pItem->maImage );
+ pItem->maImage = ImplMirrorImage(pItem->maImage);
+ pItem->maImageOriginal = ImplMirrorImage(pItem->maImageOriginal);
}
- if ( !mbCalc )
- ImplUpdateItem( nPos );
+ if (!mbCalc)
+ ImplUpdateItem(nPos);
}
}
}
-Image ToolBox::GetItemImage( sal_uInt16 nItemId ) const
+Image ToolBox::GetItemImage(sal_uInt16 nItemId) const
{
- ImplToolItem* pItem = ImplGetItem( nItemId );
+ ImplToolItem* pItem = ImplGetItem(nItemId);
+ return pItem ? pItem->maImage : Image();
+}
- if ( pItem )
- return pItem->maImage;
- else
- return Image();
+Image ToolBox::GetItemImageOriginal(sal_uInt16 nItemId) const
+{
+ ImplToolItem* pItem = ImplGetItem(nItemId);
+ return pItem ? pItem->maImageOriginal : Image();
}
void ToolBox::SetItemText( sal_uInt16 nItemId, const OUString& rText )
@@ -1830,7 +1835,7 @@ void ToolBox::UpdateCustomMenu()
if( it->IsClipped() )
{
sal_uInt16 id = it->mnId + TOOLBOX_MENUITEM_START;
- pMenu->InsertItem( id, it->maText, it->maImage, MenuItemBits::NONE, OString());
+ pMenu->InsertItem( id, it->maText, it->maImageOriginal, MenuItemBits::NONE, OString());
pMenu->EnableItem( id, it->mbEnabled );
pMenu->CheckItem ( id, it->meState == TRISTATE_TRUE );
}
@@ -1846,7 +1851,7 @@ void ToolBox::UpdateCustomMenu()
if( it->IsItemHidden() )
{
sal_uInt16 id = it->mnId + TOOLBOX_MENUITEM_START;
- pMenu->InsertItem( id, it->maText, it->maImage, MenuItemBits::NONE, OString() );
+ pMenu->InsertItem( id, it->maText, it->maImageOriginal, MenuItemBits::NONE, OString() );
pMenu->EnableItem( id, it->mbEnabled );
pMenu->CheckItem( id, it->meState == TRISTATE_TRUE );
}