Commit 2340ca2
susan101566
editor+runtime: expose Shape length via databinding
It might be useful for follow path to line break on the size of the shape instead of on the original size of the text box. This can be done through data-binding.
This PR exposes a 'length' property on Shapes that's derived from the shape's paths and cannot be set.
The method is quite similar to how worldBounds on a shape is calculated -- lazily. When we invalidate the bound, we invalidate the length property.
The UI in the editor is this text box. Note that this property won't update as you change the bounds of the shape because the property is calculated lazily. I'm inclined to just show a '-' when the value is invalid, but that's up for discussion. On the runtime side, it's pretty similar.
<img width="341" alt="image" src="https://github.com/user-attachments/assets/0a08ec74-3ce6-4bfa-97f6-aecfa97e53a1" />
Tests:
1. I added an editor test that accesses length from shape. This may seem vacuous, but mainly I just wanted to test that there's no infinite recursion problems.
2. I'd like to add a golden test for this, but it seems our testing harness doesn't support detecting a view model yet. I manually tested in the runtime viewer app that this shows up fine:
<img width="1520" alt="image" src="https://github.com/user-attachments/assets/800bb79c-a138-4788-bfa9-b7377b3462ec" />
3. I loaded up wasm locally and it seems to work fine.
Diffs=
28f17bd861 editor+runtime: expose Shape length via databinding (#9160)1 parent 08d3173 commit 2340ca2
2 files changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
0 commit comments