From 28f660a61d82f518391ef2ad5f99129a2ea542ee Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 27 Jan 2020 13:45:44 +0000 Subject: weld ExtrusionSurfaceWindow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I13b61c8e4ef0a251472b02061fa150451a7b03a5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87530 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- include/svx/strings.hrc | 4 -- svx/UIConfig_svx.mk | 1 + svx/inc/bitmaps.hlst | 4 -- svx/source/tbxctrls/extrusioncontrols.cxx | 89 +++++++++++++---------- svx/source/tbxctrls/extrusioncontrols.hxx | 14 ++-- svx/uiconfig/ui/surfacewindow.ui | 114 ++++++++++++++++++++++++++++++ 6 files changed, 177 insertions(+), 49 deletions(-) create mode 100644 svx/uiconfig/ui/surfacewindow.ui diff --git a/include/svx/strings.hrc b/include/svx/strings.hrc index 171eb4053659..e9d79ff25f89 100644 --- a/include/svx/strings.hrc +++ b/include/svx/strings.hrc @@ -1032,10 +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_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") -#define RID_SVXSTR_METAL NC_("RID_SVXSTR_METAL", "Me~tal") #define RID_SVXSTR_DEPTH_0 NC_("RID_SVXSTR_DEPTH_0", "~0 cm") #define RID_SVXSTR_DEPTH_1 NC_("RID_SVXSTR_DEPTH_1", "~1 cm") #define RID_SVXSTR_DEPTH_2 NC_("RID_SVXSTR_DEPTH_2", "~2.5 cm") diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk index a7f943c2548c..e1f1783607c5 100644 --- a/svx/UIConfig_svx.mk +++ b/svx/UIConfig_svx.mk @@ -111,6 +111,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\ svx/uiconfig/ui/sidebarstylespanel \ svx/uiconfig/ui/sidebartextpanel \ svx/uiconfig/ui/stylemenu \ + svx/uiconfig/ui/surfacewindow \ svx/uiconfig/ui/tablewindow \ svx/uiconfig/ui/textcharacterspacingcontrol \ svx/uiconfig/ui/textcontrolchardialog \ diff --git a/svx/inc/bitmaps.hlst b/svx/inc/bitmaps.hlst index 648d86d356ff..9cbe6e66405e 100644 --- a/svx/inc/bitmaps.hlst +++ b/svx/inc/bitmaps.hlst @@ -74,10 +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_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" -#define RID_SVXBMP_METAL "svx/res/metal_16.png" #define RID_SVXBMP_DEPTH_0 "svx/res/extrusion0inch_16.png" #define RID_SVXBMP_DEPTH_1 "svx/res/extrusion05inch_16.png" #define RID_SVXBMP_DEPTH_2 "svx/res/extrusion1inch_16.png" diff --git a/svx/source/tbxctrls/extrusioncontrols.cxx b/svx/source/tbxctrls/extrusioncontrols.cxx index 76fcb3a5e048..18201c948d58 100644 --- a/svx/source/tbxctrls/extrusioncontrols.cxx +++ b/svx/source/tbxctrls/extrusioncontrols.cxx @@ -794,36 +794,37 @@ com_sun_star_comp_svx_ExtrusionLightingControl_get_implementation( static const char g_sExtrusionSurface[] = ".uno:ExtrusionSurface"; -ExtrusionSurfaceWindow::ExtrusionSurfaceWindow( - svt::ToolboxController& rController, - vcl::Window* pParentWindow) - : ToolbarMenu(rController.getFrameInterface(), pParentWindow, WB_STDPOPUP) - , mrController(rController) +ExtrusionSurfaceWindow::ExtrusionSurfaceWindow(svt::PopupWindowController* pControl, weld::Widget* pParent) + : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/surfacewindow.ui", "SurfaceWindow") + , mxControl(pControl) + , mxWireFrame(m_xBuilder->weld_radio_button("wireframe")) + , mxMatt(m_xBuilder->weld_radio_button("matt")) + , mxPlastic(m_xBuilder->weld_radio_button("plastic")) + , mxMetal(m_xBuilder->weld_radio_button("metal")) { - SetSelectHdl( LINK( this, ExtrusionSurfaceWindow, SelectHdl ) ); - - Image aImgSurface1(StockImage::Yes, RID_SVXBMP_WIRE_FRAME); - Image aImgSurface2(StockImage::Yes, RID_SVXBMP_MATTE); - Image aImgSurface3(StockImage::Yes, RID_SVXBMP_PLASTIC); - Image aImgSurface4(StockImage::Yes, RID_SVXBMP_METAL); - - appendEntry(0, SvxResId(RID_SVXSTR_WIREFRAME), aImgSurface1); - appendEntry(1, SvxResId(RID_SVXSTR_MATTE), aImgSurface2); - appendEntry(2, SvxResId(RID_SVXSTR_PLASTIC), aImgSurface3); - appendEntry(3, SvxResId(RID_SVXSTR_METAL), aImgSurface4); - - SetOutputSizePixel( getMenuSize() ); + mxWireFrame->connect_clicked(LINK(this, ExtrusionSurfaceWindow, SelectHdl)); + mxMatt->connect_clicked(LINK(this, ExtrusionSurfaceWindow, SelectHdl)); + mxPlastic->connect_clicked(LINK(this, ExtrusionSurfaceWindow, SelectHdl)); + mxMetal->connect_clicked(LINK(this, ExtrusionSurfaceWindow, SelectHdl)); AddStatusListener( g_sExtrusionSurface ); } +void ExtrusionSurfaceWindow::GrabFocus() +{ + mxWireFrame->grab_focus(); +} + void ExtrusionSurfaceWindow::implSetSurface( int nSurface, bool bEnabled ) { - for(int i = 0; i < 4; ++i) - { - checkEntry( i, (i == nSurface) && bEnabled ); - enableEntry( i, bEnabled ); - } + mxWireFrame->set_active(nSurface == 0 && bEnabled); + mxWireFrame->set_sensitive(bEnabled); + mxMatt->set_active(nSurface == 1 && bEnabled); + mxMatt->set_sensitive(bEnabled); + mxPlastic->set_active(nSurface == 2 && bEnabled); + mxPlastic->set_sensitive(bEnabled); + mxMetal->set_active(nSurface == 3 && bEnabled); + mxMetal->set_sensitive(bEnabled); } void ExtrusionSurfaceWindow::statusChanged( @@ -845,23 +846,27 @@ void ExtrusionSurfaceWindow::statusChanged( } } - -IMPL_LINK_NOARG(ExtrusionSurfaceWindow, SelectHdl, ToolbarMenu*, void) +IMPL_LINK_NOARG(ExtrusionSurfaceWindow, SelectHdl, weld::Button&, void) { - if ( IsInPopupMode() ) - EndPopupMode(); + sal_Int32 nSurface; + if (mxWireFrame->get_active()) + nSurface = 0; + else if (mxMatt->get_active()) + nSurface = 1; + else if (mxPlastic->get_active()) + nSurface = 2; + else + nSurface = 3; - sal_Int32 nSurface = getSelectedEntryId(); - if( nSurface >= 0 ) - { - Sequence< PropertyValue > aArgs( 1 ); - aArgs[0].Name = OUString(g_sExtrusionSurface).copy(5); - aArgs[0].Value <<= nSurface; + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = OUString(g_sExtrusionSurface).copy(5); + aArgs[0].Value <<= nSurface; - mrController.dispatchCommand( g_sExtrusionSurface, aArgs ); + mxControl->dispatchCommand( g_sExtrusionSurface, aArgs ); - implSetSurface( nSurface, true ); - } + implSetSurface( nSurface, true ); + + mxControl->EndPopupMode(); } ExtrusionSurfaceControl::ExtrusionSurfaceControl( @@ -875,9 +880,19 @@ ExtrusionSurfaceControl::ExtrusionSurfaceControl( { } +std::unique_ptr ExtrusionSurfaceControl::weldPopupWindow() +{ + return std::make_unique(this, m_pToolbar); +} + VclPtr ExtrusionSurfaceControl::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 af46a1ee395e..67d99359b5b8 100644 --- a/svx/source/tbxctrls/extrusioncontrols.hxx +++ b/svx/source/tbxctrls/extrusioncontrols.hxx @@ -170,17 +170,22 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; }; -class ExtrusionSurfaceWindow : public svtools::ToolbarMenu +class ExtrusionSurfaceWindow final : public WeldToolbarPopup { private: - svt::ToolboxController& mrController; + rtl::Reference mxControl; + std::unique_ptr mxWireFrame; + std::unique_ptr mxMatt; + std::unique_ptr mxPlastic; + std::unique_ptr mxMetal; - DECL_LINK( SelectHdl, ToolbarMenu*, void ); + DECL_LINK( SelectHdl, weld::Button&, void ); void implSetSurface( int nSurface, bool bEnabled ); public: - ExtrusionSurfaceWindow( svt::ToolboxController& rController, vcl::Window* pParentWindow ); + ExtrusionSurfaceWindow(svt::PopupWindowController* pControl, weld::Widget* pParentWindow); + virtual void GrabFocus() override; virtual void statusChanged( const css::frame::FeatureStateEvent& Event ) override; }; @@ -191,6 +196,7 @@ class ExtrusionSurfaceControl : public svt::PopupWindowController public: explicit ExtrusionSurfaceControl( 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/surfacewindow.ui b/svx/uiconfig/ui/surfacewindow.ui new file mode 100644 index 000000000000..d8ee6219e773 --- /dev/null +++ b/svx/uiconfig/ui/surfacewindow.ui @@ -0,0 +1,114 @@ + + + + + + True + False + svx/res/plastic_16.png + + + True + False + svx/res/matte_16.png + + + True + False + svx/res/metal_16.png + + + True + False + svx/res/wireframe_16.png + + + False + True + 4 + + + True + False + vertical + 6 + + + _Wire Frame + True + True + False + image4 + True + 0 + True + True + True + + + False + True + 0 + + + + + _Matt + True + True + False + image2 + True + 0 + True + True + wireframe + + + False + True + 1 + + + + + _Plastic + True + True + False + image1 + True + 0 + True + True + wireframe + + + False + True + 2 + + + + + Me_tal + True + True + False + image3 + True + 0 + True + True + wireframe + + + False + True + 3 + + + + + + -- cgit