M6 elements and window: Element/Render/views, headless Window, div, canvas

- input: mouse events, modifiers, dispatch phases.
- window: Element / AnyElement / IntoElement, Render / AnyView (entities
  render as elements), listener(), empty(); Window with the draw cycle
  (render, layout to fill the viewport, prepaint, paint, finish) and phase
  checks; content-mask / element-offset / opacity / element-id stacks;
  element state across frames (ElementStateKey); hitboxes, hit testing,
  occlusion; mouse dispatch (capture + bubble, stop_propagation); hover-
  and notify-driven invalidation of rendered views; painting: paint_quad
  with device-pixel snapping, drop/inset shadows, paint_path, paint_style
  (port of Style::paint).
- elements: div() (Styled, children, hover, mouse down/up/move/scroll,
  clicks with element state, occlude, overflow clipping, opacity) and
  canvas(); Styled extend lists generated by tools/gen_style.py.
- app: observe_notifications hook used by windows.
- Tests: end-to-end views -> scene, clicks, hover, invalidation, nested
  views, bubbling, occlusion, shadows/borders/clipping, canvas, resize,
  and aborts on misuse. The card example now renders a real view and
  simulates hover and click.
- Docs: PORTING.md M6 status and deviations; README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SpriteandClaude Opus 5.5 committed 2026-11-24 22:55:17 +00:00
1 parent eeab51348e
commit fbe4c081e6
24 files changed
+15532 -204

No files matched your search

+18 -6
View File
@@ -16,8 +16,9 @@ Outputs (all in src/style/):
styled_extend_generated.mbt promotes all `Styled` methods on
StyleRefinement
Other packages that implement `Styled` (e.g. `Div`) need the same `extend`
list; pass `--extend Type=path/to/file.mbt` to emit it there.
Other packages that implement `Styled` need the same `extend` list. The
default run also emits it for the elements package (`Div`, `Canvas`); add
more with `--extend Type=path/to/file.mbt`.
"""
import argparse
@@ -636,11 +637,11 @@ def gen_styled():
return "".join(out), names
def gen_extend(type_name, names):
def gen_extend(type_name, names, trait_ref="Styled"):
body = ",\n ".join(names)
return (
HEADER
+ f"///|\npub extend {type_name} with Styled::{{\n {body},\n}}\n"
+ f"///|\npub extend {type_name} with {trait_ref}::{{\n {body},\n}}\n"
)
@@ -650,6 +651,13 @@ def write(path, content):
print(f"wrote {os.path.relpath(path, ROOT)}")
# Styled types outside the style package, emitted on every run.
DEFAULT_EXTENDS = [
"Div=src/elements/div_styled_generated.mbt",
"Canvas=src/elements/canvas_styled_generated.mbt",
]
def main():
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument(
@@ -668,11 +676,15 @@ def main():
os.path.join(STYLE_DIR, "styled_extend_generated.mbt"),
gen_extend("StyleRefinement", names),
)
for spec in args.extend:
for spec in DEFAULT_EXTENDS + args.extend:
if "=" not in spec:
sys.exit(f"gen_style: --extend expects TYPE=FILE, got {spec!r}")
type_name, path = spec.split("=", 1)
write(os.path.join(ROOT, path), gen_extend(type_name, names))
full = os.path.join(ROOT, path)
# Outside the style package the trait must be package-qualified.
inside = os.path.dirname(os.path.abspath(full)) == STYLE_DIR
trait_ref = "Styled" if inside else "@style.Styled"
write(full, gen_extend(type_name, names, trait_ref))
print(f"{len(names)} Styled methods")