An overlay can be placed at a viewport coordinate (RFC-0017 §Positioning) - #243
Open
Briany4717 wants to merge 1 commit into
Open
An overlay can be placed at a viewport coordinate (RFC-0017 §Positioning)#243Briany4717 wants to merge 1 commit into
Briany4717 wants to merge 1 commit into
Conversation
…sitioning) The last unimplemented row of RFC-0017's positioning table. `Overlay` could put a child in the centre, or pin it to an edge, or (since RFC-0036) hang it off another element. What it could not do is the simplest thing on the list: put it at (300, 24). Spelled `at: (x, y)` rather than by letting `anchor_to:` take a pair. `anchor_to` names an element and is compile-checked against the `as` tags declared before it; a property whose *type* silently decides which of two unrelated behaviours you get is a property people get wrong, and the compile check would have had nothing to say about half of its own inputs. Viewport-space, unconditionally. It does not flip and it does not clamp: a coordinate off the window leaves the panel off the window, because pulling it back would make a wrong number look like a layout decision, which is the harder bug to find. Writing `at:` and `anchor_to:` together is refused rather than settled by a precedence rule nobody would remember. The test that says "the offset is measured from the viewport's origin" renders the same source at two window sizes, and also asserts the actual coordinate: without that second half it passes with the feature switched off, because a panel left where the wrapper put it is viewport-invariant too.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #242. This diff is the top commit only.
The last unimplemented row of RFC-0017's positioning table.
Overlaycould put a child in the centre, pin it to an edge, or (since RFC-0036) hang it off another element. What it could not do is the simplest thing on the list: put it at (300, 24).Why
at:rather thananchor_to: (x, y)anchor_tonames an element and is compile-checked against theastags declared before it. A property whose type silently decides which of two unrelated behaviours you get is a property people get wrong, and the compile check would have had nothing to say about half of its own inputs.Viewport-space, unconditionally
It does not flip and it does not clamp. A coordinate off the window leaves the panel off the window, because pulling it back would make a wrong number look like a layout decision — the harder bug to find. Writing
at:andanchor_to:together is refused rather than settled by a precedence rule nobody would remember.One note on the tests
The "measured from the viewport's origin" test renders the same source at two window sizes and asserts the actual coordinate. Without that second half it passes with the feature switched off, because a panel left where the wrapper put it is viewport-invariant too. The other two were watched failing with the placement branch disabled.
Example
crates/byard-cli/examples/anchored_overlaygains a badge placed withat:, beside the three anchored panels, so "follows an element" and "sits at a coordinate" are next to each other.Gates
cargo fmt --all --check,cargo clippy --locked --workspace --all-targets -- -D warnings,cargo test --locked --workspace(97 suites, 0 failures),cargo run -p byard-cli -- check crates/byard-cli/examples/anchored_overlay.