Start on context_menu crate
This commit is contained in:
committed by
Antonio Scandurra
parent
b428d0de38
commit
dcee8439b6
Generated
+8
@@ -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"
|
||||
|
||||
@@ -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" }
|
||||
@@ -0,0 +1,28 @@
|
||||
use gpui::{Entity, View};
|
||||
|
||||
enum ContextMenuItem {
|
||||
Item {
|
||||
label: String,
|
||||
action: Box<dyn Action>,
|
||||
},
|
||||
Separator,
|
||||
}
|
||||
|
||||
pub struct ContextMenu {
|
||||
position: Vector2F,
|
||||
items: Vec<ContextMenuItem>,
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user