Krita

SliderSpinBox.cpp
1/*
2 * SPDX-FileCopyrightText: 2010 Justin Noel <justin@ics.com>
3 * SPDX-FileCopyrightText: 2021 Deif Lou <ginoba@gmail.com>
4 *
5 * SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7
8#include "SliderSpinBox.h"
9#include "kis_debug.h"
10
11struct SliderSpinBox::Private {
12 Private() {}
13
14 KisSliderSpinBox *widget;
15};
16
17SliderSpinBox::SliderSpinBox()
19 , d(new Private)
20{
21 d->widget = new KisSliderSpinBox();
22
23 // Forward KisSliderSpinBox::draggingFinished to SliderSpinBox::draggingFinished
24 connect(d->widget, SIGNAL(draggingFinished()), this, SIGNAL(draggingFinished()));
25}
26
27SliderSpinBox::~SliderSpinBox()
28{
29 delete d;
30}
31
33{
34 return d->widget;
35}
37{
38 return d->widget->fastSliderStep();
39}
40
42{
43 return d->widget->softMinimum();
44}
45
47{
48 return d->widget->softMaximum();
49}
50
52{
53 return d->widget->isDragging();
54}
55
56void SliderSpinBox::setValue(int newValue)
57{
58 d->widget->setValue(newValue);
59}
60
61void SliderSpinBox::setRange(int newMinimum, int newMaximum, bool computeNewFastSliderStep)
62{
63 d->widget->setRange(newMinimum, newMaximum, computeNewFastSliderStep);
64}
65
66void SliderSpinBox::setMinimum(int newMinimum, bool computeNewFastSliderStep)
67{
68 d->widget->setMinimum(newMinimum, computeNewFastSliderStep);
69}
70
71void SliderSpinBox::setMaximum(int newMaximum, bool computeNewFastSliderStep)
72{
73 d->widget->setMaximum(newMaximum, computeNewFastSliderStep);
74}
75
76void SliderSpinBox::setExponentRatio(double newExponentRatio)
77{
78 if (newExponentRatio <= 0.0) {
79 dbgScript << "Script using SliderSpinbox.setExponentRatio passed value <= 0.0 (" << newExponentRatio << "), ignoring.";
80 return;
81 }
82 d->widget->setExponentRatio(newExponentRatio);
83}
84
85void SliderSpinBox::setBlockUpdateSignalOnDrag(bool newBlockUpdateSignalOnDrag)
86{
87 d->widget->setBlockUpdateSignalOnDrag(newBlockUpdateSignalOnDrag);
88}
89
90void SliderSpinBox::setFastSliderStep(int newFastSliderStep)
91{
92 d->widget->setFastSliderStep(newFastSliderStep);
93}
94
95void SliderSpinBox::setSoftRange(int newSoftMinimum, int newSoftMaximum)
96{
97 d->widget->setSoftRange(newSoftMinimum, newSoftMaximum);
98}
99
100void SliderSpinBox::setSoftMinimum(int newSoftMinimum)
101{
102 d->widget->setSoftMinimum(newSoftMinimum);
103}
104
105void SliderSpinBox::setSoftMaximum(int newSoftMaximum)
106{
107 d->widget->setSoftMaximum(newSoftMaximum);
108}
109
110struct DoubleSliderSpinBox::Private {
111 Private() {}
112
113 KisDoubleSliderSpinBox *widget;
114};
115
116DoubleSliderSpinBox::DoubleSliderSpinBox()
118 , d(new Private)
119{
120 d->widget = new KisDoubleSliderSpinBox();
121
122 // Forward KisDoubleSliderSpinBox::draggingFinished to DoubleSliderSpinBox::draggingFinished
123 connect(d->widget, SIGNAL(draggingFinished()), this, SIGNAL(draggingFinished()));
124}
125
126DoubleSliderSpinBox::~DoubleSliderSpinBox()
127{
128 delete d;
129}
130
132{
133 return d->widget;
134}
135
136double DoubleSliderSpinBox::fastSliderStep() const
137{
138 return d->widget->fastSliderStep();
139}
140
141double DoubleSliderSpinBox::softMinimum() const
142{
143 return d->widget->softMinimum();
144}
145
146double DoubleSliderSpinBox::softMaximum() const
147{
148 return d->widget->softMaximum();
149}
150
151bool DoubleSliderSpinBox::isDragging() const
152{
153 return d->widget->isDragging();
154}
155
156void DoubleSliderSpinBox::setValue(double newValue)
157{
158 d->widget->setValue(newValue);
159}
160
161void DoubleSliderSpinBox::setRange(double newMinimum, double newMaximum, int newNumberOfDecimals, bool computeNewFastSliderStep)
162{
163 d->widget->setRange(newMinimum, newMaximum, newNumberOfDecimals, computeNewFastSliderStep);
164}
165
166void DoubleSliderSpinBox::setMinimum(double newMinimum, bool computeNewFastSliderStep)
167{
168 d->widget->setMinimum(newMinimum, computeNewFastSliderStep);
169}
170
171void DoubleSliderSpinBox::setMaximum(double newMaximum, bool computeNewFastSliderStep)
172{
173 d->widget->setMaximum(newMaximum, computeNewFastSliderStep);
174}
175
176void DoubleSliderSpinBox::setExponentRatio(double newExponentRatio)
177{
178 if (newExponentRatio <= 0.0) {
179 dbgScript << "Script using DoubleSliderSpinbox.setExponentRatio passed value <= 0.0 (" << newExponentRatio << "), ignoring.";
180 return;
181 }
182 d->widget->setExponentRatio(newExponentRatio);
183}
184
185void DoubleSliderSpinBox::setBlockUpdateSignalOnDrag(bool newBlockUpdateSignalOnDrag)
186{
187 d->widget->setBlockUpdateSignalOnDrag(newBlockUpdateSignalOnDrag);
188}
189
190void DoubleSliderSpinBox::setFastSliderStep(double newFastSliderStep)
191{
192 d->widget->setFastSliderStep(newFastSliderStep);
193}
194
195void DoubleSliderSpinBox::setSoftRange(double newSoftMinimum, double newSoftMaximum)
196{
197 d->widget->setSoftRange(newSoftMinimum, newSoftMaximum);
198}
199
200void DoubleSliderSpinBox::setSoftMinimum(double newSoftMinimum)
201{
202 setSoftRange(newSoftMinimum, d->widget->softMaximum());
203}
204
205void DoubleSliderSpinBox::setSoftMaximum(double newSoftMaximum)
206{
207 setSoftRange(d->widget->softMinimum(), newSoftMaximum);
208}
A wrapper around KisDoubleParseSpinBox, which is a cleverer doubleSpinBox, able to parse arithmetic e...
void setRange(qreal newMinimum, qreal newMaximum, int newNumberOfDecimals=0, bool computeNewFastSliderStep=true)
Set the minimum and the maximum values of the range.
QWidget * widget() const
Get the internal KisDoubleSliderSpinBox as a QWidget, so it may be added to a UI.
A wrapper around KisIntParseSpinBox, which is a cleverer SpinBox, able to parse arithmetic expression...
QSpinBox * widget() const
Get the internal KisIntParseSpinBox as a QWidget, so it may be added to a UI.
void setMinimum(int newMinimum, bool computeNewFastSliderStep=true)
Set the minimum value of the range.
int fastSliderStep() const
Get the value to which multiples the spinbox value snaps when the control key is pressed.
void setFastSliderStep(int newFastSliderStep)
Set the value to which multiples the spinbox value snaps when the control key is pressed.
void setRange(int newMinimum, int newMaximum, bool computeNewFastSliderStep=true)
Set the minimum and the maximum values of the range, computing a new "fast slider step" based on the ...
int softMinimum() const
Get the minimum value of the "soft range".
void setValue(int newValue)
Set the value.
int softMaximum() const
Get the maximum value of the "soft range".
void setSoftRange(int newSoftMinimum, int newSoftMaximum)
Set the minimum and the maximum values of the soft range.
void setBlockUpdateSignalOnDrag(bool newBlockUpdateSignalOnDrag)
Set if the spinbox should not Q_EMIT signals when dragging the slider.
void setSoftMaximum(int newSoftMaximum)
Set the maximum value of the soft range.
QWidget * widget() const
Get the internal KisSliderSpinBox as a QWidget, so it may be added to a UI.
void setExponentRatio(qreal newExponentRatio)
Set the exponent used by a power function to modify the values as a function of the horizontal positi...
void setMaximum(int newMaximum, bool computeNewFastSliderStep=true)
Set the maximum value of the range.
bool isDragging() const
Get if the user is currently dragging the slider with the pointer.
void setSoftMinimum(int newSoftMinimum)
Set the minimum value of the soft range.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.