From 4c1a8f233f1a496a8401fd255d954745baef33c0 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 27 Jan 2020 13:22:01 +0000 Subject: weld ExtrusionLightingWindow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I3078ca8315f84f03431a07630987687144857818 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87527 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- include/svx/strings.hrc | 3 - svx/UIConfig_svx.mk | 1 + svx/inc/bitmaps.hlst | 3 - svx/source/tbxctrls/extrusioncontrols.cxx | 161 ++++++++++++++---------------- svx/source/tbxctrls/extrusioncontrols.hxx | 25 +++-- svx/uiconfig/ui/lightingwindow.ui | 121 ++++++++++++++++++++++ 6 files changed, 208 insertions(+), 106 deletions(-) create mode 100644 svx/uiconfig/ui/lightingwindow.ui diff --git a/include/svx/strings.hrc b/include/svx/strings.hrc index 2d5812626993..171eb4053659 100644 --- a/include/svx/strings.hrc +++ b/include/svx/strings.hrc @@ -1032,9 +1032,6 @@ #define RID_SVXSTR_DIRECTION_SW NC_("RID_SVXSTR_DIRECTION_SW", "Extrusion South-West") #define RID_SVXSTR_DIRECTION_S NC_("RID_SVXSTR_DIRECTION_S", "Extrusion South") #define RID_SVXSTR_DIRECTION_SE NC_("RID_SVXSTR_DIRECTION_SE", "Extrusion South-East") -#define RID_SVXSTR_BRIGHT NC_("RID_SVXSTR_BRIGHT", "~Bright") -#define RID_SVXSTR_NORMAL NC_("RID_SVXSTR_NORMAL", "~Normal") -#define RID_SVXSTR_DIM NC_("RID_SVXSTR_DIM", "~Dim") #define RID_SVXSTR_WIREFRAME NC_("RID_SVXSTR_WIREFRAME", "~Wire Frame") #define RID_SVXSTR_MATTE NC_("RID_SVXSTR_MATTE", "~Matt") #define RID_SVXSTR_PLASTIC NC_("RID_SVXSTR_PLASTIC", "~Plastic") diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk index afad7bb8f9ba..a7f943c2548c 100644 --- a/svx/UIConfig_svx.mk +++ b/svx/UIConfig_svx.mk @@ -69,6 +69,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\ svx/uiconfig/ui/imapmenu \ svx/uiconfig/ui/interimdockparent \ svx/uiconfig/ui/interimparent \ + svx/uiconfig/ui/lightingwindow \ svx/uiconfig/ui/linkwarndialog \ svx/uiconfig/ui/measurewidthbar \ svx/uiconfig/ui/mediaplayback \ diff --git a/svx/inc/bitmaps.hlst b/svx/inc/bitmaps.hlst index 94bd0d116b17..648d86d356ff 100644 --- a/svx/inc/bitmaps.hlst +++ b/svx/inc/bitmaps.hlst @@ -74,9 +74,6 @@ #define RID_SVXBMP_LIGHT_PREVIEW_FROM_BOTTOM_LEFT "svx/res/lightfrombottomleft_22.png" #define RID_SVXBMP_LIGHT_PREVIEW_FROM_BOTTOM "svx/res/lightfrombottom_22.png" #define RID_SVXBMP_LIGHT_PREVIEW_FROM_BOTTOM_RIGHT "svx/res/lightfrombottomright_22.png" -#define RID_SVXBMP_LIGHTING_BRIGHT "svx/res/brightlit_16.png" -#define RID_SVXBMP_LIGHTING_NORMAL "svx/res/normallit_16.png" -#define RID_SVXBMP_LIGHTING_DIM "svx/res/dimlit_16.png" #define RID_SVXBMP_WIRE_FRAME "svx/res/wireframe_16.png" #define RID_SVXBMP_MATTE "svx/res/matte_16.png" #define RID_SVXBMP_PLASTIC "svx/res/plastic_16.png" diff --git a/svx/source/tbxctrls/extrusioncontrols.cxx b/svx/source/tbxctrls/extrusioncontrols.cxx index 3bdfba02bd63..76fcb3a5e048 100644 --- a/svx/source/tbxctrls/extrusioncontrols.cxx +++ b/svx/source/tbxctrls/extrusioncontrols.cxx @@ -557,16 +557,20 @@ com_sun_star_comp_svx_ExtrusionDepthController_get_implementation( static const char g_sExtrusionLightingDirection[] = ".uno:ExtrusionLightingDirection"; static const char g_sExtrusionLightingIntensity[] = ".uno:ExtrusionLightingIntensity"; -ExtrusionLightingWindow::ExtrusionLightingWindow(svt::ToolboxController& rController, - vcl::Window* pParentWindow) - : ToolbarMenu(rController.getFrameInterface(), pParentWindow, WB_STDPOPUP) - , mrController(rController) - , maImgBright(StockImage::Yes, RID_SVXBMP_LIGHTING_BRIGHT) - , maImgNormal(StockImage::Yes, RID_SVXBMP_LIGHTING_NORMAL) - , maImgDim(StockImage::Yes, RID_SVXBMP_LIGHTING_DIM) +ExtrusionLightingWindow::ExtrusionLightingWindow(svt::PopupWindowController* pControl, + weld::Widget* pParent) + : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/lightingwindow.ui", "LightingWindow") + , mxControl(pControl) + , mxLightingSet(new SvtValueSet(nullptr)) + , mxLightingSetWin(new weld::CustomWeld(*m_xBuilder, "valueset", *mxLightingSet)) + , mxBright(m_xBuilder->weld_radio_button("bright")) + , mxNormal(m_xBuilder->weld_radio_button("normal")) + , mxDim(m_xBuilder->weld_radio_button("dim")) , mnDirection(FROM_FRONT) , mbDirectionEnabled(false) { + mxLightingSet->SetStyle(WB_TABSTOP | WB_MENUSTYLEVALUESET | WB_FLATVALUESET | WB_NOBORDER | WB_NO_DIRECTSELECT); + for (sal_uInt16 i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; ++i) { if( i != FROM_FRONT ) @@ -577,58 +581,52 @@ ExtrusionLightingWindow::ExtrusionLightingWindow(svt::ToolboxController& rContro maImgLightingPreview[i] = Image(StockImage::Yes, aLightPreviewBmps[i]); } - SetSelectHdl( LINK( this, ExtrusionLightingWindow, SelectToolbarMenuHdl ) ); + mxLightingSet->SetHelpId( HID_VALUESET_EXTRUSION_LIGHTING ); - mpLightingSet = createEmptyValueSetControl(); - mpLightingSet->SetHelpId( HID_VALUESET_EXTRUSION_LIGHTING ); - - mpLightingSet->SetSelectHdl( LINK( this, ExtrusionLightingWindow, SelectValueSetHdl ) ); - mpLightingSet->SetColCount( 3 ); - mpLightingSet->EnableFullItemMode( false ); + mxLightingSet->SetSelectHdl( LINK( this, ExtrusionLightingWindow, SelectValueSetHdl ) ); + mxLightingSet->SetColCount( 3 ); + mxLightingSet->EnableFullItemMode( false ); for (sal_uInt16 i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; ++i) { if( i != FROM_FRONT ) { - mpLightingSet->InsertItem( i+1, maImgLightingOff[i] ); + mxLightingSet->InsertItem( i+1, maImgLightingOff[i] ); } else { - mpLightingSet->InsertItem( 5, maImgLightingPreview[FROM_FRONT] ); + mxLightingSet->InsertItem( 5, maImgLightingPreview[FROM_FRONT] ); } } - mpLightingSet->SetOutputSizePixel( Size( 72, 72 ) ); + Size aSize(72, 72); + mxLightingSet->GetDrawingArea()->set_size_request(aSize.Width(), aSize.Height()); + mxLightingSet->SetOutputSizePixel(aSize); - appendEntry(3, mpLightingSet); - appendSeparator(); - appendEntry(0, SvxResId(RID_SVXSTR_BRIGHT), maImgBright); - appendEntry(1, SvxResId(RID_SVXSTR_NORMAL), maImgNormal); - appendEntry(2, SvxResId(RID_SVXSTR_DIM), maImgDim); - - SetOutputSizePixel( getMenuSize() ); + mxBright->connect_clicked(LINK(this, ExtrusionLightingWindow, SelectToolbarMenuHdl)); + mxNormal->connect_clicked(LINK(this, ExtrusionLightingWindow, SelectToolbarMenuHdl)); + mxDim->connect_clicked(LINK(this, ExtrusionLightingWindow, SelectToolbarMenuHdl)); AddStatusListener( g_sExtrusionLightingDirection ); AddStatusListener( g_sExtrusionLightingIntensity ); } -ExtrusionLightingWindow::~ExtrusionLightingWindow() +void ExtrusionLightingWindow::GrabFocus() { - disposeOnce(); + mxLightingSet->GrabFocus(); } -void ExtrusionLightingWindow::dispose() +ExtrusionLightingWindow::~ExtrusionLightingWindow() { - mpLightingSet.clear(); - ToolbarMenu::dispose(); } void ExtrusionLightingWindow::implSetIntensity( int nLevel, bool bEnabled ) { - for (int i = 0; i < 3; ++i) - { - checkEntry( i, (i == nLevel) && bEnabled ); - enableEntry( i, bEnabled ); - } + mxBright->set_sensitive(bEnabled); + mxBright->set_active(nLevel == 0 && bEnabled); + mxNormal->set_sensitive(bEnabled); + mxNormal->set_active(nLevel == 1 && bEnabled); + mxDim->set_sensitive(bEnabled); + mxDim->set_active(nLevel == 2 && bEnabled); } void ExtrusionLightingWindow::implSetDirection( int nDirection, bool bEnabled ) @@ -644,21 +642,23 @@ void ExtrusionLightingWindow::implSetDirection( int nDirection, bool bEnabled ) { if( nItemId == FROM_FRONT ) { - mpLightingSet->SetItemImage( nItemId + 1, maImgLightingPreview[ nDirection ] ); + mxLightingSet->SetItemImage( nItemId + 1, maImgLightingPreview[ nDirection ] ); } else { - mpLightingSet->SetItemImage( + mxLightingSet->SetItemImage( nItemId + 1, static_cast(nDirection) == nItemId ? maImgLightingOn[nItemId] : maImgLightingOff[nItemId] ); } } - enableEntry( 3, bEnabled ); + if (bEnabled) + mxLightingSet->Enable(); + else + mxLightingSet->Disable(); } - void ExtrusionLightingWindow::statusChanged( const css::frame::FeatureStateEvent& Event ) @@ -691,69 +691,47 @@ void ExtrusionLightingWindow::statusChanged( } } - -void ExtrusionLightingWindow::DataChanged( const DataChangedEvent& rDCEvt ) +IMPL_LINK_NOARG(ExtrusionLightingWindow, SelectValueSetHdl, SvtValueSet*, void) { - ToolbarMenu::DataChanged( rDCEvt ); + sal_Int32 nDirection = mxLightingSet->GetSelectedItemId(); - if( ( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) && ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE ) ) + if( (nDirection > 0) && (nDirection < 10) ) { - implSetDirection( mnDirection, mbDirectionEnabled ); - setEntryImage( 0, maImgBright ); - setEntryImage( 1, maImgNormal ); - setEntryImage( 2, maImgDim ); - } -} + nDirection--; + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = OUString(g_sExtrusionLightingDirection).copy(5); + aArgs[0].Value <<= nDirection; -IMPL_LINK( ExtrusionLightingWindow, SelectValueSetHdl, ValueSet*, pControl, void ) -{ - SelectHdl(pControl); -} -IMPL_LINK( ExtrusionLightingWindow, SelectToolbarMenuHdl, ToolbarMenu*, pControl, void ) -{ - SelectHdl(pControl); -} -void ExtrusionLightingWindow::SelectHdl(void const * pControl) -{ - if ( IsInPopupMode() ) - EndPopupMode(); + mxControl->dispatchCommand( g_sExtrusionLightingDirection, aArgs ); - if( pControl == this ) - { - int nLevel = getSelectedEntryId(); - if( nLevel >= 0 && nLevel != 3 ) - { - Sequence< PropertyValue > aArgs( 1 ); - aArgs[0].Name = OUString(g_sExtrusionLightingIntensity).copy(5); - aArgs[0].Value <<= static_cast(nLevel); + implSetDirection( nDirection, true ); + } - mrController.dispatchCommand( g_sExtrusionLightingIntensity, aArgs ); + mxControl->EndPopupMode(); +} - implSetIntensity( nLevel, true ); - } - } +IMPL_LINK_NOARG(ExtrusionLightingWindow, SelectToolbarMenuHdl, weld::Button&, void) +{ + int nLevel; + if (mxBright->get_active()) + nLevel = 0; + else if (mxNormal->get_active()) + nLevel = 1; else - { - sal_Int32 nDirection = mpLightingSet->GetSelectedItemId(); - - if( (nDirection > 0) && (nDirection < 10) ) - { - nDirection--; + nLevel = 2; - Sequence< PropertyValue > aArgs( 1 ); - aArgs[0].Name = OUString(g_sExtrusionLightingDirection).copy(5); - aArgs[0].Value <<= nDirection; + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = OUString(g_sExtrusionLightingIntensity).copy(5); + aArgs[0].Value <<= static_cast(nLevel); - mrController.dispatchCommand( g_sExtrusionLightingDirection, aArgs ); + mxControl->dispatchCommand( g_sExtrusionLightingIntensity, aArgs ); - implSetDirection( nDirection, true ); - } + implSetIntensity( nLevel, true ); - } + mxControl->EndPopupMode(); } - ExtrusionLightingControl::ExtrusionLightingControl( const Reference< XComponentContext >& rxContext ) : svt::PopupWindowController( rxContext, @@ -763,10 +741,19 @@ ExtrusionLightingControl::ExtrusionLightingControl( { } +std::unique_ptr ExtrusionLightingControl::weldPopupWindow() +{ + return std::make_unique(this, m_pToolbar); +} VclPtr ExtrusionLightingControl::createVclPopupWindow( vcl::Window* pParent ) { - return VclPtr::Create( *this, pParent ); + mxInterimPopover = VclPtr::Create(getFrameInterface(), pParent, + std::make_unique(this, pParent->GetFrameWeld())); + + mxInterimPopover->Show(); + + return mxInterimPopover; } // XInitialization diff --git a/svx/source/tbxctrls/extrusioncontrols.hxx b/svx/source/tbxctrls/extrusioncontrols.hxx index 4dceea5e9848..af46a1ee395e 100644 --- a/svx/source/tbxctrls/extrusioncontrols.hxx +++ b/svx/source/tbxctrls/extrusioncontrols.hxx @@ -123,44 +123,43 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; }; -class ExtrusionLightingWindow : public svtools::ToolbarMenu +class ExtrusionLightingWindow final : public WeldToolbarPopup { private: - svt::ToolboxController& mrController; - VclPtr mpLightingSet; + rtl::Reference mxControl; + std::unique_ptr mxLightingSet; + std::unique_ptr mxLightingSetWin; + std::unique_ptr mxBright; + std::unique_ptr mxNormal; + std::unique_ptr mxDim; Image maImgLightingOff[9]; Image maImgLightingOn[9]; Image maImgLightingPreview[9]; - Image const maImgBright; - Image const maImgNormal; - Image const maImgDim; - int mnDirection; bool mbDirectionEnabled; void implSetIntensity( int nLevel, bool bEnabled ); void implSetDirection( int nDirection, bool bEnabled ); - DECL_LINK( SelectToolbarMenuHdl, ToolbarMenu*, void ); - DECL_LINK( SelectValueSetHdl, ValueSet*, void ); + DECL_LINK( SelectToolbarMenuHdl, weld::Button&, void ); + DECL_LINK( SelectValueSetHdl, SvtValueSet*, void ); void SelectHdl(void const *); public: - ExtrusionLightingWindow( svt::ToolboxController& rController, vcl::Window* pParentWindow ); + ExtrusionLightingWindow(svt::PopupWindowController* pControl, weld::Widget* pParentWindow); + virtual void GrabFocus() override; virtual ~ExtrusionLightingWindow() override; - virtual void dispose() override; virtual void statusChanged( const css::frame::FeatureStateEvent& Event ) override; - virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; }; - class ExtrusionLightingControl : public svt::PopupWindowController { public: explicit ExtrusionLightingControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual std::unique_ptr weldPopupWindow() override; virtual VclPtr createVclPopupWindow( vcl::Window* pParent ) override; // XInitialization diff --git a/svx/uiconfig/ui/lightingwindow.ui b/svx/uiconfig/ui/lightingwindow.ui new file mode 100644 index 000000000000..82c188653375 --- /dev/null +++ b/svx/uiconfig/ui/lightingwindow.ui @@ -0,0 +1,121 @@ + + + + + + True + False + svx/res/brightlit_16.png + + + True + False + svx/res/normallit_16.png + + + False + True + 4 + + + True + False + vertical + 6 + + + True + True + True + True + never + never + in + + + True + False + + + True + True + GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK + True + True + + + + + + + False + True + 0 + + + + + _Bright + True + True + False + image1 + True + 0 + True + True + True + + + False + True + 1 + + + + + _Normal + True + True + False + image2 + True + 0 + True + True + bright + + + False + True + 2 + + + + + _Dim + True + True + False + image3 + True + 0 + True + True + bright + + + False + True + 3 + + + + + + + True + False + svx/res/dimlit_16.png + + -- cgit