Add panel-wide styles and the Morph hub (#26)
Panel appearance now applies to the whole panel, with seven styles: Floating, Capsules, Notch, Edge to edge, Fused islands, Adaptive and Morph. - Share composition, geometry, and motion through the renderer-independent `ferese-panel` crate, including native materials, input regions, and Settings previews. - Add the Morph hub with media, calendar, notifications, controls, workspace previews, hover feedback, and attached mode. Keep recording and low-battery status visible and respect window clearance. - Cache workspace preview geometry, draw thumbnails directly, centralize Morph transitions, and keep rendering settings local to each shell instance. - Put Record Screen in the Morph header and show the display control only when an external monitor is connected. Update panel documentation, the desktop screenshot, and native check style names. Local validation included 660 compositor tests, 191 shell tests, isolated preview-cache checks, GPU Morph captures at 1×/1.25×/1.5×, formatting, and Clippy with warnings denied. The final header change passed all 23 Morph tests. Release workflow jobs are skipped for this PR.
This commit is contained in:
1 parent
42c3b290dd
commit
e22f0ebef9
131 files changed
+12562
-1634
No files matched your search
@@ -32,6 +32,7 @@ struct MenuStyle {
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Menu {
|
||||
Workspaces,
|
||||
Network,
|
||||
Bluetooth,
|
||||
Audio,
|
||||
@@ -74,6 +75,7 @@ impl Menu {
|
||||
|
||||
fn title(self) -> &'static str {
|
||||
match self {
|
||||
Self::Workspaces => "Workspaces",
|
||||
Self::System => "Control Center",
|
||||
Self::Overflow => "Panel items",
|
||||
Self::Network => "Wi-Fi",
|
||||
@@ -95,7 +97,7 @@ impl Menu {
|
||||
Self::Battery => status.battery.is_some(),
|
||||
Self::Calendar | Self::Recording | Self::Media => true,
|
||||
Self::Notifications => status.notifications.is_some(),
|
||||
Self::System | Self::Overflow => true,
|
||||
Self::System | Self::Overflow | Self::Workspaces => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -161,8 +163,151 @@ impl OpenMenu {
|
||||
}
|
||||
|
||||
impl FereseShell {
|
||||
pub(crate) fn view_hub_menu(&self, kind: Menu, opacity: f32) -> Element<'_, cosmic::Action<Message>> {
|
||||
let theme = self.config.theme;
|
||||
let style = MenuStyle {
|
||||
theme,
|
||||
primary: color_with_opacity(theme.text_primary, opacity),
|
||||
muted: color_with_opacity(theme.text_muted, opacity),
|
||||
opacity,
|
||||
};
|
||||
let mut rows = column::with_capacity(8).spacing(8).width(Length::Fill);
|
||||
if kind == Menu::Network
|
||||
&& let Some(network) = &self.status.network
|
||||
{
|
||||
rows = rows.push(toggle_row(
|
||||
self.render,
|
||||
"Wi-Fi",
|
||||
network.enabled,
|
||||
Action::Wifi(!network.enabled),
|
||||
theme,
|
||||
opacity,
|
||||
));
|
||||
}
|
||||
if kind == Menu::Audio
|
||||
&& let Some(audio) = &self.status.audio
|
||||
{
|
||||
rows = rows.push(toggle_row(
|
||||
self.render,
|
||||
"Mute",
|
||||
audio.muted,
|
||||
Action::Mute(!audio.muted),
|
||||
theme,
|
||||
opacity,
|
||||
));
|
||||
}
|
||||
let mut rows = match kind {
|
||||
Menu::System => system::view(self, rows, style, true),
|
||||
Menu::Network => network::view(self, rows, style),
|
||||
Menu::Bluetooth => bluetooth::view(self, rows, style, true),
|
||||
Menu::Audio => audio::view(self, rows, style, false),
|
||||
Menu::Battery => battery::view(self, rows, style),
|
||||
Menu::Calendar => rows.push(calendar::hub(self.render, self.calendar_offset, theme, opacity)),
|
||||
Menu::Media => media::hub(self, rows, style),
|
||||
Menu::Notifications => {
|
||||
let mut rows = notification_controls(self, rows, style, true);
|
||||
if self.notifications.entries.is_empty() {
|
||||
rows = rows.push(
|
||||
self.render
|
||||
.text("No notifications")
|
||||
.size(13)
|
||||
.class(theme::Text::Color(style.muted)),
|
||||
);
|
||||
} else {
|
||||
rows = rows.push(menu_button(
|
||||
self.render,
|
||||
"Clear notifications",
|
||||
Message::ClearNotifications,
|
||||
style.muted,
|
||||
opacity,
|
||||
));
|
||||
for notice in &self.notifications.entries {
|
||||
rows = rows.push(control_card(
|
||||
self.render,
|
||||
column![
|
||||
row![
|
||||
self.render
|
||||
.text(notice.app.clone())
|
||||
.size(11)
|
||||
.class(theme::Text::Color(style.muted))
|
||||
.width(Length::Fill),
|
||||
menu_button(
|
||||
self.render,
|
||||
"×",
|
||||
Message::RemoveNotification(notice.id),
|
||||
style.muted,
|
||||
opacity
|
||||
)
|
||||
],
|
||||
self.render
|
||||
.text(notice.title.clone())
|
||||
.size(13)
|
||||
.class(theme::Text::Color(style.primary)),
|
||||
self.render
|
||||
.text(notice.body.clone())
|
||||
.size(12)
|
||||
.class(theme::Text::Color(style.muted)),
|
||||
]
|
||||
.spacing(4)
|
||||
.into(),
|
||||
style.primary,
|
||||
opacity,
|
||||
));
|
||||
for (action, label) in ¬ice.actions {
|
||||
rows = rows.push(menu_button(
|
||||
self.render,
|
||||
label,
|
||||
Message::InvokeNotification(notice.id, action.clone()),
|
||||
style.primary,
|
||||
opacity,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
rows
|
||||
}
|
||||
Menu::Recording => rows.push(menu_button(
|
||||
self.render,
|
||||
if self.recorder.busy() {
|
||||
"Stop recording"
|
||||
} else {
|
||||
"Record screen"
|
||||
},
|
||||
if self.recorder.busy() {
|
||||
Message::StopRecording
|
||||
} else {
|
||||
Message::StartRecording
|
||||
},
|
||||
style.primary,
|
||||
opacity,
|
||||
)),
|
||||
Menu::Overflow | Menu::Workspaces => rows,
|
||||
};
|
||||
if !kind.available(&self.status) {
|
||||
rows = rows.push(
|
||||
self.render
|
||||
.text("Service unavailable")
|
||||
.size(13)
|
||||
.class(theme::Text::Color(style.muted)),
|
||||
);
|
||||
}
|
||||
if let Some(error) = self.status_error.as_ref().and_then(|error| kind.action_error(error)) {
|
||||
rows = rows.push(self.render.text(error).size(12).class(theme::Text::Color(style.muted)));
|
||||
}
|
||||
container(rows)
|
||||
.width(Length::Fill)
|
||||
.class(theme::Container::custom(move |_| container::Style {
|
||||
text_color: Some(style.primary),
|
||||
icon_color: Some(style.primary),
|
||||
..Default::default()
|
||||
}))
|
||||
.into()
|
||||
}
|
||||
|
||||
fn view_status_menu(&self) -> Element<'_, cosmic::Action<Message>> {
|
||||
let Some(menu) = &self.menu else { return text("").into() };
|
||||
let Some(menu) = &self.menu else {
|
||||
return self.render.text("").into();
|
||||
};
|
||||
motion::frame_driven(
|
||||
menu.motion.revision(),
|
||||
|now| self.view_status_menu_at(now),
|
||||
@@ -186,7 +331,7 @@ impl FereseShell {
|
||||
|
||||
fn view_status_menu_at(&self, now: Instant) -> Element<'_, cosmic::Action<Message>> {
|
||||
let Some(menu) = &self.menu else {
|
||||
return text("").into();
|
||||
return self.render.text("").into();
|
||||
};
|
||||
if menu.kind == Menu::Notifications && self.notifications.ready {
|
||||
return cosmic::widget::autosize::autosize(
|
||||
@@ -217,9 +362,9 @@ impl FereseShell {
|
||||
.into(),
|
||||
color(theme.accent),
|
||||
p,
|
||||
motion::radius(20.),
|
||||
self.render.radius(20.),
|
||||
);
|
||||
let mut heading = ferese_theme::menus::heading(badge, kind.title(), shell_font());
|
||||
let mut heading = ferese_theme::menus::heading(badge, kind.title(), self.render.font);
|
||||
let style = MenuStyle {
|
||||
theme,
|
||||
primary,
|
||||
@@ -237,19 +382,24 @@ impl FereseShell {
|
||||
rows = rows.push(heading);
|
||||
}
|
||||
rows = match kind {
|
||||
Menu::System => system::view(self, rows, style),
|
||||
Menu::System => system::view(self, rows, style, false),
|
||||
Menu::Network => network::view(self, rows, style),
|
||||
Menu::Bluetooth => bluetooth::view(self, rows, style),
|
||||
Menu::Bluetooth => bluetooth::view(self, rows, style, false),
|
||||
Menu::Audio => audio::view(self, rows, style, false),
|
||||
Menu::Battery => battery::view(self, rows, style),
|
||||
Menu::Calendar => rows.push(calendar::view(self.calendar_offset, theme, p)),
|
||||
Menu::Calendar => rows.push(calendar::view(self.render, self.calendar_offset, theme, p)),
|
||||
Menu::Notifications => notification_controls(self, rows, style, false),
|
||||
Menu::Recording => rows,
|
||||
Menu::Recording | Menu::Workspaces => rows,
|
||||
Menu::Overflow => self.view_panel_overflow(rows),
|
||||
Menu::Media => media::view(self, rows, style),
|
||||
};
|
||||
if kind != Menu::Calendar && !kind.available(&self.status) {
|
||||
rows = rows.push(text("Service unavailable").size(13).class(theme::Text::Color(muted)));
|
||||
rows = rows.push(
|
||||
self.render
|
||||
.text("Service unavailable")
|
||||
.size(13)
|
||||
.class(theme::Text::Color(muted)),
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(error) = self
|
||||
@@ -257,7 +407,7 @@ impl FereseShell {
|
||||
.as_ref()
|
||||
.and_then(|error| menu.kind.action_error(error))
|
||||
{
|
||||
rows = rows.push(text(error).size(12).class(theme::Text::Color(Color {
|
||||
rows = rows.push(self.render.text(error).size(12).class(theme::Text::Color(Color {
|
||||
a: p,
|
||||
..Color::from_rgb8(230, 172, 90)
|
||||
})));
|
||||
@@ -322,9 +472,9 @@ fn notification_controls<'a>(
|
||||
opacity: p,
|
||||
} = style;
|
||||
if let Some(n) = &shell.status.notifications {
|
||||
let toggle = toggle_row("Do Not Disturb", n.dnd, Action::Dnd(!n.dnd), theme, p);
|
||||
let toggle = toggle_row(shell.render, "Do Not Disturb", n.dnd, Action::Dnd(!n.dnd), theme, p);
|
||||
rows = rows.push(if combined {
|
||||
control_card(toggle, primary, p)
|
||||
control_card(shell.render, toggle, primary, p)
|
||||
} else {
|
||||
toggle
|
||||
});
|
||||
@@ -332,17 +482,20 @@ fn notification_controls<'a>(
|
||||
if !combined {
|
||||
rows = rows
|
||||
.push(
|
||||
text(if n.count == 0 {
|
||||
"No notifications".to_owned()
|
||||
} else if n.count == 1 {
|
||||
"1 notification".to_owned()
|
||||
} else {
|
||||
format!("{} notifications", n.count)
|
||||
})
|
||||
.size(13)
|
||||
.class(theme::Text::Color(muted)),
|
||||
shell
|
||||
.render
|
||||
.text(if n.count == 0 {
|
||||
"No notifications".to_owned()
|
||||
} else if n.count == 1 {
|
||||
"1 notification".to_owned()
|
||||
} else {
|
||||
format!("{} notifications", n.count)
|
||||
})
|
||||
.size(13)
|
||||
.class(theme::Text::Color(muted)),
|
||||
)
|
||||
.push(menu_button(
|
||||
shell.render,
|
||||
"Open notification center",
|
||||
Message::Control(Action::Notifications),
|
||||
primary,
|
||||
|
||||
Reference in new issue
Block a user