Add Overlay component to gpui2
This commit is contained in:
parent
8c14a8fa95
commit
74afa62a55
6 changed files with 259 additions and 32 deletions
|
@ -1,4 +1,4 @@
|
|||
use gpui::{Action, AnyView, Div, Render, VisualContext};
|
||||
use gpui::{overlay, Action, AnyView, Overlay, Render, VisualContext};
|
||||
use settings2::Settings;
|
||||
use theme2::{ActiveTheme, ThemeSettings};
|
||||
|
||||
|
@ -68,30 +68,35 @@ impl Tooltip {
|
|||
}
|
||||
|
||||
impl Render for Tooltip {
|
||||
type Element = Div<Self>;
|
||||
type Element = Overlay<Self>;
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
let ui_font = ThemeSettings::get_global(cx).ui_font.family.clone();
|
||||
v_stack()
|
||||
.elevation_2(cx)
|
||||
.font(ui_font)
|
||||
.text_ui_sm()
|
||||
.text_color(cx.theme().colors().text)
|
||||
.py_1()
|
||||
.px_2()
|
||||
.child(
|
||||
h_stack()
|
||||
.child(self.title.clone())
|
||||
.when_some(self.key_binding.clone(), |this, key_binding| {
|
||||
this.justify_between().child(key_binding)
|
||||
overlay().child(
|
||||
// padding to avoid mouse cursor
|
||||
div().pl_2().pt_2p5().child(
|
||||
v_stack()
|
||||
.elevation_2(cx)
|
||||
.font(ui_font)
|
||||
.text_ui_sm()
|
||||
.text_color(cx.theme().colors().text)
|
||||
.py_1()
|
||||
.px_2()
|
||||
.child(
|
||||
h_stack()
|
||||
.child(self.title.clone())
|
||||
.when_some(self.key_binding.clone(), |this, key_binding| {
|
||||
this.justify_between().child(key_binding)
|
||||
}),
|
||||
)
|
||||
.when_some(self.meta.clone(), |this, meta| {
|
||||
this.child(
|
||||
Label::new(meta)
|
||||
.size(LabelSize::Small)
|
||||
.color(TextColor::Muted),
|
||||
)
|
||||
}),
|
||||
)
|
||||
.when_some(self.meta.clone(), |this, meta| {
|
||||
this.child(
|
||||
Label::new(meta)
|
||||
.size(LabelSize::Small)
|
||||
.color(TextColor::Muted),
|
||||
)
|
||||
})
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue