Simple GUI Library
tile_pane.h
Go to the documentation of this file.
1/**
2 * @author Nikita Mochalov (github.com/tralf-strues)
3 * @file tile_pane.h
4 * @date 2021-11-28
5 *
6 * @copyright Copyright (c) 2021
7 */
8
9#pragma once
10
11#include "container.h"
12
13namespace Sgl
14{
15 class TilePane : public Container
16 {
17 public:
18 TilePane(int32_t prefColumns = 1);
19 virtual ~TilePane() override = default;
20
21 int32_t getTiles() const;
22
23 int32_t getPrefColumns() const;
24 void setPrefColumns(int32_t columns);
25
26 int32_t getPrefTileWidth() const;
27 void setPrefTileWidth(int32_t width);
28
29 int32_t getPrefTileHeight() const;
30 void setPrefTileHeight(int32_t height);
31
32 int32_t getColumns() const;
33 int32_t getRows() const;
34 int32_t getTileWidth() const;
35 int32_t getTileHeight() const;
36
37 int32_t getHgap() const;
38 void setHgap(int32_t gap);
39
40 int32_t getVgap() const;
41 void setVgap(int32_t gap);
42
43 private:
44 int32_t m_PrefColumns = 0;
45
46 int32_t m_PrefTileWidth = USE_COMPUTED_SIZE;
47 int32_t m_PrefTileHeight = USE_COMPUTED_SIZE;
48
49 int32_t m_Columns = 0;
50 int32_t m_Rows = 0;
51 int32_t m_TileWidth = 0;
52 int32_t m_TileHeight = 0;
53
54 int32_t m_Hgap = 0;
55 int32_t m_Vgap = 0;
56
57 private:
58 virtual void layoutChildren() override;
59
60 virtual int32_t computeCustomPrefWidth(int32_t height = -1) const override;
61 virtual int32_t computeCustomPrefHeight(int32_t width = -1) const override;
62
63 virtual int32_t computeCustomMinWidth(int32_t height = -1) const override;
64 virtual int32_t computeCustomMinHeight(int32_t width = -1) const override;
65
66 private:
67 int32_t computeTileWidth() const;
68 int32_t computeTileHeight() const;
69 int32_t computeColumns(int32_t width) const;
70 int32_t computeRows() const;
71 };
72}