Skip to content

Commit

Permalink
chore: bump iced_layershell
Browse files Browse the repository at this point in the history
  • Loading branch information
Decodetalkers committed Dec 8, 2024
1 parent e6aa131 commit 605fd53
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 47 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lala_bar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ iced = { version = "0.13.1", features = [
] }
iced_runtime = "0.13.2"
tokio = { version = "1.42", features = ["full"] }
iced_layershell = "0.12.0"
iced_layershell = "0.13.0-rc1"
iced_futures = "0.13.2"
env_logger = "0.11.5"
tracing = "0.1.40"
Expand Down
11 changes: 3 additions & 8 deletions lala_bar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use zbus_mpirs::ServiceInfo;
use futures::channel::mpsc::Sender;
use iced_aw::date_picker::Date;
use iced_aw::time_picker::Time;
use iced_layershell::{to_layer_message, WindowInfoMarker};
use iced_layershell::to_layer_message;

mod aximer;
mod config;
Expand Down Expand Up @@ -35,23 +35,18 @@ pub fn main() -> Result<(), iced_layershell::Error> {
music_bar::run_lalabar()
}

#[derive(Debug, Clone, PartialEq, WindowInfoMarker)]
#[derive(Debug, Clone, PartialEq)]
pub enum LaLaInfo {
#[singleton]
Launcher,
Notify(Box<NotifyUnitWidgetInfo>),
#[singleton]
HiddenInfo,
#[singleton]
RightPanel,
ErrorHappened(iced::window::Id),
#[singleton]
Calendar,
#[singleton]
TimePicker,
}

#[to_layer_message(multi, info_name = "LaLaInfo")]
#[to_layer_message(multi)]
#[derive(Debug, Clone)]
pub enum Message {
RequestPre,
Expand Down
83 changes: 53 additions & 30 deletions lala_bar/src/music_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ pub fn run_lalabar() -> iced_layershell::Result {
LalaMusicBar::namespace,
LalaMusicBar::update,
LalaMusicBar::view,
LalaMusicBar::id_info,
LalaMusicBar::set_id_info,
LalaMusicBar::remove_id,
)
.layer_settings(LayerShellSettings {
Expand Down Expand Up @@ -631,6 +629,8 @@ impl LalaMusicBar {
calendar_id,
)));
} else {
let id = iced::window::Id::unique();
self.set_id_info(id, LaLaInfo::Calendar);
if let Some(time_picker_id) = self.time_picker_id {
return iced_runtime::task::Task::batch([
iced_runtime::task::effect(Action::Window(WindowAction::Close(
Expand All @@ -647,7 +647,7 @@ impl LalaMusicBar {
use_last_output: true,
..Default::default()
},
info: LaLaInfo::Calendar,
id,
}),
]);
}
Expand All @@ -662,7 +662,7 @@ impl LalaMusicBar {
use_last_output: true,
..Default::default()
},
info: LaLaInfo::Calendar,
id,
});
}
}
Expand All @@ -673,6 +673,8 @@ impl LalaMusicBar {
time_picker_id,
)));
} else {
let id = iced::window::Id::unique();
self.set_id_info(id, LaLaInfo::TimePicker);
if let Some(calendar_id) = self.calendar_id {
return iced_runtime::task::Task::batch([
iced_runtime::task::effect(Action::Window(WindowAction::Close(
Expand All @@ -689,7 +691,7 @@ impl LalaMusicBar {
use_last_output: true,
..Default::default()
},
info: LaLaInfo::TimePicker,
id,
}),
]);
}
Expand All @@ -704,7 +706,7 @@ impl LalaMusicBar {
use_last_output: true,
..Default::default()
},
info: LaLaInfo::TimePicker,
id,
});
}
}
Expand Down Expand Up @@ -807,6 +809,8 @@ impl LalaMusicBar {
return Command::none();
}
self.launcher = Some(Launcher::new());
let id = iced::window::Id::unique();
self.set_id_info(id, LaLaInfo::Launcher);
return Command::batch(vec![
Command::done(Message::NewLayerShell {
settings: NewLayerShellSettings {
Expand All @@ -819,7 +823,7 @@ impl LalaMusicBar {
use_last_output: false,
..Default::default()
},
info: LaLaInfo::Launcher,
id,
}),
self.launcher.as_ref().unwrap().focus_input(),
]);
Expand All @@ -832,6 +836,8 @@ impl LalaMusicBar {
return Command::none();
}
self.launcher = Some(Launcher::new());
let id = iced::window::Id::unique();
self.set_id_info(id, LaLaInfo::Launcher);
return Command::batch(vec![
Command::done(Message::NewLayerShell {
settings: NewLayerShellSettings {
Expand All @@ -845,7 +851,7 @@ impl LalaMusicBar {
use_last_output: false,
..Default::default()
},
info: LaLaInfo::Launcher,
id,
}),
self.launcher.as_ref().unwrap().focus_input(),
]);
Expand All @@ -857,6 +863,8 @@ impl LalaMusicBar {
}
return Command::none();
}
let id = iced::window::Id::unique();
self.set_id_info(id, LaLaInfo::RightPanel);
return Command::done(Message::NewLayerShell {
settings: NewLayerShellSettings {
size: Some((300, 0)),
Expand All @@ -868,7 +876,7 @@ impl LalaMusicBar {
use_last_output: false,
..Default::default()
},
info: LaLaInfo::RightPanel,
id,
});
}
Message::Notify(NotifyMessage::UnitAdd(notify)) => {
Expand Down Expand Up @@ -931,6 +939,31 @@ impl LalaMusicBar {
}
}
} else {
// NOTE: remove the new one
let to_adjust_notification = &showned_notifications_now[1..];
for ((_, unit), (id, _)) in
to_adjust_notification.iter().zip(showned_values.iter())
{
commands.push(Command::done(Message::MarginChange {
id: **id,
margin: (unit.upper, 10, 10, 10),
}));
}

drop(showned_values);
drop(showned_notifications_now);

let id = iced::window::Id::unique();
self.set_id_info(
id,
LaLaInfo::Notify(Box::new(NotifyUnitWidgetInfo {
to_delete: false,
counter: 0,
upper: 10,
inline_reply: String::new(),
unit: *notify.clone(),
})),
);
// NOTE: if not all shown, then do as the way before
commands.push(Command::done(Message::NewLayerShell {
settings: NewLayerShellSettings {
Expand All @@ -943,25 +976,8 @@ impl LalaMusicBar {
use_last_output: true,
events_transparent: true,
},
info: LaLaInfo::Notify(Box::new(NotifyUnitWidgetInfo {
to_delete: false,
counter: 0,
upper: 10,
inline_reply: String::new(),
unit: *notify.clone(),
})),
id,
}));

// NOTE: remove the new one
let to_adjust_notification = &showned_notifications_now[1..];
for ((_, unit), (id, _)) in
to_adjust_notification.iter().zip(showned_values.iter())
{
commands.push(Command::done(Message::MarginChange {
id: **id,
margin: (unit.upper, 10, 10, 10),
}));
}
}
}

