pub struct Reorder<Id>(/* private fields */);Expand description
A strip’s tabs in motion: the one being dragged, and the ones sliding
aside for it. Kept by the view beside its Strip, one per strip.
The order changes while the drag is held, so a drop needs no handler: the tab is already where it was let go. Four places to wire:
tabs::bar("panel-tabs")
.on_drag_move(cx.listener(|view, event: &DragMoveEvent<TabDrag>, _, cx| {
view.reorder.follow(&mut view.strip, event.event.position, cx);
cx.notify();
}))
.children(self.strip.tabs().iter().map(|id| {
let tab = tabs::tab(&theme, key, label, state).on_drag(TabDrag(*id), {
let (reorder, id) = (self.reorder.clone(), *id);
move |_, at, _, cx| {
reorder.grab(id, at);
cx.new(|_| gpui::Empty)
}
});
self.reorder.tab(id, tab, &theme, cx)
}))The ghost on_drag returns is still painted at the pointer; an empty one
leaves the carried tab as the only thing that moves.
follow runs for every move of the drag, wherever the pointer is. Pointer
travel off the strip’s axis is ignored.
The carried tab paints deferred, over its neighbours and outside the strip’s clip.
Implementations§
Source§impl<Id: Clone + PartialEq + 'static> Reorder<Id>
impl<Id: Clone + PartialEq + 'static> Reorder<Id>
Sourcepub fn new(painter: Painter) -> Self
pub fn new(painter: Painter) -> Self
painter is the view the strip renders in: it is redrawn while tabs
slide.
Sourcepub fn grab(&self, id: Id, at: Point<Pixels>)
pub fn grab(&self, id: Id, at: Point<Pixels>)
Pick id up. Call it from the tab’s on_drag constructor, with the
press offset that constructor is handed.
Trait Implementations§
Auto Trait Implementations§
impl<Id> !RefUnwindSafe for Reorder<Id>
impl<Id> !Send for Reorder<Id>
impl<Id> !Sync for Reorder<Id>
impl<Id> !UnwindSafe for Reorder<Id>
impl<Id> Freeze for Reorder<Id>
impl<Id> Unpin for Reorder<Id>
impl<Id> UnsafeUnpin for Reorder<Id>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more