Krita Source Code Documentation
Loading...
Searching...
No Matches
SliderSpinBox Class Reference

This class is a wrapper around KisSliderSpinBox, a spinbox in which you can click and drag to set the value, with a slider like bar displayed inside. The widget itself is accessed with the widget() function. More...

#include <SliderSpinBox.h>

+ Inheritance diagram for SliderSpinBox:

Public Slots

int fastSliderStep () const
 Get the value to which multiples the spinbox value snaps when the control key is pressed.
 
bool isDragging () const
 Get if the user is currently dragging the slider with the pointer.
 
void setBlockUpdateSignalOnDrag (bool newBlockUpdateSignalOnDrag)
 Set if the spinbox should not Q_EMIT signals when dragging the slider.
 
void setExponentRatio (qreal newExponentRatio)
 Set the exponent used by a power function to modify the values as a function of the horizontal position.
 
void setFastSliderStep (int newFastSliderStep)
 Set the value to which multiples the spinbox value snaps when the control key is pressed.
 
void setMaximum (int newMaximum, bool computeNewFastSliderStep=true)
 Set the maximum value of the range.
 
void setMinimum (int newMinimum, bool computeNewFastSliderStep=true)
 Set the minimum value of the range.
 
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 range if required.
 
void setSoftMaximum (int newSoftMaximum)
 Set the maximum value of the soft range.
 
void setSoftMinimum (int newSoftMinimum)
 Set the minimum value of the soft range.
 
void setSoftRange (int newSoftMinimum, int newSoftMaximum)
 Set the minimum and the maximum values of the soft range.
 
void setValue (int newValue)
 Set the value.
 
int softMaximum () const
 Get the maximum value of the "soft range".
 
int softMinimum () const
 Get the minimum value of the "soft range".
 
QWidget * widget () const
 Get the internal KisSliderSpinBox as a QWidget, so it may be added to a UI.
 
- Public Slots inherited from IntParseSpinBox
bool isLastValid () const
 Get if the last expression entered is a valid one.
 
void setValue (int value, bool overwriteExpression=false)
 Set the value of the spinbox.
 
void stepBy (int steps)
 This is a reimplementation of QSpinBox::stepBy that uses setValue.
 
virtual QString veryCleanText () const
 This virtual function is similar to cleanText(). But child classes may reimplement it to further process ("clean up") the expression.
 
QSpinBox * widget () const
 Get the internal KisIntParseSpinBox as a QWidget, so it may be added to a UI.
 

Signals

void draggingFinished ()
 
- Signals inherited from IntParseSpinBox
void errorWhileParsing (const QString &expr) const
 signal emitted when the last parsed expression is not valid.
 
void noMoreParsingError () const
 signal emitted when the last parsed expression is valid and the expression before was not valid.
 

Public Member Functions

 SliderSpinBox ()
 
 ~SliderSpinBox () override
 
- Public Member Functions inherited from IntParseSpinBox
 IntParseSpinBox ()
 
 ~IntParseSpinBox () override
 

Private Attributes

Private *const d
 

Detailed Description

This class is a wrapper around KisSliderSpinBox, a spinbox in which you can click and drag to set the value, with a slider like bar displayed inside. The widget itself is accessed with the widget() function.

The value can be set by click and dragging with the mouse or pen or by typing in with the keyboard. To enter the edit mode, in which the keyboard can be used, one has to right-click inside the spinbox or click and hold the pointer inside or press the enter key. To leave the edit mode, one can press the enter key again, in which case the value is committed, or press the escape key, in which case the value is rejected.

When dragging with the pointer, one can fine tune the value by dragging far away vertically from the spinbox. The farther the pointer is, the slower the value will change. If the pointer is inside the spinbox plus a certain margin, the value will not be scaled. By pressing the shift key the slow down will be even more pronounced and by pressing the control key the value will snap to the increment set by setFastSliderStep. The two keys can be used at the same time.

A "soft range" can be set to make the slider display only a sub-range of the spinbox range. This way one can have a large range but display and set with the pointer and with more precision only the most commonly used sub-set of values. A value outside the "soft range" can be set by entering the edit mode and using the keyboard. The "soft range" is considered valid if the "soft maximum" is greater than the "soft minimum".

Definition at line 50 of file SliderSpinBox.h.

Constructor & Destructor Documentation

◆ SliderSpinBox()

SliderSpinBox::SliderSpinBox ( )
explicit

Definition at line 17 of file SliderSpinBox.cpp.

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}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
This class is a spinbox in which you can click and drag to set the value. A slider like bar is displa...
void draggingFinished()
Private *const d

References connect(), d, draggingFinished(), and krita::SliderSpinBox::Private::widget.

◆ ~SliderSpinBox()

SliderSpinBox::~SliderSpinBox ( )
override

Definition at line 27 of file SliderSpinBox.cpp.

28{
29 delete d;
30}

References d.

Member Function Documentation

◆ draggingFinished

