M7 test platform: Platform traits, Application, TestPlatform, VisualTestContext
- input: MouseExitEvent, ModifiersChangedEvent, PlatformInput, and DispatchEventResult. - platform: core Platform and PlatformWindow traits plus WindowId, WindowBounds, WindowOptions, WindowParams, and ClipboardItem. - window: Application, AnyWindowHandle, WindowHandle[V], Window::from_platform, dispatch_input, prevent_default, close/activation hooks, and replace_root_view while keeping standalone Window::new; closing a window releases its root view; hit-testing runs between prepaint and paint gated by pointer containment. - platform/test: TestPlatform, TestWindow (recording Scenes and simulating frames, input, resize, scale factor, active/hover status, and close), TestAppContext, and VisualTestContext with automatic frame pumping and a runaway-redraw guard. - Tests & example: platform tests, TestPlatform/VisualTestContext unit and panic-on-misuse tests, elements visual integration tests, and src/examples/card updated to run on TestAppContext/VisualTestContext. - Docs: updated docs/PORTING.md and README.md.
This commit is contained in:
1 parent
fbe4c081e6
commit
b388a70aa7
25 files changed
+3592
-83
No files matched your search
@@ -7,12 +7,15 @@ import {
|
||||
"experiments/gpui/geometry",
|
||||
"experiments/gpui/input",
|
||||
"experiments/gpui/layout",
|
||||
"experiments/gpui/platform",
|
||||
"experiments/gpui/scene",
|
||||
"experiments/gpui/style",
|
||||
"moonbitlang/core/debug",
|
||||
}
|
||||
|
||||
// Values
|
||||
pub fn application_for(@app.App) -> Application?
|
||||
|
||||
pub fn empty() -> AnyElement
|
||||
|
||||
pub fn fill(@geometry.Bounds[@geometry.Pixels], @color.Background) -> PaintQuad
|
||||
@@ -42,6 +45,36 @@ pub fn[V : Render] AnyView::from_entity(@app.Entity[V]) -> Self
|
||||
pub fn AnyView::into_any_element(Self) -> AnyElement
|
||||
pub impl IntoElement for AnyView
|
||||
|
||||
#derive(Compare, Eq, Hash, @debug.Debug)
|
||||
pub struct AnyWindowHandle {
|
||||
id : @platform.WindowId
|
||||
}
|
||||
pub fn[R] AnyWindowHandle::update(Self, Application, (AnyView, Window, @app.App) -> R) -> R?
|
||||
pub fn AnyWindowHandle::window_id(Self) -> @platform.WindowId
|
||||
|
||||
pub struct Application {
|
||||
app : @app.App
|
||||
platform : &@platform.Platform
|
||||
// private fields
|
||||
}
|
||||
pub fn Application::active_window(Self) -> AnyWindowHandle?
|
||||
pub fn Application::app(Self) -> @app.App
|
||||
pub fn Application::close_window(Self, @platform.WindowId) -> Unit
|
||||
pub fn Application::open_url(Self, String) -> Unit
|
||||
pub fn[V : Render] Application::open_window(Self, @platform.WindowOptions, (Window, @app.App) -> @app.Entity[V]) -> WindowHandle[V]
|
||||
pub fn Application::platform(Self) -> &@platform.Platform
|
||||
pub fn Application::quit(Self) -> Unit
|
||||
pub fn Application::read_from_clipboard(Self) -> @platform.ClipboardItem?
|
||||
pub fn Application::refresh_windows(Self) -> Unit
|
||||
pub fn Application::run(Self, (Self) -> Unit) -> Unit
|
||||
pub fn Application::set_cursor_style(Self, @style.CursorStyle) -> Unit
|
||||
pub fn[R] Application::update_window(Self, AnyWindowHandle, (AnyView, Window, @app.App) -> R) -> R?
|
||||
pub fn Application::window(Self, @platform.WindowId) -> Window?
|
||||
pub fn Application::window_count(Self) -> Int32
|
||||
pub fn Application::windows(Self) -> Array[AnyWindowHandle]
|
||||
pub fn Application::with_platform(&@platform.Platform) -> Self
|
||||
pub fn Application::write_to_clipboard(Self, @platform.ClipboardItem) -> Unit
|
||||
|
||||
pub struct ElementStateKey[S] {
|
||||
id : Int32
|
||||
name : String
|
||||
@@ -77,8 +110,12 @@ pub(all) struct PaintQuad {
|
||||
pub struct Window {
|
||||
// private fields
|
||||
}
|
||||
pub fn Window::activate_window(Self) -> Unit
|
||||
pub fn Window::bounds(Self) -> @geometry.Bounds[@geometry.Pixels]
|
||||
pub fn Window::close(Self) -> Unit
|
||||
pub fn Window::content_mask(Self) -> @geometry.ContentMask[@geometry.Pixels]
|
||||
pub fn Window::default_prevented(Self) -> Bool
|
||||
pub fn Window::dispatch_input(Self, @input.PlatformInput) -> @input.DispatchEventResult
|
||||
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
|
||||
@@ -87,33 +124,60 @@ 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_closed(Self) -> Bool
|
||||
pub fn Window::is_dirty(Self) -> Bool
|
||||
pub fn Window::is_window_active(Self) -> Bool
|
||||
pub fn Window::is_window_hovered(Self) -> Bool
|
||||
pub fn Window::layout_bounds(Self, @layout.LayoutId) -> @geometry.Bounds[@geometry.Pixels]
|
||||
pub fn Window::modifiers(Self) -> @input.Modifiers
|
||||
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_close(Self, (@app.App) -> Unit) -> Unit
|
||||
pub fn Window::on_mouse_event(Self, (@input.MouseEvent, @input.DispatchPhase, Self, @app.App) -> Unit) -> Unit
|
||||
pub fn Window::on_should_close(Self, (Self, @app.App) -> Bool) -> Unit
|
||||
pub fn Window::on_window_active_change(Self, (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::prevent_default(Self) -> Unit
|
||||
pub fn Window::read_from_clipboard(Self) -> @platform.ClipboardItem?
|
||||
pub fn Window::refresh(Self) -> Unit
|
||||
pub fn Window::rem_size(Self) -> @geometry.Pixels
|
||||
pub fn Window::remove_window(Self) -> Unit
|
||||
pub fn[V : Render] Window::replace_root_view(Self, (Self, @app.Context[V]) -> V) -> @app.Entity[V]
|
||||
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::root_view(Self) -> AnyView?
|
||||
pub fn Window::scale_factor(Self) -> Double
|
||||
pub fn Window::scene(Self) -> @scene.Scene
|
||||
pub fn Window::set_cursor_style(Self, @style.CursorStyle) -> Unit
|
||||
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::set_window_title(Self, String) -> Unit
|
||||
pub fn Window::stop_propagation(Self) -> Unit
|
||||
pub fn Window::viewport_size(Self) -> @geometry.Size[@geometry.Pixels]
|
||||
pub fn Window::window_id(Self) -> @platform.WindowId
|
||||
pub fn Window::window_title(Self) -> String?
|
||||
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
|
||||
pub fn Window::write_to_clipboard(Self, @platform.ClipboardItem) -> Unit
|
||||
|
||||
pub struct WindowHandle[V] {
|
||||
id : @platform.WindowId
|
||||
// private fields
|
||||
}
|
||||
pub fn[V] WindowHandle::entity(Self[V]) -> @app.Entity[V]
|
||||
pub fn[V, R] WindowHandle::read_with(Self[V], Application, (V, @app.App) -> R) -> R?
|
||||
pub fn[V] WindowHandle::to_any(Self[V]) -> AnyWindowHandle
|
||||
pub fn[V, R] WindowHandle::update(Self[V], Application, (V, Window, @app.Context[V]) -> R) -> R?
|
||||
pub fn[V] WindowHandle::window_id(Self[V]) -> @platform.WindowId
|
||||
|
||||
// Type aliases
|
||||
|
||||
|
||||
Reference in new issue
Block a user