diff options
author | rtk0c <[email protected]> | 2021-05-16 20:56:04 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2021-05-16 21:15:43 -0700 |
commit | dc13110c14bf49e495d4b4243fd4758232f8716f (patch) | |
tree | 8b5f6bbefab78c4956951e40cf18d6f3a3f604d6 /core/src/Model/Template/TableTemplate.hpp | |
parent | 203d65e8873f2f1d240b22899ac89855b64974c8 (diff) |
TableTemplate draft
Diffstat (limited to 'core/src/Model/Template/TableTemplate.hpp')
-rw-r--r-- | core/src/Model/Template/TableTemplate.hpp | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/core/src/Model/Template/TableTemplate.hpp b/core/src/Model/Template/TableTemplate.hpp new file mode 100644 index 0000000..d704b1f --- /dev/null +++ b/core/src/Model/Template/TableTemplate.hpp @@ -0,0 +1,89 @@ +#pragma once + +#include "Utils/Vector.hpp" +#include "Utils/VectorHash.hpp" + +#include <string> +#include <vector> + +class TableCell +{ +public: + enum TextAlignment + { + /// For horizontal alignment, this means align left. For vertical alignment, this means align top. + AlignAxisMin, + /// Align middle of the text to the middle of the axis. + AlignCenter, + /// For horizontal alignment, this means align right. For vertical alignment, this means align bottom. + AlignAxisMax, + }; + + enum CellType + { + ConstantCell, + ParametricCell, + }; + +public: + std::string Content; + Vec2i Location; + /// Location of the primary (top left) cell, if this cell is a part of a merged group. + /// Otherwise, either component of this field shall be -1. + Vec2i PrimaryCellLocation; + int SpanX; + int SpanY; + TextAlignment HorizontalAlignment = AlignAxisMin; + TextAlignment VerticalAlignment = AlignAxisMin; + CellType Type; + +public: + bool IsPrimaryCell() const; + bool IsMergedCell() const; +}; + +class TableArrayParameterGroup +{ +public: + enum ExpansionDirection + { + ExpandUp, + ExpandDown, + ExpandLeft, + ExpandRight, + }; + +public: + ExpansionDirection ExpandDirection; +}; + +class TableTemplate +{ +private: + std::vector<TableCell> mCells; + std::vector<TableArrayParameterGroup> mArrayGroups; + int mTableWidth; + int mTableHeight; + +public: + int GetTableWidth() const; + int GetTableHeight() const; + void Resize(int newWidth, int newHeight); + + const TableCell& GetCell(Vec2i pos) const; + TableCell& GetCell(Vec2i pos); + + enum MergeCellsResult + { + MCR_CellAlreadyMerged, + MCR_Success, + }; + MergeCellsResult MergeCells(Vec2i topLeft, Vec2i bottomRight); + + enum BreakCellsResult + { + BCR_CellNotMerged, + BCR_Success, + }; + BreakCellsResult BreakCells(Vec2i topLeft); +}; |