File tree 3 files changed +40
-0
lines changed
3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,12 @@ name = "game_of_life"
81
81
path = " ../examples/game_of_life/game_of_life.rs"
82
82
required-features = []
83
83
84
+ [[example ]]
85
+ name = " hello_world"
86
+ path = " ../examples/hello_world/hello_world.rs"
87
+ required-features = []
88
+
89
+
84
90
[[example ]]
85
91
name = " hot_reload"
86
92
path = " ../examples/hot_reload/hot_reload.rs"
Original file line number Diff line number Diff line change 23
23
- Shows how to use timers in order to update the game board every 200ms.
24
24
- Performance demo, performs the layout for 5600 rectangles (TODO: Should be replaced by an image).
25
25
26
+ ## ` hello_world `
27
+
28
+ - Hello World "counter" example, used for checking that the README and the wiki aren't out-of-date.
29
+
26
30
## ` hot_reload `
27
31
28
32
- Shows a window where the CSS can be hot-reloaded (you can run the demo, then edit the )
Original file line number Diff line number Diff line change
1
+ extern crate azul;
2
+
3
+ use azul:: { prelude:: * , widgets:: { label:: Label , button:: Button } } ;
4
+
5
+ struct DataModel {
6
+ counter : usize ,
7
+ }
8
+
9
+ impl Layout for DataModel {
10
+ fn layout ( & self , _info : LayoutInfo < Self > ) -> Dom < Self > {
11
+ let label = Label :: new ( format ! ( "{}" , self . counter) ) . dom ( ) ;
12
+ let button = Button :: with_label ( "Update counter" ) . dom ( )
13
+ . with_callback ( On :: MouseUp , Callback ( update_counter) ) ;
14
+
15
+ Dom :: div ( )
16
+ . with_child ( label)
17
+ . with_child ( button)
18
+ }
19
+ }
20
+
21
+ fn update_counter ( app_state : & mut AppState < DataModel > , _: & mut CallbackInfo < DataModel > ) -> UpdateScreen {
22
+ app_state. data . modify ( |state| state. counter += 1 ) ?;
23
+ Redraw
24
+ }
25
+
26
+ fn main ( ) {
27
+ let mut app = App :: new ( DataModel { counter : 0 } , AppConfig :: default ( ) ) . unwrap ( ) ;
28
+ let window = app. create_window ( WindowCreateOptions :: default ( ) , css:: native ( ) ) . unwrap ( ) ;
29
+ app. run ( window) . unwrap ( ) ;
30
+ }
You can’t perform that action at this time.
0 commit comments