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

#include <kis_aspect_ratio_locker.h>

+ Inheritance diagram for KisAspectRatioLocker:

Classes

struct  Private
 

Signals

void aspectButtonChanged ()
 
void aspectButtonToggled (bool value)
 
void sliderValueChanged ()
 

Public Member Functions

template<class AngleBoxType >
void connectAngleBoxes (AngleBoxType *spinOne, AngleBoxType *spinTwo, KoAspectButton *aspectButton)
 
template<class SpinBoxType >
void connectSpinBoxes (SpinBoxType *spinOne, SpinBoxType *spinTwo, KoAspectButton *aspectButton)
 
 KisAspectRatioLocker (QObject *parent=0)
 
void setBlockUpdateSignalOnDrag (bool block)
 
void updateAspect ()
 
 ~KisAspectRatioLocker () override
 

Private Slots

void slotAspectButtonChanged ()
 
void slotSpinDraggingFinished ()
 
void slotSpinOneChanged ()
 
void slotSpinTwoChanged ()
 

Private Attributes

const QScopedPointer< Privatem_d
 

Detailed Description

Definition at line 20 of file kis_aspect_ratio_locker.h.

Constructor & Destructor Documentation

◆ KisAspectRatioLocker()

KisAspectRatioLocker::KisAspectRatioLocker ( QObject * parent = 0)

Definition at line 140 of file kis_aspect_ratio_locker.cpp.

141 : QObject(parent),
142 m_d(new Private)
143{
144}
const QScopedPointer< Private > m_d

◆ ~KisAspectRatioLocker()

KisAspectRatioLocker::~KisAspectRatioLocker ( )
override

Definition at line 146 of file kis_aspect_ratio_locker.cpp.

147{
148}

Member Function Documentation

◆ aspectButtonChanged

void KisAspectRatioLocker::aspectButtonChanged ( )
signal

◆ aspectButtonToggled

void KisAspectRatioLocker::aspectButtonToggled ( bool value)
signal

◆ connectAngleBoxes()

template<class AngleBoxType >
template KRITAUI_EXPORT void KisAspectRatioLocker::connectAngleBoxes ( AngleBoxType * spinOne,
AngleBoxType * spinTwo,
KoAspectButton * aspectButton )

Definition at line 173 of file kis_aspect_ratio_locker.cpp.

174{
175 m_d->spinOne.reset(new SliderWrapper(spinOne));
176 m_d->spinTwo.reset(new SliderWrapper(spinTwo));
177 m_d->aspectButton = aspectButton;
178
179 connect(spinOne, SIGNAL(angleChanged(qreal)), SLOT(slotSpinOneChanged()));
180 connect(spinTwo, SIGNAL(angleChanged(qreal)), SLOT(slotSpinTwoChanged()));
181
182 connect(m_d->aspectButton, SIGNAL(keepAspectRatioChanged(bool)), SLOT(slotAspectButtonChanged()));
184}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))

References connect(), m_d, slotAspectButtonChanged(), slotSpinOneChanged(), and slotSpinTwoChanged().

◆ connectSpinBoxes()

template<class SpinBoxType >
template KRITAUI_EXPORT void KisAspectRatioLocker::connectSpinBoxes ( SpinBoxType * spinOne,
SpinBoxType * spinTwo,
KoAspectButton * aspectButton )

Definition at line 151 of file kis_aspect_ratio_locker.cpp.

152{
153 m_d->spinOne.reset(new SliderWrapper(spinOne));
154 m_d->spinTwo.reset(new SliderWrapper(spinTwo));
155 m_d->aspectButton = aspectButton;
156
157 if (QVariant::fromValue(spinOne->value()).type() == QVariant::Double) {
158 connect(spinOne, SIGNAL(valueChanged(qreal)), SLOT(slotSpinOneChanged()));
159 connect(spinTwo, SIGNAL(valueChanged(qreal)), SLOT(slotSpinTwoChanged()));
160 } else {
161 connect(spinOne, SIGNAL(valueChanged(int)), SLOT(slotSpinOneChanged()));
162 connect(spinTwo, SIGNAL(valueChanged(int)), SLOT(slotSpinTwoChanged()));
163 }
164
165 m_d->spinOne->connectDraggingFinished(this, SLOT(slotSpinDraggingFinished()));
166 m_d->spinTwo->connectDraggingFinished(this, SLOT(slotSpinDraggingFinished()));
167
168 connect(m_d->aspectButton, SIGNAL(keepAspectRatioChanged(bool)), SLOT(slotAspectButtonChanged()));
170}

