From dcee8439b690e48254c068c4f1eb9bd995dd1628 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 24 May 2022 19:59:43 -0600 Subject: [PATCH] Start on context_menu crate --- Cargo.lock | 8 +++++++ crates/context_menu/Cargo.toml | 12 +++++++++++ crates/context_menu/src/context_menu.rs | 28 +++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 crates/context_menu/Cargo.toml create mode 100644 crates/context_menu/src/context_menu.rs diff --git a/Cargo.lock b/Cargo.lock index 2be3830438..b0233d6827 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -974,6 +974,14 @@ dependencies = [ "workspace", ] +[[package]] +name = "context_menu" +version = "0.1.0" +dependencies = [ + "gpui", + "theme", +] + [[package]] name = "core-foundation" version = "0.9.3" diff --git a/crates/context_menu/Cargo.toml b/crates/context_menu/Cargo.toml new file mode 100644 index 0000000000..3392d68579 --- /dev/null +++ b/crates/context_menu/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "context_menu" +version = "0.1.0" +edition = "2021" + +[lib] +path = "src/context_menu.rs" +doctest = false + +[dependencies] +gpui = { path = "../gpui" } +theme = { path = "../theme" } diff --git a/crates/context_menu/src/context_menu.rs b/crates/context_menu/src/context_menu.rs new file mode 100644 index 0000000000..8d698ce9be --- /dev/null +++ b/crates/context_menu/src/context_menu.rs @@ -0,0 +1,28 @@ +use gpui::{Entity, View}; + +enum ContextMenuItem { + Item { + label: String, + action: Box, + }, + Separator, +} + +pub struct ContextMenu { + position: Vector2F, + items: Vec, +} + +impl Entity for ContextMenu { + type Event = (); +} + +impl View for ContextMenu { + fn ui_name() -> &'static str { + "ContextMenu" + } + + fn render(&mut self, cx: &mut gpui::RenderContext<'_, Self>) -> gpui::ElementBox { + Overlay::new().with_abs_position(self.position).boxed() + } +}