void SliderSpinBox::draggingFinished ( )
signal

◆ fastSliderStep

int SliderSpinBox::fastSliderStep ( ) const
slot

Get the value to which multiples the spinbox value snaps when the control key is pressed.

Returns
the value to which multiples the spinbox value snaps when the control key is pressed
See also
setFastSliderStep(int)

Definition at line 36 of file SliderSpinBox.cpp.

37{
38 return d->widget->fastSliderStep();
39}
int fastSliderStep() const
Get the value to which multiples the sinbox value snaps when the control key is pressed.

References d, KisSliderSpinBox::fastSliderStep(), and krita::SliderSpinBox::Private::widget.

◆ isDragging

bool SliderSpinBox::isDragging ( ) const
slot

Get if the user is currently dragging the slider with the pointer.

Returns
true if the user is currently dragging the slider with the pointer, false otherwise

Definition at line 51 of file SliderSpinBox.cpp.

52{
53 return d->widget->isDragging();
54}
bool isDragging() const
Get if the user is currently dragging the slider with the pointer.

References d, KisSliderSpinBox::isDragging(), and krita::SliderSpinBox::Private::widget.

◆ setBlockUpdateSignalOnDrag

void SliderSpinBox::setBlockUpdateSignalOnDrag ( bool newBlockUpdateSignalOnDrag)
slot

Set if the spinbox should not Q_EMIT signals when dragging the slider.

This is useful to prevent multiple updates when changing the value if the update operation is costly. A valueChanged signal will be emitted when the pointer is released from the slider.

Parameters
newBlockUpdateSignalOnDragtrue if the spinbox should not emit signals when dragging the slider. false otherwise

Definition at line 85 of file SliderSpinBox.cpp.

86{
87 d->widget->setBlockUpdateSignalOnDrag(newBlockUpdateSignalOnDrag);
88}
void setBlockUpdateSignalOnDrag(bool newBlockUpdateSignalOnDrag)
Set if the spinbox should not Q_EMIT signals when dragging the slider.

References d, KisSliderSpinBox::setBlockUpdateSignalOnDrag(), and krita::SliderSpinBox::Private::widget.

◆ setExponentRatio

void SliderSpinBox::setExponentRatio ( qreal newExponentRatio)
slot

Set the exponent used by a power function to modify the values as a function of the horizontal position.

This allows having more values concentrated in one side of the slider than the other

Parameters
newExponentRatiothe new exponent to be used by the power function

Definition at line 76 of file SliderSpinBox.cpp.

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}
void setExponentRatio(qreal newExponentRatio)
Set the exponent used by a power function to modify the values as a function of the horizontal positi...
#define dbgScript
Definition kis_debug.h:56

References d, dbgScript, KisSliderSpinBox::setExponentRatio(), and krita::SliderSpinBox::Private::widget.

◆ setFastSliderStep

void SliderSpinBox::setFastSliderStep ( int newFastSliderStep)
slot

Set the value to which multiples the spinbox value snaps when the control key is pressed.

Parameters
newFastSliderStepvalue to which multiples the spinbox value snaps when the control key is pressed
See also
fastSliderStep() const

Definition at line 90 of file SliderSpinBox.cpp.

91{
92 d->widget->setFastSliderStep(newFastSliderStep);
93}
void setFastSliderStep(int newFastSliderStep)
Set the value to which multiples the sinbox value snaps when the control key is pressed.

References d, KisSliderSpinBox::setFastSliderStep(), and krita::SliderSpinBox::Private::widget.

◆ setMaximum

void SliderSpinBox::setMaximum ( int newMaximum,
bool computeNewFastSliderStep = true )
slot

Set the maximum value of the range.

The soft range will be adapted to fit inside the range

Parameters
newMaximumthe new maximum value
computeNewFastSliderSteptrue if a new "fast slider step" must be computed based on the range
See also
setRange(int,int)
setMinimum(int)

Definition at line 71 of file SliderSpinBox.cpp.

72{
73 d->widget->setMaximum(newMaximum, computeNewFastSliderStep);
74}
void setMaximum(int newMaximum, bool computeNewFastSliderStep=true)
Set the maximum value of the range.

References d, KisSliderSpinBox::setMaximum(), and krita::SliderSpinBox::Private::widget.

◆ setMinimum

void SliderSpinBox::setMinimum ( int newMinimum,
bool computeNewFastSliderStep = true )
slot

Set the minimum value of the range.

The soft range will be adapted to fit inside the range

Parameters
newMinimumthe new minimum value
computeNewFastSliderSteptrue if a new "fast slider step" must be computed based on the range
See also
setRange(int,int)
setMaximum(int)

Definition at line 66 of file SliderSpinBox.cpp.

67{
68 d->widget->setMinimum(newMinimum, computeNewFastSliderStep);
69}
void setMinimum(int newMinimum, bool computeNewFastSliderStep=true)
Set the minimum value of the range.