References connect(), m_d, slotAspectButtonChanged(), slotSpinDraggingFinished(), slotSpinOneChanged(), and slotSpinTwoChanged().

◆ setBlockUpdateSignalOnDrag()

void KisAspectRatioLocker::setBlockUpdateSignalOnDrag ( bool block)

Definition at line 244 of file kis_aspect_ratio_locker.cpp.

245{
246 m_d->blockUpdatesOnDrag = value;
247}
float value(const T *src, size_t ch)

References m_d, and value().

◆ sliderValueChanged

void KisAspectRatioLocker::sliderValueChanged ( )
signal

◆ slotAspectButtonChanged

void KisAspectRatioLocker::slotAspectButtonChanged ( )
privateslot

Definition at line 221 of file kis_aspect_ratio_locker.cpp.

222{
223 if (m_d->aspectButton->keepAspectRatio() &&
224 m_d->spinTwo->value() > 0 &&
225 m_d->spinOne->value() > 0) {
226 m_d->aspectRatio = qreal(m_d->spinTwo->value()) / m_d->spinOne->value();
227 } else {
228 m_d->aspectRatio = 1.0;
229 }
230
231 if (!m_d->spinTwo->isDragging()) {
232 Q_EMIT aspectButtonChanged();
233 Q_EMIT aspectButtonToggled(m_d->aspectButton->keepAspectRatio());
234 }
235}
void aspectButtonToggled(bool value)

References aspectButtonChanged(), aspectButtonToggled(), and m_d.

◆ slotSpinDraggingFinished

void KisAspectRatioLocker::slotSpinDraggingFinished ( )
privateslot

Definition at line 237 of file kis_aspect_ratio_locker.cpp.

238{
239 if (m_d->blockUpdatesOnDrag) {
240 Q_EMIT sliderValueChanged();
241 }
242}

References m_d, and sliderValueChanged().

◆ slotSpinOneChanged

void KisAspectRatioLocker::slotSpinOneChanged ( )
privateslot

Definition at line 197 of file kis_aspect_ratio_locker.cpp.

198{
199 if (m_d->aspectButton->keepAspectRatio()) {
200 KisSignalsBlocker b(m_d->spinTwo->object());
201 m_d->spinTwo->setValue(m_d->aspectRatio * m_d->spinOne->value());
202 }
203
204 if (!m_d->blockUpdatesOnDrag || !m_d->spinOne->isDragging()) {
205 Q_EMIT sliderValueChanged();
206 }
207}

References m_d, and sliderValueChanged().

◆ slotSpinTwoChanged

void KisAspectRatioLocker::slotSpinTwoChanged ( )
privateslot

Definition at line 209 of file kis_aspect_ratio_locker.cpp.

210{
211 if (m_d->aspectButton->keepAspectRatio()) {
212 KisSignalsBlocker b(m_d->spinOne->object());
213 m_d->spinOne->setValue(m_d->spinTwo->value() / m_d->aspectRatio);
214 }
215
216 if (!m_d->blockUpdatesOnDrag || !m_d->spinTwo->isDragging()) {
217 Q_EMIT sliderValueChanged();
218 }
219}

References m_d, and sliderValueChanged().

◆ updateAspect()

void KisAspectRatioLocker::updateAspect ( )

Definition at line 249 of file kis_aspect_ratio_locker.cpp.

250{
251 KisSignalsBlocker b(this);
253}

References slotAspectButtonChanged().

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KisAspectRatioLocker::m_d
private

Definition at line 49 of file kis_aspect_ratio_locker.h.


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