summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2022-07-29 00:36:18 +0300
committerMaxim Monastirsky <momonasmon@gmail.com>2022-08-30 13:08:03 +0200
commit4fb8c0d14cb2468f7336438004f699b9eb7e7e4a (patch)
treeaa3b9c92c1c86e9afae76246ef33ab8268f145de /framework
parent2958e4c92f15652c424765f02c87518011eb2406 (diff)
tdf#149741 tdf#149956 Make flipping work also in the sidebar
- Reset the icon each time, as there seems to be no easy way to retrieve the existing icon from a gtk widget in order to mirror it, like we used to do for vcl. Similar approach is currently taken in ToolboxButtonColorUpdaterBase::Update. - Store the flipping state also in GtkInstanceToolbar, similar to vcl's ToolBox. This seems to be the easiest way to make flipping not break on icon theme change, covering all 4 cases (ToolBarManager, SidebarToolBox, ToolbarUnoDispatcher, GenericToolbarController), w/o too involved changes in each. This might benefit from some refactoring later on, but should be good enough for now. - One unsolved problem is the appearance of flipped icons with svg themes, as the regular variant is handed to gtk directly, whereas the flipped one is loaded by us, resulting with a different (blurry) look. Change-Id: I48c16827b46fb75fd798a041851af6e2648ae8fe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139021 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'framework')
-rw-r--r--framework/source/uielement/generictoolbarcontroller.cxx14
1 files changed, 13 insertions, 1 deletions
diff --git a/framework/source/uielement/generictoolbarcontroller.cxx b/framework/source/uielement/generictoolbarcontroller.cxx
index e8e49cb30933..312b5ed9e77f 100644
--- a/framework/source/uielement/generictoolbarcontroller.cxx
+++ b/framework/source/uielement/generictoolbarcontroller.cxx
@@ -91,6 +91,7 @@ GenericToolbarController::GenericToolbarController( const Reference< XComponentC
, m_xToolbar( pToolbar )
, m_nID( nID )
, m_bEnumCommand( isEnumCommand( aCommand ))
+ , m_bMirrored( false )
, m_bMadeInvisible( false )
, m_aEnumCommand( getEnumCommand( aCommand ))
{
@@ -189,6 +190,7 @@ void GenericToolbarController::statusChanged( const FeatureStateEvent& Event )
bool bValue;
OUString aStrValue;
+ SfxImageItem aImageItem;
if ( Event.State >>= bValue )
{
@@ -199,6 +201,13 @@ void GenericToolbarController::statusChanged( const FeatureStateEvent& Event )
{
m_pToolbar->set_item_label(sId, aStrValue);
}
+ else if ( aImageItem.PutValue( Event.State, 0 ) && aImageItem.IsMirrored() != m_bMirrored )
+ {
+ m_pToolbar->set_item_image_mirrored(sId, aImageItem.IsMirrored());
+ auto xGraphic(vcl::CommandInfoProvider::GetXGraphicForCommand(m_aCommandURL, m_xFrame, m_pToolbar->get_icon_size()));
+ m_pToolbar->set_item_image(sId, xGraphic);
+ m_bMirrored = !m_bMirrored;
+ }
else
m_pToolbar->set_item_active(sId, false);
@@ -295,9 +304,12 @@ void GenericToolbarController::statusChanged( const FeatureStateEvent& Event )
if ( m_bMadeInvisible )
m_xToolbar->ShowItem( m_nID );
}
- else if ( aImageItem.PutValue( Event.State, 0 ) )
+ else if ( aImageItem.PutValue( Event.State, 0 ) && aImageItem.IsMirrored() != m_bMirrored )
{
m_xToolbar->SetItemImageMirrorMode( m_nID, aImageItem.IsMirrored() );
+ Image aImage( vcl::CommandInfoProvider::GetImageForCommand( m_aCommandURL, m_xFrame, m_xToolbar->GetImageSize() ));
+ m_xToolbar->SetItemImage( m_nID, aImage );
+ m_bMirrored = !m_bMirrored;
if ( m_bMadeInvisible )
m_xToolbar->ShowItem( m_nID );
}