diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-01-27 12:10:51 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-01-27 20:26:51 +0100 |
commit | 41e024578469d9c452300447610a3e9c6e50e211 (patch) | |
tree | a5501396412ce03afd28c348fa7ac799222699e6 | |
parent | f6154457c704f75d37ed216d7ac2dbda8fa0c5c4 (diff) |
weld ExtrusionDirectionWindow
Change-Id: I94f6d602f489d34f9b35ee2ec20e7fdf62e50adf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87519
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | include/svx/strings.hrc | 2 | ||||
-rw-r--r-- | svx/UIConfig_svx.mk | 1 | ||||
-rw-r--r-- | svx/inc/bitmaps.hlst | 2 | ||||
-rw-r--r-- | svx/source/tbxctrls/extrusioncontrols.cxx | 163 | ||||
-rw-r--r-- | svx/source/tbxctrls/extrusioncontrols.hxx | 22 | ||||
-rw-r--r-- | svx/uiconfig/ui/directionwindow.ui | 97 |
6 files changed, 178 insertions, 109 deletions
diff --git a/include/svx/strings.hrc b/include/svx/strings.hrc index dc7122a40a9a..2d5812626993 100644 --- a/include/svx/strings.hrc +++ b/include/svx/strings.hrc @@ -1023,8 +1023,6 @@ #define RID_SVXSTR_QRY_PRINT_ALL NC_("RID_SVXSTR_QRY_PRINT_ALL", "~All") #define RID_SVXSTR_QRY_PRINT_SELECTION NC_("RID_SVXSTR_QRY_PRINT_SELECTION", "~Selection") -#define RID_SVXSTR_PERSPECTIVE NC_("RID_SVXSTR_PERSPECTIVE", "~Perspective") -#define RID_SVXSTR_PARALLEL NC_("RID_SVXSTR_PARALLEL", "P~arallel") #define RID_SVXSTR_DIRECTION_NW NC_("RID_SVXSTR_DIRECTION_NW", "Extrusion North-West") #define RID_SVXSTR_DIRECTION_N NC_("RID_SVXSTR_DIRECTION_N", "Extrusion North") #define RID_SVXSTR_DIRECTION_NE NC_("RID_SVXSTR_DIRECTION_NE", "Extrusion North-East") diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk index 56192ca71601..afad7bb8f9ba 100644 --- a/svx/UIConfig_svx.mk +++ b/svx/UIConfig_svx.mk @@ -36,6 +36,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\ svx/uiconfig/ui/defaultshapespanel \ svx/uiconfig/ui/deleteheaderdialog \ svx/uiconfig/ui/deletefooterdialog \ + svx/uiconfig/ui/directionwindow \ svx/uiconfig/ui/docking3deffects \ svx/uiconfig/ui/dockingcolorreplace \ svx/uiconfig/ui/dockingfontwork \ diff --git a/svx/inc/bitmaps.hlst b/svx/inc/bitmaps.hlst index 7316b88f7fec..94bd0d116b17 100644 --- a/svx/inc/bitmaps.hlst +++ b/svx/inc/bitmaps.hlst @@ -49,8 +49,6 @@ #define RID_SVXBMP_DIRECTION_DIRECTION_SW "svx/res/directionsouthwest_22.png" #define RID_SVXBMP_DIRECTION_DIRECTION_S "svx/res/directionsouth_22.png" #define RID_SVXBMP_DIRECTION_DIRECTION_SE "svx/res/directionsoutheast_22.png" -#define RID_SVXBMP_PERSPECTIVE "svx/res/perspective_16.png" -#define RID_SVXBMP_PARALLEL "svx/res/parallel_16.png" #define RID_SVXBMP_LIGHT_OFF_FROM_TOP_LEFT "svx/res/lightofffromtopleft_22.png" #define RID_SVXBMP_LIGHT_OFF_FROM_TOP "svx/res/lightofffromtop_22.png" #define RID_SVXBMP_LIGHT_OFF_FROM_TOP_RIGHT "svx/res/lightofffromtopright_22.png" diff --git a/svx/source/tbxctrls/extrusioncontrols.cxx b/svx/source/tbxctrls/extrusioncontrols.cxx index d81e40d26a53..3bdfba02bd63 100644 --- a/svx/source/tbxctrls/extrusioncontrols.cxx +++ b/svx/source/tbxctrls/extrusioncontrols.cxx @@ -122,105 +122,83 @@ static const char* aDirectionStrs[] = }; ExtrusionDirectionWindow::ExtrusionDirectionWindow( - svt::ToolboxController& rController, - vcl::Window* pParentWindow -) - : ToolbarMenu(rController.getFrameInterface(), pParentWindow, WB_STDPOPUP) - , mrController(rController) - , maImgPerspective(StockImage::Yes, RID_SVXBMP_PERSPECTIVE) - , maImgParallel(StockImage::Yes, RID_SVXBMP_PARALLEL) + svt::PopupWindowController* pControl, + weld::Widget* pParent) + : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/directionwindow.ui", "DirectionWindow") + , mxControl(pControl) + , mxDirectionSet(new SvtValueSet(nullptr)) + , mxDirectionSetWin(new weld::CustomWeld(*m_xBuilder, "valueset", *mxDirectionSet)) + , mxPerspective(m_xBuilder->weld_radio_button("perspective")) + , mxParallel(m_xBuilder->weld_radio_button("parallel")) { + mxDirectionSet->SetStyle(WB_TABSTOP | WB_MENUSTYLEVALUESET | WB_FLATVALUESET | WB_NOBORDER | WB_NO_DIRECTSELECT); + for (sal_uInt16 i = DIRECTION_NW; i <= DIRECTION_SE; ++i) { maImgDirection[i] = Image(StockImage::Yes, aDirectionBmps[i]); } - SetSelectHdl( LINK( this, ExtrusionDirectionWindow, SelectToolbarMenuHdl ) ); - mpDirectionSet = createEmptyValueSetControl(); - - mpDirectionSet->SetSelectHdl( LINK( this, ExtrusionDirectionWindow, SelectValueSetHdl ) ); - mpDirectionSet->SetColCount( 3 ); - mpDirectionSet->EnableFullItemMode( false ); + mxDirectionSet->SetSelectHdl( LINK( this, ExtrusionDirectionWindow, SelectValueSetHdl ) ); + mxDirectionSet->SetColCount( 3 ); + mxDirectionSet->EnableFullItemMode( false ); for (sal_uInt16 i = DIRECTION_NW; i <= DIRECTION_SE; ++i) { - mpDirectionSet->InsertItem(i + 1, maImgDirection[i], SvxResId(aDirectionStrs[i])); + mxDirectionSet->InsertItem(i + 1, maImgDirection[i], SvxResId(aDirectionStrs[i])); } - mpDirectionSet->SetOutputSizePixel(Size(72, 72)); - - appendEntry(2, mpDirectionSet ); - appendSeparator(); - appendEntry(0, SvxResId(RID_SVXSTR_PERSPECTIVE), maImgPerspective); - appendEntry(1, SvxResId(RID_SVXSTR_PARALLEL), maImgParallel); + Size aSize(72, 72); + mxDirectionSet->GetDrawingArea()->set_size_request(aSize.Width(), aSize.Height()); + mxDirectionSet->SetOutputSizePixel(aSize); - SetOutputSizePixel( getMenuSize() ); + mxPerspective->connect_clicked(LINK(this, ExtrusionDirectionWindow, SelectToolbarMenuHdl)); + mxParallel->connect_clicked(LINK(this, ExtrusionDirectionWindow, SelectToolbarMenuHdl)); AddStatusListener( g_sExtrusionDirection ); AddStatusListener( g_sExtrusionProjection ); } -ExtrusionDirectionWindow::~ExtrusionDirectionWindow() +void ExtrusionDirectionWindow::GrabFocus() { - disposeOnce(); + mxDirectionSet->GrabFocus(); } -void ExtrusionDirectionWindow::dispose() +ExtrusionDirectionWindow::~ExtrusionDirectionWindow() { - mpDirectionSet.clear(); - ToolbarMenu::dispose(); } -void ExtrusionDirectionWindow::DataChanged( const DataChangedEvent& rDCEvt ) +void ExtrusionDirectionWindow::implSetDirection( sal_Int32 nSkew, bool bEnabled ) { - ToolbarMenu::DataChanged( rDCEvt ); - - if( ( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) && ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE ) ) + sal_uInt16 nItemId; + for( nItemId = DIRECTION_NW; nItemId <= DIRECTION_SE; nItemId++ ) { - for( sal_uInt16 i = DIRECTION_NW; i <= DIRECTION_SE; i++ ) - { - mpDirectionSet->SetItemImage( i+1, maImgDirection[ i ] ); - } - - setEntryImage( 0, maImgPerspective ); - setEntryImage( 1, maImgParallel ); + if( gSkewList[nItemId] == nSkew ) + break; } -} - -void ExtrusionDirectionWindow::implSetDirection( sal_Int32 nSkew, bool bEnabled ) -{ - if( mpDirectionSet ) + if( nItemId <= DIRECTION_SE ) { - sal_uInt16 nItemId; - for( nItemId = DIRECTION_NW; nItemId <= DIRECTION_SE; nItemId++ ) - { - if( gSkewList[nItemId] == nSkew ) - break; - } - - if( nItemId <= DIRECTION_SE ) - { - mpDirectionSet->SelectItem( nItemId+1 ); - } - else - { - mpDirectionSet->SetNoSelection(); - } + mxDirectionSet->SelectItem( nItemId+1 ); + } + else + { + mxDirectionSet->SetNoSelection(); } - enableEntry( 2, bEnabled ); -} + if (bEnabled) + mxDirectionSet->Enable(); + else + mxDirectionSet->Disable(); +} void ExtrusionDirectionWindow::implSetProjection( sal_Int32 nProjection, bool bEnabled ) { - checkEntry( 0, (nProjection == 0) && bEnabled ); - checkEntry( 1, (nProjection == 1 ) && bEnabled ); - enableEntry( 0, bEnabled ); - enableEntry( 1, bEnabled ); + mxPerspective->set_active(nProjection == 0 && bEnabled); + mxParallel->set_active(nProjection == 1 && bEnabled); + mxPerspective->set_sensitive(bEnabled); + mxParallel->set_sensitive(bEnabled); } - void ExtrusionDirectionWindow::statusChanged( const css::frame::FeatureStateEvent& Event ) @@ -253,41 +231,29 @@ void ExtrusionDirectionWindow::statusChanged( } } - -IMPL_LINK( ExtrusionDirectionWindow, SelectValueSetHdl, ValueSet*, pControl, void ) -{ - SelectHdl(pControl); -} -IMPL_LINK( ExtrusionDirectionWindow, SelectToolbarMenuHdl, ToolbarMenu*, pControl, void ) +IMPL_LINK_NOARG(ExtrusionDirectionWindow, SelectValueSetHdl, SvtValueSet*, void) { - SelectHdl(pControl); + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = OUString(g_sExtrusionDirection).copy(5); + aArgs[0].Value <<= gSkewList[mxDirectionSet->GetSelectedItemId()-1]; + + mxControl->dispatchCommand( g_sExtrusionDirection, aArgs ); + + mxControl->EndPopupMode(); } -void ExtrusionDirectionWindow::SelectHdl(void const * pControl) + +IMPL_LINK_NOARG(ExtrusionDirectionWindow, SelectToolbarMenuHdl, weld::Button&, void) { - if ( IsInPopupMode() ) - EndPopupMode(); + int nProjection = mxPerspective->get_active() ? 0 : 1; - if( pControl == mpDirectionSet ) - { - Sequence< PropertyValue > aArgs( 1 ); - aArgs[0].Name = OUString(g_sExtrusionDirection).copy(5); - aArgs[0].Value <<= gSkewList[mpDirectionSet->GetSelectedItemId()-1]; + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = OUString(g_sExtrusionProjection).copy(5); + aArgs[0].Value <<= static_cast<sal_Int32>(nProjection); - mrController.dispatchCommand( g_sExtrusionDirection, aArgs ); - } - else - { - int nProjection = getSelectedEntryId(); - if( (nProjection >= 0) && (nProjection < 2 ) ) - { - Sequence< PropertyValue > aArgs( 1 ); - aArgs[0].Name = OUString(g_sExtrusionProjection).copy(5); - aArgs[0].Value <<= static_cast<sal_Int32>(nProjection); + mxControl->dispatchCommand( g_sExtrusionProjection, aArgs ); + implSetProjection( nProjection, true ); - mrController.dispatchCommand( g_sExtrusionProjection, aArgs ); - implSetProjection( nProjection, true ); - } - } + mxControl->EndPopupMode(); } ExtrusionDirectionControl::ExtrusionDirectionControl( @@ -300,10 +266,19 @@ ExtrusionDirectionControl::ExtrusionDirectionControl( { } +std::unique_ptr<WeldToolbarPopup> ExtrusionDirectionControl::weldPopupWindow() +{ + return std::make_unique<ExtrusionDirectionWindow>(this, m_pToolbar); +} VclPtr<vcl::Window> ExtrusionDirectionControl::createVclPopupWindow( vcl::Window* pParent ) { - return VclPtr<ExtrusionDirectionWindow>::Create( *this, pParent ); + mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent, + std::make_unique<ExtrusionDirectionWindow>(this, pParent->GetFrameWeld())); + + mxInterimPopover->Show(); + + return mxInterimPopover; } // XInitialization diff --git a/svx/source/tbxctrls/extrusioncontrols.hxx b/svx/source/tbxctrls/extrusioncontrols.hxx index db901dc82fe7..4dceea5e9848 100644 --- a/svx/source/tbxctrls/extrusioncontrols.hxx +++ b/svx/source/tbxctrls/extrusioncontrols.hxx @@ -47,26 +47,26 @@ class ValueSet; namespace svx { -class ExtrusionDirectionWindow : public svtools::ToolbarMenu +class ExtrusionDirectionWindow final : public WeldToolbarPopup { public: - ExtrusionDirectionWindow( svt::ToolboxController& rController, vcl::Window* pParentWindow ); + ExtrusionDirectionWindow(svt::PopupWindowController* pControl, weld::Widget* pParentWindow); + virtual void GrabFocus() override; virtual ~ExtrusionDirectionWindow() override; - virtual void dispose() override; virtual void statusChanged( const css::frame::FeatureStateEvent& Event ) override; - virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; private: - svt::ToolboxController& mrController; - VclPtr<ValueSet> mpDirectionSet; + rtl::Reference<svt::PopupWindowController> mxControl; + std::unique_ptr<SvtValueSet> mxDirectionSet; + std::unique_ptr<weld::CustomWeld> mxDirectionSetWin; + std::unique_ptr<weld::RadioButton> mxPerspective; + std::unique_ptr<weld::RadioButton> mxParallel; Image maImgDirection[9]; - Image const maImgPerspective; - Image const maImgParallel; - 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 *); void implSetDirection( sal_Int32 nSkew, bool bEnabled ); @@ -74,12 +74,12 @@ private: }; - class ExtrusionDirectionControl : public svt::PopupWindowController { public: explicit ExtrusionDirectionControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override; virtual VclPtr<vcl::Window> createVclPopupWindow( vcl::Window* pParent ) override; // XInitialization diff --git a/svx/uiconfig/ui/directionwindow.ui b/svx/uiconfig/ui/directionwindow.ui new file mode 100644 index 000000000000..831fd84ce408 --- /dev/null +++ b/svx/uiconfig/ui/directionwindow.ui @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.1 --> +<interface domain="svx"> + <requires lib="gtk+" version="3.18"/> + <object class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">svx/res/perspective_16.png</property> + </object> + <object class="GtkImage" id="image2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">svx/res/parallel_16.png</property> + </object> + <object class="GtkPopover" id="DirectionWindow"> + <property name="can_focus">False</property> + <property name="no_show_all">True</property> + <property name="border_width">4</property> + <child> + <object class="GtkBox" id="container"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkScrolledWindow" id="valuesetwin"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="hscrollbar_policy">never</property> + <property name="vscrollbar_policy">never</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkViewport"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkDrawingArea" id="valueset"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="perspective"> + <property name="label" translatable="yes" context="directionwindow|RID_SVXSTR_PERSPECTIVE">_Perspective</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="image">image1</property> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="always_show_image">True</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="parallel"> + <property name="label" translatable="yes" context="dockingwindow|RID_SVXSTR_PARALLEL">P_arallel</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="image">image2</property> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="always_show_image">True</property> + <property name="draw_indicator">True</property> + <property name="group">perspective</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + </child> + </object> +</interface> |