Skip to content

Commit

Permalink
Initial implementation of Text Effects.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaurycyLiebner committed Dec 29, 2019
1 parent b67cff1 commit de632c9
Show file tree
Hide file tree
Showing 56 changed files with 1,401 additions and 212 deletions.
4 changes: 2 additions & 2 deletions examples/rasterEffects/dabTest/dabtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ DabTest000::DabTest000() :
}

stdsptr<RasterEffectCaller> DabTest000::getEffectCaller(
const qreal relFrame, const qreal resolution) const {
const qreal radius = mRadius->getEffectiveValue(relFrame)*resolution;
const qreal relFrame, const qreal resolution, const qreal influence) const {
const qreal radius = mRadius->getEffectiveValue(relFrame)*resolution*influence;
const qreal hardness = mHardness->getEffectiveValue(relFrame);

Dab dab;
Expand Down
3 changes: 2 additions & 1 deletion examples/rasterEffects/dabTest/dabtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ class DabTest000 : public CustomRasterEffect {
DabTest000();

stdsptr<RasterEffectCaller> getEffectCaller(
const qreal relFrame, const qreal resolution) const;
const qreal relFrame, const qreal resolution,
const qreal influence) const;

CustomIdentifier getIdentifier() const;
private:
Expand Down
6 changes: 3 additions & 3 deletions examples/rasterEffects/eBlur/eblur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ eBlur::eBlur() : CustomRasterEffect(eName().toLower(),
this, &CustomRasterEffect::forcedMarginChanged);
}

stdsptr<RasterEffectCaller> eBlur::getEffectCaller(const qreal relFrame,
const qreal resolution) const {
const qreal radius = mRadius->getEffectiveValue(relFrame)*resolution;
stdsptr<RasterEffectCaller> eBlur::getEffectCaller(
const qreal relFrame, const qreal resolution, const qreal influence) const {
const qreal radius = mRadius->getEffectiveValue(relFrame)*resolution*influence;
if(isZero4Dec(radius)) return nullptr;
return enve::make_shared<eBlurCaller>(instanceHwSupport(), radius);
}
Expand Down
3 changes: 2 additions & 1 deletion examples/rasterEffects/eBlur/eblur.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class eBlur : public CustomRasterEffect {
eBlur();

stdsptr<RasterEffectCaller> getEffectCaller(const qreal relFrame,
const qreal resolution) const;
const qreal resolution,
const qreal influence) const;
QMargins getMargin() const;
bool forceMargin() const { return true; }

Expand Down
5 changes: 3 additions & 2 deletions examples/rasterEffects/eShadow/eshadow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ eShadow::eShadow() :
}

