Skip to content

Commit

Permalink
Gui: Add easing to navigation animations
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexbas authored and chennes committed Feb 29, 2024
1 parent 5e3425f commit 7e2f8c3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Gui/NavigationAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void NavigationAnimation::onStop([[maybe_unused]] bool finished)

FixedTimeAnimation::FixedTimeAnimation(NavigationStyle* navigation, const SbRotation& orientation,
const SbVec3f& rotationCenter, const SbVec3f& translation,
int duration)
int duration, const QEasingCurve::Type easingCurve)
: NavigationAnimation(navigation)
, targetOrientation(orientation)
, targetTranslation(translation)
Expand All @@ -53,6 +53,7 @@ FixedTimeAnimation::FixedTimeAnimation(NavigationStyle* navigation, const SbRota
setDuration(duration);
setStartValue(0.0);
setEndValue(duration * 1.0);
setEasingCurve(easingCurve);
}

void FixedTimeAnimation::initialize()
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/NavigationAnimation.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class GuiExport FixedTimeAnimation : public NavigationAnimation
public:
explicit FixedTimeAnimation(NavigationStyle* navigation, const SbRotation& orientation,
const SbVec3f& rotationCenter, const SbVec3f& translation,
int duration);
int duration, const QEasingCurve::Type easingCurve);

private:
float angularVelocity; // [rad/ms]
Expand Down
6 changes: 5 additions & 1 deletion src/Gui/View3DInventorViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3409,8 +3409,12 @@ void View3DInventorViewer::startAnimation(const SbRotation& orientation,
->GetInt("AnimationDuration", 500);
}

QEasingCurve::Type easingCurve = static_cast<QEasingCurve::Type>(App::GetApplication()
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
->GetInt("NavigationAnimationEasingCurve", QEasingCurve::Type::InOutCubic));

auto animation = std::make_shared<FixedTimeAnimation>(
navigation, orientation, rotationCenter, translation, duration);
navigation, orientation, rotationCenter, translation, duration, easingCurve);

navigation->startAnimating(animation, wait);
}
Expand Down

0 comments on commit 7e2f8c3

Please sign in to comment.