summaryrefslogtreecommitdiff
path: root/vcl
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 /vcl
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
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/toolbox.h1
-rw-r--r--vcl/source/window/toolbox2.cxx59
2 files changed, 33 insertions, 27 deletions
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 );
}