[Libreoffice-commits] core.git: 2 commits - sc/source sc/uiconfig sc/UIConfig_scalc.mk vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Feb 13 13:52:40 UTC 2020


 sc/UIConfig_scalc.mk                    |    1 
 sc/source/ui/cctrl/tbzoomsliderctrl.cxx |   62 +++++++++++++++++++++-----------
 sc/source/ui/inc/tbzoomsliderctrl.hxx   |   31 +++++++++++-----
 sc/uiconfig/scalc/ui/zoombox.ui         |   25 ++++++++++++
 vcl/unx/gtk3/gtk3gtkinst.cxx            |    7 +--
 5 files changed, 93 insertions(+), 33 deletions(-)

New commits:
commit bcd7eee9e074be5ffe153814664c8f0faf923f6b
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Feb 12 21:17:48 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Feb 13 14:52:16 2020 +0100

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

diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk
index 466402c958b7..7268ec8013f7 100644
--- a/sc/UIConfig_scalc.mk
+++ b/sc/UIConfig_scalc.mk
@@ -243,6 +243,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
 	sc/uiconfig/scalc/ui/validationcriteriapage \
 	sc/uiconfig/scalc/ui/validationhelptabpage \
 	sc/uiconfig/scalc/ui/xmlsourcedialog \
+	sc/uiconfig/scalc/ui/zoombox \
 	sc/uiconfig/scalc/ui/ztestdialog \
 ))
 
