Back to index

unity  6.0.0
SwitcherController.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2011 Canonical Ltd
00004  *
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 3 as
00007  * published by the Free Software Foundation.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  *
00017  * Authored by: Jason Smith <jason.smith@canonical.com>
00018  */
00019 
00020 #ifndef SWITCHERCONTROLLER_H
00021 #define SWITCHERCONTROLLER_H
00022 
00023 #include <UnityCore/Variant.h>
00024 #include <UnityCore/GLibSource.h>
00025 
00026 #include "unity-shared/Introspectable.h"
00027 #include "unity-shared/UBusWrapper.h"
00028 
00029 #include "SwitcherModel.h"
00030 #include "SwitcherView.h"
00031 
00032 #include <Nux/Nux.h>
00033 #include <Nux/BaseWindow.h>
00034 #include <Nux/WindowCompositor.h>
00035 
00036 namespace unity
00037 {
00038 namespace launcher
00039 {
00040 class AbstractLauncherIcon;
00041 }
00042 namespace switcher
00043 {
00044 
00045 enum class SortMode
00046 {
00047   LAUNCHER_ORDER,
00048   FOCUS_ORDER,
00049 };
00050 
00051 enum class ShowMode
00052 {
00053   ALL,
00054   CURRENT_VIEWPORT,
00055 };
00056 
00057 
00058 class Controller : public debug::Introspectable, public sigc::trackable
00059 {
00060 public:
00061   typedef std::shared_ptr<Controller> Ptr;
00062 
00063   Controller(unsigned int load_timeout = 20);
00064 
00065   nux::Property<int> timeout_length;
00066   nux::Property<bool> detail_on_timeout;
00067   nux::Property<int>  detail_timeout_length;
00068   nux::Property<int> initial_detail_timeout_length;
00069 
00070   void Show(ShowMode show, SortMode sort, bool reverse, std::vector<launcher::AbstractLauncherIcon::Ptr> results);
00071   void Hide(bool accept_state=true);
00072 
00073   bool Visible();
00074 
00075   void Next();
00076   void Prev();
00077 
00078   void NextDetail();
00079   void PrevDetail();
00080 
00081   void Select (int index);
00082 
00083   void SetDetail(bool detail, unsigned int min_windows = 1);
00084 
00085   void SelectFirstItem();
00086 
00087   void SetWorkspace(nux::Geometry geo, int monitor);
00088 
00089   SwitcherView * GetView ();
00090 
00091   ui::LayoutWindowList ExternalRenderTargets ();
00092 
00093   guint GetSwitcherInputWindowId() const;
00094 
00095 protected:
00096   // Introspectable methods
00097   std::string GetName() const;
00098   void AddProperties(GVariantBuilder* builder);
00099 
00100   virtual void ConstructWindow();
00101   virtual void ConstructView();
00102   virtual void ShowView();
00103 
00104   virtual bool OnDetailTimer();
00105   void OnModelSelectionChanged(launcher::AbstractLauncherIcon::Ptr icon);
00106 
00107   unsigned int construct_timeout_;
00108 
00109 private:
00110   enum DetailMode
00111   {
00112     TAB_NEXT_WINDOW,
00113     TAB_NEXT_WINDOW_LOOP,
00114     TAB_NEXT_TILE,
00115   };
00116 
00117   void OnBackgroundUpdate(GVariant* data);
00118   static bool CompareSwitcherItemsPriority(launcher::AbstractLauncherIcon::Ptr first, launcher::AbstractLauncherIcon::Ptr second);
00119 
00120   SwitcherModel::Ptr model_;
00121   SwitcherView::Ptr view_;
00122 
00123   nux::Geometry workarea_;
00124   nux::ObjectPtr<nux::BaseWindow> view_window_;
00125   nux::HLayout* main_layout_;
00126 
00127   int monitor_;
00128   bool visible_;
00129   nux::Color bg_color_;
00130   DetailMode detail_mode_;
00131 
00132   UBusManager ubus_manager_;
00133   glib::SourceManager sources_;
00134 };
00135 
00136 }
00137 }
00138 
00139 #endif // SWITCHERCONTROLLER_H
00140