mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
macro-ize the emoji menu
This commit is contained in:
parent
b7b0bdc852
commit
991f48dc1f
1 changed files with 18 additions and 35 deletions
|
|
@ -6,6 +6,19 @@ use gam::*;
|
||||||
|
|
||||||
use crate::EMOJI_MENU_NAME;
|
use crate::EMOJI_MENU_NAME;
|
||||||
|
|
||||||
|
// imef_conn must come from outside the scope of the macro because of hygeine rules.
|
||||||
|
macro_rules! emoji_item {
|
||||||
|
($emoji: expr, $imef_conn: ident) => {
|
||||||
|
MenuItem {
|
||||||
|
name: String::from_str(&$emoji.to_string()),
|
||||||
|
action_conn: Some($imef_conn),
|
||||||
|
action_opcode: ImefOpcode::ProcessKeys.to_u32().unwrap(),
|
||||||
|
action_payload: MenuPayload::Scalar([$emoji.into(), '\u{0000}'.into(), '\u{0000}'.into(), '\u{0000}'.into(), ]),
|
||||||
|
close_on_select: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// clearly, this does not scale. but, it's a good demo of the menu system.
|
// clearly, this does not scale. but, it's a good demo of the menu system.
|
||||||
// probably what this will need to turn into is a menu-of-menus....
|
// probably what this will need to turn into is a menu-of-menus....
|
||||||
pub(crate) fn emoji_menu(imef_conn: xous::CID) {
|
pub(crate) fn emoji_menu(imef_conn: xous::CID) {
|
||||||
|
|
@ -15,41 +28,11 @@ pub(crate) fn emoji_menu(imef_conn: xous::CID) {
|
||||||
move || {
|
move || {
|
||||||
menu_matic(
|
menu_matic(
|
||||||
vec![
|
vec![
|
||||||
MenuItem {
|
emoji_item!('😃', imef_conn),
|
||||||
name: String::from_str("😃"),
|
emoji_item!('😒', imef_conn),
|
||||||
action_conn: Some(imef_conn),
|
emoji_item!('🤔', imef_conn),
|
||||||
action_opcode: ImefOpcode::ProcessKeys.to_u32().unwrap(),
|
emoji_item!('😅', imef_conn),
|
||||||
action_payload: MenuPayload::Scalar(['😃'.into(), '\u{0000}'.into(), '\u{0000}'.into(), '\u{0000}'.into(), ]),
|
emoji_item!('🤣', imef_conn),
|
||||||
close_on_select: true,
|
|
||||||
},
|
|
||||||
MenuItem {
|
|
||||||
name: String::from_str("😒"),
|
|
||||||
action_conn: Some(imef_conn),
|
|
||||||
action_opcode: ImefOpcode::ProcessKeys.to_u32().unwrap(),
|
|
||||||
action_payload: MenuPayload::Scalar(['😒'.into(), '\u{0000}'.into(), '\u{0000}'.into(), '\u{0000}'.into(), ]),
|
|
||||||
close_on_select: true,
|
|
||||||
},
|
|
||||||
MenuItem {
|
|
||||||
name: String::from_str("🤔"),
|
|
||||||
action_conn: Some(imef_conn),
|
|
||||||
action_opcode: ImefOpcode::ProcessKeys.to_u32().unwrap(),
|
|
||||||
action_payload: MenuPayload::Scalar(['🤔'.into(), '\u{0000}'.into(), '\u{0000}'.into(), '\u{0000}'.into(), ]),
|
|
||||||
close_on_select: true,
|
|
||||||
},
|
|
||||||
MenuItem {
|
|
||||||
name: String::from_str("😅"),
|
|
||||||
action_conn: Some(imef_conn),
|
|
||||||
action_opcode: ImefOpcode::ProcessKeys.to_u32().unwrap(),
|
|
||||||
action_payload: MenuPayload::Scalar(['😅'.into(), '\u{0000}'.into(), '\u{0000}'.into(), '\u{0000}'.into(), ]),
|
|
||||||
close_on_select: true,
|
|
||||||
},
|
|
||||||
MenuItem {
|
|
||||||
name: String::from_str("🤣"),
|
|
||||||
action_conn: Some(imef_conn),
|
|
||||||
action_opcode: ImefOpcode::ProcessKeys.to_u32().unwrap(),
|
|
||||||
action_payload: MenuPayload::Scalar(['🤣'.into(), '\u{0000}'.into(), '\u{0000}'.into(), '\u{0000}'.into(), ]),
|
|
||||||
close_on_select: true,
|
|
||||||
},
|
|
||||||
MenuItem {
|
MenuItem {
|
||||||
name: String::from_str("Close Menu"),
|
name: String::from_str("Close Menu"),
|
||||||
action_conn: None,
|
action_conn: None,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue