diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-05-29 21:25:09 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-05-31 12:31:54 +0200 |
commit | 7c411a6df34ce5b04f964b0410b6d2535389918d (patch) | |
tree | 58d21b5bea761078c20b51c9959737ac5798e5bc | |
parent | tdf#145875 don't open Insert section dialog when pasting image (diff) | |
download | core-7c411a6df34ce5b04f964b0410b6d2535389918d.tar.gz core-7c411a6df34ce5b04f964b0410b6d2535389918d.zip |
Related: tdf#89131 draw up/down spins disabled if value is at max/min
if there is a max/min set.
Change-Id: I2dc7ccccad9ec2aa7eb89d8b5fa137e077a846fd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135105
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit 2896c5dad1799addd72b626d93d7e89b1cf19ff6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135070
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r-- | include/vcl/toolkit/spinfld.hxx | 9 | ||||
-rw-r--r-- | vcl/source/control/fmtfield.cxx | 7 | ||||
-rw-r--r-- | vcl/source/control/spinfld.cxx | 31 |
3 files changed, 44 insertions, 3 deletions
diff --git a/include/vcl/toolkit/spinfld.hxx b/include/vcl/toolkit/spinfld.hxx index f6de1202a45d..d82348bd44bb 100644 --- a/include/vcl/toolkit/spinfld.hxx +++ b/include/vcl/toolkit/spinfld.hxx @@ -61,6 +61,11 @@ public: virtual FactoryFunction GetUITestFactory() const override; + SAL_DLLPRIVATE void SetUpperEnabled(bool bEnabled); + SAL_DLLPRIVATE void SetLowerEnabled(bool bEnabled); + SAL_DLLPRIVATE bool IsUpperEnabled() const { return mbUpperEnabled; } + SAL_DLLPRIVATE bool IsLowerEnabled() const { return mbLowerEnabled; } + protected: tools::Rectangle maUpperRect; tools::Rectangle maLowerRect; @@ -91,7 +96,9 @@ private: mbInitialDown:1, mbUpperIn:1, mbLowerIn:1, - mbInDropDown:1; + mbInDropDown:1, + mbUpperEnabled:1, + mbLowerEnabled:1; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/control/fmtfield.cxx b/vcl/source/control/fmtfield.cxx index a0d96dd9caae..d3f7d88985f2 100644 --- a/vcl/source/control/fmtfield.cxx +++ b/vcl/source/control/fmtfield.cxx @@ -922,6 +922,13 @@ namespace { m_rSpinButton.SpinField::Modify(); } + + virtual void UpdateCurrentValue(double dCurrentValue) override + { + Formatter::UpdateCurrentValue(dCurrentValue); + m_rSpinButton.SetUpperEnabled(!m_bHasMax || dCurrentValue < m_dMaxValue); + m_rSpinButton.SetLowerEnabled(!m_bHasMin || dCurrentValue > m_dMinValue); + } }; class DoubleNumericFormatter : public FieldFormatter diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx index 8db25dfbc699..6bc1fac297a9 100644 --- a/vcl/source/control/spinfld.cxx +++ b/vcl/source/control/spinfld.cxx @@ -298,6 +298,8 @@ void SpinField::ImplInitSpinFieldData() mbInitialUp = false; mbInitialDown = false; mbInDropDown = false; + mbUpperEnabled = true; + mbLowerEnabled = true; } void SpinField::ImplInit(vcl::Window* pParent, WinBits nWinStyle) @@ -578,13 +580,38 @@ void SpinField::FillLayoutData() const Edit::FillLayoutData(); } +void SpinField::SetUpperEnabled(bool bEnabled) +{ + if (mbUpperEnabled == bEnabled) + return; + + mbUpperEnabled = bEnabled; + + if (mbSpin) + Invalidate(maUpperRect); +} + +void SpinField::SetLowerEnabled(bool bEnabled) +{ + if (mbLowerEnabled == bEnabled) + return; + + mbLowerEnabled = bEnabled; + + if (mbSpin) + Invalidate(maLowerRect); +} + void SpinField::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) { if (mbSpin) { - bool bEnable = IsEnabled(); + bool bEnabled = IsEnabled(); + bool bUpperEnabled = bEnabled && IsUpperEnabled(); + bool bLowerEnabled = bEnabled && IsLowerEnabled(); ImplDrawSpinButton(rRenderContext, this, maUpperRect, maLowerRect, - mbUpperIn, mbLowerIn, bEnable, bEnable); + mbUpperIn && bUpperEnabled, mbLowerIn && bLowerEnabled, + bUpperEnabled, bLowerEnabled); } if (GetStyle() & WB_DROPDOWN) |