X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgrid.h;h=01cfffaab4e95a96060141e3204e2b7c793eda31;hb=b59fab7e533ef96d72c92b224d4f24718bc6b0a1;hp=789672a774e15052283cacde8bad564777d72a1c;hpb=a84c813859b6908c511b12ab7d82d6643f4f1a42;p=libs%2Fgltk.git diff --git a/source/grid.h b/source/grid.h index 789672a..01cfffa 100644 --- a/source/grid.h +++ b/source/grid.h @@ -1,45 +1,50 @@ -/* $Id$ - -This file is part of libmspgltk -Copyright © 2011 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #ifndef MSP_GLTK_GRID_H_ #define MSP_GLTK_GRID_H_ -#include "layout.h" +#include +#include "arrangement.h" +#include "mspgltk_api.h" namespace Msp { namespace GLtk { -/** -Arranges widgets in a grid. +class MSPGLTK_API Grid: public Arrangement +{ +public: + class Loader: public DataFile::ObjectLoader + { + public: + Loader(Grid &); -This layout class places widgets in a grid, lining up their edges in rows and -columns. Widgets are placed on rows left-to-right and rows are placed top-to- -bottom. + private: + void next_row(); + void skip(); + }; -The start of each row must be indicated manually. Individual cells can be -skipped to leave them empty. -*/ -class Grid: public Layout -{ private: - bool uniform; - std::vector columns; - unsigned cur_column; - bool first; - bool skipped; + struct Column + { + Edge left; + Edge right; + }; + + std::vector columns; + Edge row_top; + Edge row_bottom; + bool first_row = true; + std::size_t column = 0; public: - Grid(bool = false); + Grid(Layout &, std::size_t); - void start_row(); - void skip_cell(); + void skip(); + void next_row(); private: - Slot *create_slot(Widget &); + void process_widget(Widget &, Side, bool) override; + void finish_widget(Widget &) override; + void finish_slot() override; + void finish_row(); }; } // namespace GLtk