doc: update layout and widget interface documentation
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 34s
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 34s
This commit is contained in:
@@ -1,16 +1,13 @@
|
|||||||
//! Dynamic dispatch for layout implementations.
|
//! Dynamic dispatch for layout implementations. Each `Layout` has to implement
|
||||||
//! Each layout should at least implement these functions:
|
//! the `Layout.Interface`.
|
||||||
//! - handle(this: *@This(), event: Event) anyerror!*std.ArrayList(Event) {}
|
|
||||||
//! - render(this: *@This(), renderer: *Renderer) anyerror!void {}
|
|
||||||
//! - deinit(this: *@This()) void {}
|
|
||||||
//!
|
//!
|
||||||
//! Create a `Layout` using `createFrom(object: anytype)` and use them through
|
//! Create a `Layout` using `createFrom(object: anytype)` and use them through
|
||||||
//! the defined interface. The layout will take care of calling the correct
|
//! the defined `Layout.Interface`. The layout will take care of calling the
|
||||||
//! implementation of the corresponding underlying type.
|
//! correct implementation of the corresponding underlying type.
|
||||||
//!
|
//!
|
||||||
//! Each `Layout` is responsible for clearing the allocated memory of the used
|
//! Each `Layout` is responsible for clearing the allocated memory of the used
|
||||||
//! widgets when deallocated. This means that `deinit()` will also deallocate
|
//! `Element`s (union of `Layout` or `Widget`) when deallocated. This means
|
||||||
//! every used widget too.
|
//! that `deinit()` will also deallocate every used `Element` too.
|
||||||
//!
|
//!
|
||||||
//! When `Layout.render` is called the provided `Renderer` type is expected
|
//! When `Layout.render` is called the provided `Renderer` type is expected
|
||||||
//! which handles how contents are rendered for a given layout.
|
//! 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
|
// test widget implementation satisfies the interface
|
||||||
comptime Type.Interface.satisfiedBy(Type);
|
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.HStack);
|
||||||
comptime Type.Interface.satisfiedBy(Type.VStack);
|
comptime Type.Interface.satisfiedBy(Type.VStack);
|
||||||
comptime Type.Interface.satisfiedBy(Type.Padding);
|
comptime Type.Interface.satisfiedBy(Type.Padding);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
//! Dynamic dispatch for widget implementations.
|
//! Dynamic dispatch for widget implementations. Each `Widget` has to implement
|
||||||
//! Each `Widget` has to implement the `WidgetInterface`
|
//! the `Widget.Interface`.
|
||||||
//!
|
//!
|
||||||
//! Create a `Widget` using `createFrom(object: anytype)` and use them through
|
//! Create a `Widget` using `createFrom(object: anytype)` and use them through
|
||||||
//! the defined interface. The widget will take care of calling the correct
|
//! the defined `Widget.Interface`. The widget will take care of calling the
|
||||||
//! implementation of the corresponding underlying type.
|
//! correct implementation of the corresponding underlying type.
|
||||||
//!
|
//!
|
||||||
//! Each `Widget` may cache its content and should if the contents will not
|
//! Each `Widget` may cache its content and should if the contents will not
|
||||||
//! change for a long time.
|
//! change for a long time.
|
||||||
|
|||||||
Reference in New Issue
Block a user