Skip to content

Commit

Permalink
Allow slowing down Animations::Simple globally.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jan 13, 2022
1 parent ba27a01 commit d7b3a68
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
11 changes: 11 additions & 0 deletions ui/effects/animation_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace anim {
namespace {

rpl::variable<bool> AnimationsDisabled = false;
int SlowMultiplierMinusOne/* = 0*/;

} // namespace

Expand Down Expand Up @@ -76,6 +77,16 @@ void SetDisabled(bool disabled) {
AnimationsDisabled = disabled;
}

int SlowMultiplier() {
return (SlowMultiplierMinusOne + 1);
}

void SetSlowMultiplier(int multiplier) {
Expects(multiplier > 0);

SlowMultiplierMinusOne = multiplier - 1;
}

void DrawStaticLoading(
QPainter &p,
QRectF rect,
Expand Down
2 changes: 2 additions & 0 deletions ui/effects/animation_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ QPainterPath path(QPointF (&from)[N]) {
rpl::producer<bool> Disables();
bool Disabled();
void SetDisabled(bool disabled);
int SlowMultiplier();
void SetSlowMultiplier(int multiplier); // 1 - default, 10 - slow x10.

void DrawStaticLoading(
QPainter &p,
Expand Down
2 changes: 1 addition & 1 deletion ui/effects/animations.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ inline void Simple::startPrepared(
anim::transition transition) {
_data->from = _data->value;
_data->delta = to - _data->from;
_data->duration = duration;
_data->duration = duration * anim::SlowMultiplier();
_data->transition = transition;
_data->animation.start();
}
Expand Down

0 comments on commit d7b3a68

Please sign in to comment.