Skip to content

Commit

Permalink
Graph: use selected properties from timeline
Browse files Browse the repository at this point in the history
Initial implementation for #177
  • Loading branch information
rodlie committed Aug 25, 2024
1 parent d586eb6 commit 0e802b7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
36 changes: 17 additions & 19 deletions src/app/GUI/graphboxeslist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,37 +556,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 @@ -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);
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

0 comments on commit 0e802b7

Please sign in to comment.