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

This class is a spinbox in which you can click and drag to set the value. A slider like bar is displayed inside. More...

#include <kis_slider_spin_box.h>

+ Inheritance diagram for KisSliderSpinBox:

Signals

void draggingFinished ()
 
- Signals inherited from KisIntParseSpinBox
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

int fastSliderStep () const
 Get the value to which multiples the sinbox value snaps when the control key is pressed.
 
bool isDragging () const
 Get if the user is currently dragging the slider with the pointer.
 
 KisSliderSpinBox (QWidget *parent=nullptr)
 
QSize minimumSizeHint () const override
 
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 sinbox 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 setPageStep (int newPageStep)
 Does nothing currently.
 
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)
 
QSize sizeHint () const override
 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".
 
 ~KisSliderSpinBox () override
 
- Public Member Functions inherited from KisIntParseSpinBox
bool isLastValid () const
 Get if the last expression entered is a valid one.
 
 KisIntParseSpinBox (QWidget *parent=0)
 
void setValue (int value, bool overwriteExpression=false)
 Set the value of the spinbox.
 
void stepBy (int steps) override
 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.
 
 ~KisIntParseSpinBox () override
 

Protected Member Functions

virtual void setInternalValue (int value, bool blockUpdateSignal)
 
void setPrivateValue (int value)
 
- Protected Member Functions inherited from KisIntParseSpinBox
QString textFromValue (int value) const override
 
QValidator::State validate (QString &input, int &pos) const override
 
int valueFromText (const QString &text) const override
 

Private Attributes

QScopedPointer< KisSliderSpinBoxPrivate< KisSliderSpinBox, KisIntParseSpinBox > > d
 

Friends

template<typename SpinBoxTypeTP , typename BaseSpinBoxTypeTP >
class KisSliderSpinBoxPrivate
 

Detailed Description

This class is a spinbox in which you can click and drag to set the value. A slider like bar is displayed inside.

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 double-click 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 kis_slider_spin_box.h.

Constructor & Destructor Documentation

◆ KisSliderSpinBox()

KisSliderSpinBox::KisSliderSpinBox ( QWidget * parent = nullptr)

Definition at line 14 of file kis_slider_spin_box.cpp.

15 : KisIntParseSpinBox(parent)
17{}
KisIntParseSpinBox(QWidget *parent=0)
QScopedPointer< KisSliderSpinBoxPrivate< KisSliderSpinBox, KisIntParseSpinBox > > d

◆ ~KisSliderSpinBox()

KisSliderSpinBox::~KisSliderSpinBox ( )
override

Definition at line 19 of file kis_slider_spin_box.cpp.

20{}

Member Function Documentation

◆ draggingFinished

void KisSliderSpinBox::draggingFinished ( )
signal

◆ fastSliderStep()

int KisSliderSpinBox::fastSliderStep ( ) const

Get the value to which multiples the sinbox 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 22 of file kis_slider_spin_box.cpp.

23{
24 return d->fastSliderStep();
25}

References d.

◆ isDragging()

bool KisSliderSpinBox::isDragging ( ) const

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 37 of file kis_slider_spin_box.cpp.

38{
39 return d->isDragging();
40}

References d.

◆ minimumSizeHint()

QSize KisSliderSpinBox::minimumSizeHint ( ) const
override

Definition at line 47 of file kis_slider_spin_box.cpp.

48{
49 return d->minimumSizeHint();
50}

References d.

◆ setBlockUpdateSignalOnDrag()

void KisSliderSpinBox::setBlockUpdateSignalOnDrag ( bool newBlockUpdateSignalOnDrag)

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 77 of file kis_slider_spin_box.cpp.

78{
79 d->setBlockUpdateSignalOnDrag(newBlockUpdateSignalOnDrag);
80}

References d.

◆ setExponentRatio()

void KisSliderSpinBox::setExponentRatio ( qreal newExponentRatio)

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 72 of file kis_slider_spin_box.cpp.

73{
74 d->setExponentRatio(newExponentRatio);
75}

References d.

◆ setFastSliderStep()

