Improve ActiveTheme trait to impl ViewContent and ModelContext to support auto import. (#49)
This commit is contained in:
parent
e95971624e
commit
613cfebb65
2 changed files with 17 additions and 2 deletions
|
|
@ -25,7 +25,7 @@ use crate::{
|
|||
h_flex,
|
||||
list::{self, List, ListDelegate, ListItem},
|
||||
styled_ext::Sizeful,
|
||||
theme::ActiveTheme,
|
||||
theme::ActiveTheme as _,
|
||||
Clickable as _, Icon, IconName, Size, StyledExt,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
use std::ops::Deref;
|
||||
|
||||
use gpui::{
|
||||
hsla, point, AppContext, BoxShadow, Global, Hsla, Pixels, SharedString, WindowAppearance,
|
||||
hsla, point, AppContext, BoxShadow, Global, Hsla, ModelContext, Pixels, SharedString,
|
||||
ViewContext, WindowAppearance,
|
||||
};
|
||||
|
||||
pub trait ActiveTheme {
|
||||
|
|
@ -12,6 +15,18 @@ impl ActiveTheme for AppContext {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, V> ActiveTheme for ViewContext<'a, V> {
|
||||
fn theme(&self) -> &Theme {
|
||||
self.deref().theme()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, V> ActiveTheme for ModelContext<'a, V> {
|
||||
fn theme(&self) -> &Theme {
|
||||
self.deref().theme()
|
||||
}
|
||||
}
|
||||
|
||||
/// Make a [gpui::Hsla] color.
|
||||
///
|
||||
/// h - 0 - 360.0
|
||||
|
|
|
|||
Loading…
Reference in a new issue