Commit 3a75eecf authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Remove "Transform around rotation center" checkbox

Now the option is always enabled, but the user can disable by holding
Alt modifier. The new behavior is the following:

No Alt pressed:

1) Scale -> scales relative to the *opposite corner*
2) Rotate -> rotates around the anchor point
3) Shear -> shear around the anchor point

Alt is pressed:

1) Scale -> scales relatinve to the *anchor point*
2) Rotate -> rotates around the center
3) Shear -> shear around the center

Tool options controls:

Always transform around the anchor point. If the user wants to
transform around center, he should just move the anchor to the
center (by clicking on the corresponding button).

Problems:

The only problem of this approach is that one cannot combine Alt modifier
with Ctrl (perspective) and Shift (keep aspect ratio) modifiers. I don't
know if it is a critical problem or nor.
parent 311061a8
......@@ -425,7 +425,7 @@ void KisFreeTransformStrategy::continuePrimaryAction(const QPointF &mousePos,
const KisTransformUtils::MatricesPack clickM(m_d->clickArgs);
const QTransform clickT = clickM.finalTransform();
const bool useRotationCenter = (m_d->currentArgs.transformAroundRotationCenter() ^ altModifierActive) &&
const bool useRotationCenter = !altModifierActive &&
!KisAlgebra2D::fuzzyPointCompare(anchorPoint, m_d->clickPos);
const QPointF rotationCenter =
......@@ -467,7 +467,7 @@ void KisFreeTransformStrategy::continuePrimaryAction(const QPointF &mousePos,
break;
case PERSPECTIVE:
{
const bool useRotationCenter = (m_d->currentArgs.transformAroundRotationCenter() ^ altModifierActive) &&
const bool useRotationCenter = !altModifierActive &&
!KisAlgebra2D::fuzzyPointCompare(anchorPoint, m_d->clickPos);
const QPointF rotationCenter =
......@@ -519,7 +519,7 @@ void KisFreeTransformStrategy::continuePrimaryAction(const QPointF &mousePos,
const QPointF targetMovingPointInView = staticPointInView + projNormVector * projLength;
// override scale static point if it is locked
if ((m_d->clickArgs.transformAroundRotationCenter() ^ altModifierActive) &&
if (altModifierActive &&
!qFuzzyCompare(anchorPoint.y(), movingPoint.y())) {
staticPoint = anchorPoint;
......@@ -572,7 +572,7 @@ void KisFreeTransformStrategy::continuePrimaryAction(const QPointF &mousePos,
const QPointF targetMovingPointInView = staticPointInView + projNormVector * projLength;
// override scale static point if it is locked
if ((m_d->currentArgs.transformAroundRotationCenter() ^ altModifierActive) &&
if (altModifierActive &&
!qFuzzyCompare(anchorPoint.x(), movingPoint.x())) {
staticPoint = anchorPoint;
......@@ -621,7 +621,7 @@ void KisFreeTransformStrategy::continuePrimaryAction(const QPointF &mousePos,
}
// override scale static point if it is locked
if ((m_d->currentArgs.transformAroundRotationCenter() ^ altModifierActive) &&
if (altModifierActive &&
!(qFuzzyCompare(anchorPoint.x(), movingPoint.x()) ||
qFuzzyCompare(anchorPoint.y(), movingPoint.y()))) {
......@@ -701,7 +701,7 @@ void KisFreeTransformStrategy::continuePrimaryAction(const QPointF &mousePos,
KisTransformUtils::MatricesPack currentM(m_d->currentArgs);
QTransform t = currentM.finalTransform();
const bool useRotationCenter = (m_d->currentArgs.transformAroundRotationCenter() ^ altModifierActive) &&
const bool useRotationCenter = !altModifierActive &&
!qFuzzyCompare(anchorPoint.y(), m_d->clickPos.y());
const QPointF rotationCenter =
......@@ -736,7 +736,7 @@ void KisFreeTransformStrategy::continuePrimaryAction(const QPointF &mousePos,
KisTransformUtils::MatricesPack currentM(m_d->currentArgs);
QTransform t = currentM.finalTransform();
const bool useRotationCenter = (m_d->currentArgs.transformAroundRotationCenter() ^ altModifierActive) &&
const bool useRotationCenter = !altModifierActive &&
!qFuzzyCompare(anchorPoint.x(), m_d->clickPos.x());
const QPointF rotationCenter =
......
......@@ -137,7 +137,6 @@ KisToolTransformConfigWidget::KisToolTransformConfigWidget(TransformTransactionP
cameraHeightBox->setRange(1, 20000, 2);
connect(m_rotationCenterButtons, SIGNAL(buttonPressed(int)), this, SLOT(slotRotationCenterChanged(int)));
connect(btnTransformAroundPivotPoint, SIGNAL(clicked(bool)), this, SLOT(slotTransformAroundRotationCenter(bool)));
// Init Free Transform Values
connect(scaleXBox, SIGNAL(valueChanged(int)), this, SLOT(slotSetScaleX(int)));
......@@ -332,9 +331,6 @@ void KisToolTransformConfigWidget::slotUpdateIcons()
middleBottomButton->setIcon(KisIconUtils::loadIcon("arrow-down"));
bottomRightButton->setIcon(KisIconUtils::loadIcon("arrow-downright"));
btnTransformAroundPivotPoint->setIcon(KisIconUtils::loadIcon("pivot-point"));
// pressure icons
liquifySizePressureBox->setIcon(KisIconUtils::loadIcon("transform_icons_penPressure"));
liquifyAmountPressureBox->setIcon(KisIconUtils::loadIcon("transform_icons_penPressure"));
......@@ -561,8 +557,6 @@ void KisToolTransformConfigWidget::updateConfig(const ToolTransformArgs &config)
}
}
btnTransformAroundPivotPoint->setChecked(config.transformAroundRotationCenter());
} else if (config.mode() == ToolTransformArgs::WARP) {
stackedWidget->setCurrentIndex(1);
......@@ -833,16 +827,6 @@ void KisToolTransformConfigWidget::slotRotationCenterChanged(int index)
}
}
void KisToolTransformConfigWidget::slotTransformAroundRotationCenter(bool value)
{
if (m_uiSlotsBlocked) return;
ToolTransformArgs *config = m_transaction->currentConfig();
config->setTransformAroundRotationCenter(value);
notifyConfigChanged();
notifyEditingFinished();
}
void KisToolTransformConfigWidget::slotSetScaleX(int value)
{
if (m_uiSlotsBlocked) return;
......@@ -850,7 +834,7 @@ void KisToolTransformConfigWidget::slotSetScaleX(int value)
ToolTransformArgs *config = m_transaction->currentConfig();
{
KisTransformUtils::AnchorHolder keeper(config->transformAroundRotationCenter(), config);
KisTransformUtils::AnchorHolder keeper(true, config);
config->setScaleX(value / 100.);
}
......@@ -862,7 +846,7 @@ void KisToolTransformConfigWidget::slotSetScaleX(int value)
scaleYBox->blockSignals(true);
scaleYBox->setValue(calculatedValue);
{
KisTransformUtils::AnchorHolder keeper(config->transformAroundRotationCenter(), config);
KisTransformUtils::AnchorHolder keeper(true, config);
config->setScaleY(calculatedValue / 100.);
}
scaleYBox->blockSignals(false);
......@@ -881,7 +865,7 @@ void KisToolTransformConfigWidget::slotSetScaleY(int value)
ToolTransformArgs *config = m_transaction->currentConfig();
{
KisTransformUtils::AnchorHolder keeper(config->transformAroundRotationCenter(), config);
KisTransformUtils::AnchorHolder keeper(true, config);
config->setScaleY(value / 100.);
}
......@@ -891,7 +875,7 @@ void KisToolTransformConfigWidget::slotSetScaleY(int value)
scaleXBox->blockSignals(true);
scaleXBox->setValue(calculatedValue);
{
KisTransformUtils::AnchorHolder keeper(config->transformAroundRotationCenter(), config);
KisTransformUtils::AnchorHolder keeper(true, config);
config->setScaleX(calculatedValue / 100.);
}
scaleXBox->blockSignals(false);
......@@ -909,7 +893,7 @@ void KisToolTransformConfigWidget::slotSetShearX(qreal value)
ToolTransformArgs *config = m_transaction->currentConfig();
{
KisTransformUtils::AnchorHolder keeper(config->transformAroundRotationCenter(), config);
KisTransformUtils::AnchorHolder keeper(true, config);
config->setShearX((double)value / 100.);
}
......@@ -924,7 +908,7 @@ void KisToolTransformConfigWidget::slotSetShearY(qreal value)
ToolTransformArgs *config = m_transaction->currentConfig();
{
KisTransformUtils::AnchorHolder keeper(config->transformAroundRotationCenter(), config);
KisTransformUtils::AnchorHolder keeper(true, config);
config->setShearY((double)value / 100.);
}
......@@ -971,7 +955,7 @@ void KisToolTransformConfigWidget::slotSetAX(qreal value)
ToolTransformArgs *config = m_transaction->currentConfig();
{
KisTransformUtils::AnchorHolder keeper(config->transformAroundRotationCenter(), config);
KisTransformUtils::AnchorHolder keeper(true, config);
config->setAX(kisDegreesToRadians(value));
}
notifyConfigChanged();
......@@ -985,7 +969,7 @@ void KisToolTransformConfigWidget::slotSetAY(qreal value)
ToolTransformArgs *config = m_transaction->currentConfig();
{
KisTransformUtils::AnchorHolder keeper(config->transformAroundRotationCenter(), config);
KisTransformUtils::AnchorHolder keeper(true, config);
config->setAY(kisDegreesToRadians(value));
}
......@@ -1000,7 +984,7 @@ void KisToolTransformConfigWidget::slotSetAZ(qreal value)
ToolTransformArgs *config = m_transaction->currentConfig();
{
KisTransformUtils::AnchorHolder keeper(config->transformAroundRotationCenter(), config);
KisTransformUtils::AnchorHolder keeper(true, config);
config->setAZ(kisDegreesToRadians(value));
}
......@@ -1024,7 +1008,7 @@ void KisToolTransformConfigWidget::slotFlipX()
ToolTransformArgs *config = m_transaction->currentConfig();
{
KisTransformUtils::AnchorHolder keeper(config->transformAroundRotationCenter(), config);
KisTransformUtils::AnchorHolder keeper(true, config);
config->setScaleX(config->scaleX() * -1);
}
......@@ -1037,7 +1021,7 @@ void KisToolTransformConfigWidget::slotFlipY()
ToolTransformArgs *config = m_transaction->currentConfig();
{
KisTransformUtils::AnchorHolder keeper(config->transformAroundRotationCenter(), config);
KisTransformUtils::AnchorHolder keeper(true, config);
config->setScaleY(config->scaleY() * -1);
}
......@@ -1050,7 +1034,7 @@ void KisToolTransformConfigWidget::slotRotateCW()
ToolTransformArgs *config = m_transaction->currentConfig();
{
KisTransformUtils::AnchorHolder keeper(config->transformAroundRotationCenter(), config);
KisTransformUtils::AnchorHolder keeper(true, config);
config->setAZ(normalizeAngle(config->aZ() + M_PI_2));
}
......@@ -1063,7 +1047,7 @@ void KisToolTransformConfigWidget::slotRotateCCW()
ToolTransformArgs *config = m_transaction->currentConfig();
{
KisTransformUtils::AnchorHolder keeper(config->transformAroundRotationCenter(), config);
KisTransformUtils::AnchorHolder keeper(true, config);
config->setAZ(normalizeAngle(config->aZ() - M_PI_2));
}
......
......@@ -43,7 +43,6 @@ public Q_SLOTS:
void slotFilterChanged(const KoID &filter);
void slotWarpTypeChanged(int index);
void slotRotationCenterChanged(int index);
void slotTransformAroundRotationCenter(bool value);
void slotSetScaleX(int value);
void slotSetScaleY(int value);
......
......@@ -25,7 +25,6 @@ ToolTransformArgs::ToolTransformArgs()
KConfigGroup configGroup = KSharedConfig::openConfig()->group("KisToolTransform");
QString savedFilterId = configGroup.readEntry("filterId", "Bicubic");
setFilterId(savedFilterId);
m_transformAroundRotationCenter = configGroup.readEntry("transformAroundRotationCenter", "0").toInt();
m_meshShowHandles = configGroup.readEntry("meshShowHandles", true);
m_meshSymmetricalHandles = configGroup.readEntry("meshSymmetricalHandles", true);
m_meshScaleHandles = configGroup.readEntry("meshScaleHandles", false);
......@@ -40,21 +39,12 @@ void ToolTransformArgs::setFilterId(const QString &id) {
}
}
void ToolTransformArgs::setTransformAroundRotationCenter(bool value)
{
m_transformAroundRotationCenter = value;
KConfigGroup configGroup = KSharedConfig::openConfig()->group("KisToolTransform");
configGroup.writeEntry("transformAroundRotationCenter", int(value));
}
void ToolTransformArgs::init(const ToolTransformArgs& args)
{
m_mode = args.mode();
m_transformedCenter = args.transformedCenter();
m_originalCenter = args.originalCenter();
m_rotationCenterOffset = args.rotationCenterOffset();
m_transformAroundRotationCenter = args.transformAroundRotationCenter();
m_cameraPos = args.m_cameraPos;
m_aX = args.aX();
m_aY = args.aY();
......@@ -143,7 +133,6 @@ bool ToolTransformArgs::operator==(const ToolTransformArgs& other) const
m_transformedCenter == other.m_transformedCenter &&
m_originalCenter == other.m_originalCenter &&
m_rotationCenterOffset == other.m_rotationCenterOffset &&
m_transformAroundRotationCenter == other.m_transformAroundRotationCenter &&
m_aX == other.m_aX &&
m_aY == other.m_aY &&
m_aZ == other.m_aZ &&
......@@ -227,7 +216,6 @@ ToolTransformArgs::ToolTransformArgs(TransformMode mode,
QPointF transformedCenter,
QPointF originalCenter,
QPointF rotationCenterOffset,
bool transformAroundRotationCenter,
double aX, double aY, double aZ,
double scaleX, double scaleY,
double shearX, double shearY,
......@@ -246,7 +234,6 @@ ToolTransformArgs::ToolTransformArgs(TransformMode mode,
, m_transformedCenter(transformedCenter)
, m_originalCenter(originalCenter)
, m_rotationCenterOffset(rotationCenterOffset)
, m_transformAroundRotationCenter(transformAroundRotationCenter)
, m_aX(aX)
, m_aY(aY)
, m_aZ(aZ)
......@@ -379,7 +366,6 @@ void ToolTransformArgs::toXML(QDomElement *e) const
KisDomUtils::saveValue(&freeEl, "transformedCenter", m_transformedCenter);
KisDomUtils::saveValue(&freeEl, "originalCenter", m_originalCenter);
KisDomUtils::saveValue(&freeEl, "rotationCenterOffset", m_rotationCenterOffset);
KisDomUtils::saveValue(&freeEl, "transformAroundRotationCenter", m_transformAroundRotationCenter);
KisDomUtils::saveValue(&freeEl, "aX", m_aX);
KisDomUtils::saveValue(&freeEl, "aY", m_aY);
......@@ -475,12 +461,6 @@ ToolTransformArgs ToolTransformArgs::fromXML(const QDomElement &e)
KisDomUtils::loadValue(freeEl, "flattenedPerspectiveTransform", &args.m_flattenedPerspectiveTransform) &&
KisDomUtils::loadValue(freeEl, "filterId", &filterId);
// transformAroundRotationCenter is a new parameter introduced in Krita 4.0,
// so it might be not present in older transform masks
if (!KisDomUtils::loadValue(freeEl, "transformAroundRotationCenter", &args.m_transformAroundRotationCenter)) {
args.m_transformAroundRotationCenter = false;
}
if (result) {
args.m_filter = KisFilterStrategyRegistry::instance()->value(filterId);
result = (bool) args.m_filter;
......
......@@ -62,7 +62,7 @@ public:
ToolTransformArgs(TransformMode mode,
QPointF transformedCenter,
QPointF originalCenter,
QPointF rotationCenterOffset, bool transformAroundRotationCenter,
QPointF rotationCenterOffset,
double aX, double aY, double aZ,
double scaleX, double scaleY,
double shearX, double shearY,
......@@ -174,9 +174,6 @@ public:
inline QPointF rotationCenterOffset() const {
return m_rotationCenterOffset;
}
inline bool transformAroundRotationCenter() const {
return m_transformAroundRotationCenter;
}
inline double aX() const {
return m_aX;
}
......@@ -214,8 +211,6 @@ public:
inline void setRotationCenterOffset(QPointF rotationCenterOffset) {
m_rotationCenterOffset = rotationCenterOffset;
}
void setTransformAroundRotationCenter(bool value);
inline void setAX(double aX) {
m_aX = aX;
}
......@@ -341,9 +336,6 @@ private:
QPointF m_rotationCenterOffset; // the position of the rotation center relative to
// the original top left corner of the selection
// before any transformation
bool m_transformAroundRotationCenter {false}; // In freehand mode makes the scaling and other transformations
// be anchored to the rotation center point.
double m_aX {0};
double m_aY {0};
double m_aZ {0};
......
......@@ -307,50 +307,6 @@
<property name="verticalSpacing">
<number>15</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>&amp;Filter:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="buddy">
<cstring>cmbFilter</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QToolButton" name="btnTransformAroundPivotPoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Transform around pivot point (Alt)</string>
</property>
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KisCmbIDList" name="cmbFilter" native="true">
<property name="sizePolicy">
......@@ -581,6 +537,28 @@
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>&amp;Filter:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="buddy">
<cstring>cmbFilter</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment