docking: the host stand-in needs no expect, and the label count drops with New Window

This commit is contained in:
aiongg committed 2026-10-23 16:42:36 +00:00
1 parent 0ecc7d2d39
commit 48272d3932
3 files changed
+11 -5

No files matched your search

+1
View File
@@ -58,6 +58,7 @@ fn driver(layout: Layout<u32>) -> DockDriver<u32, Content> {
DockDriver::new(layout, Content::default()).with_style(|s| s.command_press_floats = true).with_native_host(ORIGIN)
}
#[allow(clippy::expect_used)]
fn window(d: &DockDriver<u32, Content>, panel: u32) -> &Floating<u32> {
d.layout.floating.iter().find(|w| w.contains(&panel)).expect("floating")
}
+9 -4
View File
@@ -46,9 +46,11 @@ pub struct DockDriver<P, C> {
pub float_bounds: Option<Rect>,
/// Passed to [`DockArea::monitors`].
pub monitors: Vec<Monitor>,
/// The stand-in for OS windows, from [`Self::with_native_host`].
/// The stand-in for OS windows, in use after [`Self::with_native_host`].
#[cfg(feature = "native-windows")]
pub host: Option<std::rc::Rc<std::cell::RefCell<NativeHost>>>,
host: Option<std::rc::Rc<std::cell::RefCell<NativeHost>>>,
#[cfg(feature = "native-windows")]
no_host: std::cell::RefCell<NativeHost>,
style: Option<StyleFn>,
shapes: Vec<ClippedShape>,
time: f64,
@@ -74,6 +76,8 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static, C: DockContent<P>> Do
monitors: Vec::new(),
#[cfg(feature = "native-windows")]
host: None,
#[cfg(feature = "native-windows")]
no_host: std::cell::RefCell::new(NativeHost::new(Pos2::ZERO)),
style: None,
shapes: Vec::new(),
time: 0.0,
@@ -158,10 +162,11 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static, C: DockContent<P>> Do
self
}
/// The stand-in for OS windows. Panics without [`Self::with_native_host`].
/// The stand-in for OS windows: without [`Self::with_native_host`], one with no windows
/// that nothing uses.
#[cfg(feature = "native-windows")]
pub fn host(&self) -> std::cell::RefMut<'_, NativeHost> {
self.host.as_ref().expect("with_native_host").borrow_mut()
self.host.as_deref().unwrap_or(&self.no_host).borrow_mut()
}
/// The viewport of the floating window with this [`super::Floating::id`].
+1 -1
View File
@@ -195,7 +195,7 @@ fn localized_covers_every_label_and_contains_takes_a_borrowed_panel() {
});
full.textures_delta.clear();
let values: Vec<&str> = debug.split("_label: \"").skip(1).filter_map(|rest| rest.split('"').next()).collect();
assert_eq!(values.len(), 25, "{debug}");
assert_eq!(values.len(), 24, "{debug}");
assert!(values.iter().all(|v| v.starts_with("dock.")), "a label without a key: {values:?}");
let unique: std::collections::HashSet<_> = values.iter().collect();
assert_eq!(unique.len(), values.len());