1
0
Fork 0
forked from wry/wry

Merge pull request #534 from mahkoh/jorth/better-tile-drag

container: make dragging into mono containers more convenient
This commit is contained in:
mahkoh 2025-07-22 14:39:52 +02:00 committed by GitHub
commit e857bfa1b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1345,9 +1345,41 @@ impl ContainerNode {
return self.tile_drag_destination_mono_titles(source, abs_bounds, abs_x, abs_y);
}
let body = self.mono_body.get();
let bounds = body
let mut bounds = body
.move_(self.abs_x1.get(), self.abs_y1.get())
.intersect(abs_bounds);
if mc.node.node_id() != source && !mc.node.node_is_container() {
let delta = bounds.width() / 5;
for before in [true, false] {
let (x1, x2);
match before {
true => {
x1 = bounds.x1();
x2 = bounds.x1() + delta;
}
false => {
x1 = bounds.x2() - delta;
x2 = bounds.x2();
}
}
if abs_x >= x1 && abs_x < x2 {
return Some(TileDragDestination {
highlight: Rect::new(x1, bounds.y1(), x2, bounds.y2())?,
ty: TddType::Insert {
container: self.clone(),
neighbor: mc.node.clone(),
before,
},
});
}
}
bounds = Rect::new(
bounds.x1() + delta,
bounds.y1(),
bounds.x2() - delta,
bounds.y2(),
)?;
}
return mc
.node
.clone()