Expand All @@ -971,6 +987,8 @@ impl LalaMusicBar {
&& !self.quite_mode
&& self.hiddenid.is_none()
{
let id = iced::window::Id::unique();
self.set_id_info(id, LaLaInfo::HiddenInfo);
commands.push(Command::done(Message::NewLayerShell {
settings: NewLayerShellSettings {
size: Some((300, 25)),
Expand All @@ -982,7 +1000,7 @@ impl LalaMusicBar {
use_last_output: true,
..Default::default()
},
info: LaLaInfo::HiddenInfo,
id,
}));
}

Expand All @@ -1006,9 +1024,12 @@ impl LalaMusicBar {
} else {
for (_, notify_info) in self
.notifications
.clone()
.iter()
.filter(|(_, info)| info.counter < MAX_SHOWN_NOTIFICATIONS_COUNT)
{
let id = iced::window::Id::unique();
self.set_id_info(id, LaLaInfo::Notify(Box::new(notify_info.clone())));
commands.push(Command::done(Message::NewLayerShell {
settings: NewLayerShellSettings {
size: Some((300, 130)),
Expand All @@ -1020,12 +1041,14 @@ impl LalaMusicBar {
use_last_output: true,
..Default::default()
},
info: LaLaInfo::Notify(Box::new(notify_info.clone())),
id,
}));
}
if self.notifications.len() > MAX_SHOWN_NOTIFICATIONS_COUNT
&& self.hiddenid.is_none()
{
let id = iced::window::Id::unique();
self.set_id_info(id, LaLaInfo::HiddenInfo);
commands.push(Command::done(Message::NewLayerShell {
settings: NewLayerShellSettings {
size: Some((300, 25)),
Expand All @@ -1037,7 +1060,7 @@ impl LalaMusicBar {
use_last_output: true,
..Default::default()
},
info: LaLaInfo::HiddenInfo,
id,
}));
}
}
Expand Down

0 comments on commit 605fd53

Please sign in to comment.