Back to index

unity  6.0.0
HudView.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: Gordon Allott <gord.allott@canonical.com>
00017  */
00018 
00019 #ifndef UNITYSHELL_HUD_VIEW_H
00020 #define UNITYSHELL_HUD_VIEW_H
00021 
00022 #include <string>
00023 
00024 #include <Nux/Nux.h>
00025 #include <Nux/VLayout.h>
00026 #include <UnityCore/GLibSource.h>
00027 
00028 #include "HudIcon.h"
00029 #include "HudButton.h"
00030 #include "HudAbstractView.h"
00031 #include "unity-shared/SearchBar.h"
00032 #include "unity-shared/OverlayRenderer.h"
00033 #include "unity-shared/UBusWrapper.h"
00034 
00035 namespace unity
00036 {
00037 namespace hud
00038 {
00039 
00040 class View : public AbstractView
00041 {
00042   NUX_DECLARE_OBJECT_TYPE(View, AbstractView);
00043 public:
00044   typedef nux::ObjectPtr<View> Ptr;
00045 
00046   View();
00047   ~View();
00048 
00049   void ResetToDefault();
00050 
00051   void Relayout();
00052   nux::View* default_focus() const;
00053   std::list<HudButton::Ptr> const& buttons() const;
00054 
00055   void SetQueries(Hud::Queries queries);
00056   void SetIcon(std::string const& icon_name, unsigned int tile_size, unsigned int size, unsigned int padding);
00057   void ShowEmbeddedIcon(bool show);
00058   void SearchFinished();
00059 
00060   void AboutToShow();
00061   void AboutToHide();
00062 
00063   void SetWindowGeometry(nux::Geometry const& absolute_geo, nux::Geometry const& geo);
00064 
00065 protected:
00066   virtual Area* FindKeyFocusArea(unsigned int event_type,
00067   unsigned long x11_key_code,
00068   unsigned long special_keys_state);
00069 
00070   void SetupViews();
00071   void OnSearchChanged(std::string const& search_string);
00072   virtual long PostLayoutManagement(long LayoutResult);
00073 
00074 private:
00075   void OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key);
00076   void OnKeyDown (unsigned long event_type, unsigned long event_keysym,
00077                                 unsigned long event_state, const TCHAR* character,
00078                                 unsigned short key_repeat_count);
00079   void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);
00080   void DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw);
00081   bool InspectKeyEvent(unsigned int eventType, unsigned int key_sym, const char* character);
00082   void OnSearchbarActivated();
00083   bool AcceptKeyNavFocus();
00084   nux::Geometry GetBestFitGeometry(nux::Geometry const& for_geo);
00085 
00086   void ProcessGrowShrink();
00087 
00088   std::string GetName() const;
00089   void AddProperties(GVariantBuilder* builder);
00090   IntrospectableList GetIntrospectableChildren();
00091 
00092 private:
00093   UBusManager ubus;
00094   nux::ObjectPtr<nux::Layout> layout_;
00095   nux::ObjectPtr<nux::Layout> content_layout_;
00096   nux::ObjectPtr<nux::VLayout> button_views_;
00097   std::list<HudButton::Ptr> buttons_;
00098   IntrospectableList introspectable_children_;
00099 
00100   //FIXME - replace with dash search bar once modifications to dash search bar land
00101   SearchBar::Ptr search_bar_;
00102   Icon::Ptr icon_;
00103   bool visible_;
00104 
00105   Hud::Queries queries_;
00106   nux::Geometry content_geo_;
00107   OverlayRenderer renderer_;
00108   nux::Geometry window_geometry_;
00109   nux::Geometry absolute_window_geometry_;
00110   glib::Source::UniquePtr timeline_idle_;
00111 
00112   guint64 start_time_;
00113   int last_known_height_;
00114   int current_height_;
00115   bool timeline_need_more_draw_;
00116   int selected_button_;
00117   bool show_embedded_icon_;
00118   bool activated_signal_sent_;
00119 };
00120 
00121 
00122 } // namespace hud
00123 } // namespace unity
00124 
00125 #endif // UNITYSHELL_HUD_VIEW_H