46#include <SDL3_image/SDL_image.h>
47#include <SDL3_mixer/SDL_mixer.h>
48#include <SDL3_ttf/SDL_ttf.h>
63#include <unordered_map>
64#include <unordered_set>
73#ifndef DEBUG_LUA_TESTS
74#define DEBUG_LUA_TESTS 0
96 Exception(
const std::string& message,
const std::string& file,
int line)
97 : message_(message), file_(file), line_(line) {}
98 const char*
what() const noexcept
override {
return message_.c_str(); }
99 std::string
getFile()
const {
return file_; }
102 std::string message_;
327 constexpr float epsilon = 0.0001f;
328 return std::abs(
left - other.
left) < epsilon &&
329 std::abs(
top - other.
top) < epsilon &&
335 return !(*
this == other);
346#define ERROR(message) throw SDOM::Exception(message, __FILE__, __LINE__)
354#define WARNING(message) SDOM::showWarning(message, __FILE__, __LINE__)
361#define DEBUG_LOG(...) do { \
362 std::ostringstream _sdom_dbg_oss; \
363 _sdom_dbg_oss << __VA_ARGS__; \
364 std::cout << CLR::GREEN << "[DEBUG] " << _sdom_dbg_oss.str() << CLR::RESET << std::endl; \
372#define FAIL(...) do { \
373 std::ostringstream _sdom_dbg_oss; \
374 _sdom_dbg_oss << __VA_ARGS__; \
375 std::cout << CLR::RED << "[FAILED] " << _sdom_dbg_oss.str() << CLR::RESET << std::endl; \
383#define INFO(...) do { \
384 std::ostringstream _sdom_dbg_oss; \
385 _sdom_dbg_oss << __VA_ARGS__; \
386 std::cout << CLR::YELLOW << "[INFO] " << (_sdom_dbg_oss.str()) << CLR::RESET << std::endl; } while(0)
389#define LUA_INFO(...) do { if (DEBUG_LUA_TESTS) { std::ostringstream _sdom_lua_dbg_oss; _sdom_lua_dbg_oss << __VA_ARGS__; std::cout << CLR::YELLOW << "[LUA-INFO] " << (_sdom_lua_dbg_oss.str()) << CLR::RESET << std::endl; } } while(0)
396#define DEBUG_ERR(message) do { std::cout << CLR::DARK << \
398 CLR::YELLOW << (message) << std::endl << CLR::DARK << \
399 " File: " << CLR::ORANGE << __FILE__ << CLR::DARK << std::endl << \
400 " Line: " << CLR::ORANGE << __LINE__ << CLR::RESET << "\n" << std::endl; } while(0)
408#define ASSERT_EQ(val, expected) \
409 if ((val) != (expected)) { \
410 ERROR("Assertion failed: " + std::string(#val) + " == " + std::string(#expected) \
411 + ", actual: " + std::to_string((val)) + ", expected: " + std::to_string((expected))); \
421#ifndef SDOM_USE_INDIVIDUAL_HEADERS
constexpr int ORPHAN_GRACE_PERIOD
Definition SDOM.hpp:78
constexpr bool DEBUG_REGISTER_LUA
Definition SDOM.hpp:70
Static container for ANSI escape sequences for terminal text formatting and colorization.
Custom exception class for SDOM errors.
Definition SDOM.hpp:94
const char * what() const noexcept override
Definition SDOM.hpp:98
Exception(const std::string &message, const std::string &file, int line)
Definition SDOM.hpp:96
std::string getFile() const
Definition SDOM.hpp:99
int getLine() const
Definition SDOM.hpp:100
Contains all core classes and utilities for the SDOM library.
Definition lua_BindHelpers.hpp:7
static const std::unordered_map< std::string, AnchorPoint > stringToAnchorPoint_
Maps string names to AnchorPoint enum values.
Definition SDOM.hpp:254
static const std::unordered_map< AnchorPoint, std::string > anchorPointToString_
Maps AnchorPoint enum values to their corresponding string names.
Definition SDOM.hpp:201
AnchorPoint
Reference points for anchoring child edges to a parent.
Definition SDOM.hpp:137
@ MIDDLE_RIGHT
Middle-right edge of the parent.
@ RIGHT_TOP
Alias for TOP_RIGHT.
@ BOTTOM
Alias for BOTTOM_CENTER.
@ RIGHT
Alias for MIDDLE_RIGHT.
@ RIGHT_BOTTOM
Alias for BOTTOM_RIGHT.
@ BOTTOM_RIGHT
Bottom-right corner of the parent.
@ BOTTOM_CENTER
Bottom-center edge of the parent.
@ MIDDLE
Alias for MIDDLE_CENTER.
@ LEFT_BOTTOM
Alias for BOTTOM_LEFT.
@ DEFAULT
Default anchor point (same as TOP_LEFT)
@ LEFT_TOP
Alias for TOP_LEFT.
@ TOP
Alias for TOP_CENTER.
@ LEFT
Alias for MIDDLE_LEFT.
@ TOP_LEFT
Top-left corner of the parent.
@ MIDDLE_CENTER
Center of the parent.
@ BOTTOM_LEFT
Bottom-left corner of the parent.
@ TOP_RIGHT
Top-right corner of the parent.
@ MIDDLE_LEFT
Middle-left edge of the parent.
@ CENTER_MIDDLE
Alias for MIDDLE_CENTER.
@ CENTER_TOP
Alias for TOP_CENTER.
@ CENTER
Alias for MIDDLE_CENTER.
@ CENTER_BOTTOM
Alias for BOTTOM_CENTER.
@ TOP_CENTER
Top-center edge of the parent.
@ LEFT_MIDDLE
Alias for MIDDLE_LEFT.
@ RIGHT_MIDDLE
Alias for MIDDLE_RIGHT.
Represents a rectangle's position and size in 2D space.
Definition SDOM.hpp:307
bool operator==(const Bounds &other) const
Definition SDOM.hpp:326
float left
Left edge coordinate.
Definition SDOM.hpp:308
float top
Top edge coordinate.
Definition SDOM.hpp:309
bool operator!=(const Bounds &other) const
Definition SDOM.hpp:334
float right
Right edge coordinate.
Definition SDOM.hpp:310
float bottom
Bottom edge coordinate.
Definition SDOM.hpp:311
float height() const
Calculates the height of the bounds.
Definition SDOM.hpp:323
float width() const
Calculates the width of the bounds.
Definition SDOM.hpp:317