diff options
| author | Tim Penhey <tim.penhey@canonical.com> | 2012-08-20 06:49:39 -0400 |
|---|---|---|
| committer | Tarmac <> | 2012-08-20 06:49:39 -0400 |
| commit | 02be480ef0d93ecd84b80283d800e3177cbc3b30 (patch) | |
| tree | aee9da06214de980b7b2739ed46d54081fc2e0f6 /unity-shared | |
| parent | 500abaf438c01a2783dda1e5e567acf08a1a94e5 (diff) | |
| parent | ca49ac4cde46206ebda7b8dced2aae9e7fd7b8c8 (diff) | |
Enable the new nux animation framework. Update BGHash to use the new animations.. Fixes: . Approved by Andrea Azzarone.
(bzr r2587)
Diffstat (limited to 'unity-shared')
| -rw-r--r-- | unity-shared/BGHash.cpp | 25 | ||||
| -rw-r--r-- | unity-shared/BGHash.h | 9 |
2 files changed, 10 insertions, 24 deletions
diff --git a/unity-shared/BGHash.cpp b/unity-shared/BGHash.cpp index 767c8f377..fc299bc98 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_.SetFinishValue(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_; |
