Back to index

unity  6.0.0
ShortcutController.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: Andrea Azzarone <azzaronea@gmail.com>
00017  */
00018 
00019 #ifndef UNITYSHELL_SHORTCUTCONTROLLER_H
00020 #define UNITYSHELL_SHORTCUTCONTROLLER_H
00021 
00022 #include <boost/shared_ptr.hpp>
00023 
00024 #include <Nux/Nux.h>
00025 #include <Nux/BaseWindow.h>
00026 #include <Nux/HLayout.h>
00027 #include <NuxCore/Color.h>
00028 #include <UnityCore/Variant.h>
00029 #include <UnityCore/GLibSource.h>
00030 
00031 #include "unity-shared/Animator.h"
00032 #include "unity-shared/Introspectable.h"
00033 #include "ShortcutModel.h"
00034 #include "ShortcutView.h"
00035 #include "unity-shared/UBusWrapper.h"
00036 
00037 namespace unity
00038 {
00039 namespace shortcut
00040 {
00041 
00042 class Controller : public debug::Introspectable
00043 {
00044 public:
00045   typedef std::shared_ptr<Controller> Ptr;
00046 
00047   // Ctor
00048   Controller(std::list<AbstractHint::Ptr>& hints);
00049 
00050   // Public Methods
00051   bool Show();
00052   void Hide();
00053 
00054   bool Visible();
00055   bool IsEnabled();
00056 
00057   void SetAdjustment(int x, int y);
00058   void SetEnabled(bool enabled);
00059 
00060 protected:
00061   std::string GetName() const;
00062   void AddProperties(GVariantBuilder* builder);
00063 
00064 private:
00065   // Private Methods
00066   void ConstructView();
00067   void EnsureView();
00068   void OnBackgroundUpdate(GVariant* data);
00069   void OnFadeInUpdated(double opacity);
00070   void OnFadeInEnded();
00071   void OnFadeOutUpdated(double opacity);
00072   void OnFadeOutEnded();
00073   bool OnShowTimer();
00074 
00075   // Private Members
00076   View::Ptr view_;
00077   Model::Ptr model_;
00078 
00079   nux::Geometry workarea_;
00080   nux::ObjectPtr<nux::BaseWindow> view_window_;
00081   nux::HLayout* main_layout_;
00082 
00083   bool visible_;
00084   bool enabled_;
00085   nux::Color bg_color_;
00086 
00087   Animator fade_in_animator_;
00088   Animator fade_out_animator_;
00089 
00090   glib::Source::UniquePtr show_timer_;
00091   UBusManager ubus_manager_;
00092 };
00093 
00094 } // namespace shortcut
00095 } // namespace unity
00096 
00097 #endif //UNITYSHELL_SHORTCUTHINTCONTROLLER_H
00098