From e18b743a840475cfbdfba437a1edf8677a5f93bd Mon Sep 17 00:00:00 2001 From: Jim Raykowski Date: Thu, 11 Mar 2021 10:31:46 -0900 Subject: tdf#140936 statusbar selection mode control improvements - shows different image for each selection mode - tooltip indicates the current selection mode and mouse click hint - replaces left-click cycle selection mode with context menu popup Change-Id: Ieb2662de99cf42d4ada4c1a590bebc8363861c7b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112367 Tested-by: Jenkins Reviewed-by: Rizal Muttaqin --- svx/inc/bitmaps.hlst | 5 ++++- svx/source/stbctrls/selctrl.cxx | 27 ++++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) (limited to 'svx') diff --git a/svx/inc/bitmaps.hlst b/svx/inc/bitmaps.hlst index 684dba8772f4..3bf954339846 100644 --- a/svx/inc/bitmaps.hlst +++ b/svx/inc/bitmaps.hlst @@ -145,7 +145,10 @@ #define BMP_SQUARE "svx/res/symphony/Square.png" #define BMP_LINEAR "svx/res/symphony/linear.png" -#define RID_SVXBMP_SELECTION "svx/res/selection_10x22.png" +#define RID_SVXBMP_STANDARD_SELECTION "svx/res/standard-selection_10x22.png" +#define RID_SVXBMP_EXTENDING_SELECTION "svx/res/extending-selection_10x22.png" +#define RID_SVXBMP_ADDING_SELECTION "svx/res/adding-selection_10x22.png" +#define RID_SVXBMP_BLOCK_SELECTION "svx/res/block-selection_10x22.png" #define RID_SVXBMP_POSITION "res/sc10223.png" #define RID_SVXBMP_SIZE "res/sc10224.png" #define RID_SVXBMP_SIGNET "svx/res/signet_11x16.png" diff --git a/svx/source/stbctrls/selctrl.cxx b/svx/source/stbctrls/selctrl.cxx index 845df5a5d367..6e56e22f8d2f 100644 --- a/svx/source/stbctrls/selctrl.cxx +++ b/svx/source/stbctrls/selctrl.cxx @@ -36,6 +36,9 @@ #include #include +#include +#include + SFX_IMPL_STATUSBAR_CONTROL(SvxSelectionModeControl, SfxUInt16Item); namespace { @@ -100,10 +103,12 @@ SvxSelectionModeControl::SvxSelectionModeControl( sal_uInt16 _nSlotId, StatusBar& rStb ) : SfxStatusBarControl( _nSlotId, _nId, rStb ), mnState( 0 ), - maImage(StockImage::Yes, RID_SVXBMP_SELECTION), + maImages{Image(StockImage::Yes, RID_SVXBMP_STANDARD_SELECTION), + Image(StockImage::Yes, RID_SVXBMP_EXTENDING_SELECTION), + Image(StockImage::Yes, RID_SVXBMP_ADDING_SELECTION), + Image(StockImage::Yes, RID_SVXBMP_BLOCK_SELECTION)}, mbFeatureEnabled(false) { - GetStatusBar().SetItemText( GetId(), "" ); GetStatusBar().SetQuickHelpText(GetId(), u""); } @@ -116,15 +121,17 @@ void SvxSelectionModeControl::StateChanged( sal_uInt16, SfxItemState eState, DBG_ASSERT( dynamic_cast< const SfxUInt16Item* >(pState) != nullptr, "invalid item type" ); const SfxUInt16Item* pItem = static_cast(pState); mnState = pItem->GetValue(); - SelectionTypePopup aPop(GetStatusBar().GetFrameWeld(), mnState); - GetStatusBar().SetQuickHelpText(GetId(), aPop.GetItemTextForState(mnState)); + GetStatusBar().SetQuickHelpText(GetId(), + SvxResId(RID_SVXSTR_SELECTIONMODE_HELPTEXT). + replaceFirst("%1", aPop.GetItemTextForState(mnState))); + GetStatusBar().Invalidate(); } } bool SvxSelectionModeControl::MouseButtonDown( const MouseEvent& rEvt ) { - if (!mbFeatureEnabled || !rEvt.IsMiddle()) + if (!mbFeatureEnabled) return true; ::tools::Rectangle aRect(rEvt.GetPosPixel(), Size(1, 1)); @@ -165,6 +172,9 @@ bool SvxSelectionModeControl::MouseButtonDown( const MouseEvent& rEvt ) return true; } +void SvxSelectionModeControl::Click() +{ +} void SvxSelectionModeControl::Paint( const UserDrawEvent& rUsrEvt ) { @@ -172,12 +182,15 @@ void SvxSelectionModeControl::Paint( const UserDrawEvent& rUsrEvt ) vcl::RenderContext* pDev = rUsrEvt.GetRenderContext(); tools::Rectangle aRect = rUsrEvt.GetRect(); - Size aImgSize( maImage.GetSizePixel() ); + Size aImgSize( maImages[mnState].GetSizePixel() ); Point aPos( aRect.Left() + ( aControlRect.GetWidth() - aImgSize.Width() ) / 2, aRect.Top() + ( aControlRect.GetHeight() - aImgSize.Height() ) / 2 ); - pDev->DrawImage(aPos, maImage, mbFeatureEnabled ? DrawImageFlags::NONE : DrawImageFlags::Disable); + if (mbFeatureEnabled) + pDev->DrawImage(aPos, maImages[mnState]); + else + pDev->DrawImage(aPos, Image()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit