Back to index

nux  3.0.0
LayeredLayout.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef LAYERED_LAYOUT_H
00024 #define LAYERED_LAYOUT_H
00025 
00026 #include "Layout.h"
00027 
00028 namespace nux
00029 {
00031 
00041   class LayeredLayout: public Layout
00042   {
00043     NUX_DECLARE_OBJECT_TYPE(LayeredLayout, Layout);
00044   public:
00045     class LayeredChildProperties // : public LayeredLayout::LayoutProperties
00046     {
00047     public:
00048       LayeredChildProperties(bool expand, int x, int y, int width, int height);
00049       ~LayeredChildProperties();
00050       void Update(bool expand, int x, int y, int width, int height);
00051 
00052       bool m_expand;
00053       int  m_x;
00054       int  m_y;
00055       int  m_width;
00056       int  m_height;
00057       sigc::signal<void, Area *, bool>::iterator m_vis_it;
00058     };
00059 
00060     typedef enum
00061     {
00062       INPUT_MODE_ACTIVE = 0,
00063       INPUT_MODE_COMPOSITE
00064 
00065     } InputMode;
00066 
00067     LayeredLayout(NUX_FILE_LINE_PROTO);
00068     ~LayeredLayout();
00069 
00071 
00080     void AddLayer    (Area *area, bool expand=true, int x=0, int y=0, int width=0, int height=0);
00081 
00083 
00092     void UpdateLayer(Area *area, bool expand=true, int x=0, int y=0, int width=0, int height=0);
00093 
00095 
00099     void RemoveLayer(Area *area);
00100 
00102 
00106     void SetActiveLayerN(int index_);
00107 
00109 
00113     int GetActiveLayerN();
00114 
00116 
00120     void SetActiveLayer(Area *area);
00121 
00123 
00127     Area * GetActiveLayer  ();
00128 
00130 
00136     void SetPaintAll(bool paint_all);
00137 
00139 
00143     bool GetPaintAll();
00144 
00146 
00155     void SetInputMode(LayeredLayout::InputMode input_mode);
00156 
00158 
00163     void Raise(Area *area, Area *above);
00164 
00166 
00171     void Lower(Area *area, Area *below);
00172 
00174 
00178     void RaiseTop(Area *area);
00179 
00181 
00185     void LowerBottom(Area *area);
00186 
00188 
00192     LayeredLayout::InputMode GetInputMode();
00193 
00194 //     //! Set the layout properties for this area
00195 //     /*!
00196 //         Allows the Layout managing this area to store the properties specifc to this area. Layouts
00197 //         should create a sub-class of LayoutProperties. The LayoutProperties of an area will
00198 //         be deleted upon destruction.
00199 //         @param properties the LayoutProperties sub-class  associated with this area. Can be NULL to
00200 //          unset.
00201 //     */
00202 //     void SetLayoutProperties(LayoutProperties *properties);
00203 //
00204 //     //! Get the layout properties for this area
00205 //     /*!
00206 //         Retrieves the LayoutProperties sub-class with this area. See SetLayoutProperties
00207 //         @return LayoutProperties sub-class associated with this area.
00208 //     */
00209 //     LayoutProperties * GetLayoutProperties();
00210 
00211     void AddLayout(Layout                *layouy,
00212                     unsigned int           stretch_factor = 1,
00213                     MinorDimensionPosition position       = eAbove,
00214                     MinorDimensionSize     extend         = eFull,
00215                     float                  percentage     = 100.0f);
00216     void AddView(Area                  *view,
00217                   unsigned int           stretch_factor = 1,
00218                   MinorDimensionPosition positioning    = eAbove,
00219                   MinorDimensionSize     extend         = eFull,
00220                   float                  percentage     = 100.0f);
00221     void RemoveChildObject(Area *area);
00222     void Clear();
00223 
00224   protected:
00225     //
00226     // Overrides
00227     //
00228     long ComputeContentSize();
00229     void GetCompositeList(std::list<Area *> *ViewList);
00230 
00231     void ProcessDraw(GraphicsEngine &gfx_context, bool force_draw);
00232     Area* FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type);
00233 
00234     virtual Area* KeyNavIteration(KeyNavDirection direction);
00235     void OnLayerGeometryChanged(Area* area, Geometry geo);
00236 
00237   private:
00238     void PaintOne(Area *area, GraphicsEngine &graphics_engine, bool force_draw);
00239     void ChildQueueDraw(Area *area);
00240     void ChildVisibilityChanged(Area *area, bool visible);
00241 
00242   private:
00243     typedef std::map<Area*, std::shared_ptr<LayeredChildProperties> > AreaPropertyMap;
00244     AreaPropertyMap area_property_map_;
00245     int                       m_active_index;
00246     Area                      *m_active_area;
00247     bool                      m_paint_all;
00248     LayeredLayout::InputMode  m_input_mode;
00249     bool                      m_child_draw_queued;
00250   };
00251 }
00252 
00253 #endif // LAYERED_LAYOUT_H