[Libreoffice-commits] core.git: sd/inc sd/source sd/uiconfig sd/UIConfig_simpress.mk

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Jan 27 19:26:22 UTC 2020


 sd/UIConfig_simpress.mk                           |    1 
 sd/inc/strings.hrc                                |    2 
 sd/source/ui/controller/displaymodecontroller.cxx |  147 +++++++++-------------
 sd/uiconfig/simpress/ui/displaywindow.ui          |  134 ++++++++++++++++++++
 4 files changed, 197 insertions(+), 87 deletions(-)

New commits:
commit f6154457c704f75d37ed216d7ac2dbda8fa0c5c4
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Jan 27 10:57:31 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Jan 27 20:25:31 2020 +0100

    weld DisplayModeToolbarMenu
    
    Change-Id: I210c608d2493c5b8b1ccf32af39c51b144bb45e9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87509
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sd/UIConfig_simpress.mk b/sd/UIConfig_simpress.mk
index 09d97c630000..fe0dcce15873 100644
--- a/sd/UIConfig_simpress.mk
+++ b/sd/UIConfig_simpress.mk
@@ -115,6 +115,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/simpress,\
 	sd/uiconfig/simpress/ui/customanimationtexttab \
 	sd/uiconfig/simpress/ui/customslideshows \
 	sd/uiconfig/simpress/ui/definecustomslideshow \
+	sd/uiconfig/simpress/ui/displaywindow \
 	sd/uiconfig/simpress/ui/dlgfield \
 	sd/uiconfig/simpress/ui/dockinganimation \
 	sd/uiconfig/simpress/ui/effectmenu \
diff --git a/sd/inc/strings.hrc b/sd/inc/strings.hrc
index fe3e182f2b2f..9c645f7a6250 100644
--- a/sd/inc/strings.hrc
+++ b/sd/inc/strings.hrc
@@ -62,8 +62,6 @@
 #define STR_AUTOLAYOUT_HANDOUT4                         NC_("STR_AUTOLAYOUT_HANDOUT4", "Four Slides")
 #define STR_AUTOLAYOUT_HANDOUT6                         NC_("STR_AUTOLAYOUT_HANDOUT6", "Six Slides")
 #define STR_AUTOLAYOUT_HANDOUT9                         NC_("STR_AUTOLAYOUT_HANDOUT9", "Nine Slides")
-#define STR_DISPLAYMODE_EDITMODES                       NC_("STR_DISPLAYMODE_EDITMODES", "Edit Modes")
-#define STR_DISPLAYMODE_MASTERMODES                     NC_("STR_DISPLAYMODE_MASTERMODES", "Master Modes")
 #define STR_AUTOLAYOUT_NOTES                            NC_("STR_AUTOLAYOUT_NOTES", "Notes")
 #define STR_TRANSFORM                                   NC_("STR_TRANSFORM", "Transform")
 #define STR_LINEEND                                     NC_("STR_LINEEND", "Line Ends")
diff --git a/sd/source/ui/controller/displaymodecontroller.cxx b/sd/source/ui/controller/displaymodecontroller.cxx
index 7fc63d053e4d..1513e543fbb9 100644
--- a/sd/source/ui/controller/displaymodecontroller.cxx
+++ b/sd/source/ui/controller/displaymodecontroller.cxx
@@ -36,6 +36,7 @@ class DisplayModeController : public svt::PopupWindowController
 public:
     explicit DisplayModeController( 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
@@ -48,22 +49,25 @@ public:
     void setToolboxItemImage(const OUString& rImage);
 };
 
