mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-08 19:42:12 +00:00
docking: a native floating window's bar shows no title, as its tab names the panel
This commit is contained in:
1 parent
9ff719499d
commit
d201bc1964
2 files changed
+13
-3
No files matched your search
@@ -493,6 +493,16 @@ fn dragging_the_bar_moves_the_os_window() {
|
||||
assert!(d.host().commands.iter().any(|(_, c)| *c == ViewportCommand::StartDrag));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_native_window_names_its_panel_in_its_tab_only() {
|
||||
// As the in-window floating window does: the bar has no title.
|
||||
let mut d = driver(layout(true));
|
||||
d.settle();
|
||||
let viewport = d.viewport(window(&d, 5).id);
|
||||
let texts = texts(&d.host().windows[&viewport].shapes);
|
||||
assert_eq!(texts.iter().filter(|t| *t == "Panel 5").count(), 1, "{texts:?}");
|
||||
}
|
||||
|
||||
fn id_of(d: &DockDriver<u32, Content>) -> u64 {
|
||||
window(d, 5).id
|
||||
}
|
||||
|
||||
@@ -780,7 +780,8 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Renderer<'_, P> {
|
||||
Some(key)
|
||||
}
|
||||
|
||||
/// The bar at the top of a native window: its title and ×. Dragging it moves the window.
|
||||
/// The bar at the top of a native window: its ×, but no title, as the tab names the panel.
|
||||
/// Dragging it moves the window.
|
||||
/// Returns the rects of its buttons.
|
||||
fn native_bar(&mut self, ui: &mut Ui, window: &Floating<P>) -> Vec<Rect> {
|
||||
let Some(first) = window.panels().next().cloned() else { return Vec::new() };
|
||||
@@ -792,10 +793,9 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Renderer<'_, P> {
|
||||
let movable = window.panels().all(|p| self.permissions(p).movable);
|
||||
let closable = self.style.close_button && window.panels().all(|p| self.permissions(p).closable);
|
||||
let (move_label, close_label) = (self.style.move_window_label.clone(), self.style.close_window_label.clone());
|
||||
let title = crate::docking::dock_model::first_active(&window.root).map(|p| self.label_of(p)).unwrap_or_default();
|
||||
// On macOS the bar keeps the arrow, as native title bars do: AppKit's resize areas
|
||||
// cover its ends and top edge, and a cursor set over them flickers with AppKit's.
|
||||
let mut bar = TitleBar::new(self.id.with(("native-bar", window.id)), &move_label).title(title).movable(movable && !OS_RESIZES);
|
||||
let mut bar = TitleBar::new(self.id.with(("native-bar", window.id)), &move_label).movable(movable && !OS_RESIZES);
|
||||
if closable {
|
||||
bar = bar.close(&close_label).close_at(close_hit, close_glyph);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user