Skip to main content

devela/run/regime/cap/
definitions.rs

1// devela::run::regime::cap::definitions
2//
3//! Runtime capabilities.
4//
5
6use crate::{ColorDepth, Extent2, NonMaxU16, NonMaxU32, set, test_size_of};
7
8#[doc = crate::_tags!(runtime)]
9/// The capabilities supported by a `Runtime`.
10#[doc = crate::_doc_meta!{
11    location("run/regime"),
12    test_size_of(RunCap = 28|224),
13}]
14#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
15pub struct RunCap {
16    /// Audio capabilities.
17    pub audio: Option<RunCapAudio>,
18    /// Color capabilities.
19    pub color: Option<RunCapColor>,
20    /// Image capabilities.
21    pub image: Option<RunCapImage>,
22    /// Input capabilities.
23    pub input: Option<RunCapInput>,
24    /// System capabilities.
25    pub system: Option<RunCapSystem>,
26    /// Text capabilities.
27    pub text: Option<RunCapText>,
28    /// Windowing capabilities.
29    pub window: Option<RunCapWindow>,
30}
31
32#[doc = crate::_tags!(runtime audio)]
33/// Runtime audio capabilities.
34#[doc = crate::_doc_meta!{
35    location("run/regime"),
36    test_size_of(RunCapAudio = 1|8),
37}]
38#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
39pub struct RunCapAudio {
40    /// Audio playback capabilities.
41    pub play: bool,
42}
43
44#[doc = crate::_tags!(runtime color)]
45/// Runtime color capabilities.
46#[doc = crate::_doc_meta!{
47    location("run/regime"),
48    test_size_of(RunCapColor = 4|32),
49}]
50#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
51pub struct RunCapColor {
52    /// Maximum color depth.
53    pub depth: ColorDepth,
54    /// Maximum palette size, when indexed color is supported.
55    pub palette_size: Option<NonMaxU16>,
56    /// Whether the palette can be changed by the application.
57    pub palette_set: bool,
58}
59
60#[doc = crate::_tags!(runtime image)]
61/// Runtime image capabilities.
62#[doc = crate::_doc_meta!{
63    location("run/regime"),
64    test_size_of(RunCapImage = 12|96),
65}]
66#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
67pub struct RunCapImage {
68    /// Maximum bitmap size, in native pixels.
69    pub max_bitmap_extent: Option<Extent2<NonMaxU32>>,
70    /// Whether pixel-accurate bitmaps are supported.
71    pub pixel_native: bool,
72}
73
74set! {
75    #[doc = crate::_tags!(runtime interaction set)]
76    /// Runtime input capabilities.
77    #[doc = crate::_doc_meta!{
78        location("run/regime"),
79        test_size_of(RunCapInput = 1|8),
80    }]
81    pub struct RunCapInput(u8) {
82        /// Gamepad input capabilities.
83        GAMEPAD = 0 ;
84        /// Keyboard input capabilities.
85        KEYBOARD = 1 ;
86        /// Midi input capabilities
87        MIDI = 2 ;
88        /// Mouse input capabilities.
89        MOUSE = 3;
90        /// Touchscreen input capabilities.
91        TOUCHSCREEN = 4;
92    }
93}
94
95set! {
96    #[doc = crate::_tags!(runtime set)]
97    /// Runtime system capabilities.
98    #[doc = crate::_doc_meta!{
99        location("run/regime"),
100        test_size_of(RunCapSystem = 2|16),
101    }]
102    pub struct RunCapSystem(u16) {
103        /// Current or monotonic time can be queried.
104        TIME = 0;
105        /// Timers, sleeps, delays, or scheduled wakeups are available.
106        TIMER = 1;
107        /// Randomness or system entropy is available.
108        RANDOM = 2;
109        /// Environment variables or host environment metadata can be queried.
110        ENV = 3;
111        /// Filesystem access is available.
112        FS = 4;
113        /// Process spawning or process inspection is available.
114        PROCESS = 5;
115        /// Thread spawning or host threading is available.
116        THREAD = 6;
117        /// Network access is available.
118        NET = 7;
119        /// Host signals, interrupts, or shutdown notifications are available.
120        SIGNAL = 8;
121    }
122}
123
124set! {
125    #[doc = crate::_tags!(runtime text set)]
126    /// Runtime text capabilities.
127    #[doc = crate::_doc_meta!{
128        location("run/regime"),
129        test_size_of(RunCapText = 1|8),
130    }]
131    pub struct RunCapText(u8) {
132        /// Text output.
133        WRITE = 0;
134        /// Fixed-cell text layout.
135        CELL_GRID = 1;
136        /// Variable-width text layout.
137        PROPORTIONAL = 2;
138        /// Addressable text cursor.
139        CURSOR = 3;
140        /// Text styling, such as bold, underline, inverse, or reset.
141        STYLE = 4;
142        /// Text input or editable text regions.
143        EDIT = 5;
144        /// Text color is assigned as a foreground/background pair.
145        COLOR_PAIR = 6;
146        /// Text extents or advances can be measured.
147        MEASURE = 7;
148    }
149}
150
151test_size_of![RunCapWindow = 1]; // 8 bits
152#[doc = crate::_tags!(runtime)]
153/// Runtime window capabilities.
154#[doc = crate::_doc_meta!{location("run/regime")}]
155#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
156pub struct RunCapWindow {
157    /// Whether multiple windows are supported.
158    pub multi: bool,
159}