CYD-UI
A C++ library for building native graphic user interfaces
Loading...
Searching...
No Matches
component_anchors.cppm
Go to the documentation of this file.
1// Copyright (c) 2025, Víctor Castillo Agüero.
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4module;
5export module cydui.components.anchors;
6
7export import std;
8
9export import cydui.dimensions;
10
11#define TO_STRING(...) #__VA_ARGS__
12#define ANCHOR(PREFIX, NAME) \
13 struct NAME { \
14 static constexpr dimension_parameter_t x{TO_STRING(PREFIX##_##NAME##_x)}; \
15 static constexpr dimension_parameter_t y{TO_STRING(PREFIX##_##NAME##_y)}; \
16 }
17
18export
21 using dimension_parameter_t = dimensions::parameter<dimensions::screen_measure>;
23 static constexpr dimension_parameter_t x {"self_x"};
24 static constexpr dimension_parameter_t y {"self_y"};
25 static constexpr dimension_parameter_t width {"self_width"};
26 static constexpr dimension_parameter_t height {"self_height"};
27 static constexpr dimension_parameter_t screen_x {"self_screen_x"};
28 static constexpr dimension_parameter_t screen_y {"self_screen_y"};
29 static constexpr dimension_parameter_t content_width {"self_content_width"};
30 static constexpr dimension_parameter_t content_height {"self_content_height"};
31 };
34 static constexpr dimension_parameter_t x {"parent_x"};
35 static constexpr dimension_parameter_t y {"parent_y"};
36 static constexpr dimension_parameter_t width {"parent_width"};
37 static constexpr dimension_parameter_t height {"parent_height"};
39 ANCHOR(parent, top_left);
41 ANCHOR(parent, top_center);
43 ANCHOR(parent, top_right);
45 ANCHOR(parent, middle_left);
47 ANCHOR(parent, center);
49 ANCHOR(parent, middle_right);
51 ANCHOR(parent, bottom_left);
53 ANCHOR(parent, bottom_center);
55 ANCHOR(parent, bottom_right);
56 };
59 static constexpr dimension_parameter_t x {"prev_x"};
60 static constexpr dimension_parameter_t y {"prev_y"};
61 static constexpr dimension_parameter_t width {"prev_width"};
62 static constexpr dimension_parameter_t height {"prev_height"};
64 ANCHOR(prev, top_left);
66 ANCHOR(prev, top_center);
68 ANCHOR(prev, top_right);
70 ANCHOR(prev, middle_left);
72 ANCHOR(prev, center);
74 ANCHOR(prev, middle_right);
76 ANCHOR(prev, bottom_left);
78 ANCHOR(prev, bottom_center);
80 ANCHOR(prev, bottom_right);
81 };
82 } // namespace cydui::components
83}
#define ANCHOR(PREFIX, NAME)
dimensions::parameter< dimensions::screen_measure > dimension_parameter_t
static constexpr dimension_parameter_t height
static constexpr dimension_parameter_t y
static constexpr dimension_parameter_t width
static constexpr dimension_parameter_t x
static constexpr dimension_parameter_t y
static constexpr dimension_parameter_t width
static constexpr dimension_parameter_t x
static constexpr dimension_parameter_t height
static constexpr dimension_parameter_t x
static constexpr dimension_parameter_t width
static constexpr dimension_parameter_t height
static constexpr dimension_parameter_t screen_x
static constexpr dimension_parameter_t screen_y
static constexpr dimension_parameter_t content_height
static constexpr dimension_parameter_t y
static constexpr dimension_parameter_t content_width