diff options
| author | Nick Dedekind <nicholas.dedekind@gmail.com> | 2012-08-20 15:21:31 +0100 |
|---|---|---|
| committer | Nick Dedekind <nicholas.dedekind@gmail.com> | 2012-08-20 15:21:31 +0100 |
| commit | c1beaac992aa4099d2e9c8275db2fb4ac61246d2 (patch) | |
| tree | 8851959164b5db6454499c280bae3b399c9f2c89 /unity-shared | |
| parent | 8f918e81f5cb85d75cd68f91faa1c94d2a44e45e (diff) | |
| parent | 02be480ef0d93ecd84b80283d800e3177cbc3b30 (diff) | |
Merge with trunk
(bzr r2419.4.77)
Diffstat (limited to 'unity-shared')
| -rw-r--r-- | unity-shared/BGHash.cpp | 25 | ||||
| -rw-r--r-- | unity-shared/BGHash.h | 9 | ||||
| -rw-r--r-- | unity-shared/PluginAdapterCompiz.cpp | 7 | ||||
| -rw-r--r-- | unity-shared/ThumbnailGenerator.cpp | 6 |
4 files changed, 17 insertions, 30 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_; diff --git a/unity-shared/PluginAdapterCompiz.cpp b/unity-shared/PluginAdapterCompiz.cpp index 92ad4cea3..1c67e9659 100644 --- a/unity-shared/PluginAdapterCompiz.cpp +++ b/unity-shared/PluginAdapterCompiz.cpp @@ -242,7 +242,7 @@ void MultiActionList::InitiateAll(CompOption::Vector& extraArgs, int state) { CompOption::Vector argument; - if (!m_ActionList.size()) + if (m_ActionList.empty()) return; argument.resize(1); @@ -269,7 +269,7 @@ MultiActionList::TerminateAll(CompOption::Vector& extraArgs) { CompOption::Vector argument; CompOption::Value value; - if (!m_ActionList.size()) + if (m_ActionList.empty()) return; argument.resize(1); @@ -821,7 +821,8 @@ PluginAdapter::FocusWindowGroup(std::vector<Window> window_ids, FocusVisibility bool PluginAdapter::ScaleWindowGroup(std::vector<Window> windows, int state, bool force) { - if (windows.size() > 1 || (force && windows.size() > 0)) + std::size_t num_windows = windows.size(); + if (num_windows > 1 || (force && num_windows)) { std::string match = MatchStringForXids(&windows); InitiateScale(match, state); diff --git a/unity-shared/ThumbnailGenerator.cpp b/unity-shared/ThumbnailGenerator.cpp index d13be2b9e..c65f99ea0 100644 --- a/unity-shared/ThumbnailGenerator.cpp +++ b/unity-shared/ThumbnailGenerator.cpp @@ -239,7 +239,7 @@ void ThumbnailGeneratorImpl::RunGenerate() *********************************/ pthread_mutex_lock (&thumbnails_mutex_); - if (thumbnails_.size() == 0) + if (thumbnails_.empty()) { thumbnail_thread_is_running_ = FALSE; pthread_mutex_unlock (&thumbnails_mutex_); @@ -290,7 +290,7 @@ bool ThumbnailGeneratorImpl::OnThumbnailComplete() { pthread_mutex_lock (&thumbnails_mutex_); - if (complete_thumbnails_.size() == 0) + if (complete_thumbnails_.empty()) { thread_return_timer_.reset(); pthread_mutex_unlock (&thumbnails_mutex_); @@ -536,4 +536,4 @@ std::string Thumbnail::Generate(std::string& error_hint) -} // namespace unity \ No newline at end of file +} // namespace unity |
