Back to index

unity  6.0.0
LayoutSystem.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 UNITYSHELL_LAYOUTSYSTEM_H
00021 #define UNITYSHELL_LAYOUTSYSTEM_H
00022 
00023 #include <boost/shared_ptr.hpp>
00024 #include <sigc++/sigc++.h>
00025 
00026 #include <X11/Xlib.h>
00027 
00028 #include <Nux/Nux.h>
00029 
00030 namespace unity {
00031 namespace ui {
00032 
00033 class LayoutWindow
00034 {
00035 public:
00036   typedef boost::shared_ptr<LayoutWindow> Ptr;
00037 
00038   LayoutWindow (Window xid);
00039   
00040   Window xid;
00041 
00042   nux::Geometry geo;
00043   nux::Geometry result;
00044 
00045   float aspect_ratio;
00046   float alpha;
00047 };
00048 
00049 typedef std::vector<LayoutWindow::Ptr> LayoutWindowList;
00050 
00051 class LayoutSystem
00052 {
00053 public:
00054   typedef boost::shared_ptr<LayoutSystem> Ptr;
00055 
00056   nux::Property<int> spacing;
00057   nux::Property<int> max_row_height;
00058 
00059   LayoutSystem ();
00060   ~LayoutSystem ();
00061 
00062   void LayoutWindows (LayoutWindowList windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds);
00063 
00064 protected:
00065   void LayoutGridWindows (LayoutWindowList const& windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds);
00066 
00067   nux::Geometry LayoutRow (LayoutWindowList const& row, nux::Geometry const& row_bounds);
00068   nux::Geometry CompressAndPadRow (LayoutWindowList const& windows, nux::Geometry const& max_bounds);
00069 
00070   std::vector<LayoutWindowList> GetRows (LayoutWindowList const& windows, nux::Geometry const& max_bounds);
00071 
00072   nux::Size GridSizeForWindows (LayoutWindowList windows, nux::Geometry const& max_bounds);
00073 
00074   nux::Geometry ScaleBoxIntoBox (nux::Geometry const& bounds, nux::Geometry const& box);
00075 };
00076 
00077 }
00078 }
00079 
00080 #endif // UNITYSHELL_LAYOUTSYSTEM_H