Back to index

unity  6.0.0
BGHash.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2011 Canonical Ltd
00003  *
00004  * This program is free software: you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License version 3 as
00006  * published by the Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  * GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00015  *
00016  * Authored by: Gordon Allott <gord.alott@canonical.com>
00017  */
00018 
00019 #ifndef BGHASH_H
00020 #define BGHASH_H
00021 
00022 #include <Nux/Nux.h>
00023 #include "Animator.h"
00024 #include "UBusWrapper.h"
00025 
00026 namespace unity {
00027 namespace colors {
00028   const nux::Color Aubergine(0x3E, 0x20, 0x60);
00029 };
00030 };
00031 
00032 namespace unity
00033 {
00034   class BGHash
00035   {
00036   public:
00037     BGHash();
00038 
00039     nux::Color const& CurrentColor() const;
00040     void RefreshColor();
00041     void OverrideColor(nux::Color const& color);
00042 
00043   private:
00044     void OnTransitionUpdated(double progress);
00045     void DoUbusColorEmit();
00046     void TransitionToNewColor(nux::Color const& new_color);
00047     nux::Color InterpolateColor(nux::Color const& colora, nux::Color const& colorb, float value) const;
00048     nux::Color MatchColor(nux::Color const& base_color) const;
00049 
00050   private:
00051     Animator transition_animator_;
00052 
00053     nux::Color current_color_; // the current colour, including steps in transitions
00054     nux::Color new_color_;     // in transitions, the next colour, otherwise the current colour
00055     nux::Color old_color_;     // the last colour chosen, used for transitions
00056     nux::Color override_color_;
00057 
00058     UBusManager ubus_manager_;
00059   };
00060 };
00061 
00062 #endif // BGHASH_H