]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/grid.h
Use the override specifier when overriding a virtual function
[libs/gltk.git] / source / grid.h
index 519151eace3be77a90be986c92b5026bf7c8862d..4ed43d56442f59d0b475ba7b3cf6fd097b676225 100644 (file)
@@ -1,38 +1,49 @@
 #ifndef MSP_GLTK_GRID_H_
 #define MSP_GLTK_GRID_H_
 
-#include "layout.h"
+#include <msp/datafile/objectloader.h>
+#include "arrangement.h"
+#include "mspgltk_api.h"
 
 namespace Msp {
 namespace GLtk {
 
-/**
-Arranges widgets in a 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.
-
-The start of each row must be indicated manually.  Individual cells can be
-skipped to leave them empty.
-*/
-class Grid: public Layout
+class MSPGLTK_API Grid: public Arrangement
 {
+public:
+       class Loader: public DataFile::ObjectLoader<Grid>
+       {
+       public:
+               Loader(Grid &);
+       private:
+               void next_row();
+               void skip();
+       };
+
 private:
-       bool uniform;
-       std::vector<Slot *> columns;
-       unsigned cur_column;
-       bool first;
-       bool skipped;
+       struct Column
+       {
+               Edge left;
+               Edge right;
+       };
+
+       std::vector<Column> columns;
+       Edge row_top;
+       Edge row_bottom;
+       bool first_row = true;
+       unsigned column = 0;
 
 public:
-       Grid(bool = false);
+       Grid(Layout &, unsigned);
 
-       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