Compare commits

..

No commits in common. "88171af028aacf75fa1a11b68f606a75f841c4ab" and "ce2e6b04dade671e7757e1e675daebddf86ba848" have entirely different histories.

17 changed files with 49 additions and 271 deletions

View File

@ -18,10 +18,6 @@
#include "colorvaluerect.h" #include "colorvaluerect.h"
#include "colorlabel.h" #include "colorlabel.h"
#include "colorpickingwidget.h"
#include "GUI/mainwindow.h"
#include "GUI/actionbutton.h"
#include <QWindow>
#include <QVBoxLayout> #include <QVBoxLayout>
@ -79,15 +75,7 @@ PaintColorWidget::PaintColorWidget(QWidget* const parent) :
layout->addWidget(aRect); layout->addWidget(aRect);
const QString pickIcon = "toolbarButtons/pickUnchecked.png"; layout->addWidget(mColorLabel);
const auto pickingButton = new ActionButton(pickIcon, "", this);
connect(pickingButton, &ActionButton::released,
this, &PaintColorWidget::startColorPicking);
const auto colorPickLay = new QHBoxLayout();
colorPickLay->addWidget(mColorLabel);
colorPickLay->addWidget(pickingButton);
layout->addLayout(colorPickLay);
setLayout(layout); setLayout(layout);
} }
@ -123,16 +111,6 @@ void PaintColorWidget::setDisplayedColor(const QColor& color) {
mColorLabel->setAlpha(color.alphaF()); mColorLabel->setAlpha(color.alphaF());
} }
void PaintColorWidget::startColorPicking() {
const auto parent = MainWindow::sGetInstance();
const auto screen = parent->windowHandle()->screen();
const auto wid = new ColorPickingWidget(screen, parent);
connect(wid, &ColorPickingWidget::colorSelected,
[this](const QColor & color) {
setColor(color);
});
}
void PaintColorWidget::setColor(const QColor& color) { void PaintColorWidget::setColor(const QColor& color) {
setDisplayedColor(color); setDisplayedColor(color);
emit colorChanged(color); emit colorChanged(color);

View File

@ -32,7 +32,6 @@ public:
signals: signals:
void colorChanged(const QColor& color); void colorChanged(const QColor& color);
private: private:
void startColorPicking();
void setColor(const QColor& color); void setColor(const QColor& color);
void updateFromRGB(); void updateFromRGB();

View File

@ -186,8 +186,16 @@ void BasicTransformAnimator::moveByAbs(const QPointF &absTrans) {
if(!mParentTransform) return; if(!mParentTransform) return;
const auto savedRelPos = mPosAnimator->getSavedValue(); const auto savedRelPos = mPosAnimator->getSavedValue();
const auto savedAbsPos = mParentTransform->mapRelPosToAbs(savedRelPos); const auto savedAbsPos = mParentTransform->mapRelPosToAbs(savedRelPos);
const auto relPos = mParentTransform->mapAbsPosToRel(savedAbsPos + absTrans); moveToAbs(savedAbsPos + absTrans);
setRelativePos(relPos); }
void BasicTransformAnimator::moveToAbs(const QPointF &absPos) {
setAbsolutePos(absPos);
}
void BasicTransformAnimator::setAbsolutePos(const QPointF &pos) {
if(!mParentTransform) return;
setRelativePos(mParentTransform->mapAbsPosToRel(pos));
} }
void BasicTransformAnimator::setRelativePos(const QPointF &relPos) { void BasicTransformAnimator::setRelativePos(const QPointF &relPos) {

View File

@ -54,6 +54,8 @@ public:
void startScaleTransform(); void startScaleTransform();
void setRelativePos(const QPointF &relPos); void setRelativePos(const QPointF &relPos);
void setAbsolutePos(const QPointF &pos);
void moveToAbs(const QPointF &absPos);
void moveByAbs(const QPointF &absTrans); void moveByAbs(const QPointF &absTrans);
void rotateRelativeToSavedValue(const qreal rotRel); void rotateRelativeToSavedValue(const qreal rotRel);

View File

@ -52,10 +52,8 @@ QList<BrushStrokeSet> BrushStrokeSet::sFromSkPath(
if(segLists.isEmpty()) return result; if(segLists.isEmpty()) return result;
for(auto& segs : segLists) { for(auto& segs : segLists) {
if(segs.isEmpty()) continue; if(segs.isEmpty()) continue;
const double totLen = segs.getTotalLength();
if(isZero4Dec(totLen)) continue;
const double minL = 0; const double minL = 0;
const double maxL = segs.isClosed() ? 1 + 10/totLen : 1; const double maxL = segs.isClosed() ? 1 + 10/segs.getTotalLength() : 1;
auto segsT = segs.getFragmentUnbound(minL, maxL); auto segsT = segs.getFragmentUnbound(minL, maxL);
result << sFromCubicList(segsT, timeCurve, result << sFromCubicList(segsT, timeCurve,
pressureCurve, widthCurve, spacingCurve); pressureCurve, widthCurve, spacingCurve);

View File

@ -29,8 +29,6 @@ BoundingBox* BoxTargetProperty::getTarget() const {
void BoxTargetProperty::setTargetAction(BoundingBox* const box) { void BoxTargetProperty::setTargetAction(BoundingBox* const box) {
if(box == mTarget_d) return; if(box == mTarget_d) return;
const auto oldValue = mTarget_d.get();
emit setActionStarted(oldValue, box);
{ {
prp_pushUndoRedoName("Set Box Target"); prp_pushUndoRedoName("Set Box Target");
UndoRedo ur; UndoRedo ur;
@ -46,7 +44,6 @@ void BoxTargetProperty::setTargetAction(BoundingBox* const box) {
} }
setTarget(box); setTarget(box);
emit setActionFinished(oldValue, box);
} }
void BoxTargetProperty::setTarget(BoundingBox* const box) { void BoxTargetProperty::setTarget(BoundingBox* const box) {

View File

@ -53,8 +53,6 @@ public:
void setValidator(const Validator& validator) void setValidator(const Validator& validator)
{ mValidator = validator; } { mValidator = validator; }
signals: signals:
void setActionStarted(BoundingBox*, BoundingBox*);
void setActionFinished(BoundingBox*, BoundingBox*);
void targetSet(BoundingBox*); void targetSet(BoundingBox*);
private: private:
std::function<bool(BoundingBox*)> mValidator = nullptr; std::function<bool(BoundingBox*)> mValidator = nullptr;

View File

@ -34,12 +34,10 @@ CubicList::CubicList(const CubicList &src) {
CubicList CubicList::getFragment(const qreal minLenFrac, CubicList CubicList::getFragment(const qreal minLenFrac,
const qreal maxLenFrac) const { const qreal maxLenFrac) const {
if(minLenFrac > maxLenFrac) return CubicList(); if(minLenFrac > maxLenFrac) return CubicList();
const qreal totLen = getTotalLength();
if(isZero4Dec(totLen)) return *this;
//Q_ASSERT(minLenFrac > 0); //Q_ASSERT(minLenFrac > 0);
//Q_ASSERT(maxLenFrac < 1); //Q_ASSERT(maxLenFrac < 1);
const qreal minLen = totLen*CLAMP01(minLenFrac); const qreal minLen = getTotalLength()*CLAMP01(minLenFrac);
const qreal maxLen = totLen*CLAMP01(maxLenFrac); const qreal maxLen = getTotalLength()*CLAMP01(maxLenFrac);
qreal minT = 0, maxT = 1; qreal minT = 0, maxT = 1;
int minI = -1, maxI = mSegments.count() - 1; int minI = -1, maxI = mSegments.count() - 1;
qreal currLen = 0; qreal currLen = 0;
@ -60,7 +58,6 @@ CubicList CubicList::getFragment(const qreal minLenFrac,
break; break;
} }
} }
if(minI == -1) return CubicList();
QList<qCubicSegment2D> fragSegs; QList<qCubicSegment2D> fragSegs;
if(minI == maxI) { if(minI == maxI) {

View File

@ -38,51 +38,6 @@ FollowObjectTransformEffect::FollowObjectTransformEffect() :
ca_addChild(mRotInfluence); ca_addChild(mRotInfluence);
} }
void FollowObjectTransformEffect::setRotScaleAfterTargetChange(
BoundingBox* const oldTarget, BoundingBox* const newTarget) {
const auto parent = getFirstAncestor<BoundingBox>();
if(!parent) return;
const qreal scaleXInfl = mScaleInfluence->getEffectiveXValue();
const qreal scaleYInfl = mScaleInfluence->getEffectiveYValue();
const qreal rotInfl = mRotInfluence->getEffectiveValue();
qreal rot = 0.;
qreal scaleX = 1.;
qreal scaleY = 1.;
if(oldTarget) {
const auto trans = oldTarget->getTransformAnimator();
const auto rotAnim = trans->getRotAnimator();
const auto scaleAnim = trans->getScaleAnimator();
rot += rotAnim->getEffectiveValue()*rotInfl;
scaleX *= 1 + (scaleAnim->getEffectiveXValue() - 1)*scaleXInfl;
scaleY *= 1 + (scaleAnim->getEffectiveYValue() - 1)*scaleYInfl;
}
if(newTarget) {
const auto trans = newTarget->getTransformAnimator();
const auto rotAnim = trans->getRotAnimator();
const auto scaleAnim = trans->getScaleAnimator();
rot -= rotAnim->getEffectiveValue()*rotInfl;
const qreal scaleXDiv = 1 + (scaleAnim->getEffectiveXValue() - 1)*scaleXInfl;
const qreal scaleYDiv = 1 + (scaleAnim->getEffectiveYValue() - 1)*scaleYInfl;
if(!isZero4Dec(scaleXDiv)) {
scaleX /= scaleXDiv;
}
if(!isZero4Dec(scaleYDiv)) {
scaleY /= scaleYDiv;
}
}
parent->startRotTransform();
parent->rotateBy(rot);
parent->startScaleTransform();
parent->scale(scaleX, scaleY);
}
void FollowObjectTransformEffect::applyEffect( void FollowObjectTransformEffect::applyEffect(
const qreal relFrame, const qreal relFrame,

View File

@ -33,11 +33,6 @@ public:
qreal &shearX, qreal &shearY, qreal &shearX, qreal &shearY,
BoundingBox* const parent) override; BoundingBox* const parent) override;
private: private:
void setRotScaleAfterTargetChange(
BoundingBox* const oldTarget,
BoundingBox* const newTarget) override;
qsptr<QPointFAnimator> mPosInfluence; qsptr<QPointFAnimator> mPosInfluence;
qsptr<QPointFAnimator> mScaleInfluence; qsptr<QPointFAnimator> mScaleInfluence;
qsptr<QrealAnimator> mRotInfluence; qsptr<QrealAnimator> mRotInfluence;

View File

@ -35,95 +35,6 @@ FollowPathTransformEffect::FollowPathTransformEffect() :
ca_addChild(mInfluence); ca_addChild(mInfluence);
} }
void calculateFollowRotPosChange(
const SkPath relPath,
const QMatrix transform,
const bool lengthBased,
const bool rotate,
const qreal infl,
qreal per,
qreal& rotChange,
qreal& posXChange,
qreal& posYChange) {
SkPath path;
relPath.transform(toSkMatrix(transform), &path);
const QPainterPath qpath = toQPainterPath(path);
if(lengthBased) {
const qreal length = qpath.length();
per = qpath.percentAtLength(per*length);
}
const auto p1 = qpath.pointAtPercent(per);
if(rotate) {
qreal t2 = per + 0.0001;
const bool reverse = t2 > 1;
if(reverse) t2 = 0.9999;
const auto p2 = qpath.pointAtPercent(t2);
const QLineF baseLine(QPointF(0., 0.), QPointF(100., 0.));
QLineF l;
if(reverse) l = QLineF(p2, p1);
else l = QLineF(p1, p2);
qreal trackAngle = l.angleTo(baseLine);
if(trackAngle > 180) trackAngle -= 360;
rotChange = trackAngle*infl;
} else rotChange = 0;
posXChange = p1.x();
posYChange = p1.y();
}
void FollowPathTransformEffect::setRotScaleAfterTargetChange(
BoundingBox* const oldTarget, BoundingBox* const newTarget) {
const bool rotate = mRotate->getValue();
if(!rotate) return;
const auto parent = getFirstAncestor<BoundingBox>();
if(!parent) return;
const auto oldTargetP = static_cast<PathBox*>(oldTarget);
const auto newTargetP = static_cast<PathBox*>(newTarget);
const qreal infl = mInfluence->getEffectiveValue();
const qreal per = mComplete->getEffectiveValue();
const bool lengthBased = mLengthBased->getValue();
const qreal relFrame = parent->anim_getCurrentRelFrame();
const auto parentTransform = parent->getInheritedTransformAtFrame(relFrame);
qreal rot = 0.;
if(oldTargetP) {
const auto relPath = oldTargetP->getRelativePath();
const auto targetTransform = oldTargetP->getTotalTransform();
const auto transform = targetTransform*parentTransform.inverted();
qreal rotChange;
qreal posXChange;
qreal posYChange;
calculateFollowRotPosChange(relPath, transform,
lengthBased, rotate, infl, per,
rotChange, posXChange, posYChange);
rot += rotChange;
}
if(newTargetP) {
const auto relPath = newTargetP->getRelativePath();
const auto targetTransform = newTargetP->getTotalTransform();
const auto transform = targetTransform*parentTransform.inverted();
qreal rotChange;
qreal posXChange;
qreal posYChange;
calculateFollowRotPosChange(relPath, transform,
lengthBased, rotate, infl, per,
rotChange, posXChange, posYChange);
rot -= rotChange;
}
parent->startRotTransform();
parent->rotateBy(rot);
}
void FollowPathTransformEffect::applyEffect( void FollowPathTransformEffect::applyEffect(
const qreal relFrame, const qreal relFrame,
qreal& pivotX, qreal& pivotY, qreal& pivotX, qreal& pivotY,
@ -152,22 +63,38 @@ void FollowPathTransformEffect::applyEffect(
const auto transform = targetTransform*parentTransform.inverted(); const auto transform = targetTransform*parentTransform.inverted();
SkPath path;
const auto relPath = target->getRelativePath(targetRelFrame); const auto relPath = target->getRelativePath(targetRelFrame);
relPath.transform(toSkMatrix(transform), &path);
const QPainterPath qpath = toQPainterPath(path);
const qreal infl = mInfluence->getEffectiveValue(relFrame); const qreal infl = mInfluence->getEffectiveValue(relFrame);
qreal per = mComplete->getEffectiveValue(relFrame); qreal per = mComplete->getEffectiveValue(relFrame);
const bool rotate = mRotate->getValue(); const bool rotate = mRotate->getValue();
const bool lengthBased = mLengthBased->getValue(); const bool lengthBased = mLengthBased->getValue();
qreal rotChange; if(lengthBased) {
qreal posXChange; const qreal length = qpath.length();
qreal posYChange; per = qpath.percentAtLength(per*length);
}
const auto p1 = qpath.pointAtPercent(per);
calculateFollowRotPosChange(relPath, transform, if(rotate) {
lengthBased, rotate, infl, per, qreal t2 = per + 0.0001;
rotChange, posXChange, posYChange); const bool reverse = t2 > 1;
if(reverse) t2 = 0.9999;
const auto p2 = qpath.pointAtPercent(t2);
if(rotate) rot += rotChange; const QLineF baseLine(QPointF(0., 0.), QPointF(100., 0.));
QLineF l;
if(reverse) l = QLineF(p2, p1);
else l = QLineF(p1, p2);
qreal trackAngle = l.angleTo(baseLine);
if(trackAngle > 180) trackAngle -= 360;
posX += posXChange; //p1.x()*infl; rot += trackAngle*infl;
posY += posYChange; //p1.y()*infl; }
posX += p1.x()*infl;
posY += p1.y()*infl;
} }

View File

@ -33,10 +33,6 @@ public:
qreal &shearX, qreal &shearY, qreal &shearX, qreal &shearY,
BoundingBox* const parent) override; BoundingBox* const parent) override;
private: private:
void setRotScaleAfterTargetChange(
BoundingBox* const oldTarget,
BoundingBox* const newTarget) override;
qsptr<BoolProperty> mRotate; qsptr<BoolProperty> mRotate;
qsptr<BoolProperty> mLengthBased; qsptr<BoolProperty> mLengthBased;
qsptr<QrealAnimator> mComplete; qsptr<QrealAnimator> mComplete;

View File

@ -18,8 +18,6 @@
#include "Boxes/boundingbox.h" #include "Boxes/boundingbox.h"
#include "Animators/transformanimator.h" #include "Animators/transformanimator.h"
#include "Animators/qrealanimator.h"
#include "Animators/qpointfanimator.h"
TargetTransformEffect::TargetTransformEffect( TargetTransformEffect::TargetTransformEffect(
const QString& name, const QString& name,
@ -52,28 +50,6 @@ TargetTransformEffect::TargetTransformEffect(
} }
}); });
connect(mTarget.get(), &BoxTargetProperty::setActionStarted,
this, [this]() {
const auto parent = getFirstAncestor<BoundingBox>();
if(!parent) return;
mPosBeforeTargetChange = parent->getPivotAbsPos();
});
connect(mTarget.get(), &BoxTargetProperty::setActionFinished,
this, [this](BoundingBox* const oldTarget,
BoundingBox* const newTarget) {
const auto parent = getFirstAncestor<BoundingBox>();
if(!parent) return;
const auto posAfter = parent->getPivotAbsPos();
parent->startPosTransform();
parent->moveByAbs(mPosBeforeTargetChange - posAfter);
setRotScaleAfterTargetChange(oldTarget, newTarget);
parent->finishTransform();
});
ca_addChild(mTarget); ca_addChild(mTarget);
} }
@ -90,12 +66,6 @@ FrameRange TargetTransformEffect::prp_getIdenticalRelRange(
return thisIdent*prp_absRangeToRelRange(absParentIdent); return thisIdent*prp_absRangeToRelRange(absParentIdent);
} }
void TargetTransformEffect::setRotScaleAfterTargetChange(
BoundingBox* const oldTarget, BoundingBox* const newTarget) {
Q_UNUSED(oldTarget)
Q_UNUSED(newTarget)
}
BoxTargetProperty* TargetTransformEffect::targetProperty() const { BoxTargetProperty* TargetTransformEffect::targetProperty() const {
return mTarget.get(); return mTarget.get();
} }

View File

@ -28,13 +28,8 @@ public:
FrameRange prp_getIdenticalRelRange(const int relFrame) const; FrameRange prp_getIdenticalRelRange(const int relFrame) const;
protected: protected:
virtual void setRotScaleAfterTargetChange(
BoundingBox* const oldTarget,
BoundingBox* const newTarget);
BoxTargetProperty* targetProperty() const; BoxTargetProperty* targetProperty() const;
private: private:
QPointF mPosBeforeTargetChange;
ConnContextQPtr<BoundingBox> mTargetConn; ConnContextQPtr<BoundingBox> mTargetConn;
qsptr<BoxTargetProperty> mTarget; qsptr<BoxTargetProperty> mTarget;
}; };

