Format Rust sources at 100 columns

This commit is contained in:
Samuel Onoja committed 2026-10-22 01:28:03 +01:00
1 parent 4661f595f8
commit 610478f8c7
336 files changed
+23497 -7892

No files matched your search

@@ -23,27 +23,46 @@ fn a_binding_mode_owns_the_panel_instead_of_hidden_morph_hover_or_menus() {
.reset(&shell.config.panels[0], &shell.snapshot, Some("test"));
let id = shell.outputs[0].bar;
shell.snapshot.binding_mode = Some("resize".into());
let allocation = shell.outputs[0].runtime.hub.as_ref().unwrap().borrow().allocation;
let allocation = shell.outputs[0]
.runtime
.hub
.as_ref()
.unwrap()
.borrow()
.allocation;
drop(shell.hub_hover(id, true));
assert_eq!(shell.hub_mode(id), Some(ferese_panel::morph::Mode::Idle));
drop(shell.open_hub(id, status_ui::Menu::Calendar));
assert_eq!(shell.hub_mode(id), Some(ferese_panel::morph::Mode::Idle));
assert_eq!(
shell.outputs[0].runtime.hub.as_ref().unwrap().borrow().allocation,
shell.outputs[0]
.runtime
.hub
.as_ref()
.unwrap()
.borrow()
.allocation,
allocation
);
}
#[test]
fn mode_entry_dismisses_existing_popovers_and_collapses_expanded_morph_content() {
for style in [ferese_panel::PanelStyle::Flat, ferese_panel::PanelStyle::Morph] {
for style in [
ferese_panel::PanelStyle::Flat,
ferese_panel::PanelStyle::Morph,
] {
let mut shell = crate::tests::shell_with_measured_panel();
shell.config.panels[0].style = style;
shell.outputs[0]
.runtime
.reset(&shell.config.panels[0], &shell.snapshot, Some("test"));
let id = shell.outputs[0].bar;
let collapsed = shell.outputs[0].runtime.hub.as_ref().map(|hub| hub.borrow().allocation);
let collapsed = shell.outputs[0]
.runtime
.hub
.as_ref()
.map(|hub| hub.borrow().allocation);
if collapsed.is_some() {
drop(shell.open_hub(id, status_ui::Menu::Calendar));
assert!(shell.hub_mode(id).unwrap().expanded());
@@ -117,13 +136,19 @@ fn mode_name_and_escape_hint_fit_the_published_shape_in_every_panel_style() {
.hub
.as_ref()
.map(|hub| hub.borrow().allocation)
.unwrap_or([1200, shell.config.panels[0].resolved_geometry().height as u32]);
let viewport = Rectangle::with_size(Size::new(allocation[0] as f32, allocation[1] as f32));
.unwrap_or([
1200,
shell.config.panels[0].resolved_geometry().height as u32,
]);
let viewport =
Rectangle::with_size(Size::new(allocation[0] as f32, allocation[1] as f32));
let mut view = shell.view_layer(id);
let mut tree = widget::Tree::new(&view);
let node =
view.as_widget_mut()
.layout(&mut tree, &renderer, &layout::Limits::new(Size::ZERO, viewport.size()));
let node = view.as_widget_mut().layout(
&mut tree,
&renderer,
&layout::Limits::new(Size::ZERO, viewport.size()),
);
let mut messages = Vec::new();
view.as_widget_mut().update(
&mut tree,
@@ -141,7 +166,11 @@ fn mode_name_and_escape_hint_fit_the_published_shape_in_every_panel_style() {
cosmic::Action::App(Message::PanelSurfaceChanged(_, scene)) => Some(scene),
_ => None,
})
.unwrap_or_else(|| panic!("{style}: mode must replace the previous native clipping and input shape"));
.unwrap_or_else(|| {
panic!(
"{style}: mode must replace the previous native clipping and input shape"
)
});
let mut labels = TextBounds::default();
view.as_widget_mut()
.operate(&mut tree, Layout::new(&node), &renderer, &mut labels);
@@ -150,7 +179,10 @@ fn mode_name_and_escape_hint_fit_the_published_shape_in_every_panel_style() {
"{style}: mode name missing"
);
assert!(
labels.0.iter().any(|(text, _)| text.contains("Esc to exit")),
labels
.0
.iter()
.any(|(text, _)| text.contains("Esc to exit")),
"{style}: exit hint missing"
);
for (text, bounds) in &labels.0 {
@@ -186,7 +218,11 @@ fn mode_name_and_escape_hint_fit_the_published_shape_in_every_panel_style() {
mouse::Cursor::Unavailable,
&viewport,
);
let pixels = renderer.screenshot(Size::new(allocation[0], allocation[1]), 1., Color::TRANSPARENT);
let pixels = renderer.screenshot(
Size::new(allocation[0], allocation[1]),
1.,
Color::TRANSPARENT,
);
assert!(
pixels.chunks_exact(4).any(|pixel| pixel[3] > 0),
"{style}: no visible pixels"
+36 -14
View File
@@ -2,7 +2,10 @@ use cosmic::iced::advanced::{Clipboard, Layout, Shell, Widget, layout, mouse, re
use cosmic::iced::{Event, Length, Rectangle, Size, Vector};
use cosmic::{Element, Theme};
pub(super) fn hover<'a, M: 'a>(content: Element<'a, M>, hover: Option<HoverTarget<'a, M>>) -> Element<'a, M> {
pub(super) fn hover<'a, M: 'a>(
content: Element<'a, M>,
hover: Option<HoverTarget<'a, M>>,
) -> Element<'a, M> {
Element::new(Hover { content, hover })
}
@@ -63,7 +66,9 @@ impl<M> Widget<M, Theme, cosmic::Renderer> for Hover<'_, M> {
tree: &widget::Tree,
cursor: mouse::Cursor,
) -> iced_accessibility::A11yTree {
self.content.as_widget().a11y_nodes(layout, &tree.children[0], cursor)
self.content
.as_widget()
.a11y_nodes(layout, &tree.children[0], cursor)
}
fn update(
@@ -88,9 +93,12 @@ impl<M> Widget<M, Theme, cosmic::Renderer> for Hover<'_, M> {
target: &hover.id,
bounds: None,
};
self.content
.as_widget_mut()
.operate(&mut tree.children[0], layout, renderer, &mut target);
self.content.as_widget_mut().operate(
&mut tree.children[0],
layout,
renderer,
&mut target,
);
if matches!(event, Event::Mouse(mouse::Event::CursorLeft))
|| !cursor.is_over(*viewport)
|| !target.bounds.is_some_and(|bounds| cursor.is_over(bounds))
@@ -125,9 +133,15 @@ impl<M> Widget<M, Theme, cosmic::Renderer> for Hover<'_, M> {
cursor: mouse::Cursor,
viewport: &Rectangle,
) {
self.content
.as_widget()
.draw(&tree.children[0], renderer, theme, style, layout, cursor, viewport);
self.content.as_widget().draw(
&tree.children[0],
renderer,
theme,
style,
layout,
cursor,
viewport,
);
}
fn mouse_interaction(
@@ -138,9 +152,13 @@ impl<M> Widget<M, Theme, cosmic::Renderer> for Hover<'_, M> {
viewport: &Rectangle,
renderer: &cosmic::Renderer,
) -> mouse::Interaction {
self.content
.as_widget()
.mouse_interaction(&tree.children[0], layout, cursor, viewport, renderer)
self.content.as_widget().mouse_interaction(
&tree.children[0],
layout,
cursor,
viewport,
renderer,
)
}
fn operate(
@@ -163,8 +181,12 @@ impl<M> Widget<M, Theme, cosmic::Renderer> for Hover<'_, M> {
viewport: &Rectangle,
translation: Vector,
) -> Option<cosmic::iced::advanced::overlay::Element<'a, M, Theme, cosmic::Renderer>> {
self.content
.as_widget_mut()
.overlay(&mut tree.children[0], layout, renderer, viewport, translation)
self.content.as_widget_mut().overlay(
&mut tree.children[0],
layout,
renderer,
viewport,
translation,
)
}
}