void KisSliderSpinBox::setFastSliderStep ( int newFastSliderStep)

Set the value to which multiples the sinbox 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 82 of file kis_slider_spin_box.cpp.

83{
84 d->setFastSliderStep(newFastSliderStep);
85}

References d.

◆ setInternalValue()

void KisSliderSpinBox::setInternalValue ( int value,
bool blockUpdateSignal )
protectedvirtual

Definition at line 107 of file kis_slider_spin_box.cpp.

108{
109 d->setValue(newValue, newBlockUpdateSignal);
110}

References d.

◆ setMaximum()

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

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 67 of file kis_slider_spin_box.cpp.

68{
69 setRange(minimum(), newMaximum, computeNewFastSliderStep);
70}
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 setRange().

◆ setMinimum()

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

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 62 of file kis_slider_spin_box.cpp.

63{
64 setRange(newMinimum, maximum(), computeNewFastSliderStep);
65}

References setRange().

◆ setPageStep()

void KisSliderSpinBox::setPageStep ( int newPageStep)

Does nothing currently.

Definition at line 87 of file kis_slider_spin_box.cpp.

88{
89 Q_UNUSED(value);
90}
float value(const T *src, size_t ch)

References value().

◆ setPrivateValue()

void KisSliderSpinBox::setPrivateValue ( int value)
protected

Definition at line 112 of file kis_slider_spin_box.cpp.

113{
114 setValue(newValue);
115}
void setValue(int newValue)

References setValue().

◆ setRange()

void KisSliderSpinBox::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.

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 57 of file kis_slider_spin_box.cpp.

58{
59 d->setRange(newMinimum, newMaximum, computeNewFastSliderStep);
60}

References d.

◆ setSoftMaximum()

void KisSliderSpinBox::setSoftMaximum ( int newSoftMaximum)

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 102 of file kis_slider_spin_box.cpp.

103{
104 setSoftRange(d->softMinimum(), newSoftMaximum);
105}
void setSoftRange(int newSoftMinimum, int newSoftMaximum)
Set the minimum and the maximum values of the soft range.

References d, and setSoftRange().

◆ setSoftMinimum()

void KisSliderSpinBox::setSoftMinimum ( int newSoftMinimum)

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 97 of file kis_slider_spin_box.cpp.

98{
99 setSoftRange(newSoftMinimum, d->softMaximum());
100}

References d, and setSoftRange().

◆ setSoftRange()

void KisSliderSpinBox::setSoftRange ( int newSoftMinimum,
int newSoftMaximum )

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 92 of file kis_slider_spin_box.cpp.

93{
94 d->setSoftRange(newSoftMinimum, newSoftMaximum);
95}

References d.

◆ setValue()

void KisSliderSpinBox::setValue ( int newValue)

Definition at line 52 of file kis_slider_spin_box.cpp.

53{
54 d->setValue(newValue);
55}

References d.

◆ sizeHint()

QSize KisSliderSpinBox::sizeHint ( ) const
override

Set the value.

Parameters
newValuethe new value

Definition at line 42 of file kis_slider_spin_box.cpp.

43{
44 return d->sizeHint();
45}

References d.

◆ softMaximum()

int KisSliderSpinBox::softMaximum ( ) const

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 32 of file kis_slider_spin_box.cpp.

33{
34 return d->softMaximum();
35}

References d.

◆ softMinimum()

int KisSliderSpinBox::softMinimum ( ) const

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 27 of file kis_slider_spin_box.cpp.

28{
29 return d->softMinimum();
30}

References d.

Friends And Related Symbol Documentation

◆ KisSliderSpinBoxPrivate

template<typename SpinBoxTypeTP , typename BaseSpinBoxTypeTP >
friend class KisSliderSpinBoxPrivate
friend

Definition at line 201 of file kis_slider_spin_box.h.

Member Data Documentation

◆ d

QScopedPointer<KisSliderSpinBoxPrivate<KisSliderSpinBox, KisIntParseSpinBox> > KisSliderSpinBox::d
private

Definition at line 202 of file kis_slider_spin_box.h.


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