-class DisplayModeToolbarMenu : public svtools::ToolbarMenu
+class DisplayModeToolbarMenu final : public WeldToolbarPopup
 {
 public:
-    DisplayModeToolbarMenu( DisplayModeController& rController, vcl::Window* pParent );
-    virtual ~DisplayModeToolbarMenu() override;
-    virtual void dispose() override;
-
-protected:
-    DECL_LINK( SelectToolbarMenuHdl, ToolbarMenu*, void );
-    DECL_LINK( SelectValueSetHdl, ValueSet*, void );
-    void SelectHdl(void const *);
+    DisplayModeToolbarMenu(DisplayModeController* pControl, weld::Widget* pParent);
+    virtual void GrabFocus() override
+    {
+        mxDisplayModeSet1->GrabFocus();
+    }
 
 private:
-    DisplayModeController& mrController;
-    VclPtr<ValueSet> mpDisplayModeSet1;
-    VclPtr<ValueSet> mpDisplayModeSet2;
+    rtl::Reference<DisplayModeController> mxControl;
+    std::unique_ptr<weld::Frame> mxFrame1;
+    std::unique_ptr<SvtValueSet> mxDisplayModeSet1;
+    std::unique_ptr<weld::CustomWeld> mxDisplayModeSetWin1;
+    std::unique_ptr<weld::Frame> mxFrame2;
+    std::unique_ptr<SvtValueSet> mxDisplayModeSet2;
+    std::unique_ptr<weld::CustomWeld> mxDisplayModeSetWin2;
+
+    DECL_LINK(SelectValueSetHdl, SvtValueSet*, void);
 };
 
 struct snewfoil_value_info
@@ -115,7 +119,7 @@ static const snewfoil_value_info mastermodes[] =
 };
 
 
-static void fillLayoutValueSet( ValueSet* pValue, const snewfoil_value_info* pInfo )
+static void fillLayoutValueSet(SvtValueSet* pValue, const snewfoil_value_info* pInfo)
 {
     Size aLayoutItemSize;
     for( ; pInfo->mnId; pInfo++ )
@@ -130,97 +134,60 @@ static void fillLayoutValueSet( ValueSet* pValue, const snewfoil_value_info* pIn
     }
 
     aLayoutItemSize = pValue->CalcItemSizePixel( aLayoutItemSize );
-    pValue->SetSizePixel( pValue->CalcWindowSizePixel( aLayoutItemSize ) );
-}
+    Size aSize(pValue->CalcWindowSizePixel(aLayoutItemSize));
 
-DisplayModeToolbarMenu::DisplayModeToolbarMenu( DisplayModeController& rController, vcl::Window* pParent )
-: svtools::ToolbarMenu( rController.getFrameInterface(), pParent, WB_CLIPCHILDREN )
-, mrController( rController )
-, mpDisplayModeSet1( nullptr )
-, mpDisplayModeSet2( nullptr )
-{
     const sal_Int32 LAYOUT_BORDER_PIX = 7;
+    aSize.AdjustWidth((pValue->GetColCount() + 1) * LAYOUT_BORDER_PIX );
+    aSize.AdjustHeight((pValue->GetLineCount() +1) * LAYOUT_BORDER_PIX );
 
-    OUString aTitle1( SdResId( STR_DISPLAYMODE_EDITMODES ) );
-    OUString aTitle2( SdResId( STR_DISPLAYMODE_MASTERMODES ) );
+    pValue->GetDrawingArea()->set_size_request(aSize.Width(), aSize.Height());
+    pValue->SetOutputSizePixel(aSize);
+}
 
