Skip to content

Commit 2039559

Browse files
authored
Merge pull request #6 from artstorm/update-docs
Update docs
2 parents 598b600 + 96d76a7 commit 2039559

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed
4.95 KB
Loading

Packages/com.bitbebop.ui-toolkit-safe-area/Runtime/SafeArea.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public override string ToString()
2121

2222
public new class UxmlFactory : UxmlFactory<SafeArea, UxmlTraits> {}
2323

24-
public bool CollapseMargin { get; set; }
24+
public bool CollapseMargins { get; set; }
2525
public bool ExcludeLeft { get; set; }
2626
public bool ExcludeRight { get; set; }
2727
public bool ExcludeTop { get; set; }
@@ -30,7 +30,7 @@ public override string ToString()
3030

3131
public new class UxmlTraits : VisualElement.UxmlTraits
3232
{
33-
private UxmlBoolAttributeDescription _collapseMarginAttr = new() { name = "collapse-margin", defaultValue = true };
33+
private UxmlBoolAttributeDescription _collapseMarginsAttr = new() { name = "collapse-margins", defaultValue = true };
3434
private UxmlBoolAttributeDescription _excludeLeftAttr = new() { name = "exclude-left", defaultValue = false };
3535
private UxmlBoolAttributeDescription _excludeRightAttr = new() { name = "exclude-right", defaultValue = false };
3636
private UxmlBoolAttributeDescription _excludeTopAttr = new() { name = "exclude-top", defaultValue = false };
@@ -47,7 +47,7 @@ public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext
4747
base.Init(ve, bag, cc);
4848
var ate = ve as SafeArea;
4949

50-
ate.CollapseMargin = _collapseMarginAttr.GetValueFromBag(bag, cc);
50+
ate.CollapseMargins = _collapseMarginsAttr.GetValueFromBag(bag, cc);
5151
ate.ExcludeLeft = _excludeLeftAttr.GetValueFromBag(bag, cc);
5252
ate.ExcludeRight = _excludeRightAttr.GetValueFromBag(bag, cc);
5353
ate.ExcludeTop = _excludeTopAttr.GetValueFromBag(bag, cc);
@@ -88,7 +88,7 @@ private void OnGeometryChanged(GeometryChangedEvent evt)
8888
var safeArea = GetSafeAreaOffset();
8989
var margin = GetMarginOffset();
9090

91-
if (CollapseMargin)
91+
if (CollapseMargins)
9292
{
9393
_contentContainer.style.marginLeft = Mathf.Max(margin.Left, safeArea.Left) - margin.Left;
9494
_contentContainer.style.marginRight = Mathf.Max(margin.Right, safeArea.Right) - margin.Right;

README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020

2121
The goal of the safe area container is to provide a custom control to simplify handling safe areas with UI Toolkit on relevant devices.
2222

23-
- Optional safe area and margin collapse.
23+
- Option to collapse margins with the safe area.
24+
- Option to exclude specific safe area edges.
25+
- Option to exclude safe area on tvOS.
2426

2527
## Usage
2628

@@ -30,19 +32,31 @@ The SafeArea container is available in the Library in UI Builder and can be foun
3032

3133
The SafeArea container should be added as the top element in the hierarchy to ensure that it can fill up the entire screen. All child elements dropped into the SafeArea container will live inside `safe-area-content-container` and be adjusted accordingly depending on the current device SafeArea.
3234

33-
Margins can be set on the SafeArea container, useful when running on devices that does not utilize a safe area.
35+
Margins can be set on the SafeArea container, which can be useful when running on devices that does not utilize a safe area.
3436

35-
The container margins and the safe area is collapsed by default. That can be disabled in the inspector.
37+
The SafeArea container has a selection of custom attributes that can be set in the UI Builder inspector.
3638

3739
![UI Builder Inspector](https://raw.githubusercontent.com/artstorm/ui-toolkit-safe-area/main/.github/readme/ui-builder-inspector.png)
3840

41+
### Collapse Margins
42+
43+
The container margins and the safe area is collapsed by default. That can be disabled in the inspector.
44+
3945
Take a look at these screenshots which helps illustrate the differences how margin, safe area and collapse comes together. In each example the margin is set to `10px 10px 0px 10px`.
4046

4147
![UI Builder Inspector](https://raw.githubusercontent.com/artstorm/ui-toolkit-safe-area/main/.github/readme/collapse-margin.png)
4248

4349
1. For a device without a safe area, the margin values are used as-is and collapse margins doesn't play a part as there is no safe area to collapse with.
4450
2. For a device with a safe area the margins are collapsed with the safe area. The margin value is used if it would be larger than the safe area.
45-
3. If `Collapse Margin` is disabled, the margin is added to the safe area.
51+
3. If `Collapse Margins` is disabled, the margin is added to the safe area.
52+
53+
### Exclude Edges
54+
55+
With exclude edges, the safe area value of `left`, `right`, `top` and `bottom` edges can optionally be excluded from the calculations. If an edge is excluded, only the margin value for that edge will be used.
56+
57+
### Exclude tvOS
58+
59+
This option excludes the safe area values for all edges on tvOS. If selected, tvOS builds will not use safe area but only the margin values.
4660

4761
## Installation
4862

0 commit comments

Comments
 (0)