mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-25 13:06:00 +03:00
[GH-ISSUE #87] [Proposal] Anchor constrained positioning #19
Labels
No labels
bug
core
documentation
feature
good first issue
help wanted
pull-request
question
react
solid
tmux
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/opentui#19
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Adictya on GitHub (Aug 26, 2025).
Original GitHub issue: https://github.com/anomalyco/opentui/issues/87
Originally assigned to: @Adictya on GitHub.
Proposal
Add support for minute subset of css anchor-positioning like api to enable positioning elements relative to non parent renderables.
Similar behavior can already be achieved by directly referencing the renderables and doing some calculations in user space, this would just be a neater way of doing the same.
The api could look something like this for phase 1 atleast:
Implementation thoughts
All in all shouldn't be too hard to implement?
@kommander commented on GitHub (Aug 26, 2025):
Good proposal!
You cannot exclude anchored elements from the layout, as then their own layout including the children would not be calculated anymore, unless you call calculate layout from the anchored element for the subtree.
I think it would be simpler to force position the anchored element absolute and in the x/y getters use the anchor.x/y as relation/anchor instead of parent.x/y?
@Adictya commented on GitHub (Aug 26, 2025):
Yeah makes sense, much simpler
@kommander commented on GitHub (Aug 26, 2025):
We would have to make sure that you cannot anchor to a child. Also, anchoring to an element in another branch makes it complicated, as that branch might be rendered later and does not have updated position yet. So you are right that we have to defer rendering of anchored elements until after the anchor is rendered.
I would do that by letting the anchor know which elements use it as anchor, then stop rendering the branch when encountering an anchored element and resume in the anchor by rendering all anchored elements it has referenced.
Sounds complicated lol, it's really not.