Back to index

unity  6.0.0
LensView.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2010, 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: Neil Jagdish Patel <neil.patel@canonical.com>
00018  */
00019 
00020 #ifndef UNITY_LENS_VIEW_H_
00021 #define UNITY_LENS_VIEW_H_
00022 
00023 #include <string>
00024 
00025 #include <NuxGraphics/GraphicsEngine.h>
00026 #include <Nux/Nux.h>
00027 #include <Nux/HLayout.h>
00028 #include <Nux/View.h>
00029 #include <Nux/VLayout.h>
00030 #include <UnityCore/Lens.h>
00031 #include <UnityCore/GLibSource.h>
00032 
00033 #include "FilterBar.h"
00034 #include "unity-shared/Introspectable.h"
00035 #include "PlacesGroup.h"
00036 #include "PlacesVScrollBar.h"
00037 #include "ResultViewGrid.h"
00038 #include "unity-shared/UBusWrapper.h"
00039 
00040 namespace unity
00041 {
00042 namespace dash
00043 {
00044 class LensScrollView;
00045 
00046 class LensView : public nux::View, public unity::debug::Introspectable
00047 {
00048   NUX_DECLARE_OBJECT_TYPE(LensView, nux::View);
00049   typedef std::vector<PlacesGroup*> CategoryGroups;
00050   typedef std::map<PlacesGroup*, unsigned int> ResultCounts;
00051 
00052 public:
00053   LensView();
00054   LensView(Lens::Ptr lens, nux::Area* show_filters);
00055 
00056   CategoryGroups& categories() { return categories_; }
00057   FilterBar* filter_bar() const { return filter_bar_; }
00058   Lens::Ptr lens() const;
00059   nux::Area* fscroll_view() const;
00060 
00061   int GetNumRows();
00062   void JumpToTop();
00063 
00064   virtual void ActivateFirst();
00065 
00066   nux::ROProperty<std::string> search_string;
00067   nux::Property<bool> filters_expanded;
00068   nux::Property<ViewType> view_type;
00069   nux::Property<bool> can_refine_search;
00070 
00071   sigc::signal<void, std::string const&> uri_activated;
00072 
00073   void PerformSearch(std::string const& search_query);
00074   void CheckNoResults(Lens::Hints const& hints);
00075   void HideResultsMessage();
00076 
00077 private:
00078   void SetupViews(nux::Area* show_filters);
00079   void SetupCategories();
00080   void SetupResults();
00081   void SetupFilters();
00082 
00083   void OnCategoryAdded(Category const& category);
00084   void OnResultAdded(Result const& result);
00085   void OnResultRemoved(Result const& result);
00086   void UpdateCounts(PlacesGroup* group);
00087   void OnGroupExpanded(PlacesGroup* group);
00088   void OnColumnsChanged();
00089   void OnFilterAdded(Filter::Ptr filter);
00090   void OnFilterRemoved(Filter::Ptr filter);
00091   void OnViewTypeChanged(ViewType view_type);
00092   void QueueFixRenderering();
00093   bool FixRenderering();
00094 
00095   virtual void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);
00096   virtual void DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw);
00097 
00098   virtual bool AcceptKeyNavFocus();
00099   virtual std::string GetName() const;
00100   virtual void AddProperties(GVariantBuilder* builder);
00101 
00102   std::string get_search_string() const;
00103 
00104 private:
00105   Lens::Ptr lens_;
00106   CategoryGroups categories_;
00107   ResultCounts counts_;
00108   bool initial_activation_;
00109   bool no_results_active_;
00110   std::string search_string_;
00111 
00112   nux::HLayout* layout_;
00113   LensScrollView* scroll_view_;
00114   nux::VLayout* scroll_layout_;
00115   LensScrollView* fscroll_view_;
00116   nux::VLayout* fscroll_layout_;
00117   FilterBar* filter_bar_;
00118   nux::StaticCairoText* no_results_;
00119 
00120   UBusManager ubus_manager_;
00121   glib::Source::UniquePtr fix_rendering_idle_;
00122 };
00123 
00124 
00125 }
00126 }
00127 #endif