// -*- C++ -*-
#ifndef _LayoutTree_h_
#define _LayoutTree_h_

#include <GG/PtRect.h>

#include <boost/tuple/tuple.hpp>

#include <set>

namespace GG {
    class Layout;
    class Wnd;
}

class LayoutTree
{
public:
    LayoutTree();

    boost::tuple<GG::Layout*, int, int> Cell(const GG::Pt& pt) const;

    void Reset(const GG::Wnd* wnd, const std::set<GG::Wnd*>& children);

private:
    struct Node
    {
        Node();
        Node(const GG::Rect& rect, const GG::Pt& offset);
        Node(GG::Layout* layout, const GG::Pt& offset);
        GG::Layout*                     m_layout;
        GG::Rect                        m_bounds_rect;
        std::vector<std::vector<Node> > m_cells;
    };

    boost::tuple<GG::Layout*, int, int> Cell(const Node& node, const GG::Pt& pt) const;

    std::vector<Node> m_root_nodes;
};

#endif // _LayoutTree_h_
