[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - include/vcl svx/source vcl/source

Pranam Lashkari (via logerrit) logerrit at kemper.freedesktop.org
Wed Jan 6 11:18:25 UTC 2021


 include/vcl/spinfld.hxx                             |    3 
 svx/source/sidebar/possize/PosSizePropertyPanel.cxx |   97 ++++++++++++++++++--
 svx/source/sidebar/possize/PosSizePropertyPanel.hxx |   22 +++-
 vcl/source/control/spinfld.cxx                      |   14 ++
 4 files changed, 124 insertions(+), 12 deletions(-)

New commits:
commit 0165dbab57acfb89c7eff4c226285c6027e14d99
Author:     Pranam Lashkari <lpranam at collabora.com>
AuthorDate: Fri Jan 1 16:04:43 2021 +0530
Commit:     Pranam Lashkari <lpranam at collabora.com>
CommitDate: Wed Jan 6 12:17:52 2021 +0100

    Stop modifying size values in sidebar when user still editing
    
    Change-Id: Ie630a40e14f7dce7260da7bb9ba6f8cbc4984b83
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108574
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Pranam Lashkari <lpranam at collabora.com>

diff --git a/include/vcl/spinfld.hxx b/include/vcl/spinfld.hxx
index cbf9f8bde2d0..fd71ae589ef5 100644
--- a/include/vcl/spinfld.hxx
+++ b/include/vcl/spinfld.hxx
@@ -37,6 +37,7 @@ public:
 
     virtual void    Up();
     virtual void    Down();
+    virtual void    Enter();
     virtual void    First();
     virtual void    Last();
 
@@ -52,6 +53,7 @@ public:
 
     void            SetUpHdl( const Link<SpinField&,void>& rLink ) { maUpHdlLink = rLink; }
     void            SetDownHdl( const Link<SpinField&,void>& rLink ) { maDownHdlLink = rLink; }
+    void            SetEnterHdl( const Link<Control&,void>& rLink ) { maEnterHdlLink = rLink; }
 
     virtual Size    CalcMinimumSize() const override;
     virtual Size    CalcMinimumSizeForText(const OUString &rString) const override;
@@ -84,6 +86,7 @@ private:
     AutoTimer       maRepeatTimer;
     Link<SpinField&,void>  maUpHdlLink;
     Link<SpinField&,void>  maDownHdlLink;
+    Link<Control&,void>  maEnterHdlLink;
     bool            mbRepeat:1,
                     mbSpin:1,
                     mbInitialUp:1,
diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
index 00676302ae57..5e2458946fa9 100644
--- a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
+++ b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
@@ -182,12 +182,35 @@ namespace
 void PosSizePropertyPanel::Initialize()
 {
     //Position : Horizontal / Vertical
-    mpMtrPosX->SetModifyHdl( LINK( this, PosSizePropertyPanel, ChangePosXHdl ) );
-    mpMtrPosY->SetModifyHdl( LINK( this, PosSizePropertyPanel, ChangePosYHdl ) );
+    mpMtrPosX->SetLoseFocusHdl( LINK( this, PosSizePropertyPanel, ChangePosXHdl ) );
+    mpMtrPosX->SetEnterHdl(LINK( this, PosSizePropertyPanel, ChangePosXHdl ) );
+    mpMtrPosX->SetUpHdl( LINK( this, PosSizePropertyPanel, ChangePosXUpDownHdl ) );
+    mpMtrPosX->SetDownHdl( LINK( this, PosSizePropertyPanel, ChangePosXUpDownHdl ) );
+
+    mpMtrPosY->SetLoseFocusHdl( LINK( this, PosSizePropertyPanel, ChangePosYHdl ) );
+    mpMtrPosY->SetEnterHdl( LINK( this, PosSizePropertyPanel, ChangePosYHdl ) );
+    mpMtrPosY->SetUpHdl( LINK( this, PosSizePropertyPanel, ChangePosYUpDownHdl ) );
+    mpMtrPosY->SetDownHdl( LINK( this, PosSizePropertyPanel, ChangePosYUpDownHdl ) );
+
 
     //Size : Width / Height
-    mpMtrWidth->SetModifyHdl( LINK( this, PosSizePropertyPanel, ChangeWidthHdl ) );
-    mpMtrHeight->SetModifyHdl( LINK( this, PosSizePropertyPanel, ChangeHeightHdl ) );
+    mpMtrWidth->SetLoseFocusHdl( LINK( this, PosSizePropertyPanel, ChangeWidthHdl ) );
+    mpMtrWidth->SetEnterHdl( LINK( this, PosSizePropertyPanel, ChangeWidthHdl ) );
+    mpMtrWidth->SetUpHdl( LINK( this, PosSizePropertyPanel, ChangeWidthUpDownHdl ) );
+    mpMtrWidth->SetDownHdl( LINK( this, PosSizePropertyPanel, ChangeWidthUpDownHdl ) );
+
+    mpMtrHeight->SetLoseFocusHdl( LINK( this, PosSizePropertyPanel, ChangeHeightHdl ) );
+    mpMtrHeight->SetEnterHdl( LINK( this, PosSizePropertyPanel, ChangeHeightHdl ) );
+    mpMtrHeight->SetUpHdl( LINK( this, PosSizePropertyPanel, ChangeHeightUpDownHdl ) );
+    mpMtrHeight->SetDownHdl( LINK( this, PosSizePropertyPanel, ChangeHeightUpDownHdl ) );
+
+    if (SfxLokHelper::getDeviceFormFactor() == LOKDeviceFormFactor::MOBILE)
+    {
+        mpMtrPosX->SetModifyHdl( LINK( this, PosSizePropertyPanel, ChangePosXMobileHdl ) );
+        mpMtrPosY->SetModifyHdl( LINK( this, PosSizePropertyPanel, ChangePosYMobileHdl ) );
+        mpMtrWidth->SetModifyHdl( LINK( this, PosSizePropertyPanel, ChangeWidthMobileHdl ) );
+        mpMtrHeight->SetModifyHdl( LINK( this, PosSizePropertyPanel, ChangeHeightMobileHdl ) );
+    }
 
     //Size : Keep ratio
     mpCbxScale->SetClickHdl( LINK( this, PosSizePropertyPanel, ClickAutoHdl ) );
@@ -345,7 +368,7 @@ void PosSizePropertyPanel::HandleContextChange(
 }
 
 
-IMPL_LINK_NOARG( PosSizePropertyPanel, ChangeWidthHdl, Edit&, void )
+void PosSizePropertyPanel::AdjustWidth()
 {
     if( mpCbxScale->IsChecked() &&
         mpCbxScale->IsEnabled() )
@@ -366,8 +389,22 @@ IMPL_LINK_NOARG( PosSizePropertyPanel, ChangeWidthHdl, Edit&, void )
     executeSize();
 }
 
+IMPL_LINK_NOARG( PosSizePropertyPanel, ChangeWidthHdl, Control&, void )
+{
+    AdjustWidth();
+}
+
+IMPL_LINK_NOARG( PosSizePropertyPanel, ChangeWidthMobileHdl, Edit&, void )
+{
+    AdjustWidth();
+}
+
+IMPL_LINK_NOARG( PosSizePropertyPanel, ChangeWidthUpDownHdl, SpinField&, void )
+{
+    AdjustWidth();
+}
 
-IMPL_LINK_NOARG( PosSizePropertyPanel, ChangeHeightHdl, Edit&, void )
+void PosSizePropertyPanel::AdjustHeight()
 {
     if( mpCbxScale->IsChecked() &&
         mpCbxScale->IsEnabled() )
@@ -388,8 +425,22 @@ IMPL_LINK_NOARG( PosSizePropertyPanel, ChangeHeightHdl, Edit&, void )
     executeSize();
 }
 
+IMPL_LINK_NOARG( PosSizePropertyPanel, ChangeHeightHdl, Control&, void )
+{
+    AdjustHeight();
+}
+
+IMPL_LINK_NOARG( PosSizePropertyPanel, ChangeHeightMobileHdl, Edit&, void )
+{
+    AdjustHeight();
+}
+
+IMPL_LINK_NOARG( PosSizePropertyPanel, ChangeHeightUpDownHdl, SpinField&, void )
+{
+    AdjustHeight();
+}
 
-IMPL_LINK_NOARG( PosSizePropertyPanel, ChangePosXHdl, Edit&, void )
+void PosSizePropertyPanel::AdjustXPos()
 {
     if ( mpMtrPosX->IsValueModified())
     {
@@ -405,8 +456,22 @@ IMPL_LINK_NOARG( PosSizePropertyPanel, ChangePosXHdl, Edit&, void )
     }
 }
 
+IMPL_LINK_NOARG( PosSizePropertyPanel, ChangePosXHdl, Control&, void )
+{
+    AdjustXPos();
+}
+
+IMPL_LINK_NOARG( PosSizePropertyPanel, ChangePosXMobileHdl, Edit&, void )
+{
+    AdjustXPos();
+}
+
+IMPL_LINK_NOARG( PosSizePropertyPanel, ChangePosXUpDownHdl, SpinField&, void )
+{
+    AdjustXPos();
+}
 
-IMPL_LINK_NOARG( PosSizePropertyPanel, ChangePosYHdl, Edit&, void )
+void PosSizePropertyPanel::AdjustYPos()
 {
     if ( mpMtrPosY->IsValueModified() )
     {
@@ -423,6 +488,22 @@ IMPL_LINK_NOARG( PosSizePropertyPanel, ChangePosYHdl, Edit&, void )
 }
 
 
+IMPL_LINK_NOARG( PosSizePropertyPanel, ChangePosYHdl, Control&, void )
+{
+    AdjustYPos();
+}
+
+IMPL_LINK_NOARG( PosSizePropertyPanel, ChangePosYMobileHdl, Edit&, void )
+{
+    AdjustYPos();
+}
+
+IMPL_LINK_NOARG( PosSizePropertyPanel, ChangePosYUpDownHdl, SpinField&, void )
+{
+    AdjustYPos();
+}
+
+
 IMPL_LINK_NOARG( PosSizePropertyPanel, ClickAutoHdl, Button*, void )
 {
     if ( mpCbxScale->IsChecked() )
diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.hxx b/svx/source/sidebar/possize/PosSizePropertyPanel.hxx
index 40ee624e55a6..79081895d051 100644
--- a/svx/source/sidebar/possize/PosSizePropertyPanel.hxx
+++ b/svx/source/sidebar/possize/PosSizePropertyPanel.hxx
@@ -20,6 +20,7 @@
 #define INCLUDED_SVX_SOURCE_SIDEBAR_POSSIZE_POSSIZEPROPERTYPANEL_HXX
 
 #include <vcl/ctrl.hxx>
+#include <vcl/spinfld.hxx>
 #include <sfx2/sidebar/SidebarPanelBase.hxx>
 #include <sfx2/sidebar/ControllerItem.hxx>
 #include <sfx2/sidebar/IContextChangeReceiver.hxx>
@@ -157,10 +158,18 @@ private:
 
     css::uno::Reference<css::ui::XSidebar> mxSidebar;
 
-    DECL_LINK( ChangePosXHdl, Edit&, void );
-    DECL_LINK( ChangePosYHdl, Edit&, void );
-    DECL_LINK( ChangeWidthHdl, Edit&, void );
-    DECL_LINK( ChangeHeightHdl, Edit&, void );
+    DECL_LINK( ChangePosXHdl, Control&, void );
+    DECL_LINK( ChangePosYHdl, Control&, void );
+    DECL_LINK( ChangePosXMobileHdl, Edit&, void );
+    DECL_LINK( ChangePosYMobileHdl, Edit&, void );
+    DECL_LINK( ChangePosXUpDownHdl, SpinField&, void );
+    DECL_LINK( ChangePosYUpDownHdl, SpinField&, void );
+    DECL_LINK( ChangeWidthHdl, Control&, void );
+    DECL_LINK( ChangeHeightHdl, Control&, void );
+    DECL_LINK( ChangeWidthMobileHdl, Edit&, void );
+    DECL_LINK( ChangeHeightMobileHdl, Edit&, void );
+    DECL_LINK( ChangeWidthUpDownHdl, SpinField&, void );
+    DECL_LINK( ChangeHeightUpDownHdl, SpinField&, void );
     DECL_LINK( ClickAutoHdl, Button*, void );
     DECL_LINK( AngleModifiedHdl, Edit&, void );
     DECL_LINK( RotationHdl, svx::DialControl*, void );
@@ -186,6 +195,11 @@ private:
         c) invalidate the items for position and size to trigger notifications of their current values.
     */
     void UpdateUIScale();
+
+    void AdjustWidth();
+    void AdjustHeight();
+    void AdjustXPos();
+    void AdjustYPos();
 };
 
 
diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx
index c954c698dffd..cc0da5999d77 100644
--- a/vcl/source/control/spinfld.cxx
+++ b/vcl/source/control/spinfld.cxx
@@ -367,6 +367,11 @@ void SpinField::Down()
     ImplCallEventListenersAndHandler( VclEventId::SpinfieldDown, [this] () { maDownHdlLink.Call(*this); } );
 }
 
+void SpinField::Enter()
+{
+    ImplCallEventListenersAndHandler( VclEventId::EditModify, [this] () { maEnterHdlLink.Call(*this); } );
+}
+
 void SpinField::First()
 {
     ImplCallEventListenersAndHandler(VclEventId::SpinfieldFirst, nullptr);
@@ -541,6 +546,15 @@ bool SpinField::EventNotify(NotifyEvent& rNEvt)
                     }
                 }
                 break;
+                case KEY_RETURN:
+                {
+                    if (!nMod)
+                    {
+                        Enter();
+                        bDone = true;
+                    }
+                }
+                break;
             }
         }
     }


More information about the Libreoffice-commits mailing list