File tree 2 files changed +40
-0
lines changed
2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ mod fs;
11
11
pub mod graphics;
12
12
mod input;
13
13
pub mod math;
14
+ mod menu;
14
15
mod misc;
15
16
mod net;
16
17
pub mod shapes;
@@ -20,6 +21,7 @@ pub mod sudo;
20
21
pub use fs:: * ;
21
22
pub use graphics:: * ;
22
23
pub use input:: * ;
24
+ pub use menu:: * ;
23
25
pub use misc:: * ;
24
26
pub use net:: * ;
25
27
Original file line number Diff line number Diff line change
1
+ /// Add a custom item on the app menu.
2
+ ///
3
+ /// The `i` index is the value passed into the `handle_menu` callback
4
+ /// when the menu item is selected by the user.
5
+ /// Its value doesn't have to be unique or continious.
6
+ pub fn add_menu_item ( i : u8 , t : & str ) {
7
+ let ptr = t. as_ptr ( ) as u32 ;
8
+ let len = t. len ( ) as u32 ;
9
+ unsafe {
10
+ bindings:: add_menu_item ( i as u32 , ptr, len) ;
11
+ }
12
+ }
13
+
14
+ /// Remove a custom menu item with the given index.
15
+ pub fn remove_menu_item ( i : u8 ) {
16
+ unsafe {
17
+ bindings:: remove_menu_item ( i as u32 ) ;
18
+ }
19
+ }
20
+
21
+ /// Open the app menu.
22
+ ///
23
+ /// It will be opened before the next update.
24
+ /// The current update and then render will proceed as planned.
25
+ pub fn open_menu ( ) {
26
+ unsafe {
27
+ bindings:: open_menu ( ) ;
28
+ }
29
+ }
30
+
31
+ mod bindings {
32
+ #[ link( wasm_import_module = "menu" ) ]
33
+ extern {
34
+ pub ( crate ) fn add_menu_item ( index : u32 , text_ptr : u32 , text_len : u32 ) ;
35
+ pub ( crate ) fn remove_menu_item ( index : u32 ) ;
36
+ pub ( crate ) fn open_menu ( ) ;
37
+ }
38
+ }
You can’t perform that action at this time.
0 commit comments