mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-02 16:55:24 +00:00
docking: a tab dragged to an edge without a dock makes one
A tab that shares its group moves alone into the new dock with Action::MovePanel, as window.panel.dock does (P6).
This commit is contained in:
1 parent
9359332fd7
commit
bfda13d2af
2 files changed
+15
-3
No files matched your search
@@ -281,6 +281,16 @@ fn group_dropped_on_the_window_edge_without_a_dock_makes_a_new_dock() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tab_dragged_to_the_window_edge_without_a_dock_makes_a_dock_of_that_panel() {
|
||||
let mut d = testing::DockDriver::new(docked(Side::Start, &[&[&[2, 3]]]), TestContent::default());
|
||||
let tab = d.hit(&Hit::Tab(3)).unwrap_or_else(|| panic!("{:?}", d.hits()));
|
||||
let out = d.drag(tab.center(), pos2(795.0, 300.0));
|
||||
assert!(out.actions.contains(&Action::MovePanel { panel: 3, to: Target::NewDock { side: Side::End } }), "{:?}", out.actions);
|
||||
assert_eq!(columns(&d.layout, Side::End), vec![vec![vec![3]]]);
|
||||
assert_eq!(columns(&d.layout, Side::Start), vec![vec![vec![2]]]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_column_takes_groups_anywhere_in_it_and_as_tabs() {
|
||||
let windows = [(5, [400.0, 40.0, 150.0, 120.0]), (6, [400.0, 220.0, 150.0, 120.0]), (7, [400.0, 400.0, 150.0, 120.0])];
|
||||
|
||||
@@ -461,8 +461,9 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Renderer<'_, P> {
|
||||
self.checked(action).map(|action| (action, drop.line))
|
||||
}
|
||||
|
||||
/// The dock target a single tab drag would take: a new group or column of that panel. A new
|
||||
/// dock only takes a panel that is alone in its group.
|
||||
/// The dock target a single tab drag would take: a new group, column or dock of that panel.
|
||||
/// A panel alone in its group takes the group's state to a new dock; one that shares its
|
||||
/// group leaves the other tabs behind (P6).
|
||||
pub(super) fn dock_tab_proposal(&self, ctx: &Context, panel: &P, pointer: Pos2) -> Option<(Option<Action<P>>, Rect)> {
|
||||
if self.dock_covered(ctx, pointer, None) {
|
||||
return None;
|
||||
@@ -476,7 +477,8 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Renderer<'_, P> {
|
||||
{
|
||||
Action::MoveGroup { panel: panel.clone(), to }
|
||||
}
|
||||
Target::NewDock { .. } | Target::Float { .. } => return None,
|
||||
to @ Target::NewDock { .. } => Action::MovePanel { panel: panel.clone(), to },
|
||||
Target::Float { .. } => return None,
|
||||
};
|
||||
self.checked(action).map(|action| (action, drop.line))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user