|
Krita Source Code Documentation
|
#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< Private > | m_d |
KisAspectRatioLocker is a class for locking the ratio between two sliders, i.e. to keep width and height of the image proportional.
When the locker takes responsibility of two sliders and a button, you should not use the valueChanged() and toggled() signals of the sliders and the button themselves. Instead you need to connect to the corresponding signals of the locker.
Usage:
\code{.cpp}
KisIntParseSpinBox *intRoundCornersX = ...;
KisIntParseSpinBox *intRoundCornersY = ...;
KoAspectButton *cornersAspectButton = ...;
auto *cornersAspectLocker = new KisAspectRatioLocker(this);
cornersAspectLocker->connectSpinBoxes(intRoundCornersX, intRoundCornersY, cornersAspectButton);
connect(cornersAspectLocker, SIGNAL(sliderValueChanged()), SLOT(slotRoundCornersChanged()));
connect(cornersAspectLocker, SIGNAL(aspectButtonChanged()), SLOT(slotRoundCornersAspectLockChanged()));
\endcode
Definition at line 46 of file kis_aspect_ratio_locker.h.
| KisAspectRatioLocker::KisAspectRatioLocker | ( | QObject * | parent = 0 | ) |
Definition at line 140 of file kis_aspect_ratio_locker.cpp.
|
override |
Definition at line 146 of file kis_aspect_ratio_locker.cpp.
|
signal |
Emitted when the aspec locking button state is changed.
|
signal |
Emitted when the aspec locking button state is changed, but also passing its new state.
| template KRITAUI_EXPORT void KisAspectRatioLocker::connectAngleBoxes | ( | AngleBoxType * | spinOne, |
| AngleBoxType * | spinTwo, | ||
| KoAspectButton * | aspectButton ) |
Link two angular spin boxes and an aspect button together
Definition at line 173 of file kis_aspect_ratio_locker.cpp.
References m_d, slotAspectButtonChanged(), slotSpinOneChanged(), and slotSpinTwoChanged().
| template KRITAUI_EXPORT void KisAspectRatioLocker::connectSpinBoxes | ( | SpinBoxType * | spinOne, |
| SpinBoxType * | spinTwo, | ||
| KoAspectButton * | aspectButton ) |
Link two spin boxes and an aspect button together
Definition at line 151 of file kis_aspect_ratio_locker.cpp.
References m_d, slotAspectButtonChanged(), slotSpinDraggingFinished(), slotSpinOneChanged(), and slotSpinTwoChanged().
| void KisAspectRatioLocker::setBlockUpdateSignalOnDrag | ( | bool | block | ) |
Selects whether sliderValueChanged() signal should be emitted continuously while the user drags one of the slider or only once when the drag operation is completed
Definition at line 244 of file kis_aspect_ratio_locker.cpp.
|
signal |
Emitted when a value of any of the sliders has changed and all aspect corrections have been completed.
You should use this signal instead of the own signals of the sliders, because these signals might be either blocked or come in undefined order.
|
privateslot |
Definition at line 221 of file kis_aspect_ratio_locker.cpp.
References aspectButtonChanged(), aspectButtonToggled(), and m_d.
|
privateslot |
Definition at line 237 of file kis_aspect_ratio_locker.cpp.
References m_d, and sliderValueChanged().
|
privateslot |
Definition at line 197 of file kis_aspect_ratio_locker.cpp.
References m_d, and sliderValueChanged().
|
privateslot |
Definition at line 209 of file kis_aspect_ratio_locker.cpp.
References m_d, and sliderValueChanged().
| void KisAspectRatioLocker::updateAspect | ( | ) |
Recalculate and lock the new aspect ratio of the sliders. The function takes the current values of the sliders and calculates the new ratio based on them.
This function is expected to be used when a saved value is restored into the sliders. Make sure that you block signals of the controls while loading values.
Usage:
\code{.cpp}
// load values in a locked state
KisSignalsBlocker b(intRoundCornersX, intRoundCornersY, cornersAspectButton);
intRoundCornersX->setValue(cfg.readEntry("roundCornersX", 0));
intRoundCornersY->setValue(cfg.readEntry("roundCornersY", 0));
cornersAspectButton->setKeepAspectRatio(cfg.readEntry("roundCornersAspectLocked", true));
// update new aspect ratio
cornersAspectLocker->updateAspect();
\endcode
Definition at line 249 of file kis_aspect_ratio_locker.cpp.
References slotAspectButtonChanged().
|
private |
Definition at line 127 of file kis_aspect_ratio_locker.h.