-    SetSelectHdl( LINK( this, DisplayModeToolbarMenu, SelectToolbarMenuHdl ) );
+DisplayModeToolbarMenu::DisplayModeToolbarMenu(DisplayModeController* pControl, weld::Widget* pParent)
+    : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "modules/simpress/ui/displaywindow.ui", "DisplayWindow")
+    , mxControl(pControl)
+    , mxFrame1(m_xBuilder->weld_frame("editframe"))
+    , mxDisplayModeSet1(new SvtValueSet(nullptr))
+    , mxDisplayModeSetWin1(new weld::CustomWeld(*m_xBuilder, "valueset1", *mxDisplayModeSet1))
+    , mxFrame2(m_xBuilder->weld_frame("masterframe"))
+    , mxDisplayModeSet2(new SvtValueSet(nullptr))
+    , mxDisplayModeSetWin2(new weld::CustomWeld(*m_xBuilder, "valueset2", *mxDisplayModeSet2))
+{
+    mxDisplayModeSet1->SetStyle(WB_TABSTOP | WB_MENUSTYLEVALUESET | WB_FLATVALUESET | WB_NOBORDER | WB_NO_DIRECTSELECT);
+    mxDisplayModeSet1->SetStyle(WB_TABSTOP | WB_MENUSTYLEVALUESET | WB_FLATVALUESET | WB_NOBORDER | WB_NO_DIRECTSELECT);
 
-    mpDisplayModeSet1 = createEmptyValueSetControl();
-    mpDisplayModeSet1->SetSelectHdl( LINK( this, DisplayModeToolbarMenu, SelectValueSetHdl ) );
+    mxDisplayModeSet1->SetSelectHdl( LINK( this, DisplayModeToolbarMenu, SelectValueSetHdl ) );
+    mxDisplayModeSet2->SetSelectHdl( LINK( this, DisplayModeToolbarMenu, SelectValueSetHdl ) );
 
     sal_Int16 nColCount = 2;
-    mpDisplayModeSet1->SetColCount( nColCount );
-    fillLayoutValueSet( mpDisplayModeSet1, &editmodes[0] );
-
-    Size aSize( mpDisplayModeSet1->GetOutputSizePixel() );
-    aSize.AdjustWidth((mpDisplayModeSet1->GetColCount() + 1) * LAYOUT_BORDER_PIX );
-    aSize.AdjustHeight((mpDisplayModeSet1->GetLineCount() +1) * LAYOUT_BORDER_PIX );
-    mpDisplayModeSet1->SetOutputSizePixel( aSize );
-
-    appendEntry( -1, aTitle1 );
-    appendEntry( 1, mpDisplayModeSet1 );
-
-    mpDisplayModeSet2 = createEmptyValueSetControl();
-
-    mpDisplayModeSet2->SetSelectHdl( LINK( this, DisplayModeToolbarMenu, SelectValueSetHdl ) );
-    mpDisplayModeSet2->SetColCount( nColCount );
-
-    fillLayoutValueSet( mpDisplayModeSet2, &mastermodes[0] );
-
-    aSize = mpDisplayModeSet2->GetOutputSizePixel();
-    aSize.AdjustWidth((mpDisplayModeSet2->GetColCount() + 1) * LAYOUT_BORDER_PIX );
-    aSize.AdjustHeight((mpDisplayModeSet2->GetLineCount() + 1) * LAYOUT_BORDER_PIX );
-    mpDisplayModeSet2->SetOutputSizePixel( aSize );
-
-    appendEntry( -1, aTitle2 );
-    appendEntry( 2, mpDisplayModeSet2 );
-
-    SetOutputSizePixel( getMenuSize() );
-}
 
-DisplayModeToolbarMenu::~DisplayModeToolbarMenu()
-{
-    disposeOnce();
-}
+    mxDisplayModeSet1->SetColCount( nColCount );
+    fillLayoutValueSet( mxDisplayModeSet1.get(), &editmodes[0] );
 
-void DisplayModeToolbarMenu::dispose()
-{
-    mpDisplayModeSet1.clear();
-    mpDisplayModeSet2.clear();
-    svtools::ToolbarMenu::dispose();
+    mxDisplayModeSet2->SetColCount( nColCount );
+    fillLayoutValueSet( mxDisplayModeSet2.get(), &mastermodes[0] );
 }
 
