From f585cad330de7d243ded6a569b4f7a775efe615e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Sat, 24 Aug 2024 21:59:03 +0200 Subject: [PATCH 1/4] Property: add check for parent state Adds a function to check if parent box is contained in scene or not. Ref: #177 --- src/core/Properties/property.cpp | 10 ++++++++++ src/core/Properties/property.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/core/Properties/property.cpp b/src/core/Properties/property.cpp index e8ca66ada..90acd79cd 100644 --- a/src/core/Properties/property.cpp +++ b/src/core/Properties/property.cpp @@ -362,6 +362,16 @@ bool Property::prp_isParentBoxSelected() const { return false; } +bool Property::prp_isParentBoxContained() const +{ + const auto pBox = getFirstAncestor(); + 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; diff --git a/src/core/Properties/property.h b/src/core/Properties/property.h index a5875467a..eb586aed9 100644 --- a/src/core/Properties/property.h +++ b/src/core/Properties/property.h @@ -249,6 +249,7 @@ class CORE_EXPORT Property : public SingleWidgetTarget { } bool prp_isParentBoxSelected() const; + bool prp_isParentBoxContained() const; bool prp_drawsOnCanvas() const { return mDrawOnCanvas; } From f5e82b12e18ad1e2f9a688674be37fb00903eb2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Sat, 24 Aug 2024 22:28:08 +0200 Subject: [PATCH 2/4] Graph: remove 'View only selected' action #177 --- src/app/GUI/animationdockwidget.cpp | 11 ----------- src/app/GUI/animationdockwidget.h | 1 - 2 files changed, 12 deletions(-) diff --git a/src/app/GUI/animationdockwidget.cpp b/src/app/GUI/animationdockwidget.cpp index 1b2b5ac38..18ed379a0 100644 --- a/src/app/GUI/animationdockwidget.cpp +++ b/src/app/GUI/animationdockwidget.cpp @@ -38,7 +38,6 @@ AnimationDockWidget::AnimationDockWidget(QWidget *parent, , mSmoothButton(nullptr) , mCornerButton(nullptr) , mFitToHeightButton(nullptr) - , mOnlySelectedAct(nullptr) { setObjectName(QString::fromUtf8("animationDockWidget")); setSizePolicy(QSizePolicy::Maximum, @@ -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); @@ -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)); @@ -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, diff --git a/src/app/GUI/animationdockwidget.h b/src/app/GUI/animationdockwidget.h index 6e697afe3..390618dd5 100644 --- a/src/app/GUI/animationdockwidget.h +++ b/src/app/GUI/animationdockwidget.h @@ -52,7 +52,6 @@ class AnimationDockWidget : public QToolBar QAction *mSmoothButton; QAction *mCornerButton; QAction *mFitToHeightButton; - QAction *mOnlySelectedAct; }; #endif // ANIMATIONDOCKWIDGET_H From d586eb6d040779ea1269f9bebe340ba404e0d19a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Sun, 25 Aug 2024 01:06:51 +0200 Subject: [PATCH 3/4] Box: handle property selected changed #177 And disable graph icon for properties. --- src/app/GUI/BoxesList/boxsinglewidget.cpp | 28 +++++++++++++++++++---- src/app/GUI/BoxesList/boxsinglewidget.h | 2 ++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/app/GUI/BoxesList/boxsinglewidget.cpp b/src/app/GUI/BoxesList/boxsinglewidget.cpp index ca168a66a..96a7a6e4e 100644 --- a/src/app/GUI/BoxesList/boxsinglewidget.cpp +++ b/src/app/GUI/BoxesList/boxsinglewidget.cpp @@ -177,12 +177,12 @@ BoxSingleWidget::BoxSingleWidget(BoxScroller * const parent) } else if (const auto eEff = enve_cast(target)) { if (eEff->isVisible()) { return BoxSingleWidget::VISIBLE_ICON; } return BoxSingleWidget::INVISIBLE_ICON; - } else if (enve_cast(target)) { + } /*else if (enve_cast(target)) { const auto bsvt = static_cast(mParent); const auto keysView = bsvt->getKeysView(); if (keysView) { return BoxSingleWidget::GRAPH_PROPERTY_ICON; } return static_cast(nullptr); - } + }*/ return static_cast(nullptr); }); @@ -382,6 +382,24 @@ void BoxSingleWidget::setComboProperty(ComboBoxProperty* const combo) { mPropertyComboBox->show(); } +void BoxSingleWidget::handlePropertySelectedChanged(const Property *prop) +{ + if (const auto graph = enve_cast(prop)) { + const auto bsvt = static_cast(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; @@ -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); @@ -878,7 +898,7 @@ void BoxSingleWidget::switchBoxVisibleAction() { ebos->switchVisible(); } else if(const auto eEff = enve_cast(target)) { eEff->switchVisible(); - } else if(const auto graph = enve_cast(target)) { + } /*else if(const auto graph = enve_cast(target)) { const auto bsvt = static_cast(mParent); const auto keysView = bsvt->getKeysView(); if(keysView) { @@ -889,7 +909,7 @@ void BoxSingleWidget::switchBoxVisibleAction() { } Document::sInstance->actionFinished(); } - } + }*/ Document::sInstance->actionFinished(); update(); } diff --git a/src/app/GUI/BoxesList/boxsinglewidget.h b/src/app/GUI/BoxesList/boxsinglewidget.h index 0363c4047..0989a5b31 100644 --- a/src/app/GUI/BoxesList/boxsinglewidget.h +++ b/src/app/GUI/BoxesList/boxsinglewidget.h @@ -134,6 +134,8 @@ class BoxSingleWidget : public SingleWidget { void setComboProperty(ComboBoxProperty * const combo); + void handlePropertySelectedChanged(const Property *prop); + BoxScroller* const mParent; bool mDragPressPos = false; From 0e802b71a66b66a114ae4809464cb97db01a02f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Sun, 25 Aug 2024 02:02:43 +0200 Subject: [PATCH 4/4] Graph: use selected properties from timeline Initial implementation for #177 --- src/app/GUI/graphboxeslist.cpp | 36 ++++++++++++++++------------------ src/app/GUI/keysview.cpp | 15 +++++++++++--- src/app/GUI/keysview.h | 5 ++--- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/app/GUI/graphboxeslist.cpp b/src/app/GUI/graphboxeslist.cpp index d57a53168..1a9b9dda4 100644 --- a/src/app/GUI/graphboxeslist.cpp +++ b/src/app/GUI/graphboxeslist.cpp @@ -556,20 +556,15 @@ 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]() { @@ -577,16 +572,18 @@ void KeysView::graphAddToViewedAnimatorList(GraphAnimator * const 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); } } } } @@ -608,6 +605,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); diff --git a/src/app/GUI/keysview.cpp b/src/app/GUI/keysview.cpp index 9077e1bdc..1867fcb80 100644 --- a/src/app/GUI/keysview.cpp +++ b/src/app/GUI/keysview.cpp @@ -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) { diff --git a/src/app/GUI/keysview.h b/src/app/GUI/keysview.h index 1472189d4..6c2cd2c5c 100644 --- a/src/app/GUI/keysview.h +++ b/src/app/GUI/keysview.h @@ -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); @@ -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, @@ -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;