Skip to content

Commit

Permalink
Merge branch 'main' into svg-follow-path
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlie committed Aug 28, 2024
2 parents 5a9930d + ab62c35 commit 30e8a10
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 41 deletions.
28 changes: 24 additions & 4 deletions src/app/GUI/BoxesList/boxsinglewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,12 @@ BoxSingleWidget::BoxSingleWidget(BoxScroller * const parent)
} else if (const auto eEff = enve_cast<eEffect*>(target)) {
if (eEff->isVisible()) { return BoxSingleWidget::VISIBLE_ICON; }
return BoxSingleWidget::INVISIBLE_ICON;
} else if (enve_cast<GraphAnimator*>(target)) {
} /*else if (enve_cast<GraphAnimator*>(target)) {
const auto bsvt = static_cast<BoxScroller*>(mParent);
const auto keysView = bsvt->getKeysView();
if (keysView) { return BoxSingleWidget::GRAPH_PROPERTY_ICON; }
return static_cast<QPixmap*>(nullptr);
}
}*/
return static_cast<QPixmap*>(nullptr);
});

Expand Down Expand Up @@ -382,6 +382,24 @@ void BoxSingleWidget::setComboProperty(ComboBoxProperty* const combo) {
mPropertyComboBox->show();
}

void BoxSingleWidget::handlePropertySelectedChanged(const Property *prop)
{
if (const auto graph = enve_cast<GraphAnimator*>(prop)) {
const auto bsvt = static_cast<BoxScroller*>(mParent);
const auto keysView = bsvt->getKeysView();
if (keysView) {
const bool graphSelected = keysView->graphIsSelected(graph);
const bool isSelected = prop->prp_isSelected();
if (graphSelected) {
if (!isSelected) { keysView->graphRemoveViewedAnimator(graph); }
} else {
if (isSelected) { keysView->graphAddViewedAnimator(graph); }
}
Document::sInstance->actionFinished();
}
}
}

