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:
1 parent
eeab51348e
commit
fbe4c081e6
24 files changed
+15532
-204
No files matched your search
@@ -0,0 +1,134 @@
|
||||
// Generated using `moon info`, DON'T EDIT IT
|
||||
package "experiments/gpui/window"
|
||||
|
||||
import {
|
||||
"experiments/gpui/app",
|
||||
"experiments/gpui/color",
|
||||
"experiments/gpui/geometry",
|
||||
"experiments/gpui/input",
|
||||
"experiments/gpui/layout",
|
||||
"experiments/gpui/scene",
|
||||
"experiments/gpui/style",
|
||||
"moonbitlang/core/debug",
|
||||
}
|
||||
|
||||
// Values
|
||||
pub fn empty() -> AnyElement
|
||||
|
||||
pub fn fill(@geometry.Bounds[@geometry.Pixels], @color.Background) -> PaintQuad
|
||||
|
||||
pub fn[T, E] listener(@app.Context[T], (T, E, Window, @app.Context[T]) -> Unit) -> (E, Window, @app.App) -> Unit
|
||||
|
||||
pub fn outline(@geometry.Bounds[@geometry.Pixels], @color.Hsla, border_style? : @scene.BorderStyle) -> PaintQuad
|
||||
|
||||
// Errors
|
||||
|
||||
// Types and methods
|
||||
pub struct AnyElement {
|
||||
// private fields
|
||||
}
|
||||
pub fn AnyElement::bounds(Self) -> @geometry.Bounds[@geometry.Pixels]?
|
||||
pub fn AnyElement::new(&Element) -> Self
|
||||
pub fn AnyElement::paint(Self, Window, @app.App) -> Unit
|
||||
pub fn AnyElement::prepaint(Self, Window, @app.App) -> Unit
|
||||
pub fn AnyElement::request_layout(Self, Window, @app.App) -> @layout.LayoutId
|
||||
pub impl IntoElement for AnyElement
|
||||
|
||||
pub struct AnyView {
|
||||
entity_id : @app.EntityId
|
||||
// private fields
|
||||
}
|
||||
pub fn[V : Render] AnyView::from_entity(@app.Entity[V]) -> Self
|
||||
pub fn AnyView::into_any_element(Self) -> AnyElement
|
||||
pub impl IntoElement for AnyView
|
||||
|
||||
pub struct ElementStateKey[S] {
|
||||
id : Int32
|
||||
name : String
|
||||
// private fields
|
||||
}
|
||||
pub fn[S] ElementStateKey::new(String) -> Self[S]
|
||||
|
||||
#derive(Eq, @debug.Debug)
|
||||
pub(all) struct Hitbox {
|
||||
id : Int32
|
||||
bounds : @geometry.Bounds[@geometry.Pixels]
|
||||
content_mask : @geometry.ContentMask[@geometry.Pixels]
|
||||
behavior : HitboxBehavior
|
||||
}
|
||||
pub fn Hitbox::is_hovered(Self, Window) -> Bool
|
||||
|
||||
#derive(Eq, Hash, @debug.Debug)
|
||||
pub(all) enum HitboxBehavior {
|
||||
Normal
|
||||
BlockMouse
|
||||
}
|
||||
|
||||
#derive(Eq, @debug.Debug)
|
||||
pub(all) struct PaintQuad {
|
||||
bounds : @geometry.Bounds[@geometry.Pixels]
|
||||
corner_radii : @geometry.Corners[@geometry.Pixels]
|
||||
background : @color.Background
|
||||
border_widths : @geometry.Edges[@geometry.Pixels]
|
||||
border_color : @color.Hsla
|
||||
border_style : @scene.BorderStyle
|
||||
}
|
||||
|
||||
pub struct Window {
|
||||
// private fields
|
||||
}
|
||||
pub fn Window::close(Self) -> Unit
|
||||
pub fn Window::content_mask(Self) -> @geometry.ContentMask[@geometry.Pixels]
|
||||
pub fn Window::dispatch_mouse_event(Self, @input.MouseEvent) -> Bool
|
||||
pub fn Window::draw(Self) -> @scene.Scene
|
||||
pub fn Window::draw_if_dirty(Self) -> Bool
|
||||
pub fn Window::element_offset(Self) -> @geometry.Point[@geometry.Pixels]
|
||||
pub fn Window::element_opacity(Self) -> Double
|
||||
pub fn Window::frame_count(Self) -> Int32
|
||||
pub fn Window::global_element_id(Self) -> String?
|
||||
pub fn Window::insert_hitbox(Self, @geometry.Bounds[@geometry.Pixels], HitboxBehavior) -> Hitbox
|
||||
pub fn Window::is_dirty(Self) -> Bool
|
||||
pub fn Window::layout_bounds(Self, @layout.LayoutId) -> @geometry.Bounds[@geometry.Pixels]
|
||||
pub fn Window::mouse_position(Self) -> @geometry.Point[@geometry.Pixels]
|
||||
pub fn Window::new(@app.App, @geometry.Size[@geometry.Pixels], scale_factor? : Double, rem_size? : @geometry.Pixels) -> Self
|
||||
pub fn Window::on_mouse_event(Self, (@input.MouseEvent, @input.DispatchPhase, Self, @app.App) -> Unit) -> Unit
|
||||
pub fn Window::paint_drop_shadows(Self, @geometry.Bounds[@geometry.Pixels], @geometry.Corners[@geometry.Pixels], Array[@style.BoxShadow]) -> Unit
|
||||
pub fn Window::paint_inset_shadows(Self, @geometry.Bounds[@geometry.Pixels], @geometry.Corners[@geometry.Pixels], Array[@style.BoxShadow]) -> Unit
|
||||
pub fn Window::paint_path(Self, Array[Array[@geometry.Point[@geometry.Pixels]]], @color.Background) -> Unit
|
||||
pub fn Window::paint_primitive(Self, @scene.Primitive) -> Unit
|
||||
pub fn Window::paint_quad(Self, PaintQuad) -> Unit
|
||||
pub fn Window::paint_style(Self, @style.Style, @geometry.Bounds[@geometry.Pixels], () -> Unit) -> Unit
|
||||
pub fn Window::refresh(Self) -> Unit
|
||||
pub fn Window::rem_size(Self) -> @geometry.Pixels
|
||||
pub fn Window::request_layout(Self, @style.Style, Array[@layout.LayoutId]) -> @layout.LayoutId
|
||||
pub fn Window::request_measured_layout(Self, @style.Style, (@geometry.Size[@geometry.Pixels?], @geometry.Size[@layout.AvailableSpace]) -> @geometry.Size[@geometry.Pixels]) -> @layout.LayoutId
|
||||
pub fn Window::resize(Self, @geometry.Size[@geometry.Pixels], scale_factor? : Double) -> Unit
|
||||
pub fn Window::scale_factor(Self) -> Double
|
||||
pub fn Window::scene(Self) -> @scene.Scene
|
||||
pub fn Window::set_rem_size(Self, @geometry.Pixels) -> Unit
|
||||
pub fn[V : Render] Window::set_root_view(Self, @app.Entity[V]) -> Unit
|
||||
pub fn Window::stop_propagation(Self) -> Unit
|
||||
pub fn Window::viewport_size(Self) -> @geometry.Size[@geometry.Pixels]
|
||||
pub fn[R] Window::with_content_mask(Self, @geometry.ContentMask[@geometry.Pixels]?, () -> R) -> R
|
||||
pub fn[R] Window::with_element_id(Self, String?, () -> R) -> R
|
||||
pub fn[R] Window::with_element_offset(Self, @geometry.Point[@geometry.Pixels], () -> R) -> R
|
||||
pub fn[R] Window::with_element_opacity(Self, Double?, () -> R) -> R
|
||||
pub fn[S, R] Window::with_element_state(Self, ElementStateKey[S], (S?) -> (R, S)) -> R
|
||||
|
||||
// Type aliases
|
||||
|
||||
// Traits
|
||||
pub(open) trait Element {
|
||||
fn request_layout(Self, Window, @app.App) -> @layout.LayoutId
|
||||
fn prepaint(Self, @geometry.Bounds[@geometry.Pixels], Window, @app.App) -> Unit
|
||||
fn paint(Self, @geometry.Bounds[@geometry.Pixels], Window, @app.App) -> Unit
|
||||
}
|
||||
|
||||
pub(open) trait IntoElement {
|
||||
fn into_any_element(Self) -> AnyElement
|
||||
}
|
||||
pub impl[V : Render] IntoElement for @app.Entity[V]
|
||||
|
||||
pub(open) trait Render {
|
||||
fn render(Self, Window, @app.Context[Self]) -> AnyElement
|
||||
}
|
||||
Reference in new issue
Block a user