Back to index

unity  6.0.0
SwitcherView.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 SWITCHERVIEW_H
00021 #define SWITCHERVIEW_H
00022 
00023 #include "SwitcherModel.h"
00024 #include "unity-shared/AbstractIconRenderer.h"
00025 #include "unity-shared/StaticCairoText.h"
00026 #include "LayoutSystem.h"
00027 #include "unity-shared/BackgroundEffectHelper.h"
00028 #include "unity-shared/UnityWindowView.h"
00029 
00030 #include <Nux/View.h>
00031 #include <NuxCore/Property.h>
00032 
00033 #include <UnityCore/GLibSource.h>
00034 
00035 
00036 namespace unity
00037 {
00038 namespace launcher
00039 {
00040 class AbstractLauncherIcon;
00041 }
00042 namespace switcher
00043 {
00044 
00045 class SwitcherView : public ui::UnityWindowView
00046 {
00047   NUX_DECLARE_OBJECT_TYPE(SwitcherView, ui::UnityWindowView);
00048 public:
00049   typedef nux::ObjectPtr<SwitcherView> Ptr;
00050 
00051   SwitcherView();
00052 
00053   ui::LayoutWindowList ExternalTargets ();
00054 
00055   void SetModel(SwitcherModel::Ptr model);
00056   SwitcherModel::Ptr GetModel();
00057 
00058   nux::Property<bool> render_boxes;
00059   nux::Property<int> border_size;
00060   nux::Property<int> flat_spacing;
00061   nux::Property<int> icon_size;
00062   nux::Property<int> minimum_spacing;
00063   nux::Property<int> tile_size;
00064   nux::Property<int> vertical_size;
00065   nux::Property<int> text_size;
00066   nux::Property<int> animation_length;
00067   nux::Property<int> monitor;
00068   nux::Property<double> spread_size;
00069 
00070 protected:
00071   // Introspectable methods
00072   std::string GetName() const;
00073   void AddProperties(GVariantBuilder* builder);
00074 
00075   void PreDraw(nux::GraphicsEngine& GfxContext, bool force_draw);
00076   void DrawOverlay(nux::GraphicsEngine& GfxContext, bool force_draw, nux::Geometry clip);
00077   nux::Geometry GetBackgroundGeometry();
00078 
00079   ui::RenderArg InterpolateRenderArgs(ui::RenderArg const& start, ui::RenderArg const& end, float progress);
00080   nux::Geometry InterpolateBackground (nux::Geometry const& start, nux::Geometry const& end, float progress);
00081 
00082   std::list<ui::RenderArg> RenderArgsFlat(nux::Geometry& background_geo, int selection, timespec const& current);
00083 
00084   ui::RenderArg CreateBaseArgForIcon(launcher::AbstractLauncherIcon::Ptr icon);
00085 private:
00086   void OnSelectionChanged(launcher::AbstractLauncherIcon::Ptr selection);
00087   void OnDetailSelectionChanged (bool detail);
00088   void OnDetailSelectionIndexChanged (unsigned int index);
00089 
00090   void OnIconSizeChanged (int size);
00091   void OnTileSizeChanged (int size);
00092 
00093   nux::Geometry UpdateRenderTargets (nux::Point const& center, timespec const& current);
00094   void OffsetRenderTargets (int x, int y);
00095 
00096   nux::Size SpreadSize ();
00097 
00098   void GetFlatIconPositions (int n_flat_icons, 
00099                              int size, 
00100                              int selection, 
00101                              int &first_flat, 
00102                              int &last_flat, 
00103                              int &half_fold_left, 
00104                              int &half_fold_right);
00105 
00106   void SaveLast ();
00107 
00108   ui::LayoutSystem::Ptr layout_system_;
00109   ui::AbstractIconRenderer::Ptr icon_renderer_;
00110   SwitcherModel::Ptr model_;
00111   bool target_sizes_set_;
00112 
00113   nux::ObjectPtr<nux::BaseTexture> rounding_texture_;
00114   nux::ObjectPtr<nux::StaticCairoText> text_view_;
00115 
00116   std::list<ui::RenderArg> last_args_;
00117   std::list<ui::RenderArg> saved_args_;
00118 
00119   nux::Geometry last_background_;
00120   nux::Geometry saved_background_;
00121 
00122   ui::LayoutWindowList render_targets_;
00123 
00124   timespec current_;
00125   timespec save_time_;
00126 
00127   bool animation_draw_;
00128 
00129   glib::Source::UniquePtr redraw_idle_;
00130 };
00131 
00132 }
00133 }
00134 
00135 #endif // SWITCHERVIEW_H
00136