summaryrefslogtreecommitdiff
path: root/shortcuts
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2013-09-13 03:39:58 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2013-09-13 03:39:58 +0200
commit7caea4526d09668085344449aae6ba524feb45fd (patch)
tree842bb8d2b0a019d3f43e14f24eb3d155795a182a /shortcuts
parentd1a7bd68692609c834f36a0ef78f7973879d7e72 (diff)
ShortcutController: use AnimationUtils methods to start and reverse the animation
(bzr r3494.7.11)
Diffstat (limited to 'shortcuts')
-rw-r--r--shortcuts/ShortcutController.cpp30
1 files changed, 6 insertions, 24 deletions
diff --git a/shortcuts/ShortcutController.cpp b/shortcuts/ShortcutController.cpp
index 12ef5e01b..05c1b7b19 100644
--- a/shortcuts/ShortcutController.cpp
+++ b/shortcuts/ShortcutController.cpp
@@ -20,11 +20,10 @@
#include "ShortcutController.h"
#include "ShortcutModel.h"
+#include "unity-shared/AnimationUtils.h"
#include "unity-shared/UBusMessages.h"
#include "unity-shared/UScreen.h"
-namespace na = nux::animation;
-
namespace unity
{
namespace shortcut
@@ -129,16 +128,7 @@ bool Controller::OnShowTimer()
if (visible_)
{
view_->live_background = true;
-
- if (fade_animator_.CurrentState() == na::Animation::State::Running)
- {
- if (fade_animator_.GetFinishValue() == 0.0f)
- fade_animator_.Reverse();
- }
- else
- {
- fade_animator_.SetStartValue(0.0f).SetFinishValue(1.0f).Start();
- }
+ animation::StartOrReverse(fade_animator_, animation::Direction::FORWARD);
}
return false;
@@ -214,16 +204,7 @@ void Controller::Hide()
if (view_window_ && view_window_->GetOpacity() > 0.0f)
{
view_->live_background = false;
-
- if (fade_animator_.CurrentState() == na::Animation::State::Running)
- {
- if (fade_animator_.GetFinishValue() == 1.0f)
- fade_animator_.Reverse();
- }
- else
- {
- fade_animator_.SetStartValue(1.0f).SetFinishValue(0.0f).Start();
- }
+ animation::StartOrReverse(fade_animator_, animation::Direction::BACKWARD);
}
}
@@ -258,12 +239,13 @@ std::string Controller::GetName() const
void Controller::AddProperties(GVariantBuilder* builder)
{
bool animating = (fade_animator_.CurrentState() == na::Animation::State::Running);
+ auto direction = animation::GetDirection(fade_animator_);
unity::variant::BuilderWrapper(builder)
.add("timeout_duration", SUPER_TAP_DURATION + FADE_DURATION)
.add("enabled", IsEnabled())
- .add("about_to_show", (Visible() && animating && fade_animator_.GetFinishValue() == 1.0f))
- .add("about_to_hide", (Visible() && animating && fade_animator_.GetFinishValue() == 0.0f))
+ .add("about_to_show", (Visible() && animating && direction == animation::Direction::FORWARD))
+ .add("about_to_hide", (Visible() && animating && direction == animation::Direction::FORWARD))
.add("visible", (Visible() && view_window_ && view_window_->GetOpacity() == 1.0f));
}