This commit is contained in:
2026-10-29 19:58:13 +07:00
parent cc22baca6e
commit 2f81f2848d
6 changed files with 859 additions and 2 deletions
+46
View File
@@ -10,6 +10,7 @@ use gpui_native_core::checkbox::Checkbox;
use gpui_native_core::common::{Sizable as _, h_flex, v_flex};
use gpui_native_core::input::{Input, InputState};
use gpui_native_core::link::Link;
use gpui_native_core::menu::{Menu, MenuItem};
use gpui_native_core::popover::Popover;
use gpui_native_core::progress::Progress;
use gpui_native_core::radio::{Radio, RadioGroup};
@@ -30,6 +31,7 @@ struct Gallery {
volume: f32,
input_state: Entity<InputState>,
popover_open: bool,
menu_open: bool,
scroll: gpui::ScrollHandle,
}
@@ -278,6 +280,49 @@ impl Render for Gallery {
),
),
)
.child(
v_flex()
.gap_2()
.child(section_label(
"menu · native ref — NSMenu, WinUI MenuFlyout, Adwaita popover menu",
colors,
))
.child({
let gallery = gallery.clone();
Menu::new("gallery-menu")
.open(self.menu_open)
.on_change(move |open, _, cx| {
gallery.update(cx, |gallery, cx| {
gallery.menu_open = open;
cx.notify();
});
})
.trigger(|_, _| {
Button::new("gallery-menu-trigger")
.label("Actions")
.variant(ButtonVariant::Secondary)
.into_any_element()
})
.items(|_, _| {
vec![
MenuItem::new("Cut")
.shortcut("cmd-x")
.handler(|_, cx| {
eprintln!("menu: cut");
let _ = cx;
}),
MenuItem::new("Copy").shortcut("cmd-c"),
MenuItem::new("Paste").shortcut("cmd-v"),
MenuItem::separator(),
MenuItem::new("Use quiet mode").checked(true),
MenuItem::new("Show hidden files"),
MenuItem::separator(),
MenuItem::new("Unavailable").disabled(true),
MenuItem::new("Delete").destructive(true),
]
})
}),
)
.child(
v_flex()
.gap_2()
@@ -679,6 +724,7 @@ fn main() {
volume: 40.0,
input_state,
popover_open: false,
menu_open: false,
scroll: gpui::ScrollHandle::new(),
})
},