Skip to content

Commit

Permalink
Rename muda feature flag to menu and make it default (but not enabled…
Browse files Browse the repository at this point in the history
… on android or ios)
  • Loading branch information
matthunz committed Jun 26, 2024
1 parent 3c6d6ac commit 823f309
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/dioxus-blitz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ version = "0.0.0"
edition = "2021"

[features]
muda = ["dep:muda"]
menu = ["dep:muda"]
default = ["menu"]

[dependencies]
winit = { version = "0.30.2", features = ["rwh_06"] }
Expand Down
9 changes: 6 additions & 3 deletions packages/dioxus-blitz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ pub fn launch_cfg_with_props<P: Clone + 'static, M: 'static>(
)
}

pub fn launch_url(url: &str, #[cfg(target_os = "android")] android_app: android_activity::AndroidApp,) {
pub fn launch_url(
url: &str,
#[cfg(target_os = "android")] android_app: android_activity::AndroidApp,
) {
const USER_AGENT: &str = "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0";
println!("{}", url);

Expand Down Expand Up @@ -153,7 +156,7 @@ fn launch_with_window<Doc: DocumentLike + 'static>(

pending_windows.push(window);

#[cfg(feature = "muda")]
#[cfg(all(feature = "menu", not(any(target_os = "android", target_os = "ios"))))]
let menu_channel = muda::MenuEvent::receiver();

#[cfg(not(any(target_os = "android", target_os = "ios")))]
Expand Down Expand Up @@ -244,7 +247,7 @@ fn launch_with_window<Doc: DocumentLike + 'static>(
_ => (),
}

#[cfg(feature = "muda")]
#[cfg(all(feature = "menu", not(any(target_os = "android", target_os = "ios"))))]
if let Ok(event) = menu_channel.try_recv() {
if event.id == muda::MenuId::new("dev.show_layout") {
for (_, view) in windows.iter_mut() {
Expand Down
9 changes: 5 additions & 4 deletions packages/dioxus-blitz/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub(crate) struct View<'s, Doc: DocumentLike> {
keyboard_modifiers: ModifiersState,

/// Main menu bar of this view's window.
#[cfg(feature = "muda")]
#[cfg(all(feature = "menu", not(any(target_os = "android", target_os = "ios"))))]
menu: Option<muda::Menu>,
}

Expand All @@ -34,7 +34,7 @@ impl<'a, Doc: DocumentLike> View<'a, Doc> {
scene: Scene::new(),
waker: None,
keyboard_modifiers: Default::default(),
#[cfg(feature = "muda")]
#[cfg(all(feature = "menu", not(any(target_os = "android", target_os = "ios"))))]
menu: None,
}
}
Expand Down Expand Up @@ -288,7 +288,7 @@ impl<'a, Doc: DocumentLike> View<'a, Doc> {
}))
.unwrap();

#[cfg(feature = "muda")]
#[cfg(all(feature = "menu", not(any(target_os = "android", target_os = "ios"))))]
{
self.menu = Some(init_menu(
#[cfg(target_os = "windows")]
Expand Down Expand Up @@ -318,7 +318,8 @@ impl<'a, Doc: DocumentLike> View<'a, Doc> {
}
}

#[cfg(feature = "muda")]
#[cfg(all(feature = "menu", not(any(target_os = "android", target_os = "ios"))))]

/// Initialize the default menu bar.
pub fn init_menu(#[cfg(target_os = "windows")] window: &Window) -> Menu {
let menu = Menu::new();
Expand Down

0 comments on commit 823f309

Please sign in to comment.