Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/app/GUI/BoxesList/boxsinglewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ void BoxSingleWidget::mouseMoveEvent(QMouseEvent *event) {
const auto drag = new QDrag(this);
{
const auto prop = static_cast<Property*>(mTarget->getTarget());
const QString name = prop->prp_getName();
const QString name = getDisplayName(prop);
const int nameWidth = QApplication::fontMetrics().horizontalAdvance(name);
QPixmap pixmap(mFillWidget->x() + nameWidth + eSizesUI::widget, height());
render(&pixmap);
Expand Down Expand Up @@ -886,7 +886,7 @@ void BoxSingleWidget::paintEvent(QPaintEvent *) {
}

const QRect textRect(nameX, 0, width() - nameX - eSizesUI::widget, eSizesUI::widget);
const QString& name = prop->prp_getName();
const QString name = getDisplayName(prop);
QTextOption opts(Qt::AlignVCenter);
opts.setWrapMode(QTextOption::NoWrap);
p.drawText(textRect, name, opts);
Expand Down Expand Up @@ -947,6 +947,27 @@ void BoxSingleWidget::switchBoxLockedAction() {
update();
}

QString BoxSingleWidget::getDisplayName(Property* const prop) const {
if(!prop) return QString();

QString name = prop->prp_getName();

const auto rules = mParent->getRulesCollection();
if(rules.fParamRule != SWT_ParamRule::animatedOnly) return name;

const auto vecParent = prop->getFirstAncestor<QPointFAnimator>();
if(!vecParent) return name;
const auto xAnim = vecParent->getXAnimator();
const auto yAnim = vecParent->getYAnimator();
if(!xAnim || !yAnim) return name;
if(prop != xAnim && prop != yAnim) return name;

const auto parentName = vecParent->prp_getName();
if(parentName.isEmpty()) return name;

return parentName + " / " + name;
}

void BoxSingleWidget::updateValueSlidersForQPointFAnimator() {
if(!mTarget) return;
const auto target = mTarget->getTarget();
Expand Down
2 changes: 2 additions & 0 deletions src/app/GUI/BoxesList/boxsinglewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class BoxSingleWidget : public SingleWidget {
void clearAndHideValueAnimators();
void updateValueSlidersForQPointFAnimator();
private:
QString getDisplayName(Property* const prop) const;

ContainerBox *getPromoteTargetGroup();

void clearSelected() { setSelected(false); }
Expand Down
28 changes: 27 additions & 1 deletion src/app/GUI/timelinewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,25 +140,46 @@ TimelineWidget::TimelineWidget(Document &document,
typeActionAdder(SWT_Type::sound, "Sound");
typeActionAdder(SWT_Type::graphics, "Graphics");

QMenu * const paramMenu = settingsMenu->addMenu(filterIcon, tr("Parameters"));

const auto paramActionAdder = [this, paramMenu](
const SWT_ParamRule paramRule, const QString& text) {
const auto slot = [this, paramRule]() { setParamRule(paramRule); };
const auto action = paramMenu->addAction(text, this, slot);
action->setCheckable(true);
connect(this, &TimelineWidget::paramRuleChanged,
action, [action, paramRule](const SWT_ParamRule setRule) {
action->setChecked(paramRule == setRule);
});
return action;
};

paramActionAdder(SWT_ParamRule::all, tr("All"))->setChecked(true);
paramActionAdder(SWT_ParamRule::animated, tr("Animated"));
paramActionAdder(SWT_ParamRule::animatedOnly, tr("Animated (plain)"));

settingsMenu->addSeparator();

{
const auto op = [this]() {
setBoxRule(SWT_BoxRule::all);
setTarget(SWT_Target::canvas);
setType(SWT_Type::all);
setParamRule(SWT_ParamRule::all);
};
const auto act = settingsMenu->addAction("Reset", this, op);
const auto can = [this]() {
const auto rules = mBoxesListWidget->getRulesCollection();
return rules.fRule != SWT_BoxRule::all ||
rules.fTarget != SWT_Target::canvas ||
rules.fType != SWT_Type::all;
rules.fType != SWT_Type::all ||
rules.fParamRule != SWT_ParamRule::all;
};
const auto setEnabled = [act, can]() { act->setEnabled(can()); };
connect(this, &TimelineWidget::typeChanged, act, setEnabled);
connect(this, &TimelineWidget::targetChanged, act, setEnabled);
connect(this, &TimelineWidget::boxRuleChanged, act, setEnabled);
connect(this, &TimelineWidget::paramRuleChanged, act, setEnabled);
}

//QMenu *viewMenu = mBoxesListMenuBar->addMenu("View");
Expand Down Expand Up @@ -571,6 +592,11 @@ void TimelineWidget::setType(const SWT_Type type) {
emit typeChanged(type);
}

void TimelineWidget::setParamRule(const SWT_ParamRule rule) {
mBoxesListWidget->setCurrentParamRule(rule);
emit paramRuleChanged(rule);
}

void TimelineWidget::setSearchText(const QString &text) {
mBoxesListWidget->setCurrentSearchText(text);
}
Expand Down
3 changes: 3 additions & 0 deletions src/app/GUI/timelinewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class XevReadBoxesHandler;
enum class SWT_Type : short;
enum class SWT_BoxRule : short;
enum class SWT_Target : short;
enum class SWT_ParamRule : short;

class TimelineWidget : public QWidget {
Q_OBJECT
Expand Down Expand Up @@ -96,10 +97,12 @@ class TimelineWidget : public QWidget {
void typeChanged(const SWT_Type target);
void targetChanged(const SWT_Target target);
void boxRuleChanged(const SWT_BoxRule rule);
void paramRuleChanged(const SWT_ParamRule rule);
private:
void setType(const SWT_Type type);
void setBoxRule(const SWT_BoxRule rule);
void setTarget(const SWT_Target target);
void setParamRule(const SWT_ParamRule rule);

Canvas* mCurrentScene = nullptr;

Expand Down
42 changes: 42 additions & 0 deletions src/core/Properties/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,48 @@ QMatrix Property::getTransform(const qreal relFrame) const {
return QMatrix();
}

bool Property::SWT_shouldBeVisible(const SWT_RulesCollection &rules,
const bool parentSatisfies,
const bool parentMainTarget) const {
if(!parentSatisfies || parentMainTarget) return false;

const auto paramRule = rules.fParamRule;
if(paramRule == SWT_ParamRule::all) return true;

if(enve_cast<const eBoxOrSound*>(this) || enve_cast<const Canvas*>(this)) {
return true;
}

const auto animator = enve_cast<const Animator*>(this);
const bool animated = animator && animator->anim_isDescendantRecording();

if(paramRule == SWT_ParamRule::animated) {
return animated;
}

if(paramRule == SWT_ParamRule::animatedOnly) {
if(!animated) return false;
if(const auto cAnim = enve_cast<const ComplexAnimator*>(this)) {
if(cAnim->ca_hasChildren()) return false;
}
return true;
}

return true;
}

bool Property::SWT_shouldPassThrough(const SWT_RulesCollection &rules) const {
if(rules.fParamRule != SWT_ParamRule::animatedOnly) return false;
if(enve_cast<const eBoxOrSound*>(this) || enve_cast<const Canvas*>(this)) {
return false;
}
const auto animator = enve_cast<const Animator*>(this);
const auto complexAnimator = enve_cast<const ComplexAnimator*>(this);
if(!animator || !complexAnimator) return false;
if(!complexAnimator->ca_hasChildren()) return false;
return animator->anim_isDescendantRecording();
}

void Property::prp_setSelected(const bool selected) {
if(prp_mSelected == selected) return;
prp_mSelected = selected;
Expand Down
6 changes: 6 additions & 0 deletions src/core/Properties/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ class CORE_EXPORT Property : public SingleWidgetTarget {

virtual BasicTransformAnimator *getTransformAnimator() const;

bool SWT_shouldBeVisible(const SWT_RulesCollection &rules,
const bool parentSatisfies,
const bool parentMainTarget) const override;

bool SWT_shouldPassThrough(const SWT_RulesCollection &rules) const override;

virtual void prp_afterChangedAbsRange(const FrameRange &range,
const bool clip = true);

Expand Down
5 changes: 5 additions & 0 deletions src/core/singlewidgettarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ class CORE_EXPORT SingleWidgetTarget : public SelfRef {
return parentSatisfies && !parentMainTarget;
}

virtual bool SWT_shouldPassThrough(const SWT_RulesCollection &rules) const {
Q_UNUSED(rules)
return false;
}

virtual QMimeData *SWT_createMimeData() {
return nullptr;
}
Expand Down
18 changes: 13 additions & 5 deletions src/core/swt_abstraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ bool SWT_Abstraction::setAbstractions(
if(currY > maxY) return true;
const bool satisfiesRule = mTarget_k->SWT_shouldBeVisible(
rules, parentSatisfiesRule, parentMainTarget);
const bool passThrough = (parentSatisfiesRule || parentMainTarget) &&
!satisfiesRule &&
mTarget_k->SWT_shouldPassThrough(rules);
if(currY > minY && satisfiesRule && !mIsMainTarget) {
setAbsFunc(this, currX);
}
Expand All @@ -56,7 +59,7 @@ bool SWT_Abstraction::setAbstractions(
currY += swtHeight;
}
const bool childrenVisible = (satisfiesRule && mContentVisible) ||
mIsMainTarget;
passThrough || mIsMainTarget;
for(const auto& abs : mChildren) {
if(abs->setAbstractions(minY, maxY, currY, currX,
swtHeight, setAbsFunc, rules,
Expand All @@ -76,13 +79,18 @@ int SWT_Abstraction::updateHeight(const SWT_RulesCollection &rules,
if(mTarget_k->SWT_isVisible()) {
const bool satisfiesRule = mTarget_k->SWT_shouldBeVisible(
rules, parentSatisfiesRule, parentMainTarget);
const bool passThrough = (parentSatisfiesRule || parentMainTarget) &&
!satisfiesRule &&
mTarget_k->SWT_shouldPassThrough(rules);
if(satisfiesRule && !mIsMainTarget)
mHeight += swtHeight;
const bool childrenVisible = (satisfiesRule && mContentVisible) ||
mIsMainTarget;
for(const auto& abs : mChildren) {
mHeight += abs->updateHeight(rules, childrenVisible,
mIsMainTarget, swtHeight);
passThrough || mIsMainTarget;
if(childrenVisible) {
for(const auto& abs : mChildren) {
mHeight += abs->updateHeight(rules, childrenVisible,
mIsMainTarget, swtHeight);
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/core/swt_rulescollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ SWT_RulesCollection::SWT_RulesCollection(const SWT_BoxRule rule,
const bool alwaysShowChildren,
const SWT_Target target,
const SWT_Type type,
const SWT_ParamRule paramRule,
const QString &searchString) {
fRule = rule;
fAlwaysShowChildren = alwaysShowChildren;
fTarget = target;
fType = type;
fParamRule = paramRule;
fSearchString = searchString;
}
8 changes: 8 additions & 0 deletions src/core/swt_rulescollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,26 @@ enum class SWT_Type : short {
sound
};

enum class SWT_ParamRule : short {
all,
animated,
animatedOnly
};

struct CORE_EXPORT SWT_RulesCollection {
SWT_RulesCollection();
SWT_RulesCollection(const SWT_BoxRule rule,
const bool alwaysShowChildren,
const SWT_Target target,
const SWT_Type type,
const SWT_ParamRule paramRule,
const QString &searchString);

SWT_BoxRule fRule = SWT_BoxRule::all;
bool fAlwaysShowChildren = false;
SWT_Target fTarget = SWT_Target::canvas;
SWT_Type fType = SWT_Type::all;
SWT_ParamRule fParamRule = SWT_ParamRule::all;
QString fSearchString = "";
};

Expand Down
4 changes: 4 additions & 0 deletions src/ui/optimalscrollarena/scrollwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ void ScrollWidget::setCurrentType(const SWT_Type type) {
mVisiblePartWidget->setCurrentType(type);
}

void ScrollWidget::setCurrentParamRule(const SWT_ParamRule rule) {
mVisiblePartWidget->setCurrentParamRule(rule);
}

SWT_RulesCollection ScrollWidget::getRulesCollection()
{ return mVisiblePartWidget->getRulesCollection(); }

Expand Down
2 changes: 2 additions & 0 deletions src/ui/optimalscrollarena/scrollwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class ScrollArea;
enum class SWT_BoxRule : short;
enum class SWT_Target : short;
enum class SWT_Type : short;
enum class SWT_ParamRule : short;

class UI_EXPORT ScrollWidget : public MinimalScrollWidget
{
Expand All @@ -61,6 +62,7 @@ class UI_EXPORT ScrollWidget : public MinimalScrollWidget
const SWT_Target target);
void setCurrentSearchText(const QString &text);
void setCurrentType(const SWT_Type type);
void setCurrentParamRule(const SWT_ParamRule rule);

void scheduleContentUpdateIfIsCurrentRule(const SWT_BoxRule rule);
bool isCurrentRule(const SWT_BoxRule rule);
Expand Down
5 changes: 5 additions & 0 deletions src/ui/optimalscrollarena/scrollwidgetvisiblepart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ void ScrollWidgetVisiblePart::setCurrentType(const SWT_Type type) {
updateParentHeightAndContent();
}

void ScrollWidgetVisiblePart::setCurrentParamRule(const SWT_ParamRule rule) {
mRulesCollection.fParamRule = rule;
updateParentHeightAndContent();
}

void ScrollWidgetVisiblePart::setupUpdateFuncs() {
const QPointer<ScrollWidgetVisiblePart> thisQPtr = this;
mUpdateFuncs.fContentUpdateIfIsCurrentRule =
Expand Down
1 change: 1 addition & 0 deletions src/ui/optimalscrollarena/scrollwidgetvisiblepart.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class UI_EXPORT ScrollWidgetVisiblePart : public ScrollVisiblePartBase
void setAlwaysShowChildren(const bool alwaysShowChildren);
void setCurrentSearchText(const QString &text);
void setCurrentType(const SWT_Type type);
void setCurrentParamRule(const SWT_ParamRule rule);

void scheduleContentUpdateIfIsCurrentRule(const SWT_BoxRule rule);
bool isCurrentRule(const SWT_BoxRule rule);
Expand Down