Back to index

unity  6.0.0
DashView.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2010 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: Neil Jagdish Patel <neil.patel@canonical.com>
00017  */
00018 
00019 #ifndef UNITY_DASH_VIEW_H_
00020 #define UNITY_DASH_VIEW_H_
00021 
00022 #include <Nux/Nux.h>
00023 #include <Nux/PaintLayer.h>
00024 #include <Nux/View.h>
00025 #include <Nux/VLayout.h>
00026 #include <UnityCore/FilesystemLenses.h>
00027 #include <UnityCore/HomeLens.h>
00028 #include <UnityCore/GLibSource.h>
00029 
00030 #include "unity-shared/BackgroundEffectHelper.h"
00031 #include "unity-shared/SearchBar.h"
00032 #include "unity-shared/Introspectable.h"
00033 #include "LensBar.h"
00034 #include "LensView.h"
00035 #include "unity-shared/UBusWrapper.h"
00036 #include "unity-shared/OverlayRenderer.h"
00037 
00038 namespace unity
00039 {
00040 namespace dash
00041 {
00042 
00043 class DashLayout;
00044 
00045 class DashView : public nux::View, public unity::debug::Introspectable
00046 {
00047   NUX_DECLARE_OBJECT_TYPE(DashView, nux::View);
00048   typedef std::map<std::string, LensView*> LensViews;
00049 
00050 public:
00051   DashView();
00052   ~DashView();
00053 
00054   void AboutToShow();
00055   void AboutToHide();
00056   void Relayout();
00057   void DisableBlur();
00058   void OnActivateRequest(GVariant* args);
00059   void SetMonitorOffset(int x, int y);
00060 
00061   std::string const GetIdForShortcutActivation(std::string const& shortcut) const;
00062   std::vector<char> GetAllShortcuts();
00063 
00064   nux::View* default_focus() const;
00065 
00066 protected:
00067   void ProcessDndEnter();
00068 
00069   virtual Area* FindKeyFocusArea(unsigned int key_symbol,
00070     unsigned long x11_key_code,
00071     unsigned long special_keys_state);
00072 
00073 private:
00074   void SetupViews();
00075   void SetupUBusConnections();
00076 
00077   nux::Geometry GetBestFitGeometry(nux::Geometry const& for_geo);
00078 
00079   void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);
00080   void DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw);
00081   virtual long PostLayoutManagement (long LayoutResult);
00082 
00083   void OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key);
00084   void OnBackgroundColorChanged(GVariant* args);
00085   void OnSearchChanged(std::string const& search_string);
00086   void OnLiveSearchReached(std::string const& search_string);
00087   void OnLensAdded(Lens::Ptr& lens);
00088   void OnLensBarActivated(std::string const& id);
00089   void OnSearchFinished(Lens::Hints const& hints);
00090   void OnGlobalSearchFinished(Lens::Hints const& hints);
00091   void OnAppsGlobalSearchFinished(Lens::Hints const& hints);
00092   void OnUriActivated(std::string const& uri);
00093   void OnUriActivatedReply(std::string const& uri, HandledType type, Lens::Hints const&);
00094   bool DoFallbackActivation(std::string const& uri);
00095   bool LaunchApp(std::string const& appname);
00096   void OnEntryActivated();
00097   std::string AnalyseLensURI(std::string const& uri);
00098   void UpdateLensFilter(std::string lens, std::string filter, std::string value);
00099   void UpdateLensFilterValue(Filter::Ptr filter, std::string value);
00100   void EnsureLensesInitialized();
00101 
00102   bool AcceptKeyNavFocus();
00103   bool InspectKeyEvent(unsigned int eventType, unsigned int key_sym, const char* character);
00104   std::string GetName() const;
00105   void AddProperties(GVariantBuilder* builder);
00106 
00107   nux::Area* KeyNavIteration(nux::KeyNavDirection direction);
00108 
00109 private:
00110   UBusManager ubus_manager_;
00111   FilesystemLenses lenses_;
00112   HomeLens::Ptr home_lens_;
00113   LensViews lens_views_;
00114 
00115 
00116   // View related
00117   nux::VLayout* layout_;
00118   DashLayout* content_layout_;
00119   nux::HLayout* search_bar_layout_;
00120   SearchBar* search_bar_;
00121   nux::VLayout* lenses_layout_;
00122   LensBar* lens_bar_;
00123 
00124   LensView* home_view_;
00125   LensView* active_lens_view_;
00126 
00127   // Drawing related
00128   nux::Geometry content_geo_;
00129   OverlayRenderer renderer_;
00130 
00131   std::string last_activated_uri_;
00132   // we're passing this back to g_* functions, so we'll keep the g* type
00133   bool search_in_progress_;
00134   bool activate_on_finish_;
00135 
00136   bool visible_;
00137 
00138   glib::Source::UniquePtr searching_timeout_;
00139   glib::Source::UniquePtr hide_message_delay_;
00140 };
00141 
00142 
00143 }
00144 }
00145 #endif