Back to index

unity  6.0.0
AbstractIconRenderer.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 ABSTRACTICONRENDERER_H
00021 #define ABSTRACTICONRENDERER_H
00022 
00023 #include <Nux/Nux.h>
00024 #include <boost/shared_ptr.hpp>
00025 
00026 #include "IconTextureSource.h"
00027 
00028 namespace unity
00029 {
00030 namespace ui
00031 {
00032 
00033 enum PipRenderStyle 
00034 {
00035   OUTSIDE_TILE,
00036   OVER_TILE,
00037 };
00038 
00039 class RenderArg
00040 {
00041 public:
00042   RenderArg()
00043     : icon(0)
00044     , colorify(nux::color::White)
00045     , x_rotation(0)
00046     , y_rotation(0)
00047     , z_rotation(0)
00048     , alpha(1.0f)
00049     , saturation(1.0f)
00050     , backlight_intensity(0.0f)
00051     , glow_intensity(0.0f)
00052     , shimmer_progress(0.0f)
00053     , progress(0.0f)
00054     , progress_bias(-1.0f)
00055     , running_arrow(false)
00056     , running_colored(false)
00057     , running_on_viewport(false)
00058     , draw_edge_only(false)
00059     , active_arrow(false)
00060     , active_colored(false)
00061     , skip(false)
00062     , stick_thingy(false)
00063     , keyboard_nav_hl(false)
00064     , draw_shortcut(false)
00065     , system_item(false)
00066     , colorify_background(false)
00067     , window_indicators(0)
00068     , shortcut_label(0)
00069   {
00070   }
00071 
00072   IconTextureSource* icon;
00073   nux::Point3   render_center;
00074   nux::Point3   logical_center;
00075   nux::Color    colorify;
00076   float         x_rotation;
00077   float         y_rotation;
00078   float         z_rotation;
00079   float         alpha;
00080   float         saturation;
00081   float         backlight_intensity;
00082   float         glow_intensity;
00083   float         shimmer_progress;
00084   float         progress;
00085   float         progress_bias;
00086   bool          running_arrow;
00087   bool          running_colored;
00088   bool          running_on_viewport;
00089   bool          draw_edge_only;
00090   bool          active_arrow;
00091   bool          active_colored;
00092   bool          skip;
00093   bool          stick_thingy;
00094   bool          keyboard_nav_hl;
00095   bool          draw_shortcut;
00096   bool          system_item;
00097   bool          colorify_background;
00098   int           window_indicators;
00099   char          shortcut_label;
00100 };
00101 
00102 class AbstractIconRenderer
00103 {
00104 public:
00105   typedef boost::shared_ptr<AbstractIconRenderer> Ptr;
00106 
00107   virtual ~AbstractIconRenderer() {}
00108 
00109   nux::Property<PipRenderStyle> pip_style;
00110   nux::Property<int> monitor;
00111 
00112   // RenderArgs not const in case processor needs to modify positions to do a perspective correct.
00113   virtual void PreprocessIcons(std::list<RenderArg>& args, nux::Geometry const& target_window) = 0;
00114 
00115   virtual void RenderIcon(nux::GraphicsEngine& GfxContext, RenderArg const& arg, nux::Geometry const& anchor_geo, nux::Geometry const& owner_geo) = 0;
00116 
00117   virtual void SetTargetSize(int tile_size, int image_size, int spacing) = 0;
00118 };
00119 
00120 }
00121 }
00122 
00123 #endif // ABSTRACTICONRENDERER_H
00124