-IMPL_LINK( DisplayModeToolbarMenu, SelectValueSetHdl, ValueSet*, pControl, void )
+IMPL_LINK( DisplayModeToolbarMenu, SelectValueSetHdl, SvtValueSet*, pControl, void )
 {
-    SelectHdl(pControl);
-}
-IMPL_LINK( DisplayModeToolbarMenu, SelectToolbarMenuHdl, ToolbarMenu *, pControl, void )
-{
-    SelectHdl(pControl);
-}
-
-void DisplayModeToolbarMenu::SelectHdl(void const * pControl)
-{
-    if ( IsInPopupMode() )
-        EndPopupMode();
-
     OUString sCommandURL;
     OUString sImage;
 
-    if( pControl == mpDisplayModeSet1 ) {
-        sCommandURL = OUString::createFromAscii(editmodes[mpDisplayModeSet1->GetSelectedItemId() - 1 ].msUnoCommand);
-        sImage = OUString::createFromAscii(editmodes[mpDisplayModeSet1->GetSelectedItemId() - 1 ].msBmpResId);
+    if( pControl == mxDisplayModeSet1.get() ) {
+        sCommandURL = OUString::createFromAscii(editmodes[mxDisplayModeSet1->GetSelectedItemId() - 1 ].msUnoCommand);
+        sImage = OUString::createFromAscii(editmodes[mxDisplayModeSet1->GetSelectedItemId() - 1 ].msBmpResId);
     }
-    else if( pControl == mpDisplayModeSet2 ) {
-        sCommandURL = OUString::createFromAscii(mastermodes[mpDisplayModeSet2->GetSelectedItemId() - 5 ].msUnoCommand);
-        sImage = OUString::createFromAscii(mastermodes[mpDisplayModeSet2->GetSelectedItemId() - 5 ].msBmpResId);
+    else if( pControl == mxDisplayModeSet2.get() ) {
+        sCommandURL = OUString::createFromAscii(mastermodes[mxDisplayModeSet2->GetSelectedItemId() - 5 ].msUnoCommand);
+        sImage = OUString::createFromAscii(mastermodes[mxDisplayModeSet2->GetSelectedItemId() - 5 ].msBmpResId);
     }
 
     if (!sCommandURL.isEmpty())
-        mrController.dispatchCommand( sCommandURL, Sequence< PropertyValue >() );
+        mxControl->dispatchCommand( sCommandURL, Sequence< PropertyValue >() );
 
-    mrController.setToolboxItemImage(sImage);
+    mxControl->setToolboxItemImage(sImage);
+    mxControl->EndPopupMode();
 }
 
 DisplayModeController::DisplayModeController( const css::uno::Reference< css::uno::XComponentContext >& rxContext )
@@ -238,9 +205,19 @@ void SAL_CALL DisplayModeController::initialize( const css::uno::Sequence< css::
     setToolboxItemImage(BMP_DISPLAYMODE_SLIDE);
 }
 
+std::unique_ptr<WeldToolbarPopup> DisplayModeController::weldPopupWindow()
+{
+    return std::make_unique<sd::DisplayModeToolbarMenu>(this, m_pToolbar);
+}
+
 VclPtr<vcl::Window> DisplayModeController::createVclPopupWindow( vcl::Window* pParent )
 {
-    return VclPtr<sd::DisplayModeToolbarMenu>::Create( *this, pParent );
+    mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
+        std::make_unique<sd::DisplayModeToolbarMenu>(this, pParent->GetFrameWeld()));
+
+    mxInterimPopover->Show();
+
+    return mxInterimPopover;
 }
 
 void DisplayModeController::setToolboxItemImage(const OUString& rImage)
diff --git a/sd/uiconfig/simpress/ui/displaywindow.ui b/sd/uiconfig/simpress/ui/displaywindow.ui
new file mode 100644
index 000000000000..71522c09d189
--- /dev/null
+++ b/sd/uiconfig/simpress/ui/displaywindow.ui
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface domain="sd">
+  <requires lib="gtk+" version="3.18"/>
+  <object class="GtkPopover" id="DisplayWindow">
+    <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="GtkFrame" id="editframe">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">True</property>
+            <property name="vexpand">True</property>
+            <property name="label_xalign">0</property>
+            <property name="shadow_type">none</property>
+            <child>
+              <object class="GtkAlignment">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="top_padding">6</property>
+                <child>
+                  <object class="GtkScrolledWindow" id="valuesetwin1">
+                    <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="valueset1">
+                            <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>
+                </child>
+              </object>
+            </child>
+            <child type="label">
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes" context="displaywindow|STR_DISPLAYMODE_EDITMODES">Edit Modes</property>
+                <attributes>
+                  <attribute name="weight" value="bold"/>
+                </attributes>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkFrame" id="masterframe">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">True</property>
+            <property name="vexpand">True</property>
+            <property name="label_xalign">0</property>
+            <property name="shadow_type">none</property>
+            <child>
+              <object class="GtkAlignment">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="top_padding">6</property>
+                <child>
+                  <object class="GtkScrolledWindow" id="valuesetwin2">
+                    <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="valueset2">
+                            <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>
+                </child>
+              </object>
+            </child>
+            <child type="label">
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes" context="displaywindow|STR_DISPLAYMODE_MASTERMODES">Master Modes</property>
+                <attributes>
+                  <attribute name="weight" value="bold"/>
+                </attributes>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>


More information about the Libreoffice-commits mailing list