Skip to content

Commit 98a9914

Browse files
committed
Add safe area and document coordinate systems
Added `Window::safe_area`, which describes the area of the surface that is unobstructed by notches, bezels etc. The drawing code in the examples have been updated to draw a star inside the safe area, and the plain background outside of it. Also renamed `Window::inner_position` to `Window::surface_position`, and changed it to from screen coordinates to window coordinates, to better align how these coordinate systems work together. Finally, added some SVG images and documentation to describe how all of this works.
1 parent b674d20 commit 98a9914

File tree

15 files changed

+385
-127
lines changed

15 files changed

+385
-127
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ objc2-foundation = { version = "0.2.2", features = [
150150
"NSDictionary",
151151
"NSDistributedNotificationCenter",
152152
"NSEnumerator",
153+
"NSGeometry",
153154
"NSKeyValueObserving",
154155
"NSNotification",
155156
"NSObjCRuntime",

docs/res/ATTRIBUTION.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@ by [Tomiĉo] (https://commons.wikimedia.org/wiki/User:Tomi%C4%89o). It was
99
originally released under the [CC-BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/deed.en)
1010
License. Minor modifications have been made by [John Nunley](https://github.com/notgull),
1111
which have been released under the same license as a derivative work.
12+
13+
## `coordinate-systems*`
14+
15+
These files are created by [Mads Marquart](https://github.com/madsmtm) using
16+
[draw.io](https://draw.io/), and compressed using [svgomg.net](https://svgomg.net/).
17+
18+
They are licensed under the [CC-BY 4.0](https://creativecommons.org/licenses/by/4.0/) license.
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

docs/res/coordinate-systems.drawio

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<mxfile host="app.diagrams.net" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:129.0) Gecko/20100101 Firefox/129.0" version="24.7.7" pages="2">
2+
<diagram name="desktop" id="gtVbs73I2UO8pAmaLwRr">
3+
<mxGraphModel grid="1" page="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" pageScale="1" pageWidth="1200" pageHeight="600" background="none" math="0" shadow="0">
4+
<root>
5+
<mxCell id="0" />
6+
<mxCell id="1" parent="0" />
7+
<mxCell id="cjd5JdkAijNJT3bZ5lQT-18" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E8E8E8;fontColor=#333333;strokeColor=#666666;" vertex="1" parent="1">
8+
<mxGeometry x="320" y="40" width="560" height="480" as="geometry" />
9+
</mxCell>
10+
<mxCell id="37gYTUeosCAi_c7jJ1JD-1" value="" style="rounded=1;whiteSpace=wrap;html=1;shadow=0;fillColor=#dae8fc;strokeColor=#666666;" vertex="1" parent="1">
11+
<mxGeometry x="400" y="160" width="400" height="80" as="geometry" />
12+
</mxCell>
13+
<mxCell id="cjd5JdkAijNJT3bZ5lQT-1" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#DBDBDB;strokeColor=#666666;fontColor=#333333;" vertex="1" parent="1">
14+
<mxGeometry x="320" y="40" width="560" height="40" as="geometry" />
15+
</mxCell>
16+
<mxCell id="cjd5JdkAijNJT3bZ5lQT-5" value="" style="rounded=1;whiteSpace=wrap;html=1;shadow=0;fillColor=#d5e8d4;strokeColor=#666666;" vertex="1" parent="1">
17+
<mxGeometry x="400" y="360" width="400" height="80" as="geometry" />
18+
</mxCell>
19+
<mxCell id="cjd5JdkAijNJT3bZ5lQT-7" value="" style="rounded=0;whiteSpace=wrap;html=1;strokeColor=none;fillColor=#d5e8d4;" vertex="1" parent="1">
20+
<mxGeometry x="400" y="200" width="400" height="200" as="geometry" />
21+
</mxCell>
22+
<mxCell id="cjd5JdkAijNJT3bZ5lQT-8" value="" style="endArrow=none;html=1;rounded=0;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;strokeColor=#666666;" edge="1" parent="1" source="cjd5JdkAijNJT3bZ5lQT-5" target="37gYTUeosCAi_c7jJ1JD-1">
23+
<mxGeometry width="50" height="50" relative="1" as="geometry">
24+
<mxPoint x="150" y="330" as="sourcePoint" />
25+
<mxPoint x="200" y="280" as="targetPoint" />
26+
</mxGeometry>
27+
</mxCell>
28+
<mxCell id="cjd5JdkAijNJT3bZ5lQT-9" value="" style="endArrow=none;html=1;rounded=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;strokeColor=#666666;" edge="1" parent="1" source="cjd5JdkAijNJT3bZ5lQT-5" target="37gYTUeosCAi_c7jJ1JD-1">
29+
<mxGeometry width="50" height="50" relative="1" as="geometry">
30+
<mxPoint x="910" y="590" as="sourcePoint" />
31+
<mxPoint x="910" y="230" as="targetPoint" />
32+
</mxGeometry>
33+
</mxCell>
34+
<mxCell id="cjd5JdkAijNJT3bZ5lQT-12" value="" style="endArrow=none;html=1;rounded=0;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0;entryDx=0;entryDy=0;strokeColor=#666666;" edge="1" parent="1" source="37gYTUeosCAi_c7jJ1JD-1" target="cjd5JdkAijNJT3bZ5lQT-7">
35+
<mxGeometry width="50" height="50" relative="1" as="geometry">
36+
<mxPoint x="360.0000000000002" y="199.69" as="sourcePoint" />
37+
<mxPoint x="880.0000000000002" y="199.69" as="targetPoint" />
38+
</mxGeometry>
39+
</mxCell>
40+
<mxCell id="cjd5JdkAijNJT3bZ5lQT-21" value="&lt;font&gt;outer_position&lt;/font&gt;" style="endArrow=none;html=1;strokeWidth=3;rounded=0;exitX=0;exitY=0;exitDx=0;exitDy=0;dashed=1;align=right;fontSize=20;fontFamily=monospace;fontColor=#6C8EBF;labelBackgroundColor=none;spacingLeft=0;spacingRight=15;spacing=0;fillColor=#dae8fc;strokeColor=#6C8EBF;" edge="1" parent="1" source="cjd5JdkAijNJT3bZ5lQT-1">
41+
<mxGeometry x="0.125" width="50" height="50" relative="1" as="geometry">
42+
<mxPoint x="240" y="160" as="sourcePoint" />
43+
<mxPoint x="280" y="160" as="targetPoint" />
44+
<Array as="points">
45+
<mxPoint x="200" y="40" />
46+
<mxPoint x="200" y="160" />
47+
</Array>
48+
<mxPoint as="offset" />
49+
</mxGeometry>
50+
</mxCell>
51+
<mxCell id="cjd5JdkAijNJT3bZ5lQT-24" value="&lt;font&gt;outer_size&lt;/font&gt;" style="endArrow=none;html=1;strokeWidth=3;rounded=0;dashed=1;align=left;fontSize=20;fontFamily=monospace;fontColor=#6C8EBF;labelBackgroundColor=none;spacingLeft=15;spacingRight=0;spacing=0;exitX=1;exitY=0;exitDx=0;exitDy=0;fillColor=#dae8fc;strokeColor=#6c8ebf;" edge="1" parent="1" source="37gYTUeosCAi_c7jJ1JD-1">
52+
<mxGeometry width="50" height="50" relative="1" as="geometry">
53+
<mxPoint x="1010" y="190" as="sourcePoint" />
54+
<mxPoint x="920" y="440" as="targetPoint" />
55+
<Array as="points">
56+
<mxPoint x="1080" y="160" />
57+
<mxPoint x="1080" y="440" />
58+
</Array>
59+
<mxPoint as="offset" />
60+
</mxGeometry>
61+
</mxCell>
62+
<mxCell id="cjd5JdkAijNJT3bZ5lQT-27" value="&lt;font&gt;surface_size&lt;/font&gt;" style="endArrow=none;html=1;strokeWidth=3;rounded=0;dashed=1;align=left;fontSize=20;fontFamily=monospace;fontColor=#82B366;labelBackgroundColor=none;spacingLeft=15;spacingRight=0;spacing=0;entryX=1;entryY=1;entryDx=0;entryDy=0;fillColor=#d5e8d4;strokeColor=#82B366;" edge="1" parent="1" target="cjd5JdkAijNJT3bZ5lQT-5">
63+
<mxGeometry width="50" height="50" relative="1" as="geometry">
64+
<mxPoint x="800" y="200" as="sourcePoint" />
65+
<mxPoint x="920" y="440" as="targetPoint" />
66+
<Array as="points">
67+
<mxPoint x="920" y="200" />
68+
<mxPoint x="920" y="440" />
69+
</Array>
70+
<mxPoint as="offset" />
71+
</mxGeometry>
72+
</mxCell>
73+
<mxCell id="cjd5JdkAijNJT3bZ5lQT-23" value="&lt;font&gt;surface_position&lt;/font&gt;" style="endArrow=none;html=1;strokeWidth=3;rounded=0;entryX=0;entryY=0;entryDx=0;entryDy=0;dashed=1;align=right;fontSize=20;fontFamily=monospace;fontColor=#82B366;labelBackgroundColor=none;spacingLeft=0;spacingRight=15;spacing=0;fillColor=#d5e8d4;strokeColor=#82b366;exitX=0;exitY=0;exitDx=0;exitDy=0;" edge="1" parent="1" source="37gYTUeosCAi_c7jJ1JD-1" target="cjd5JdkAijNJT3bZ5lQT-7">
74+
<mxGeometry x="0.1429" width="50" height="50" relative="1" as="geometry">
75+
<mxPoint x="280" y="160" as="sourcePoint" />
76+
<mxPoint x="390" y="300" as="targetPoint" />
77+
<Array as="points">
78+
<mxPoint x="280" y="160" />
79+
<mxPoint x="280" y="200" />
80+
</Array>
81+
<mxPoint as="offset" />
82+
</mxGeometry>
83+
</mxCell>
84+
</root>
85+
</mxGraphModel>
86+
</diagram>
87+
<diagram id="6GWURxXdhDjWmP84JA9J" name="mobile">
88+
<mxGraphModel grid="1" page="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" pageScale="1" pageWidth="720" pageHeight="720" math="0" shadow="0">
89+
<root>
90+
<mxCell id="0" />
91+
<mxCell id="1" parent="0" />
92+
<mxCell id="RxwCrVmIsQwV7z5iJ9nY-1" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#E8E8E8;fontColor=#333333;strokeColor=#666666;" vertex="1" parent="1">
93+
<mxGeometry x="320" y="40" width="320" height="640" as="geometry" />
94+
</mxCell>
95+
<mxCell id="RxwCrVmIsQwV7z5iJ9nY-2" value="" style="rounded=1;whiteSpace=wrap;html=1;shadow=0;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1">
96+
<mxGeometry x="330" y="50" width="300" height="620" as="geometry" />
97+
</mxCell>
98+
<mxCell id="RxwCrVmIsQwV7z5iJ9nY-4" value="" style="rounded=0;whiteSpace=wrap;html=1;shadow=0;fillColor=#ffe6cc;strokeColor=#d79b00;" vertex="1" parent="1">
99+
<mxGeometry x="340" y="80" width="280" height="560" as="geometry" />
100+
</mxCell>
101+
<mxCell id="RxwCrVmIsQwV7z5iJ9nY-9" value="safe_area" style="endArrow=none;html=1;strokeWidth=3;rounded=0;dashed=1;align=right;fontSize=20;fontFamily=monospace;fontColor=#D79B00;labelBackgroundColor=none;spacingLeft=0;spacingRight=15;spacing=0;fillColor=#ffe6cc;strokeColor=#d79b00;exitX=0;exitY=0;exitDx=0;exitDy=0;entryX=0;entryY=1;entryDx=0;entryDy=0;" edge="1" parent="1" source="RxwCrVmIsQwV7z5iJ9nY-4" target="RxwCrVmIsQwV7z5iJ9nY-4">
102+
<mxGeometry width="50" height="50" relative="1" as="geometry">
103+
<mxPoint x="170" y="60" as="sourcePoint" />
104+
<mxPoint x="160" y="110" as="targetPoint" />
105+
<Array as="points">
106+
<mxPoint x="280" y="80" />
107+
<mxPoint x="280" y="640" />
108+
</Array>
109+
<mxPoint as="offset" />
110+
</mxGeometry>
111+
</mxCell>
112+
<mxCell id="RxwCrVmIsQwV7z5iJ9nY-12" value="&lt;font&gt;surface_size&lt;/font&gt;" style="endArrow=none;html=1;strokeWidth=3;rounded=0;dashed=1;align=right;fontSize=20;fontFamily=monospace;fontColor=#82B366;labelBackgroundColor=none;spacingLeft=0;spacingRight=15;spacing=0;fillColor=#d5e8d4;strokeColor=#82b366;entryX=0;entryY=1;entryDx=0;entryDy=0;" edge="1" parent="1" target="RxwCrVmIsQwV7z5iJ9nY-2">
113+
<mxGeometry width="50" height="50" relative="1" as="geometry">
114+
<mxPoint x="330" y="50" as="sourcePoint" />
115+
<mxPoint x="320" y="630" as="targetPoint" />
116+
<Array as="points">
117+
<mxPoint x="160" y="50" />
118+
<mxPoint x="160" y="670" />
119+
</Array>
120+
<mxPoint as="offset" />
121+
</mxGeometry>
122+
</mxCell>
123+
<mxCell id="RxwCrVmIsQwV7z5iJ9nY-20" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#DBDBDB;strokeColor=#666666;fontColor=#333333;" vertex="1" parent="1">
124+
<mxGeometry x="410" y="640" width="140" height="10" as="geometry" />
125+
</mxCell>
126+
<mxCell id="RxwCrVmIsQwV7z5iJ9nY-3" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#DBDBDB;strokeColor=#666666;fontColor=#333333;" vertex="1" parent="1">
127+
<mxGeometry x="420" y="50" width="120" height="30" as="geometry" />
128+
</mxCell>
129+
</root>
130+
</mxGraphModel>
131+
</diagram>
132+
</mxfile>

0 commit comments

Comments
 (0)