Loading...
Searching...
No Matches
Align.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//
5// Created by Dave Smith on 11/13/22.
6//
7
8#ifndef MALENA_ALIGN_H
9#define MALENA_ALIGN_H
10
11#pragma once
12
14#include <SFML/Graphics.hpp>
15#include <cmath>
16#include <float.h>
17#include <queue>
18#include "../Utilities/Helper.h"
19#include "../Utilities/Tween.h"
20
21namespace ml
22{
59 {
60 public:
61 // ── Object overloads ─────────────────────────────────────────────────
62
69 template<class T>
70 static void centerText(const T& obj, sf::Text& text);
71
79 template<class T, class S>
80 static void setRightOf(const T& constObj, S& obj, float spacing = 0);
81
89 template<class T, class S>
90 static void setLeftOf(const T& constObj, S& obj, float spacing = 0);
91
99 template<class T, class S>
100 static void setBelow(const T& constObj, S& obj, float spacing = 0);
101
109 template<class T, class S>
110 static void setAbove(const T& constObj, S& obj, float spacing = 0);
111
116 template<class T, class S>
117 static void centerOn(const T& constObj, S& obj);
118
123 template<class T, class S>
124 static void centerVertically(const T& constObj, S& obj);
125
130 template<class T, class S>
131 static void centerHorizontally(const T& constObj, S& obj);
132
133 // ── FloatRect overloads ───────────────────────────────────────────────
134
136 template<class S>
137 static void setRightOf(const sf::FloatRect& bounds, S& obj, float spacing = 0);
138
140 template<class S>
141 static void setLeftOf(const sf::FloatRect& bounds, S& obj, float spacing = 0);
142
144 template<class S>
145 static void setBelow(const sf::FloatRect& bounds, S& obj, float spacing = 0);
146
148 template<class S>
149 static void setAbove(const sf::FloatRect& bounds, S& obj, float spacing = 0);
150
152 template<class S>
153 static void centerOn(const sf::FloatRect& bounds, S& obj);
154
156 template<class S>
157 static void centerVertically(const sf::FloatRect& bounds, S& obj);
158
160 template<class S>
161 static void centerHorizontally(const sf::FloatRect& bounds, S& obj);
162
163 // ── Vector2 overloads (size-based) ────────────────────────────────────
164
173 template<class S, class U>
174 static void setRightOf(const sf::Vector2<U>& size, S& obj, float spacing = 0);
175
177 template<class S, class U>
178 static void setLeftOf(const sf::Vector2<U>& size, S& obj, float spacing = 0);
179
181 template<class S, class U>
182 static void setBelow(const sf::Vector2<U>& size, S& obj, float spacing = 0);
183
185 template<class S, class U>
186 static void setAbove(const sf::Vector2<U>& size, S& obj, float spacing = 0);
187
189 template<class S, class U>
190 static void centerOn(const sf::Vector2<U>& size, S& obj);
191
193 template<class S, class U>
194 static void centerVertically(const sf::Vector2<U>& size, S& obj);
195
197 template<class S, class U>
198 static void centerHorizontally(const sf::Vector2<U>& size, S& obj);
199 };
200
201} // namespace ml
202
203#include "../../../src/Utilities/Align.tpp"
204#endif // MALENA_ALIGN_H
Static layout helpers for positioning objects relative to one another.
Definition Align.h:59
static void setRightOf(const T &constObj, S &obj, float spacing=0)
Place obj immediately to the right of constObj.
static void centerOn(const T &constObj, S &obj)
Center obj both horizontally and vertically within constObj.
static void setLeftOf(const sf::Vector2< U > &size, S &obj, float spacing=0)
Place obj to the left of a size-defined region.
static void setBelow(const sf::FloatRect &bounds, S &obj, float spacing=0)
Place obj below bounds.
static void centerVertically(const T &constObj, S &obj)
Center obj vertically within constObj (horizontal position unchanged).
static void setBelow(const T &constObj, S &obj, float spacing=0)
Place obj immediately below constObj.
static void setRightOf(const sf::FloatRect &bounds, S &obj, float spacing=0)
Place obj to the right of bounds.
static void setAbove(const sf::Vector2< U > &size, S &obj, float spacing=0)
Place obj above a size-defined region.
static void centerOn(const sf::Vector2< U > &size, S &obj)
Center obj within a size-defined region (both axes).
static void centerHorizontally(const sf::Vector2< U > &size, S &obj)
Center obj horizontally within a size-defined region.
static void setAbove(const sf::FloatRect &bounds, S &obj, float spacing=0)
Place obj above bounds.
static void setLeftOf(const sf::FloatRect &bounds, S &obj, float spacing=0)
Place obj to the left of bounds.
static void setAbove(const T &constObj, S &obj, float spacing=0)
Place obj immediately above constObj.
static void centerVertically(const sf::FloatRect &bounds, S &obj)
Center obj vertically within bounds.
static void setBelow(const sf::Vector2< U > &size, S &obj, float spacing=0)
Place obj below a size-defined region.
static void centerVertically(const sf::Vector2< U > &size, S &obj)
Center obj vertically within a size-defined region.
static void centerHorizontally(const sf::FloatRect &bounds, S &obj)
Center obj horizontally within bounds.
static void setRightOf(const sf::Vector2< U > &size, S &obj, float spacing=0)
Place obj to the right of a region defined by size.
static void setLeftOf(const T &constObj, S &obj, float spacing=0)
Place obj immediately to the left of constObj.
static void centerOn(const sf::FloatRect &bounds, S &obj)
Center obj within bounds (both axes).
static void centerHorizontally(const T &constObj, S &obj)
Center obj horizontally within constObj (vertical position unchanged).
static void centerText(const T &obj, sf::Text &text)
Center text within the bounds of obj.
#define MALENA_API
Definition Component.h:22
Rect< float > FloatRect