Back to index

unity  6.0.0
OverlayRenderer.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: Gordon Allott <gord.allott@canonical.com>
00018  */
00019 
00020 
00021 #ifndef OVERLAYRENDERER_H
00022 #define OVERLAYRENDERER_H
00023 
00024 #include <memory>
00025 
00026 #include <Nux/Nux.h>
00027 #include <Nux/View.h>
00028 
00029 namespace unity 
00030 {
00031 
00032 class OverlayRendererImpl;
00033 class OverlayRenderer
00034 {
00035 public:
00036   // We only ever want one OverlayRenderer per view, so if you must take a pointer, take this unique one that will die 
00037   // when it goes out of scope
00038   typedef std::unique_ptr<OverlayRenderer> Ptr;
00039 
00040   nux::Property<int> x_offset;
00041   nux::Property<int> y_offset;
00042   
00043   OverlayRenderer();
00044   ~OverlayRenderer();
00045   
00046   /*
00047    * Call when we are about to show, gets the blur ready for rendering
00048    */
00049   void AboutToShow();
00050   
00051   /*
00052    * Call when the interface is hiding, saves on resources
00053    */
00054   void AboutToHide();
00055   
00056   /*
00057    * Disables the blur, if you need it disabled. can not re-enable it.
00058    */
00059   void DisableBlur();
00060   
00061   /*
00062    * Needed internally, should be called with yourself as the owner as soon as possible
00063    */
00064   void SetOwner(nux::View *owner);
00065   
00066   /*
00067    * Draws the entire stack of visuals using direct rendering, use in the Draw() call, not DrawContent()
00068    * 
00069    * content_geo: the geometry of the content we are renderering, should be smaller than geo
00070    * absolute_geo: your views GetAbsoluteGeometry()
00071    * geo: your views GetGeometry()
00072    */
00073   void DrawFull(nux::GraphicsEngine& gfx_context, nux::Geometry content_geo, nux::Geometry absolute_geo, nux::Geometry geo, bool force_edges=false);
00074   
00075   /*
00076    * Draws just the stack that is overlay behind the inner_geometry using push/pop layers, call in DrawContent() before drawing your content
00077    */
00078   void DrawInner(nux::GraphicsEngine& gfx_context, nux::Geometry content_geo, nux::Geometry absolute_geo, nux::Geometry geo);
00079   
00080   /* 
00081    * Call after calling DrawInner and drawing your own content
00082    */
00083   void DrawInnerCleanup(nux::GraphicsEngine& gfx_context, nux::Geometry content_geo, nux::Geometry absolute_geo, nux::Geometry geo);
00084   
00085   sigc::signal<void> need_redraw;
00086 
00087 private:
00088   OverlayRendererImpl *pimpl_;
00089 
00090 };
00091 
00092 }
00093 #endif // OVERLAYRENDERER_H