diff --git a/sc/source/ui/cctrl/tbzoomsliderctrl.cxx b/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
index 94de56024b03..7ff3c26035c6 100644
--- a/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
+++ b/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
@@ -79,13 +79,13 @@ VclPtr<vcl::Window> ScZoomSliderControl::CreateItemWindow( vcl::Window *pParent
 {
     // #i98000# Don't try to get a value via SfxViewFrame::Current here.
     // The view's value is always notified via StateChanged later.
-    VclPtrInstance<ScZoomSliderWnd> pSlider( pParent,
+    VclPtrInstance<ScZoomSliderWnd> xSlider( pParent,
         css::uno::Reference< css::frame::XDispatchProvider >( m_xFrame->getController(),
         css::uno::UNO_QUERY ), 100 );
-    return pSlider.get();
+    return xSlider;
 }
 
-struct ScZoomSliderWnd::ScZoomSliderWnd_Impl
+struct ScZoomSlider::ScZoomSliderWnd_Impl
 {
     sal_uInt16                   mnCurrentZoom;
     sal_uInt16                   mnMinZoom;
@@ -124,7 +124,7 @@ const long nSliderXOffset   = 20;
 const long nSnappingEpsilon = 5; // snapping epsilon in pixels
 const long nSnappingPointsMinDist = nSnappingEpsilon; // minimum distance of two adjacent snapping points
 
-sal_uInt16 ScZoomSliderWnd::Offset2Zoom( long nOffset ) const
+sal_uInt16 ScZoomSlider::Offset2Zoom( long nOffset ) const
 {
     Size aSliderWindowSize = GetOutputSizePixel();
     const long nControlWidth = aSliderWindowSize.Width();
@@ -176,7 +176,7 @@ sal_uInt16 ScZoomSliderWnd::Offset2Zoom( long nOffset ) const
     return nRet;
 }
 
-long ScZoomSliderWnd::Zoom2Offset( sal_uInt16 nCurrentZoom ) const
+long ScZoomSlider::Zoom2Offset( sal_uInt16 nCurrentZoom ) const
 {
     Size aSliderWindowSize = GetOutputSizePixel();
     const long nControlWidth = aSliderWindowSize.Width();
@@ -205,16 +205,16 @@ long ScZoomSliderWnd::Zoom2Offset( sal_uInt16 nCurrentZoom ) const
 ScZoomSliderWnd::ScZoomSliderWnd( vcl::Window* pParent,
                 const css::uno::Reference< css::frame::XDispatchProvider >& rDispatchProvider,
                 sal_uInt16 nCurrentZoom ):
-                Window( pParent ),
-                mpImpl( new ScZoomSliderWnd_Impl( nCurrentZoom ) ),
-                aLogicalSize( 115, 40 ),
-                m_xDispatchProvider( rDispatchProvider )
+                InterimItemWindow(pParent, "modules/scalc/ui/zoombox.ui", "ZoomBox"),
+                mxWidget(new ScZoomSlider(rDispatchProvider, nCurrentZoom)),
+                mxWeld(new weld::CustomWeld(*m_xBuilder, "zoom", *mxWidget)),
+                aLogicalSize( 115, 40 )
 {
-    mpImpl->maSliderButton      = Image(StockImage::Yes, RID_SVXBMP_SLIDERBUTTON);
-    mpImpl->maIncreaseButton    = Image(StockImage::Yes, RID_SVXBMP_SLIDERINCREASE);
-    mpImpl->maDecreaseButton    = Image(StockImage::Yes, RID_SVXBMP_SLIDERDECREASE);
-    Size  aSliderSize           = LogicToPixel( aLogicalSize, MapMode( MapUnit::Map10thMM ) );
-    SetSizePixel( Size( aSliderSize.Width() * nSliderWidth-1, aSliderSize.Height() + nSliderHeight ) );
+    Size aSliderSize = LogicToPixel(aLogicalSize, MapMode(MapUnit::Map10thMM));
+    Size aPreferredSize(aSliderSize.Width() * nSliderWidth-1, aSliderSize.Height() + nSliderHeight);
+    mxWidget->GetDrawingArea()->set_size_request(aPreferredSize.Width(), aPreferredSize.Height());
+    mxWidget->SetOutputSizePixel(aPreferredSize);
+    SetSizePixel(aPreferredSize);
 }
 
 ScZoomSliderWnd::~ScZoomSliderWnd()
@@ -224,11 +224,22 @@ ScZoomSliderWnd::~ScZoomSliderWnd()
 
 void ScZoomSliderWnd::dispose()
 {
-    mpImpl.reset();
-    vcl::Window::dispose();
+    mxWeld.reset();
+    mxWidget.reset();
+    InterimItemWindow::dispose();
+}
+
+ScZoomSlider::ScZoomSlider(const css::uno::Reference< css::frame::XDispatchProvider>& rDispatchProvider,
+                           sal_uInt16 nCurrentZoom)
+    : mpImpl(new ScZoomSliderWnd_Impl(nCurrentZoom))
+    , m_xDispatchProvider(rDispatchProvider)
+{
+    mpImpl->maSliderButton      = Image(StockImage::Yes, RID_SVXBMP_SLIDERBUTTON);
+    mpImpl->maIncreaseButton    = Image(StockImage::Yes, RID_SVXBMP_SLIDERINCREASE);
+    mpImpl->maDecreaseButton    = Image(StockImage::Yes, RID_SVXBMP_SLIDERDECREASE);
 }
 
-void ScZoomSliderWnd::MouseButtonDown( const MouseEvent& rMEvt )
+bool ScZoomSlider::MouseButtonDown( const MouseEvent& rMEvt )
 {
     Size aSliderWindowSize = GetOutputSizePixel();
 
@@ -261,7 +272,7 @@ void ScZoomSliderWnd::MouseButtonDown( const MouseEvent& rMEvt )
         mpImpl->mnCurrentZoom = mpImpl->mnMaxZoom;
 
     if( nOldZoom == mpImpl->mnCurrentZoom )
-        return ;
+        return true;
 
     tools::Rectangle aRect( Point( 0, 0 ), aSliderWindowSize );
 
@@ -280,9 +291,11 @@ void ScZoomSliderWnd::MouseButtonDown( const MouseEvent& rMEvt )
     SfxToolBoxControl::Dispatch( m_xDispatchProvider, ".uno:ScalingFactor", aArgs );
 
     mpImpl->mbOmitPaint = false;
+
+    return true;
 }
 
-void ScZoomSliderWnd::MouseMove( const MouseEvent& rMEvt )
+bool ScZoomSlider::MouseMove( const MouseEvent& rMEvt )
 {
     Size aSliderWindowSize   = GetOutputSizePixel();
     const long nControlWidth = aSliderWindowSize.Width();
@@ -317,9 +330,16 @@ void ScZoomSliderWnd::MouseMove( const MouseEvent& rMEvt )
             mpImpl->mbOmitPaint = false;
         }
     }
+
+    return false;
 }
 
 void ScZoomSliderWnd::UpdateFromItem( const SvxZoomSliderItem* pZoomSliderItem )
+{
+    mxWidget->UpdateFromItem(pZoomSliderItem);
+}
+
+void ScZoomSlider::UpdateFromItem(const SvxZoomSliderItem* pZoomSliderItem)
 {
     if( pZoomSliderItem )
     {
@@ -364,12 +384,12 @@ void ScZoomSliderWnd::UpdateFromItem( const SvxZoomSliderItem* pZoomSliderItem )
        Invalidate(aRect);
 }
 
-void ScZoomSliderWnd::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/)
+void ScZoomSlider::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/)
 {
     DoPaint(rRenderContext);
 }
 
-void ScZoomSliderWnd::DoPaint(vcl::RenderContext& rRenderContext)
+void ScZoomSlider::DoPaint(vcl::RenderContext& rRenderContext)
 {
     if (mpImpl->mbOmitPaint)
         return;
diff --git a/sc/source/ui/inc/tbzoomsliderctrl.hxx b/sc/source/ui/inc/tbzoomsliderctrl.hxx
index 2b664bf4dd16..d12de0f29294 100644
--- a/sc/source/ui/inc/tbzoomsliderctrl.hxx
+++ b/sc/source/ui/inc/tbzoomsliderctrl.hxx
@@ -19,8 +19,10 @@
 #ifndef INCLUDED_SC_SOURCE_UI_INC_TBZOOMSLIDERCTRL_HXX
 #define INCLUDED_SC_SOURCE_UI_INC_TBZOOMSLIDERCTRL_HXX
 
+#include <vcl/customweld.hxx>
 #include <vcl/window.hxx>
 #include <svl/poolitem.hxx>
+#include <sfx2/InterimItemWindow.hxx>
 #include <sfx2/tbxctrl.hxx>
 
 namespace com { namespace sun { namespace star { namespace frame { class XDispatchProvider; } } } }
@@ -38,30 +40,43 @@ public:
     virtual VclPtr<vcl::Window> CreateItemWindow( vcl::Window *pParent ) override;
 };
 
-class ScZoomSliderWnd: public vcl::Window
+class ScZoomSlider final : public weld::CustomWidgetController
 {
 private:
     struct ScZoomSliderWnd_Impl;
     std::unique_ptr<ScZoomSliderWnd_Impl> mpImpl;
-    Size const aLogicalSize;
     css::uno::Reference<css::frame::XDispatchProvider> m_xDispatchProvider;
 
     sal_uInt16 Offset2Zoom(long nOffset) const;
     long Zoom2Offset(sal_uInt16 nZoom) const;
+
     void DoPaint(vcl::RenderContext& rRenderContext);
+public:
+    ScZoomSlider(const css::uno::Reference<css::frame::XDispatchProvider>& rDispatchProvider,
+                 sal_uInt16 nCurrentZoom);
+
+    void UpdateFromItem(const SvxZoomSliderItem* pZoomSliderItem);
+
+    virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
+    virtual bool MouseMove( const MouseEvent& rMEvt ) override;
+    virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
+};
+
+class ScZoomSliderWnd final : public InterimItemWindow
+{
+private:
+    std::unique_ptr<ScZoomSlider> mxWidget;
+    std::unique_ptr<weld::CustomWeld> mxWeld;
+    Size const aLogicalSize;
 
 public:
-    ScZoomSliderWnd(vcl::Window* pParent, const css::uno::Reference<css::frame::XDispatchProvider >& rDispatchProvider,
+    ScZoomSliderWnd(vcl::Window* pParent, const css::uno::Reference<css::frame::XDispatchProvider>& rDispatchProvider,
                     sal_uInt16 nCurrentZoom);
     virtual ~ScZoomSliderWnd() override;
     virtual void dispose() override;
     void UpdateFromItem( const SvxZoomSliderItem* pZoomSliderItem );
-
-protected:
-    virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
-    virtual void MouseMove( const MouseEvent& rMEvt ) override;
-    virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
 };
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/uiconfig/scalc/ui/zoombox.ui b/sc/uiconfig/scalc/ui/zoombox.ui
new file mode 100644
index 000000000000..7cbea01705aa
--- /dev/null
+++ b/sc/uiconfig/scalc/ui/zoombox.ui
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface domain="sc">
+  <requires lib="gtk+" version="3.18"/>
+  <object class="GtkBox" id="ZoomBox">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="hexpand">True</property>
+    <property name="spacing">6</property>
+    <child>
+      <object class="GtkDrawingArea" id="zoom">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="events">GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">0</property>
+      </packing>
+    </child>
+  </object>
+</interface>
commit 420e5a9ced6ad64ad3f81e3441c629b7076a776d
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Feb 13 10:23:31 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Feb 13 14:52:02 2020 +0100

    use what gtk reports as the held buttons for mouse move
    
    Change-Id: I52242eb652802913382551527763737d92127129
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88597
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index ceab06bd4311..8ed4f0c5ee0d 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -2091,6 +2091,7 @@ private:
         }
 
         sal_uInt32 nModCode = GtkSalFrame::GetMouseModCode(pEvent->state);
+        // strip out which buttons are involved from the nModCode and replace with m_nLastMouseButton
         sal_uInt16 nCode = m_nLastMouseButton | (nModCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2));
         MouseEvent aMEvt(aPos, m_nLastMouseClicks, ImplGetMouseButtonMode(m_nLastMouseButton, nModCode), nCode, nCode);
 
