diff options
author | Pranam Lashkari <lpranam@collabora.com> | 2021-01-01 16:04:43 +0530 |
---|---|---|
committer | Pranam Lashkari <lpranam@collabora.com> | 2021-01-06 12:17:10 +0100 |
commit | a4aa110f2ffd2b9439a1bcb5abcacf7704ff41a4 (patch) | |
tree | 6547c6651c0291ab73f14168382d32449c09076a | |
parent | 3286d9a70bda46da2685a23ff6f353fbb1e055f4 (diff) |
Stop modifying size values in sidebar when user still editing
Change-Id: Ie630a40e14f7dce7260da7bb9ba6f8cbc4984b83
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108555
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r-- | include/vcl/spinfld.hxx | 3 | ||||
-rw-r--r-- | svx/source/sidebar/possize/PosSizePropertyPanel.cxx | 97 | ||||
-rw-r--r-- | svx/source/sidebar/possize/PosSizePropertyPanel.hxx | 22 | ||||
-rw-r--r-- | vcl/source/control/spinfld.cxx | 14 |
4 files changed, 124 insertions, 12 deletions
diff --git a/include/vcl/spinfld.hxx b/include/vcl/spinfld.hxx index 8fb21f8605fd..d6a1c540b3e9 100644 --- a/include/vcl/spinfld.hxx +++ b/include/vcl/spinfld.hxx @@ -36,6 +36,7 @@ public: virtual void Up(); virtual void Down(); + virtual void Enter(); virtual void First(); virtual void Last(); @@ -51,6 +52,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; @@ -83,6 +85,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 e5cc427a0f2a..764502642c93 100644 --- a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx +++ b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx @@ -190,12 +190,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 ) ); @@ -353,7 +376,7 @@ void PosSizePropertyPanel::HandleContextChange( } -IMPL_LINK_NOARG( PosSizePropertyPanel, ChangeWidthHdl, Edit&, void ) +void PosSizePropertyPanel::AdjustWidth() { if( mpCbxScale->IsChecked() && mpCbxScale->IsEnabled() ) @@ -374,8 +397,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() ) @@ -396,8 +433,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()) { @@ -413,8 +464,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() ) { @@ -431,6 +496,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 26854fa4873c..c70070b4b793 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 e4cac9a03766..f4660ce64dca 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; } } } |