@@ -31,6 +31,7 @@ mod theme_selector;
|
||||
mod title_bar;
|
||||
mod toast;
|
||||
mod toolbar;
|
||||
mod tooltip;
|
||||
mod traffic_lights;
|
||||
mod workspace;
|
||||
|
||||
@@ -67,5 +68,6 @@ pub use theme_selector::*;
|
||||
pub use title_bar::*;
|
||||
pub use toast::*;
|
||||
pub use toolbar::*;
|
||||
pub use tooltip::*;
|
||||
pub use traffic_lights::*;
|
||||
pub use workspace::*;
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
use gpui2::{
|
||||
div, px, Div, ParentElement, Render, SharedString, Styled, View, ViewContext, VisualContext,
|
||||
};
|
||||
use theme2::ActiveTheme;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct TextTooltip {
|
||||
title: SharedString,
|
||||
}
|
||||
|
||||
impl TextTooltip {
|
||||
pub fn new(str: SharedString) -> Self {
|
||||
Self { title: str }
|
||||
}
|
||||
|
||||
pub fn build_view<C: VisualContext>(str: SharedString, cx: &mut C) -> C::Result<View<Self>> {
|
||||
cx.build_view(|cx| TextTooltip::new(str))
|
||||
}
|
||||
}
|
||||
|
||||
impl Render for TextTooltip {
|
||||
type Element = Div<Self>;
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
let theme = cx.theme();
|
||||
div()
|
||||
.bg(theme.colors().background)
|
||||
.rounded(px(8.))
|
||||
.border()
|
||||
.border_color(theme.colors().border)
|
||||
.text_color(theme.colors().text)
|
||||
.pl_2()
|
||||
.pr_2()
|
||||
.child(self.title.clone())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user