From 543627690056d566567f7ae9f13e802cd76a7ddd Mon Sep 17 00:00:00 2001 From: ShootingStarDragons Date: Wed, 13 Nov 2024 10:53:31 +0900 Subject: [PATCH] feat: add topbar example --- iced_examples/counter_muti/src/main.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/iced_examples/counter_muti/src/main.rs b/iced_examples/counter_muti/src/main.rs index 8536bfc..dd812f3 100644 --- a/iced_examples/counter_muti/src/main.rs +++ b/iced_examples/counter_muti/src/main.rs @@ -40,6 +40,7 @@ enum WindowInfo { Left, Right, PopUp, + TopBar, } #[derive(Debug, Clone, Copy)] @@ -205,9 +206,19 @@ impl MultiApplication for Counter { info: WindowInfo::Right, }), Message::Close(id) => task::effect(Action::Window(WindowAction::Close(id))), - Message::Wayland(ev) => { - println!("wayland events: {ev:?}"); - Command::none() + Message::Wayland(WaylandEvents::OutputInsert(output)) => { + Command::done(Message::NewLayerShell { + settings: NewLayerShellSettings { + size: Some((0, 20)), + exclusive_zone: None, + anchor: Anchor::Top | Anchor::Right | Anchor::Left, + layer: Layer::Top, + margin: None, + keyboard_interactivity: KeyboardInteractivity::Exclusive, + output_setting: LayerOutputSetting::ChosenOutput(output), + }, + info: WindowInfo::TopBar, + }) } _ => unreachable!(), } @@ -220,6 +231,9 @@ impl MultiApplication for Counter { if let Some(WindowInfo::Right) = self.id_info(id) { return button("close right").on_press(Message::Close(id)).into(); } + if let Some(WindowInfo::TopBar) = self.id_info(id) { + return text("topbar").into(); + } if let Some(WindowInfo::PopUp) = self.id_info(id) { return container(button("close PopUp").on_press(Message::Close(id))) .center_x(Length::Fill)