Start to add base concepts to Readme.
@@ -85,6 +85,59 @@ fn main() {
}
```
+## Base concepts
+
+### Widget
+
+Widgets are the building blocks of user interfaces created with OrbTk like Buttons, TextBoxes, ListViews, Views (Screens) and Grid(Layout)s. Each widget does implement the [Widget trait](https://github.com/redox-os/orbtk/blob/develop/crates/api/src/widget/mod.rs) and is generated by the [widget! macro](https://github.com/redox-os/orbtk/blob/develop/crates/api/src/macros.rs). A widget consists of a name like `Button` and a list of its properties like `text: String16`, `background: Brush` or `count: u32`. After the `build` method of a widget is called, the widget exists as `Entity` (index) and its properties as `Components` in the Entity Component System. The struct of a widget serves itself as builder.
+
+Base usage of the widget! macro:
+
+```rust
+widget!(
+ MyWidget {
+ background: Brush,
+ count: u32,
+ text: String16,
+ ...
+ }
+);
+```
+
+### Widget Templates
+
+Each widget must implement the [Template trait](https://github.com/redox-os/orbtk/blob/develop/crates/api/src/widget/template.rs). A template is used to define the default property values of a widget and to define its structure. A
+Button e.g. consists of a `Container` widget, a `StackPanel` widget and a `TextBlock` widget.
+
+Base usage of the Template trait:
+
+```rust
+impl Template for MyWidget {
+ fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
+ self.name("MyWidget")
+ .background("#000000")
+ .count(0)
+ .text("Initial text")
+ .child(
+ Container::create()
+ // Containers references the same background as MyWidget
+ .background(id)
+ .child(
+ TextBlock::create()
+ // TextBlock references the same text as MyWidget
+ .text(id)
+ .build(ctx)
+ )
+ .build(ctx)
+ )
+ }
+}
+```
+
+### Widget States
+
+tbd
+
## Run Examples
You can find examples in the `examples/` directory.