ColorAnimator *BoxSingleWidget::getColorTarget() const {
const auto swt = mTarget->getTarget();
ColorAnimator * color = nullptr;
Expand Down Expand Up @@ -561,6 +579,8 @@ void BoxSingleWidget::setTargetAbstraction(SWT_Abstraction *abs) {
if(!boundingBox && !eindependentSound) {
mTargetConn << connect(prop, &Property::prp_selectionChanged,
this, qOverload<>(&QWidget::update));
mTargetConn << connect(prop, &Property::prp_selectionChanged,
this, [this, prop]() { handlePropertySelectedChanged(prop); });
}

mValueSlider->setVisible(valueSliderVisible);
Expand Down Expand Up @@ -878,7 +898,7 @@ void BoxSingleWidget::switchBoxVisibleAction() {
ebos->switchVisible();
} else if(const auto eEff = enve_cast<eEffect*>(target)) {
eEff->switchVisible();
} else if(const auto graph = enve_cast<GraphAnimator*>(target)) {
} /*else if(const auto graph = enve_cast<GraphAnimator*>(target)) {
const auto bsvt = static_cast<BoxScroller*>(mParent);
const auto keysView = bsvt->getKeysView();
if(keysView) {
Expand All @@ -889,7 +909,7 @@ void BoxSingleWidget::switchBoxVisibleAction() {
}
Document::sInstance->actionFinished();
}
}
}*/
Document::sInstance->actionFinished();
update();
}
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 @@ -134,6 +134,8 @@ class BoxSingleWidget : public SingleWidget {

void setComboProperty(ComboBoxProperty * const combo);

void handlePropertySelectedChanged(const Property *prop);

BoxScroller* const mParent;

bool mDragPressPos = false;
Expand Down
11 changes: 0 additions & 11 deletions src/app/GUI/animationdockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ AnimationDockWidget::AnimationDockWidget(QWidget *parent,
, mSmoothButton(nullptr)
, mCornerButton(nullptr)
, mFitToHeightButton(nullptr)
, mOnlySelectedAct(nullptr)
{
setObjectName(QString::fromUtf8("animationDockWidget"));
setSizePolicy(QSizePolicy::Maximum,
Expand Down Expand Up @@ -98,14 +97,6 @@ AnimationDockWidget::AnimationDockWidget(QWidget *parent,
connect(selectedVisible, &SwitchButton::toggled,
keysView, &KeysView::graphSetOnlySelectedVisible);*/

mOnlySelectedAct = new QAction(QIcon::fromTheme("onlySelectedVisible"),
QString(),
this);
mOnlySelectedAct->setCheckable(true);
mOnlySelectedAct->setToolTip(tr("View only selected"));
connect(mOnlySelectedAct, &QAction::triggered,
keysView, &KeysView::graphSetOnlySelectedVisible);

addWidget(easingButton);
addAction(mLineButton);
addAction(mCurveButton);
Expand All @@ -114,7 +105,6 @@ AnimationDockWidget::AnimationDockWidget(QWidget *parent,
addAction(mCornerButton);
addAction(mFitToHeightButton);
//addWidget(valueLines);
addAction(mOnlySelectedAct);

eSizesUI::widget.add(this, [this](const int size) {
setIconSize(QSize(size, size));
Expand All @@ -129,7 +119,6 @@ void AnimationDockWidget::showGraph(const bool show)
mSmoothButton->setVisible(show);
mCornerButton->setVisible(show);
mFitToHeightButton->setVisible(show);
mOnlySelectedAct->setVisible(show);
}

void AnimationDockWidget::generateEasingActions(QPushButton *button,
Expand Down
1 change: 0 additions & 1 deletion src/app/GUI/animationdockwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class AnimationDockWidget : public QToolBar
QAction *mSmoothButton;
QAction *mCornerButton;
QAction *mFitToHeightButton;
QAction *mOnlySelectedAct;
};

#endif // ANIMATIONDOCKWIDGET_H
36 changes: 17 additions & 19 deletions src/app/GUI/graphboxeslist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,37 +553,34 @@ void KeysView::graphResetValueScaleAndMinShown() {
graphUpdateDimensions();
}

void KeysView::graphSetOnlySelectedVisible(const bool selectedOnly) {
if(graph_mOnlySelectedVisible == selectedOnly) return;
graph_mOnlySelectedVisible = selectedOnly;
graphUpdateVisbile();
}

bool KeysView::graphValidateVisible(GraphAnimator* const animator) {
if(graph_mOnlySelectedVisible){
return animator->prp_isParentBoxSelected();
}
return true;
bool KeysView::graphValidateVisible(GraphAnimator* const animator)
{
if (animator->prp_isSelected() &&
animator->prp_isParentBoxContained()) { return true; }
return false;
}

void KeysView::graphAddToViewedAnimatorList(GraphAnimator * const animator) {
if (mGraphAnimators.contains(animator)) { return; }
auto& connContext = mGraphAnimators.addObj(animator);
connContext << connect(animator, &QObject::destroyed,
this, [this, animator]() {
graphRemoveViewedAnimator(animator);
});
}

void KeysView::graphUpdateVisbile() {
mGraphAnimators.clear();
if(mCurrentScene) {
void KeysView::graphUpdateVisible()
{
qDebug() << "graphUpdateVisible";
//mGraphAnimators.clear();
if (mCurrentScene) {
const int id = mBoxesListWidget->getId();
const auto all = mCurrentScene->getSelectedForGraph(id);
if(all) {
for(const auto anim : *all) {
if(graphValidateVisible(anim)) {
graphAddToViewedAnimatorList(anim);
}
if (all) {
qDebug() << "selected for graph" << all->count();
for (const auto anim : *all) {
if (graphValidateVisible(anim)) { graphAddToViewedAnimatorList(anim); }
else { graphRemoveViewedAnimator(anim); }
}
}
}
Expand All @@ -605,6 +602,7 @@ void KeysView::graphAddViewedAnimator(GraphAnimator * const animator) {
}

void KeysView::graphRemoveViewedAnimator(GraphAnimator * const animator) {
if (!mGraphAnimators.contains(animator)) { return; }
if(!mCurrentScene) return Q_ASSERT(false);
const int id = mBoxesListWidget->getId();
mCurrentScene->removeSelectedForGraph(id, animator);
Expand Down
15 changes: 12 additions & 3 deletions src/app/GUI/keysview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,27 @@ void KeysView::setCurrentScene(Canvas * const scene)
{
if (mCurrentScene) {
disconnect(mCurrentScene.data(), &Canvas::objectSelectionChanged,
this, &KeysView::graphUpdateVisbile);
this, &KeysView::graphUpdateVisible);
disconnect(mCurrentScene.data(), &Canvas::requestUpdate,
this, &KeysView::sceneRequestedUpdate);
disconnect(mCurrentScene.data(), &Canvas::requestEasingAction,
this, &KeysView::graphEasingAction);
}
mCurrentScene = scene;
if (mCurrentScene) {
connect(mCurrentScene.data(), &Canvas::objectSelectionChanged,
this, &KeysView::graphUpdateVisbile);
this, &KeysView::graphUpdateVisible);
connect(mCurrentScene.data(), &Canvas::requestUpdate,
this, &KeysView::sceneRequestedUpdate);
connect(mCurrentScene.data(), &Canvas::requestEasingAction,
this, &KeysView::graphEasingAction);
}
graphUpdateVisbile();
graphUpdateVisible();
}

void KeysView::sceneRequestedUpdate()
{
graphUpdateVisible();
}

void KeysView::setGraphViewed(const bool bT) {
Expand Down
5 changes: 2 additions & 3 deletions src/app/GUI/keysview.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class KeysView : public QWidget, public KeyFocusTarget {
QWidget *parent = nullptr);

void setCurrentScene(Canvas* const scene);
void sceneRequestedUpdate();

void setGraphViewed(const bool bT);

Expand Down Expand Up @@ -162,8 +163,7 @@ class KeysView : public QWidget, public KeyFocusTarget {
int graphGetAnimatorId(GraphAnimator * const anim);
QrealPoint *graphGetPointAtPos(const QPointF &pressPos) const;
bool graphValidateVisible(GraphAnimator * const animator);
void graphUpdateVisbile();
void graphSetOnlySelectedVisible(const bool selectedOnly);
void graphUpdateVisible();
bool graphIsSelected(GraphAnimator * const anim);
void graphEasingAction(const QString &easing);
void graphEasingApply(QrealAnimator *anim,
Expand Down Expand Up @@ -269,7 +269,6 @@ class KeysView : public QWidget, public KeyFocusTarget {

// graph

bool graph_mOnlySelectedVisible = false;
bool graph_mValueLinesVisible = true;
qreal mPixelsPerValUnit = 0;
qreal mMinShownVal = 0;
Expand Down
10 changes: 10 additions & 0 deletions src/core/Properties/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,16 @@ bool Property::prp_isParentBoxSelected() const {
return false;
}

bool Property::prp_isParentBoxContained() const
{
const auto pBox = getFirstAncestor<eBoxOrSound>();
if (pBox && mParentScene) {
const auto contained = mParentScene->getContainedBoxes();
for (const auto &box : contained) { if (box == pBox) { return true; } }
}
return false;
}

#include "canvas.h"
void Property::prp_selectionChangeTriggered(const bool shiftPressed) {
if(!mParentScene) return;
Expand Down
1 change: 1 addition & 0 deletions src/core/Properties/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ class CORE_EXPORT Property : public SingleWidgetTarget {
}

bool prp_isParentBoxSelected() const;
bool prp_isParentBoxContained() const;

bool prp_drawsOnCanvas() const
{ return mDrawOnCanvas; }
Expand Down

0 comments on commit 30e8a10

Please sign in to comment.