Start on context_menu crate

This commit is contained in:
Nathan Sobo 2022-05-24 19:59:43 -06:00 committed by Antonio Scandurra
parent b428d0de38
commit dcee8439b6
3 changed files with 48 additions and 0 deletions

View 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()
}
}