Skip to content

Commit

Permalink
Only show usable animators in graph
Browse files Browse the repository at this point in the history
This is a proposed solution for issue #176.

Introduces a new "isGraphSelected" function for boxes and "prp_isParentBoxGraphSelected" for properties. This function is used by the graph to figure out which animators are usable or not, the state is controlled by the canvas. if "isGraphSelected" is false then the box should be considered removed and the animator connected to the box should be ignored, we do not remove it since that breaks undo.
  • Loading branch information
rodlie committed May 28, 2024
1 parent d4fc7c8 commit 629e18e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/app/GUI/graphboxeslist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,9 @@ void KeysView::graphSetOnlySelectedVisible(const bool selectedOnly) {
}

bool KeysView::graphValidateVisible(GraphAnimator* const animator) {
if(graph_mOnlySelectedVisible){
// https://github.com/friction2d/friction/issues/176
if (!animator->prp_isParentBoxGraphSelected()) { return false; }
if (graph_mOnlySelectedVisible) {
return animator->prp_isParentBoxSelected();
}
return true;
Expand Down
6 changes: 6 additions & 0 deletions src/core/Animators/eboxorsound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,12 @@ void eBoxOrSound::setSelected(const bool select) {
emit selectionChanged(select);
}

void eBoxOrSound::setGraphSelected(const bool select)
{
if (mGraphSelected == select) { return; }
mGraphSelected = select;
}

void eBoxOrSound::select() {
setSelected(true);
}
Expand Down
3 changes: 3 additions & 0 deletions src/core/Animators/eboxorsound.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,11 @@ class CORE_EXPORT eBoxOrSound : public StaticComplexAnimator {
bool isFrameFVisibleAndInDurationRect(const qreal relFrame) const;

void setSelected(const bool select);
void setGraphSelected(const bool select);
void select();
void deselect();
bool isSelected() const { return mSelected; }
bool isGraphSelected() const { return mGraphSelected; }
void selectionChangeTriggered(const bool shiftPressed);

void hide();
Expand Down Expand Up @@ -146,6 +148,7 @@ class CORE_EXPORT eBoxOrSound : public StaticComplexAnimator {
void lockedChanged(bool);
private:
bool mSelected = false;
bool mGraphSelected = false;
bool mVisible = true;
bool mLocked = false;
int mZListIndex = 0;
Expand Down
7 changes: 7 additions & 0 deletions src/core/Properties/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,13 @@ bool Property::prp_isParentBoxSelected() const {
return false;
}

bool Property::prp_isParentBoxGraphSelected() const
{
const auto pBox = getFirstAncestor<eBoxOrSound>();
if (pBox) { return pBox->isGraphSelected(); }
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_isParentBoxGraphSelected() const;

bool prp_drawsOnCanvas() const
{ return mDrawOnCanvas; }
Expand Down
4 changes: 3 additions & 1 deletion src/core/canvasselectedboxesactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ void Canvas::addBoxToSelection(BoundingBox * const box)
});

box->setSelected(true);
box->setGraphSelected(true);
schedulePivotUpdate();

sortSelectedBoxesDesc();
Expand All @@ -455,9 +456,10 @@ void Canvas::addBoxToSelection(BoundingBox * const box)
}

void Canvas::removeBoxFromSelection(BoundingBox * const box) {
if(!box->isSelected()) return;
if (!box->isSelected()) { return; }
mSelectedBoxes.removeObj(box);
box->setSelected(false);
box->setGraphSelected(false);
schedulePivotUpdate();
//if(mCurrentMode == CanvasMode::paint) updatePaintBox();
if (mSelectedBoxes.isEmpty()) { setCurrentBox(nullptr); }
Expand Down

0 comments on commit 629e18e

Please sign in to comment.