View File

@ -27,43 +27,6 @@ TrackTransformEffect::TrackTransformEffect() :
ca_prependChild(targetProperty(), mInfluence); ca_prependChild(targetProperty(), mInfluence);
} }
qreal calculateTrackAngle(const QPointF& parentPos,
const QPointF& targetPos) {
const QLineF baseLine(parentPos, parentPos + QPointF(100., 0.));
const QLineF trackLine(parentPos, targetPos);
qreal trackAngle = trackLine.angleTo(baseLine);
if(trackAngle > 180) trackAngle -= 360;
return trackAngle;
}
void TrackTransformEffect::setRotScaleAfterTargetChange(
BoundingBox* const oldTarget, BoundingBox* const newTarget) {
const auto parent = getFirstAncestor<BoundingBox>();
if(!parent) return;
const qreal infl = mInfluence->getEffectiveValue();
qreal rot = 0.;
if(oldTarget) {
const auto targetPos = oldTarget->getPivotAbsPos();
const auto parentPos = parent->getPivotAbsPos();
const qreal trackAngle = calculateTrackAngle(parentPos, targetPos);
rot += trackAngle*infl;
}
if(newTarget) {
const auto targetPos = newTarget->getPivotAbsPos();
const auto parentPos = parent->getPivotAbsPos();
const qreal trackAngle = calculateTrackAngle(parentPos, targetPos);
rot -= trackAngle*infl;
}
parent->startRotTransform();
parent->rotateBy(rot);
}
void TrackTransformEffect::applyEffect( void TrackTransformEffect::applyEffect(
const qreal relFrame, const qreal relFrame,
qreal& pivotX, qreal& pivotY, qreal& pivotX, qreal& pivotY,
@ -91,7 +54,12 @@ void TrackTransformEffect::applyEffect(
const auto targetPos = target->getPivotAbsPos(targetRelFrame); const auto targetPos = target->getPivotAbsPos(targetRelFrame);
const auto parentPos = parent->getPivotAbsPos(relFrame); const auto parentPos = parent->getPivotAbsPos(relFrame);
const QLineF baseLine(parentPos, parentPos + QPointF(100., 0.));
const QLineF trackLine(parentPos, targetPos);
qreal trackAngle = trackLine.angleTo(baseLine);
if(trackAngle > 180) trackAngle -= 360;
const qreal infl = mInfluence->getEffectiveValue(relFrame); const qreal infl = mInfluence->getEffectiveValue(relFrame);
const qreal trackAngle = calculateTrackAngle(parentPos, targetPos);
rot += trackAngle*infl; rot += trackAngle*infl;
} }

View File

@ -31,10 +31,6 @@ public:
qreal &shearX, qreal &shearY, qreal &shearX, qreal &shearY,
BoundingBox* const parent) override; BoundingBox* const parent) override;
private: private:
void setRotScaleAfterTargetChange(
BoundingBox* const oldTarget,
BoundingBox* const newTarget) override;
qsptr<QrealAnimator> mInfluence; qsptr<QrealAnimator> mInfluence;
}; };

View File

@ -305,9 +305,8 @@ public:
} }
QRect getCurrentBounds() const { QRect getCurrentBounds() const {
//if(mClipToCanvasSize) return getCanvasBounds(); if(mClipToCanvasSize) return getCanvasBounds();
//else return getMaxBounds(); else return getMaxBounds();
return getMaxBounds();
} }
int getCanvasHeight() const { int getCanvasHeight() const {