gpui-kit GitHub

Components

SplitButton view

One action, plus the ones it stands in for.

A view survives a frame. Hold it in an Entity with cx.new(..) and reach it with .update(..).

use gpui_kit::controls::SplitButton;

Construct

new(ident: impl Into<Ident>, window: &mut Window, cx: &mut Context<Self>) -> Self

Options

Chain onto the value.

label(label: impl Into<SharedString>) -> Self
icon(glyph: Icon) -> Self
variant(variant: ButtonVariant) -> Self
primary() -> Self
secondary() -> Self
items(items: impl IntoIterator<Item = MenuItem>, cx: &mut Context<Self>) -> Self
menu_name(name: impl Into<SharedString>, cx: &mut Context<Self>) -> Self
default_disabled(disabled: bool) -> Self
on_click(handler: impl Fn(&mut Window, &mut App) + 'static) -> Self

Commands

Need a Context, so they need a view.

set_disabled(disabled: bool, window: &mut Window, cx: &mut Context<Self>)

Queries

Only answer; they change nothing.

menu() -> &Entity<Menu>
is_open(cx: &App) -> bool
open_menu(window: &mut Window, cx: &mut Context<Self>)

Rendered by

Each of these compiles and is captured by the gate, so the code behind them is verified rather than written.

Source: crates/gpui-kit/src/controls/split_button.rs