Skip to content

Commit

Permalink
feat: add topbar example
Browse files Browse the repository at this point in the history
  • Loading branch information
Decodetalkers committed Nov 13, 2024
1 parent 13fe005 commit 4bc107b
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions iced_examples/counter_muti/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ enum WindowInfo {
Left,
Right,
PopUp,
TopBar,
}

#[derive(Debug, Clone, Copy)]
Expand Down Expand Up @@ -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!(),
}
Expand All @@ -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)
Expand Down

0 comments on commit 4bc107b

Please sign in to comment.