References d, KisSliderSpinBox::setMinimum(), and krita::SliderSpinBox::Private::widget.

◆ setRange

void SliderSpinBox::setRange ( int newMinimum,
int newMaximum,
bool computeNewFastSliderStep = true )
slot

Set the minimum and the maximum values of the range, computing a new "fast slider step" based on the range if required.

The soft range will be adapted to fit inside the range

Parameters
newMinimumthe new minimum value
newMaximumthe new maximum value
computeNewFastSliderSteptrue if a new "fast slider step" must be computed based on the range
See also
setMinimum(int)
setMaximum(int)

Definition at line 61 of file SliderSpinBox.cpp.

62{
63 d->widget->setRange(newMinimum, newMaximum, computeNewFastSliderStep);
64}
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 ...

References d, KisSliderSpinBox::setRange(), and krita::SliderSpinBox::Private::widget.

◆ setSoftMaximum

void SliderSpinBox::setSoftMaximum ( int newSoftMaximum)
slot

Set the maximum value of the soft range.

Parameters
newSoftMaximumthe new maximum value
See also
setSoftRange(int,int)
setSoftMinimum(int)
softMinimum() const
softMaximum() const

Definition at line 105 of file SliderSpinBox.cpp.

106{
107 d->widget->setSoftMaximum(newSoftMaximum);
108}
void setSoftMaximum(int newSoftMaximum)
Set the maximum value of the soft range.

References d, KisSliderSpinBox::setSoftMaximum(), and krita::SliderSpinBox::Private::widget.

◆ setSoftMinimum

void SliderSpinBox::setSoftMinimum ( int newSoftMinimum)
slot

Set the minimum value of the soft range.

Parameters
newSoftMinimumthe new minimum value
See also
setSoftRange(int,int)
setSoftMaximum(int)
softMinimum() const
softMaximum() const

Definition at line 100 of file SliderSpinBox.cpp.

101{
102 d->widget->setSoftMinimum(newSoftMinimum);
103}
void setSoftMinimum(int newSoftMinimum)
Set the minimum value of the soft range.

References d, KisSliderSpinBox::setSoftMinimum(), and krita::SliderSpinBox::Private::widget.

◆ setSoftRange

void SliderSpinBox::setSoftRange ( int newSoftMinimum,
int newSoftMaximum )
slot

Set the minimum and the maximum values of the soft range.

Parameters
newSoftMinimumthe new minimum value
newSoftMaximumthe new maximum value
See also
setSoftMinimum(int)
setSoftMaximum(int)
softMinimum() const
softMaximum() const

Definition at line 95 of file SliderSpinBox.cpp.

96{
97 d->widget->setSoftRange(newSoftMinimum, newSoftMaximum);
98}
void setSoftRange(int newSoftMinimum, int newSoftMaximum)
Set the minimum and the maximum values of the soft range.

References d, KisSliderSpinBox::setSoftRange(), and krita::SliderSpinBox::Private::widget.

◆ setValue

void SliderSpinBox::setValue ( int newValue)
slot

Set the value.

Parameters
newValuethe new value

Definition at line 56 of file SliderSpinBox.cpp.

57{
58 d->widget->setValue(newValue);
59}
void setValue(int newValue)

References d, KisSliderSpinBox::setValue(), and krita::SliderSpinBox::Private::widget.

◆ softMaximum

int SliderSpinBox::softMaximum ( ) const
slot

Get the maximum value of the "soft range".

Returns
the maximum value of the "soft range"
See also
setSoftMaximum(int)
setSoftRange(int, int)
softMinimum) const

Definition at line 46 of file SliderSpinBox.cpp.

47{
48 return d->widget->softMaximum();
49}
int softMaximum() const
Get the maximum value of the "soft range".

References d, KisSliderSpinBox::softMaximum(), and krita::SliderSpinBox::Private::widget.

◆ softMinimum

int SliderSpinBox::softMinimum ( ) const
slot

Get the minimum value of the "soft range".

Returns
the minimum value of the "soft range"
See also
setSoftMinimum(int)
setSoftRange(int, int)
softMaximum() const

Definition at line 41 of file SliderSpinBox.cpp.

42{
43 return d->widget->softMinimum();
44}
int softMinimum() const
Get the minimum value of the "soft range".

References d, KisSliderSpinBox::softMinimum(), and krita::SliderSpinBox::Private::widget.

◆ widget

QWidget * SliderSpinBox::widget ( ) const
slot

Get the internal KisSliderSpinBox as a QWidget, so it may be added to a UI.

Returns
the internal KisSliderSpinBox as a QWidget

Definition at line 32 of file SliderSpinBox.cpp.

33{
34 return d->widget;
35}

References d, and krita::SliderSpinBox::Private::widget.

Member Data Documentation

◆ d

Private* const SliderSpinBox::d
private

Definition at line 204 of file SliderSpinBox.h.


The documentation for this class was generated from the following files: