summaryrefslogtreecommitdiff
path: root/unity-shared
diff options
authorTim Penhey <tim.penhey@canonical.com>2012-08-15 16:58:17 +1200
committerTim Penhey <tim.penhey@canonical.com>2012-08-15 16:58:17 +1200
commit2d5d64decaba63eb133b8dc5dd0b02e3cdd43b23 (patch)
tree0e6e95febb0ac34896a5b3928ddbf3e10cdc1a75 /unity-shared
parent1d55a67ab74a3768c81b0077105f72c3af2abb09 (diff)
Update the BGHash to use a color animation.
(bzr r2565.1.2)
Diffstat (limited to 'unity-shared')
-rw-r--r--unity-shared/BGHash.cpp25
-rw-r--r--unity-shared/BGHash.h9
2 files changed, 10 insertions, 24 deletions
diff --git a/unity-shared/BGHash.cpp b/unity-shared/BGHash.cpp
index 767c8f377..cc3d23236 100644
--- a/unity-shared/BGHash.cpp
+++ b/unity-shared/BGHash.cpp
@@ -31,14 +31,12 @@ namespace unity
{
BGHash::BGHash()
- : transition_animator_(500)
- , current_color_(unity::colors::Aubergine)
- , new_color_(unity::colors::Aubergine)
- , old_color_(unity::colors::Aubergine)
+ : current_color_(unity::colors::Aubergine)
{
+ transition_animator_.SetDuration(500);
override_color_.alpha = 0.0f;
- transition_animator_.animation_updated.connect(sigc::mem_fun(this, &BGHash::OnTransitionUpdated));
+ transition_animator_.updated.connect(sigc::mem_fun(this, &BGHash::OnTransitionUpdated));
ubus_manager_.RegisterInterest(UBUS_BACKGROUND_REQUEST_COLOUR_EMIT, [&](GVariant *) { DoUbusColorEmit(); } );
RefreshColor();
@@ -100,14 +98,6 @@ void BGHash::RefreshColor()
}
}
-nux::Color BGHash::InterpolateColor(nux::Color const& colora, nux::Color const& colorb, float value) const
-{
- // takes two colours, transitions between them, we can do it linearly or whatever
- // i don't think it will matter that much
- // it doesn't happen too often
- return colora + ((colorb - colora) * value);
-}
-
void BGHash::TransitionToNewColor(nux::color::Color const& new_color)
{
if (new_color == current_color_)
@@ -115,16 +105,15 @@ void BGHash::TransitionToNewColor(nux::color::Color const& new_color)
LOG_DEBUG(logger) << "transitioning from: " << current_color_.red << " to " << new_color.red;
- old_color_ = current_color_;
- new_color_ = new_color;
-
+ transition_animator_.SetStartValue(current_color_);
+ transition_animator_.SetEndValue(new_color_);
transition_animator_.Stop();
transition_animator_.Start();
}
-void BGHash::OnTransitionUpdated(double progress)
+void BGHash::OnTransitionUpdated(nux::Color const& new_color)
{
- current_color_ = InterpolateColor(old_color_, new_color_, progress);
+ current_color_ = new_color;
DoUbusColorEmit();
}
diff --git a/unity-shared/BGHash.h b/unity-shared/BGHash.h
index 7cbb7d4f6..b32ec1c64 100644
--- a/unity-shared/BGHash.h
+++ b/unity-shared/BGHash.h
@@ -19,8 +19,8 @@
#ifndef BGHASH_H
#define BGHASH_H
+#include <NuxCore/Animation.h>
#include <Nux/Nux.h>
-#include "Animator.h"
#include "UBusWrapper.h"
namespace unity {
@@ -41,18 +41,15 @@ namespace unity
void OverrideColor(nux::Color const& color);
private:
- void OnTransitionUpdated(double progress);
+ void OnTransitionUpdated(nux::Color const& new_color);
void DoUbusColorEmit();
void TransitionToNewColor(nux::Color const& new_color);
- nux::Color InterpolateColor(nux::Color const& colora, nux::Color const& colorb, float value) const;
nux::Color MatchColor(nux::Color const& base_color) const;
private:
- Animator transition_animator_;
+ nux::animation::AnimateValue<nux::Color> transition_animator_;
nux::Color current_color_; // the current colour, including steps in transitions
- nux::Color new_color_; // in transitions, the next colour, otherwise the current colour
- nux::Color old_color_; // the last colour chosen, used for transitions
nux::Color override_color_;
UBusManager ubus_manager_;