Loading...
Searching...
No Matches
Align.h
Go to the documentation of this file.
1//
2// Created by Dave Smith on 11/13/22.
3//
4
5#ifndef ALIGN_H
6#define ALIGN_H
7
8#pragma once
9
10#include <SFML/Graphics.hpp>
11#include <cmath>
12#include <float.h>
13#include <queue>
14#include "../Utilities/Helper.h"
15#include "../Utilities/Tween.h"
16
17namespace ml
18{
54 class Align
55 {
56 public:
57 // ── Object overloads ─────────────────────────────────────────────────
58
65 template<class T>
66 static void centerText(const T& obj, sf::Text& text);
67
75 template<class T, class S>
76 static void setRightOf(const T& constObj, S& obj, float spacing = 0);
77
85 template<class T, class S>
86 static void setLeftOf(const T& constObj, S& obj, float spacing = 0);
87
95 template<class T, class S>
96 static void setBelow(const T& constObj, S& obj, float spacing = 0);
97
105 template<class T, class S>
106 static void setAbove(const T& constObj, S& obj, float spacing = 0);
107
112 template<class T, class S>
113 static void centerOn(const T& constObj, S& obj);
114
119 template<class T, class S>
120 static void centerVertically(const T& constObj, S& obj);
121
126 template<class T, class S>
127 static void centerHorizontally(const T& constObj, S& obj);
128
129 // ── FloatRect overloads ───────────────────────────────────────────────
130
132 template<class S>
133 static void setRightOf(const sf::FloatRect& bounds, S& obj, float spacing = 0);
134
136 template<class S>
137 static void setLeftOf(const sf::FloatRect& bounds, S& obj, float spacing = 0);
138
140 template<class S>
141 static void setBelow(const sf::FloatRect& bounds, S& obj, float spacing = 0);
142
144 template<class S>
145 static void setAbove(const sf::FloatRect& bounds, S& obj, float spacing = 0);
146
148 template<class S>
149 static void centerOn(const sf::FloatRect& bounds, S& obj);
150
152 template<class S>
153 static void centerVertically(const sf::FloatRect& bounds, S& obj);
154
156 template<class S>
157 static void centerHorizontally(const sf::FloatRect& bounds, S& obj);
158
159 // ── Vector2 overloads (size-based) ────────────────────────────────────
160
169 template<class S, class U>
170 static void setRightOf(const sf::Vector2<U>& size, S& obj, float spacing = 0);
171
173 template<class S, class U>
174 static void setLeftOf(const sf::Vector2<U>& size, S& obj, float spacing = 0);
175
177 template<class S, class U>
178 static void setBelow(const sf::Vector2<U>& size, S& obj, float spacing = 0);
179
181 template<class S, class U>
182 static void setAbove(const sf::Vector2<U>& size, S& obj, float spacing = 0);
183
185 template<class S, class U>
186 static void centerOn(const sf::Vector2<U>& size, S& obj);
187
189 template<class S, class U>
190 static void centerVertically(const sf::Vector2<U>& size, S& obj);
191
193 template<class S, class U>
194 static void centerHorizontally(const sf::Vector2<U>& size, S& obj);
195 };
196
197} // namespace ml
198
199#include "../../../src/Utilities/Align.tpp"
200#endif // ALIGN_H
Static layout helpers for positioning objects relative to one another.
Definition Align.h:55
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.
Definition Component.h:18
Rect< float > FloatRect