Files
feresaria/shell/ferese-shell/src/status_ui/bluetooth.rs
T
Samuel Onoja e22f0ebef9 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.
2026-10-12 01:31:34 +01:00

81 lines
2.5 KiB
Rust

use cosmic::iced::Length;
use cosmic::widget::column;
use cosmic::{Element, theme};
use super::bar::status_icon;
use super::controls::status_summary;
use super::{Menu, MenuRows, MenuStyle};
use crate::status::Action;
use crate::{FereseShell, Message};
const DEVICE_LIST_HEIGHT: f32 = 180.0;
fn device_list_height(count: usize) -> Option<f32> {
(count > 4).then_some(DEVICE_LIST_HEIGHT)
}
pub(super) fn view<'a>(shell: &'a FereseShell, mut rows: MenuRows<'a>, style: MenuStyle, in_hub: bool) -> MenuRows<'a> {
let MenuStyle { muted, .. } = style;
if let Some(b) = &shell.status.bluetooth {
rows = rows.push(status_summary(
shell.render,
status_icon(Menu::Bluetooth, &shell.status).0,
if b.enabled {
"Bluetooth is on"
} else {
"Bluetooth is off"
},
if !b.enabled {
"Device connections are paused"
} else if b.devices.is_empty() {
"No devices connected"
} else {
"Your connected devices"
},
style,
b.enabled,
Some((b.enabled, Action::Bluetooth(!b.enabled))),
));
if b.enabled && !b.devices.is_empty() {
let mut devices = column::with_capacity(b.devices.len()).spacing(8);
for device in &b.devices {
devices = devices.push(
column![
shell.render.text(device).size(14),
shell.render.text("Connected").size(12).class(theme::Text::Color(muted)),
]
.spacing(3),
);
}
// Morph scrolls the whole view, so its device list needs no nested viewport.
let list: Element<'_, cosmic::Action<Message>> =
if let Some(height) = device_list_height(b.devices.len()).filter(|_| !in_hub) {
cosmic::iced::widget::scrollable(devices)
.height(height)
.width(Length::Fill)
.into()
} else {
devices.into()
};
rows = rows.push(list);
}
}
rows
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn short_device_lists_shrink_and_long_lists_are_bounded() {
for count in 0..=4 {
assert_eq!(device_list_height(count), None);
}
for count in [5, 20, 1000] {
assert_eq!(device_list_height(count), Some(180.0));
}
}
}