@@ -2135,8 +2136,7 @@ private:
         if (SwapForRTL())
             aPos.setX(gtk_widget_get_allocated_width(m_pWidget) - 1 - aPos.X());
         sal_uInt32 nModCode = GtkSalFrame::GetMouseModCode(pEvent->state);
-        sal_uInt16 nCode = m_nLastMouseButton | (nModCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2));
-        MouseEvent aMEvt(aPos, 0, ImplGetMouseMoveMode(nModCode), nCode, nCode);
+        MouseEvent aMEvt(aPos, 0, ImplGetMouseMoveMode(nModCode), nModCode, nModCode);
 
         m_aMouseMotionHdl.Call(aMEvt);
         return true;
@@ -2158,10 +2158,9 @@ private:
         if (SwapForRTL())
             aPos.setX(gtk_widget_get_allocated_width(m_pWidget) - 1 - aPos.X());
         sal_uInt32 nModCode = GtkSalFrame::GetMouseModCode(pEvent->state);
-        sal_uInt16 nCode = m_nLastMouseButton | (nModCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2));
         MouseEventModifiers eModifiers = ImplGetMouseMoveMode(nModCode);
         eModifiers = eModifiers | (pEvent->type == GDK_ENTER_NOTIFY ? MouseEventModifiers::ENTERWINDOW : MouseEventModifiers::LEAVEWINDOW);
-        MouseEvent aMEvt(aPos, 0, eModifiers, nCode, nCode);
+        MouseEvent aMEvt(aPos, 0, eModifiers, nModCode, nModCode);
 
         m_aMouseMotionHdl.Call(aMEvt);
         return true;


More information about the Libreoffice-commits mailing list