stdsptr<RasterEffectCaller>
eShadow::getEffectCaller(const qreal relFrame, const qreal resolution) const {
eShadow::getEffectCaller(const qreal relFrame, const qreal resolution,
const qreal influence) const {
const qreal blur = mBlurRadius->getEffectiveValue(relFrame)*resolution;
const QColor color = mColor->getColor(relFrame);
const QPointF trans = mTranslation->getEffectiveValue(relFrame)*resolution;
const qreal opacity = mOpacity->getEffectiveValue(relFrame);
const qreal opacity = mOpacity->getEffectiveValue(relFrame)*influence;

const int iL = qMax(0, qCeil(blur - trans.x()));
const int iT = qMax(0, qCeil(blur - trans.y()));
Expand Down
3 changes: 2 additions & 1 deletion examples/rasterEffects/eShadow/eshadow.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class eShadow : public CustomRasterEffect {
eShadow();

stdsptr<RasterEffectCaller> getEffectCaller(
const qreal relFrame, const qreal resolution) const;
const qreal relFrame, const qreal resolution,
const qreal influence) const;
bool forceMargin() const { return true; }

CustomIdentifier getIdentifier() const;
Expand Down
44 changes: 24 additions & 20 deletions src/app/GUI/BoxesList/boxsinglewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,10 @@ BoxSingleWidget::BoxSingleWidget(BoxScroller * const parent) :
if(static_cast<SingleSound*>(target)->isVisible()) {
return BoxSingleWidget::UNMUTED_PIXMAP;
} else return BoxSingleWidget::MUTED_PIXMAP;
} else if(target->SWT_isRasterEffect()) {
if(static_cast<RasterEffect*>(target)->isVisible()) {
return BoxSingleWidget::VISIBLE_PIXMAP;
} else return BoxSingleWidget::INVISIBLE_PIXMAP;
} else if(target->SWT_isPathEffect()) {
if(static_cast<PathEffect*>(target)->isVisible()) {
} else if(target->SWT_isRasterEffect() ||
target->SWT_isPathEffect() ||
target->SWT_isTextEffect()) {
if(static_cast<eEffect*>(target)->isVisible()) {
return BoxSingleWidget::VISIBLE_PIXMAP;
} else return BoxSingleWidget::INVISIBLE_PIXMAP;
} else if(target->SWT_isGraphAnimator()) {
Expand Down Expand Up @@ -181,6 +179,7 @@ BoxSingleWidget::BoxSingleWidget(BoxScroller * const parent) :
this, &BoxSingleWidget::switchBoxLockedAction);

mHwSupportButton = new PixmapActionButton(this);
// mHwSupportButton->setToolTip(gSingleLineTooltip("GPU/CPU Processing"));
mHwSupportButton->setPixmapChooser([this]() {
if(!mTarget) return static_cast<QPixmap*>(nullptr);
const auto target = mTarget->getTarget();
Expand Down Expand Up @@ -220,6 +219,7 @@ BoxSingleWidget::BoxSingleWidget(BoxScroller * const parent) :
mColorButton->setContentsMargins(0, 3, 0, 3);

mPropertyComboBox = new QComboBox(this);
mPropertyComboBox->setFocusPolicy(Qt::NoFocus);
connect(mPropertyComboBox, qOverload<int>(&QComboBox::activated),
this, [this](const int id) {
if(!mTarget) return;
Expand Down Expand Up @@ -353,6 +353,7 @@ void BoxSingleWidget::setTargetAbstraction(SWT_Abstraction *abs) {
target->SWT_isSound() ||
target->SWT_isPathEffect() ||
target->SWT_isRasterEffect() ||
target->SWT_isTextEffect() ||
target->SWT_isGraphAnimator());
mLockedButton->setVisible(target->SWT_isBoundingBox());
mHwSupportButton->setVisible(target->SWT_isRasterEffect());
Expand Down Expand Up @@ -462,7 +463,15 @@ void BoxSingleWidget::setTargetAbstraction(SWT_Abstraction *abs) {
connect(static_cast<Animator*>(target), &Animator::anim_isRecordingChanged,
this, [this]() { mRecordButton->update(); });
}
if(target->SWT_isPathEffect() || target->SWT_isRasterEffect()) {
if(target->SWT_isPathEffect() ||
target->SWT_isRasterEffect() ||
target->SWT_isTextEffect()) {
if(target->SWT_isRasterEffect()) {
const auto effect = static_cast<RasterEffect*>(target);
connect(effect, &RasterEffect::hardwareSupportChanged,
this, [this]() { mHwSupportButton->update(); });
}

const auto effTarget = static_cast<eEffect*>(target);
connect(effTarget, &eEffect::effectVisibilityChanged,
this, [this]() { mVisibleButton->update(); });
Expand Down Expand Up @@ -533,7 +542,6 @@ void BoxSingleWidget::clearStaticPixmaps() {

void BoxSingleWidget::mousePressEvent(QMouseEvent *event) {
if(!mTarget) return;
if(isTargetDisabled()) return;
if(event->x() < mFillWidget->x() ||
event->x() > mFillWidget->x() + mFillWidget->width()) return;
const auto target = mTarget->getTarget();
Expand Down Expand Up @@ -562,15 +570,10 @@ void BoxSingleWidget::mousePressEvent(QMouseEvent *event) {
Document::sInstance->actionFinished();
}

bool BoxSingleWidget::isTargetDisabled() {
if(!mTarget) return true;
return mTarget->getTarget()->SWT_isDisabled();
}

void BoxSingleWidget::mouseMoveEvent(QMouseEvent *event) {
if(!mTarget) return;
if(!mDragPressPos) return;
if(!(event->buttons() & Qt::LeftButton)) return;
if(isTargetDisabled()) return;
const auto dist = (event->pos() - mDragStartPos).manhattanLength();
if(dist < QApplication::startDragDistance()) return;
const auto drag = new QDrag(this);
Expand All @@ -594,7 +597,7 @@ void BoxSingleWidget::mouseMoveEvent(QMouseEvent *event) {
}

void BoxSingleWidget::mouseReleaseEvent(QMouseEvent *event) {
if(isTargetDisabled()) return;
if(!mTarget) return;
if(event->x() < mFillWidget->x() ||
event->x() > mFillWidget->x() + mFillWidget->width()) return;
setSelected(false);
Expand All @@ -612,7 +615,7 @@ void BoxSingleWidget::mouseReleaseEvent(QMouseEvent *event) {
}

void BoxSingleWidget::mouseDoubleClickEvent(QMouseEvent *e) {
if(isTargetDisabled()) return;
if(!mTarget) return;
if(e->modifiers() & Qt::ShiftModifier) {
//mousePressEvent(e);
} else Document::sInstance->actionFinished();
Expand Down Expand Up @@ -734,6 +737,7 @@ void BoxSingleWidget::paintEvent(QPaintEvent *) {
}
} else nameX += MIN_WIDGET_DIM;

if(!target->SWT_isAnimator()) nameX += MIN_WIDGET_DIM;
p.setPen(Qt::white);
} else { //if(target->SWT_isComplexAnimator()) {
p.setPen(Qt::white);
Expand Down Expand Up @@ -773,10 +777,10 @@ void BoxSingleWidget::switchBoxVisibleAction() {
if(!target) return;
if(target->SWT_isBoundingBox() || target->SWT_isSound()) {
static_cast<eBoxOrSound*>(target)->switchVisible();
} else if(target->SWT_isRasterEffect()) {
static_cast<RasterEffect*>(target)->switchVisible();
} else if(target->SWT_isPathEffect()) {
static_cast<PathEffect*>(target)->switchVisible();
} else if(target->SWT_isRasterEffect() ||
target->SWT_isPathEffect() ||
target->SWT_isTextEffect()) {
static_cast<eEffect*>(target)->switchVisible();
} else if(target->SWT_isGraphAnimator()) {
const auto bsvt = static_cast<BoxScroller*>(mParent);
const auto keysView = bsvt->getKeysView();
Expand Down
1 change: 0 additions & 1 deletion src/app/GUI/BoxesList/boxsinglewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ class BoxSingleWidget : public SingleWidget {
mSelected = selected;
update();
}
bool isTargetDisabled();
protected:
bool mSelected = false;
void mousePressEvent(QMouseEvent *e);
Expand Down
2 changes: 1 addition & 1 deletion src/app/GUI/ekeyfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ eKeyFilter *eKeyFilter::sCreateNumberFilter(MainWindow * const window) {
bool eKeyFilter::eventFilter(QObject *watched, QEvent *event) {
Q_UNUSED(watched)
if(event->type() == QEvent::KeyPress ||
event->type() == QEvent::KeyRelease) {
event->type() == QEvent::KeyRelease) {
const auto kEvent = static_cast<QKeyEvent*>(event);
if(mAllow(kEvent->key())) return false;
if(mMainWindow->processKeyEvent(kEvent)) return true;
Expand Down
1 change: 1 addition & 0 deletions src/app/GUI/keysview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ bool KeysView::KFT_keyPressEvent(QKeyEvent *event) {
if(inputHandled) {
handleMouseMove(mLastMovePos, QApplication::mouseButtons());
} else if(event->key() == Qt::Key_Escape) {
if(!mIsMouseGrabbing) return false;
cancelTransform();
} else if(event->key() == Qt::Key_Return ||
event->key() == Qt::Key_Enter) {
Expand Down
6 changes: 5 additions & 1 deletion src/app/GUI/timelinedockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,11 @@ bool TimelineDockWidget::processKeyPress(QKeyEvent *event) {
const CanvasMode mode = mDocument.fCanvasMode;
const int key = event->key();
const auto mods = event->modifiers();
if(key == Qt::Key_Space) {
if(key == Qt::Key_Escape) {
const auto state = RenderHandler::sInstance->currentPreviewState();
if(state == PreviewSate::stopped) return false;
interruptPreview();
} else if(key == Qt::Key_Space) {
const auto state = RenderHandler::sInstance->currentPreviewState();
switch(state) {
case PreviewSate::stopped: renderPreview(); break;
Expand Down
23 changes: 9 additions & 14 deletions src/core/Animators/complexanimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,16 @@ void ComplexAnimator::ca_replaceChild(const qsptr<Property>& child,
ca_insertChild(replaceWith, id);
}

void ComplexAnimator::ca_setHiddenWhenEmpty() {
if(ca_mHiddenEmpty) return;
ca_mHiddenEmpty = true;
if(!ca_hasChildren()) {
SWT_setEnabled(false);
SWT_setVisible(false);
}
void ComplexAnimator::ca_setHiddenWhenEmpty(const bool hidden) {
if(ca_mHiddenEmpty == hidden) return;
ca_mHiddenEmpty = hidden;
SWT_setVisible(ca_hasChildren() || !hidden);
}

void ComplexAnimator::ca_setDisabledWhenEmpty(const bool disabled) {
if(ca_mDisabledEmpty == disabled) return;
ca_mDisabledEmpty = disabled;
if(ca_mDisabledEmpty && !ca_hasChildren()) {
SWT_setEnabled(false);
} else SWT_setEnabled(true);
SWT_setEnabled(!ca_mDisabledEmpty || ca_hasChildren());
}

int ComplexAnimator::ca_getNumberOfChildren() const {
Expand Down Expand Up @@ -109,8 +104,8 @@ void ComplexAnimator::ca_insertChild(const qsptr<Property>& child,
return ca_moveChildInList(child.get(), (cId < id ? id - 1 : id));
}

if(ca_mDisabledEmpty && !ca_hasChildren()) {
SWT_setEnabled(true);
if(!ca_hasChildren()) {
if(ca_mDisabledEmpty) SWT_setEnabled(true);
if(ca_mHiddenEmpty) SWT_setVisible(true);
}

Expand Down Expand Up @@ -237,8 +232,8 @@ void ComplexAnimator::ca_removeChild(const qsptr<Property> child) {
prp_afterChangedAbsRange(changedRange);
}

if(ca_mDisabledEmpty && !ca_hasChildren()) {
SWT_setEnabled(false);
if(!ca_hasChildren()) {
if(ca_mDisabledEmpty) SWT_setEnabled(false);
if(ca_mHiddenEmpty) SWT_setVisible(false);
}

Expand Down
6 changes: 3 additions & 3 deletions src/core/Animators/complexanimator.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ class ComplexAnimator : public Animator {

void ca_addDescendantsKey(Key * const key);
void ca_removeDescendantsKey(Key * const key);

void ca_setHiddenWhenEmpty(const bool hidden);
void ca_setDisabledWhenEmpty(const bool disabled);
signals:
void ca_childAdded(Property*);
void ca_childRemoved(Property*);
Expand All @@ -148,9 +151,6 @@ class ComplexAnimator : public Animator {
void ca_replaceChild(const qsptr<Property> &child,
const qsptr<Property>& replaceWith);


void ca_setHiddenWhenEmpty();
void ca_setDisabledWhenEmpty(const bool disabled);
const QList<qsptr<Property>>& ca_getChildren() const
{ return ca_mChildren; }
private:
Expand Down
3 changes: 3 additions & 0 deletions src/core/Animators/eeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class eEffect : public StaticComplexAnimator {

virtual void writeIdentifier(eWriteStream& dst) const = 0;

bool SWT_isTextEffect() const final
{ return true; }

void prp_writeProperty(eWriteStream& dst) const;
void prp_readProperty(eReadStream& src);

Expand Down
17 changes: 11 additions & 6 deletions src/core/Animators/qrealsnapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@
#include "qrealkey.h"

void QrealSnapshot::appendKey(const QrealKey * const key) {
mKeys.append({key->getC0Frame()*mFrameMultiplier,
key->getC0Value()*mValueMultiplier,
key->getRelFrame()*mFrameMultiplier,
key->getValue()*mValueMultiplier,
key->getC1Frame()*mFrameMultiplier,
key->getC1Value()*mValueMultiplier});
appendKey(key->getC0Frame(), key->getC0Value(),
key->getRelFrame(), key->getValue(),
key->getC1Frame(), key->getC1Value());
}

void QrealSnapshot::appendKey(const qreal c0Frame, const qreal c0Value,
const qreal pFrame, const qreal pValue,
const qreal c1Frame, const qreal c1Value) {
mKeys.append({c0Frame*mFrameMultiplier, c0Value*mValueMultiplier,
pFrame*mFrameMultiplier, pValue*mValueMultiplier,
c1Frame*mFrameMultiplier, c1Value*mValueMultiplier});
}

qreal QrealSnapshot::getValue(const qreal relFrame) const {
Expand Down
7 changes: 5 additions & 2 deletions src/core/Animators/qrealsnapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,16 @@ class QrealSnapshot {
QrealSnapshot(const qreal currentValue) :
QrealSnapshot(currentValue, 1, 1) {}
QrealSnapshot(const qreal currentValue,
const qreal frameMultiplier,
const qreal valueMultiplier) :
const qreal frameMultiplier,
const qreal valueMultiplier) :
mCurrentValue(currentValue*valueMultiplier),
mFrameMultiplier(frameMultiplier),
mValueMultiplier(valueMultiplier) {}

void appendKey(const QrealKey * const key);
void appendKey(const qreal c0Frame, const qreal c0Value,
const qreal pFrame, const qreal pValue,
const qreal c1Frame, const qreal c1Value);

qreal getValue(const qreal relFrame) const;
protected:
Expand Down
Loading

0 comments on commit de632c9

Please sign in to comment.