Native popovers anchored to controls on a tilted panel

The panel is HTML that a canvas draws on a quad in perspective. Its buttons open browser-native top-layer UI with no script: Scenes opens a popover through commandfor, ? shows a popover="hint" through interestfor (hover, keyboard focus, or a long press on touch), and Turn off opens a modal <dialog>. The popovers are placed with CSS anchor positioning against buttons that are only pictures on a texture. Move the two sliders on the panel, or switch on the swing, and an open popover follows its button.

Living room

21.5°

Scene: Evening

This panel is one element drawn by a canvas. The hint is anchored to the place where the ? button is drawn.
Turn everything off?

 

The results are in the Live checks table below.

Show the code buttons in the canvas, popovers outside it, anchors
  1. The markup. commandfor, command and interestfor on buttons inside the canvas, pointing at elements outside it.
  2. The anchors. anchor-name on a button in the canvas, position-anchor on its popover.
  3. The panel's matrix. One matrix draws the quad and, through updateElementGeometry(), tells the browser where the panel is. Anchors and hit tests use that place.
  4. On paint. Upload the panel when it changed, draw its shadow and the panel.
  5. The fragment shader. A highlight that depends on the tilt, and a ring around the button whose popover is open.

How it works

The panel is one drawable child of the canvas, uploaded as a texture and drawn on a quad through a matrix with perspective. The same matrix goes to updateElementGeometry() in each paint event. From then on the browser's hit tests, focus rings and anchor rectangles for the panel's buttons use the drawn place. The popovers and the dialog are ordinary elements outside the canvas; commandfor and interestfor open them and CSS anchor positioning places them. The canvas repaints every frame only while the panel swings or a popover is open.

Live checks

The button under the demo runs these. They use the demo itself, so it has to be on screen: a point outside the window can't be hit tested.

CheckResultDetail
A point on the drawn Scenes button hit tests to the buttonnot run
The button's rectangle is the bounding box of its drawn quadnot run
The popover opens next to the drawn buttonnot run
The open popover follows the button when the panel turnsnot run

Findings