Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSelectionPropertySlider< T > Class Template Reference

#include <KisSelectionPropertySlider.h>

+ Inheritance diagram for KisSelectionPropertySlider< T >:

Public Member Functions

 KisSelectionPropertySlider (QWidget *parent=0)
 
QList< T > selection () const
 
void setSelection (QList< T > newSelection)
 
void setValueGetter (qreal(*getter)(T))
 
- Public Member Functions inherited from KisSelectionPropertySliderBase
 KisSelectionPropertySliderBase (QWidget *parent=0)
 
void setPrefix (const QString &)=delete
 
void setSuffix (const QString &)=delete
 
void setTextTemplates (const QString &normalTemplate, const QString &mixedTemplate)
 
 ~KisSelectionPropertySliderBase () override
 
- Public Member Functions inherited from KisDoubleSliderSpinBox
qreal fastSliderStep () const
 
bool isDragging () const
 
 KisDoubleSliderSpinBox (QWidget *parent=nullptr)
 
QSize minimumSizeHint () const override
 
void setBlockUpdateSignalOnDrag (bool newBlockUpdateSignalOnDrag)
 
void setExponentRatio (qreal newExponentRatio)
 
void setFastSliderStep (qreal newFastSliderStep)
 
void setMaximum (qreal newMaximum, bool computeNewFastSliderStep=true)
 
void setMinimum (qreal newMinimum, bool computeNewFastSliderStep=true)
 
void setRange (qreal newMinimum, qreal newMaximum, int newNumberOfDecimals=0, bool computeNewFastSliderStep=true)
 Set the minimum and the maximum values of the range.
 
void setSoftMaximum (qreal newSoftMaximum)
 
void setSoftMinimum (qreal newSoftMinimum)
 
void setSoftRange (qreal newSoftMinimum, qreal newSoftMaximum)
 
void setValue (qreal newValue)
 
QSize sizeHint () const override
 
qreal softMaximum () const
 
qreal softMinimum () const
 
 ~KisDoubleSliderSpinBox () override
 
- Public Member Functions inherited from KisDoubleParseSpinBox
bool isLastValid () const
 Get if the last expression entered is a valid one.
 
 KisDoubleParseSpinBox (QWidget *parent=0)
 
void setValue (double value, bool overwriteExpression=false)
 Set the value of the spinbox.
 
void stepBy (int steps) override
 This is a reimplementation of QDoubleSpinBox::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.
 
 ~KisDoubleParseSpinBox () override
 

Protected Member Functions

qreal getCommonValue () const override
 
bool hasSelection () const override
 
- Protected Member Functions inherited from KisSelectionPropertySliderBase
void setInternalValue (qreal value, bool blockUpdateSignal) override
 
void setSelectionValue (qreal commonValue, bool mixed)
 
- Protected Member Functions inherited from KisDoubleSliderSpinBox
void setPrivateValue (qreal newValue)
 
- Protected Member Functions inherited from KisDoubleParseSpinBox
QString textFromValue (double value) const override
 
QValidator::State validate (QString &input, int &pos) const override
 
double valueFromText (const QString &text) const override
 

Private Attributes

QList< T > m_selection
 
qreal(* m_valueGetter )(T)
 

Additional Inherited Members

- Signals inherited from KisDoubleSliderSpinBox
void draggingFinished ()
 
- Signals inherited from KisDoubleParseSpinBox
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.
 

Detailed Description

template<class T>
class KisSelectionPropertySlider< T >

This is a generic slider for adjusting a property across a set of one or more items such as a selection.

When using this class, first call the setValueGetter method to allow the slider to get values from the items. For example: slider->setValueGetter( [](KoShape *s) { return s->transparency(); } );

To update the slider, call setSelection with the new set of objects.

When the slider is dragged, valueChanged(qreal) signals are emitted after signal compression.

Definition at line 80 of file KisSelectionPropertySlider.h.

Constructor & Destructor Documentation

◆ KisSelectionPropertySlider()

template<class T >
KisSelectionPropertySlider< T >::KisSelectionPropertySlider ( QWidget * parent = 0)
inlineexplicit

Definition at line 83 of file KisSelectionPropertySlider.h.

Member Function Documentation

◆ getCommonValue()

template<class T >
qreal KisSelectionPropertySlider< T >::getCommonValue ( ) const
inlineoverrideprotectedvirtual

Implements KisSelectionPropertySliderBase.

Definition at line 114 of file KisSelectionPropertySlider.h.

115 {
116 qreal commonValue = -1.0;
117
118 Q_FOREACH (T item, m_selection) {
119 const qreal itemValue = m_valueGetter(item);
120
121 if (commonValue < 0) {
122 commonValue = itemValue;
123 } else if (!qFuzzyCompare(commonValue, itemValue)) {
124 commonValue = -1.0;
125 break;
126 }
127 }
128
129 return commonValue;
130 }
static bool qFuzzyCompare(half p1, half p2)

References qFuzzyCompare().

◆ hasSelection()

template<class T >
bool KisSelectionPropertySlider< T >::hasSelection ( ) const
inlineoverrideprotectedvirtual

Implements KisSelectionPropertySliderBase.

Definition at line 109 of file KisSelectionPropertySlider.h.

110 {
111 return !m_selection.isEmpty();
112 }

◆ selection()

template<class T >
QList< T > KisSelectionPropertySlider< T >::selection ( ) const
inline

Definition at line 104 of file KisSelectionPropertySlider.h.

104 {
105 return m_selection;
106 }

◆ setSelection()

template<class T >
void KisSelectionPropertySlider< T >::setSelection ( QList< T > newSelection)
inline

Definition at line 92 of file KisSelectionPropertySlider.h.

93 {
94 KisSignalsBlocker b(this);
95
96 m_selection = newSelection;
97
98 const qreal commonValue = getCommonValue();
99
100 setEnabled(!m_selection.isEmpty());
101 setSelectionValue(commonValue, commonValue < 0.0);
102 }
void setSelectionValue(qreal commonValue, bool mixed)

◆ setValueGetter()

template<class T >
void KisSelectionPropertySlider< T >::setValueGetter ( qreal(*)(T) getter)
inline

Definition at line 87 of file KisSelectionPropertySlider.h.

88 {
89 m_valueGetter = getter;
90 }

Member Data Documentation

◆ m_selection

template<class T >
QList<T> KisSelectionPropertySlider< T >::m_selection
private

Definition at line 134 of file KisSelectionPropertySlider.h.

◆ m_valueGetter

template<class T >
qreal(* KisSelectionPropertySlider< T >::m_valueGetter) (T)
inlineprivate

Definition at line 133 of file KisSelectionPropertySlider.h.

133{nullptr};

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