Components / controls
TransferList view
A controlled source/target assignment control.
A view survives a frame. Hold it in an Entity with cx.new(..) and reach it with .update(..).
use gpui_kit::controls::transfer_list::TransferList;
Reviewed in transfer-list.
Construct
new(ident: impl Into<Ident>, window: &mut Window, cx: &mut Context<Self>) -> Self
Options
Chain onto the value.
source(items: impl IntoIterator<Item = TransferItem>) -> Self
target(items: impl IntoIterator<Item = TransferItem>) -> Self
source_selected(ids: impl IntoIterator<Item = impl Into<SharedString>>) -> Self
target_selected(ids: impl IntoIterator<Item = impl Into<SharedString>>) -> Self
source_label(label: impl Into<SharedString>) -> Self
target_label(label: impl Into<SharedString>) -> Self
Commands
Need a Context, so they need a view.
set_items(source: Vec<TransferItem>, target: Vec<TransferItem>, cx: &mut Context<Self>)
set_selection(source: Vec<SharedString>, target: Vec<SharedString>, cx: &mut Context<Self>)
set_labels(source: SharedString, target: SharedString, cx: &mut Context<Self>)
set_control_size(size: ControlSize, cx: &mut Context<Self>)
set_disabled(disabled: bool, cx: &mut Context<Self>)
set_query(query: impl Into<SharedString>, cx: &mut Context<Self>)
Queries
Only answer; they change nothing.
is_disabled() -> bool
Reports
The variants of the event it emits. It never applies the change itself.
- ToggleSource
- ToggleTarget
- MoveToTarget
- MoveToSource
- QueryChanged
Example · transfer-list
fn transfer_list(window: &mut Window, cx: &mut App) -> AnyElement {
if !cx.has_global::<SceneTransferList>() {
let control = cx.new(|cx| {
TransferList::new("scene.transfer-list", window, cx)
.source([
TransferItem::new("runtime", "Native runtime"),
TransferItem::new("gateway", "Remote gateway"),
TransferItem::new("preview", "Preview models").disabled(true),
])
.target([TransferItem::new("logs", "Run logs")])
.source_selected(["gateway"])
.target_selected(["logs"])
.source_label("Available capabilities")
.target_label("Assigned capabilities")
});
cx.set_global(SceneTransferList { control });
}
let theme = cx.theme().clone();
let control = cx.global::<SceneTransferList>().control.clone();
stack(&theme)
.w(px(720.0))
.child(caption(
&theme,
"Each pane reports stable item intents; the host performs the assignment",
))
.child(control)
.into_any_element()
}