CYD-UI
A C++ library for building native graphic user interfaces
Loading...
Searching...
No Matches
_types.cppm
Go to the documentation of this file.
1
5
6module;
7#include <quantify/unit_macros.h>
9export module cydui.dimensions:types;
10
11export import quantify;
13
14constexpr double DPI = 92.0; // TODO - find a runtime way of getting this value
15
16export namespace cydui::dimensions {
17 SCALE(screen) {
18 UNIT(pixel, "px", 1, 1)
19 }
21 using screen_measure = quantify::quantity_t<screen::pixel, double>;
22}
23SCALE_CONVERSION(cydui::dimensions::screen::scale, quantify::distance::scale)
24 SCALE_FORWARD_CONVERSION((it / ((100.0 / 2.54) * DPI))) SCALE_BACKWARD_CONVERSION(it * ((100.0 / 2.54) * DPI))
25
26export namespace cydui::dimensions {
27 template<typename T>
28 class context;
29 template<typename T>
30 class dimension;
31 template<typename T>
32 class expression;
33
34 template <typename T>
35 struct parameter {
36 std::string name{};
37
38 bool operator==(const parameter& other) const {
39 return name == other.name;
40 }
41 };
42
43 template <typename T>
44 struct cycle_t;
45
46 template<typename T>
47 struct compute_result_t;
48
49 template <typename ...>
50 struct is_dimension: std::false_type {};
51
52 template <typename... Args>
53 struct is_dimension<dimension<Args...>>: std::true_type {};
54
55 template <typename... Args>
56 constexpr bool is_dimension_v = is_dimension<Args...>::value;
57
58 template <typename ...>
59 struct is_expression: std::false_type {};
60
61 template <typename... Args>
62 struct is_expression<expression<Args...>>: std::true_type {};
63
64 template <typename... Args>
65 constexpr bool is_expression_v = is_expression<Args...>::value;
66}
67
68namespace cydui::dimensions {
69 template<typename T>
70 class dimension_impl;
71
73}
74
76operator""_px(long double value) noexcept {
77 return {static_cast<double>(value)};
78}
79
81operator""_px(unsigned long long value) noexcept {
82 return {static_cast<double>(value)};
83}
84
85export constexpr cydui::dimensions::parameter<cydui::dimensions::screen_measure>
86operator""_param(const char* str, unsigned long len) noexcept {
87 return {std::string{str, len}};
88}
89
90export template<typename T>
91struct std::hash<cydui::dimensions::parameter<T>> {
92 std::size_t operator()(const cydui::dimensions::parameter<T>& param) const noexcept {
93 return std::hash<std::string>{}(param.name);
94 }
95};
96
97export {
98#define OPERATOR +
99#include "operators_decl.inc"
100#undef OPERATOR
101
102#define OPERATOR -
103#include "operators_decl.inc"
104#undef OPERATOR
105
106#define OPERATOR *
107#include "operators_decl.inc"
108#undef OPERATOR
109
110#define OPERATOR /
111#include "operators_decl.inc"
112#undef OPERATOR
113}
constexpr double DPI
Definition _types.cppm:14
bool operator==(const data_series_t &lhs, const data_series_t &rhs)
quantify::quantity_t< screen::pixel, double > screen_measure
Definition _types.cppm:21