Loading...
Searching...
No Matches
Grid.h
Go to the documentation of this file.
1#ifndef GRID_H
2#define GRID_H
3
4#pragma once
5
6#include <SFML/Graphics.hpp>
9
10namespace ml
11{
48 class Grid final : public CoreManager<Positionable>, public Core
49 {
50 float max_height = 0;
51 float max_width = 0;
52 float spacing = 10;
53 unsigned int row = 1;
54 unsigned int col = 1;
55
62 void reposition();
63
64 public:
69
76
81 [[nodiscard]] float getSpacing() const;
82
90 void setSpacing(float spacing);
91
96 [[nodiscard]] int getRow() const;
97
106 void setRow(int row);
107
119 void addComponent(Core& component);
120
129 void setPosition(const sf::Vector2f& position);
130
135 [[nodiscard]] sf::Vector2f getPosition() const;
136
145 [[nodiscard]] sf::FloatRect getGlobalBounds() const;
146 };
147
148} // namespace ml
149
150#endif // GRID_H
Virtual base class for all Malena framework objects.
Definition Core.h:67
Static, type-safe collection manager for Core-derived objects.
Definition CoreManager.h:53
void setRow(int row)
Set the number of columns per row.
sf::Vector2f getPosition() const
Return the current world-space origin of the grid.
void addComponent(Core &component)
Add a Core object to the grid and reposition all items.
Grid(sf::Vector2u size)
Construct a grid with a specified column and row count.
void setPosition(const sf::Vector2f &position)
Set the world-space origin of the grid.
float getSpacing() const
Return the current spacing between cells in pixels.
Grid()
Construct a single-row grid with default spacing.
int getRow() const
Return the current number of columns.
void setSpacing(float spacing)
Set the spacing between cells.
sf::FloatRect getGlobalBounds() const
Return the axis-aligned bounding box of the entire grid.
Definition Component.h:18
Rect< float > FloatRect
Vector2< unsigned int > Vector2u
Vector2< float > Vector2f