Loading...
Searching...
No Matches
Grid.h
Go to the documentation of this file.
1// Copyright (c) 2025 Dave R. Smith. All rights reserved.
2// Malena Framework — Proprietary Software. See LICENSE for terms.
3
4#ifndef MALENA_GRID_H
5#define MALENA_GRID_H
6
7#pragma once
8
10#include <SFML/Graphics.hpp>
11#include <Malena/Core/Core.h>
13#include <vector>
14
15namespace ml
16{
47 class MALENA_API Grid final : public Core
48 {
49 std::vector<Positionable*> _items;
50
51 float max_height = 0;
52 float max_width = 0;
53 float spacing = 10;
54 unsigned int row = 1;
55 unsigned int col = 1;
56
63 void reposition();
64
65 public:
70
77
82 [[nodiscard]] float getSpacing() const;
83
91 void setSpacing(float spacing);
92
97 [[nodiscard]] int getRow() const;
98
107 void setRow(int row);
108
117 void addItem(Core& item);
118
126 void setPosition(const sf::Vector2f& position) override;
127
132 [[nodiscard]] sf::Vector2f getPosition() const override;
133
138 [[nodiscard]] sf::FloatRect getGlobalBounds() const override;
139 };
140
141} // namespace ml
142
143#endif // MALENA_GRID_H
Virtual base class for all Malena framework objects.
Definition Core.h:69
void setRow(int row)
Set the number of columns per row.
void setPosition(const sf::Vector2f &position) override
Set the world-space origin of the grid.
Grid(sf::Vector2u size)
Construct a grid with a specified column and row count.
float getSpacing() const
Return the current spacing between cells in pixels.
void addItem(Core &item)
Add a Core object to the grid layout and reposition all items.
sf::Vector2f getPosition() const override
Return the current world-space origin of the grid.
sf::FloatRect getGlobalBounds() const override
Return the axis-aligned bounding box of the entire grid.
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.
#define MALENA_API
Definition Component.h:22
Rect< float > FloatRect
Vector2< unsigned int > Vector2u
Vector2< float > Vector2f