diff --git a/src/layout.zig b/src/layout.zig index 2f16139..0378e29 100644 --- a/src/layout.zig +++ b/src/layout.zig @@ -1,16 +1,13 @@ -//! Dynamic dispatch for layout implementations. -//! Each layout should at least implement these functions: -//! - handle(this: *@This(), event: Event) anyerror!*std.ArrayList(Event) {} -//! - render(this: *@This(), renderer: *Renderer) anyerror!void {} -//! - deinit(this: *@This()) void {} +//! Dynamic dispatch for layout implementations. Each `Layout` has to implement +//! the `Layout.Interface`. //! //! Create a `Layout` using `createFrom(object: anytype)` and use them through -//! the defined interface. The layout will take care of calling the correct -//! implementation of the corresponding underlying type. +//! the defined `Layout.Interface`. The layout will take care of calling the +//! correct implementation of the corresponding underlying type. //! //! Each `Layout` is responsible for clearing the allocated memory of the used -//! widgets when deallocated. This means that `deinit()` will also deallocate -//! every used widget too. +//! `Element`s (union of `Layout` or `Widget`) when deallocated. This means +//! that `deinit()` will also deallocate every used `Element` too. //! //! When `Layout.render` is called the provided `Renderer` type is expected //! which handles how contents are rendered for a given layout. @@ -95,7 +92,6 @@ pub fn Layout(comptime Event: type, comptime Renderer: type) type { }; // test widget implementation satisfies the interface comptime Type.Interface.satisfiedBy(Type); - // TODO: there is a dependency loop (due to the necessary `Layout` type for the `Element`) comptime Type.Interface.satisfiedBy(Type.HStack); comptime Type.Interface.satisfiedBy(Type.VStack); comptime Type.Interface.satisfiedBy(Type.Padding); diff --git a/src/widget.zig b/src/widget.zig index 546434e..1fb77db 100644 --- a/src/widget.zig +++ b/src/widget.zig @@ -1,9 +1,9 @@ -//! Dynamic dispatch for widget implementations. -//! Each `Widget` has to implement the `WidgetInterface` +//! Dynamic dispatch for widget implementations. Each `Widget` has to implement +//! the `Widget.Interface`. //! //! Create a `Widget` using `createFrom(object: anytype)` and use them through -//! the defined interface. The widget will take care of calling the correct -//! implementation of the corresponding underlying type. +//! the defined `Widget.Interface`. The widget will take care of calling the +//! correct implementation of the corresponding underlying type. //! //! Each `Widget` may cache its content and should if the contents will not //! change for a long time.