home
readme
diff
tree
note
docs
0commit 6db9a0fcb7a8414618065ae276b8beac83f516fc
1Author: Mason Wright <mason@lakefox.net>
2Date: Fri Aug 8 17:23:29 2025 -0600
3
4 Media query structure set
5
6diff --git a/Makefile b/Makefile
7index 5c2f5b2..0406c7f 100644
8--- a/Makefile
9+++ b/Makefile
10@@ -56,6 +56,7 @@ HTML_FILES := $(MD_FILES:docs/content/%.md=docs/dist/%.html)
11 docs: $(HTML_FILES)
12 cd ../build && ./tracker.sh
13
14+# See 080f729 note for the template command
15 docs/dist/%.html: docs/content/%.md docs/components/navbar.html
16 pandoc $< | template docs/components/navbar.html --stdin docs/template.html > $@
17
18diff --git a/docs/content/features/supported-css-selectors.md b/docs/content/features/supported-css-selectors.md
19index f92cb2e..cda043a 100644
20--- a/docs/content/features/supported-css-selectors.md
21+++ b/docs/content/features/supported-css-selectors.md
22@@ -123,12 +123,22 @@
23 | @view-transition ||||| This is useful but will not be implemented until later |
24 ## Functions
25 ## Types
26+| Name | Support | Values | Note |
27+|-|-|-|-|
28+| AnyHover | X | None, Hover | |
29+| AnyPointer | X | None, Fine, Coarse | |
30+| Orientation | X | Landscape, Portrait | |
31+| ColorScheme | X | Light, Dark | |
32+| Contrast | X | NoPreference, More, Less | |
33+| ReducedMotion | X | NoPreference, Reduce | |
34+| ReducedTranparency | X | NoPreference, Reduce | |
35+| Update | X | Fast, Slow | |
36
37 ### Media Queries
38 | Name | Support | Usage | Note |
39 |-|-|-|-|
40-| any-hover | X | window.setMouse("none") | Options "none", "coarse", "fine". If not "none" then any-hover will be set to "hover". |
41-| any-pointer | X | window.setMouse("fine") | Options "none", "coarse", "fine". |
42+| any-hover | X | window.setMouse(AnyPointer::Fine) | Will be set to AnyHover::Hover if AnyPointer is not AnyPointer::None, default AnyHover::Hover |
43+| any-pointer | X | window.setMouse(AnyPointer::Coarse) | Default AnyPointer::Fine |
44 | aspect-ratio | X | window.getAspectRatio() | Derived from width and height, returned as a double |
45 | color | * | | All colors are stored as RGBA values |
46 | color-gamut | * | | Only matches on "srgb" |
47@@ -139,19 +149,19 @@
48 | forced-colors | * | | Only matches on "none" |
49 | grid | * | | Only matches on 0 |
50 | height | X | window.setHeight(int) | Supports height, min-height, max-height |
51-| hover | X | window.setMouse("fine") | Will match any-hover |
52+| hover | X | window.setMouse(AnyPointer::Fine) | Will match any-hover |
53 | inverted-colors | * | | Only matches on "none" |
54 | monochrome | * | | Only matches on 0 |
55-| orientation | X | window.setOrientation("portrait") | Defaults to "landscape" |
56+| orientation | X | window.setOrientation(Orientation::Portrait) | Defaults to Orientation::Landscape |
57 | overflow-block | * | | Only matches on "scroll" |
58 | overflow-inline | * | | Only matches on "scroll" |
59-| pointer | X | window.setMouse("fine") | Will match any-pointer |
60-| prefers-color-scheme | X | window.setColorScheme("light" \|\| "dark") | Defaults to "light" |
61-| prefers-contrast | X | window.setContrast("more" \|\| "less" \|\| "no-preference") | Defaults to "no-preference" |
62-| prefers-reduced-motion | X | window.setReducedMotion("reduce" \|\| "no-preference") | Defaults to "no-preference" |
63-| prefers-reduced-transparency | X | window.setReducedTransparency("reduce" \|\| "no-preference") | Defaults to "no-preference" |
64+| pointer | X | window.setMouse(AnyPointer) | Will match any-pointer |
65+| prefers-color-scheme | X | window.setColorScheme(ColorScheme::Dark) | Defaults to ColorScheme::Light |
66+| prefers-contrast | X | window.setContrast(Contrast::Less) | Defaults to ColorScheme::NoPreference |
67+| prefers-reduced-motion | X | window.setReducedMotion(ReducedMotion::Reduce) | Defaults to ReducedMotion::NoPreference |
68+| prefers-reduced-transparency | X | window.setReducedTransparency(ReducedTransparency::Reduce) | Defaults to ReducedTransparency::NoPreference |
69 | resolution | X | window.setResolution(int) | Defaults to 72dpi, accepts a int in dpi |
70 | scripting | / | | Not needed |
71-| update | X | window.setUpdate("fast" \|\| "slow" \|\| "none") | Defaults to "fast" |
72+| update | X | window.setUpdate(Update::Slow) | Defaults to Update::Fast |
73 | video-dynamic-range | * | | Only matches on "standard" |
74 | width | X | window.setWidth(int) | Supports width, min-width, max-width |
75diff --git a/docs/template.html b/docs/template.html
76index 8d8a7ed..ad2b1b2 100644
77--- a/docs/template.html
78+++ b/docs/template.html
79@@ -26,9 +26,9 @@ th {
80 <body>
81 <main style="margin: 0 4rem 0 4rem">
82 <div style="display: flex; gap: 1rem">
83- $V1
84+ %s
85 <div style="width: 100%">
86- <section>$V2</section>
87+ <section>%s</section>
88 </div>
89 </div>
90 </main>
91diff --git a/include/grim.h b/include/grim.h
92index 0d8490a..93364ff 100644
93--- a/include/grim.h
94+++ b/include/grim.h
95@@ -237,69 +237,117 @@ class StyleHandler {
96 // make a function that will return a list of attributes the will cause style changes if set
97 };
98
99-class Window {
100- private:
101- int width = 0;
102- int height = 0;
103- int resolution = 0;
104- std::string anyHover = "hover";
105- std::string anyPointer = "fine";
106- std::string orientation = "landscape";
107- std::string colorScheme = "light";
108- std::string contrast = "no-preference";
109- std::string reducedMotion = "no-preference";
110- std::string reducedTransparency = "no-preference";
111- std::string update = "fast";
112- public:
113- void setWidth(int value) {
114- width = value;
115- }
116- void setHeight(int value) {
117- height = value;
118- }
119- void setResolution(int value) {
120- resolution = value;
121- }
122- void setMouse(std::string pointer) {
123- if (pointer == "none") {
124- anyHover = "none";
125- } else {
126- anyHover = "hover";
127- }
128+enum class AnyHover {
129+ None,
130+ Hover
131+};
132
133- anyPointer = pointer;
134- }
135- void setOrientation(std::string value) {
136- orientation = value;
137- }
138- void setColorScheme(std::string value) {
139- colorScheme = value;
140- }
141- void setContrast(std::string value) {
142- contrast = value;
143- }
144- void setReducedMotion(std::string value) {
145- reducedMotion = value;
146- }
147- void setReducedTransparency(std::string value) {
148- reducedTransparency = value;
149- }
150- void setUpdate(std::string value) {
151- update = value;
152- }
153-
154-
155+enum class AnyPointer {
156+ None,
157+ Fine,
158+ Coarse
159+};
160
161- int getWidth() {
162- return width;
163- }
164- int getHeight() {
165- return height;
166- }
167- double getAspectRatio() {
168- return width/height;
169- }
170+enum class Orientation {
171+ Landscape,
172+ Portrait
173+};
174+
175+enum class ColorScheme {
176+ Light,
177+ Dark
178+};
179+
180+enum class Contrast {
181+ NoPreference,
182+ More,
183+ Less
184 };
185
186+enum class ReducedMotion {
187+ NoPreference,
188+ Reduce
189+};
190+
191+enum class ReducedTransparency {
192+ NoPreference,
193+ Reduce
194+};
195+
196+enum class Update {
197+ Fast,
198+ Slow
199+};
200+
201+class Window {
202+private:
203+ int width = 0;
204+ int height = 0;
205+ int resolution = 0;
206+ AnyHover anyHover = AnyHover::Hover;
207+ AnyPointer anyPointer = AnyPointer::Fine;
208+ Orientation orientation = Orientation::Landscape;
209+ ColorScheme colorScheme = ColorScheme::Light;
210+ Contrast contrast = Contrast::NoPreference;
211+ ReducedMotion reducedMotion = ReducedMotion::NoPreference;
212+ ReducedTransparency reducedTransparency = ReducedTransparency::NoPreference;
213+ Update update = Update::Fast;
214+
215+public:
216+ void setWidth(int value) {
217+ width = value;
218+ }
219+ void setHeight(int value) {
220+ height = value;
221+ }
222+ void setResolution(int value) {
223+ resolution = value;
224+ }
225+
226+ void setMouse(AnyPointer pointer) {
227+ if (pointer == AnyPointer::None) {
228+ anyHover = AnyHover::None;
229+ } else {
230+ anyHover = AnyHover::Hover;
231+ }
232+ anyPointer = pointer;
233+ }
234+
235+ void setOrientation(Orientation value) {
236+ orientation = value;
237+ }
238+
239+ void setColorScheme(ColorScheme value) {
240+ colorScheme = value;
241+ }
242+
243+ void setContrast(Contrast value) {
244+ contrast = value;
245+ }
246+
247+ void setReducedMotion(ReducedMotion value) {
248+ reducedMotion = value;
249+ }
250+
251+ void setReducedTransparency(ReducedTransparency value) {
252+ reducedTransparency = value;
253+ }
254+
255+ void setUpdate(Update value) {
256+ update = value;
257+ }
258+
259+ // Getters
260+ int getWidth() const {
261+ return width;
262+ }
263+ int getHeight() const {
264+ return height;
265+ }
266+ double getAspectRatio() const {
267+ if (height == 0) return 0.0;
268+ return static_cast<double>(width) / height;
269+ }
270+};
271
272 #endif // NODE_H
273diff --git a/notes b/notes
274deleted file mode 100644
275index db68ba6..0000000
276--- a/notes
277+++ /dev/null
278@@ -1,37 +0,0 @@
279-ul > li::innerHTML {
280-// I think node templating would work the best, the parser is fast enough not to matter too much
281-// if I can't get the testSelector speed down, only use inline styles
282- "<div class=\"li_internal_dot\"></div>{{$.innerHTML}}"
283-}
284-
285-.li_internal_dot {
286- width: 10px;
287- height: 10px;
288- border-radius: 10px;
289-}
290-
291-
292-node.click()
293- +
294-event handler
295- +
296-class.toggle
297- +
298-apply styles
299- +
300-run templates
301- +
302-compute rel position and size/color
303- +
304-update adapter
305-
306-
307-or
308-
309-SELECT("ul > li::innerHTML") {
310- WIDTH()
311- HEIGHT()
312- MARGIN_LEFT()
313- BACKGROUND_COLOR()
314- BACKGROUND_IMAGE()
315-}