mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-03 00:55:39 +03:00
Start on context_menu crate
This commit is contained in:
parent
b428d0de38
commit
dcee8439b6
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -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"
|
||||
|
12
crates/context_menu/Cargo.toml
Normal file
12
crates/context_menu/Cargo.toml
Normal file
@ -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" }
|
28
crates/context_menu/src/context_menu.rs
Normal file
28
crates/context_menu/src/context_menu.rs
Normal file
@ -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()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user