pub struct ThemeToken {
pub color: Hsla,
pub background: Background,
}Expand description
A theme token that keeps a solid representative color and its renderable background.
Fields§
§color: Hsla§background: BackgroundImplementations§
Source§impl ThemeToken
impl ThemeToken
pub fn new(color: Hsla, background: Background) -> Self
Methods from Deref<Target = Hsla>§
Sourcepub fn is_transparent(&self) -> bool
pub fn is_transparent(&self) -> bool
Returns true if the HSLA color is fully transparent, false otherwise.
Sourcepub fn is_opaque(&self) -> bool
pub fn is_opaque(&self) -> bool
Returns true if the HSLA color is fully opaque, false otherwise.
Sourcepub fn grayscale(&self) -> Hsla
pub fn grayscale(&self) -> Hsla
Returns a new HSLA color with the same hue, and lightness, but with no saturation.
Sourcepub fn opacity(&self, factor: f32) -> Hsla
pub fn opacity(&self, factor: f32) -> Hsla
Multiplies the alpha value of the color by a given factor and returns a new HSLA color.
Useful for transforming colors with dynamic opacity, like a color from an external source.
Example:
let color = gpui::red();
let faded_color = color.opacity(0.5);
assert_eq!(faded_color.a, 0.5);This will return a red color with half the opacity.
Example:
use gpui::hsla;
let color = hsla(0.7, 1.0, 0.5, 0.7); // A saturated blue
let faded_color = color.opacity(0.16);
assert!((faded_color.a - 0.112).abs() < 1e-6);This will return a blue color with around ~10% opacity, suitable for an element’s hover or selected state.
Sourcepub fn alpha(&self, a: f32) -> Hsla
pub fn alpha(&self, a: f32) -> Hsla
Returns a new HSLA color with the same hue, saturation, and lightness, but with a new alpha value.
Example:
let color = gpui::red();
let red_color = color.alpha(0.25);
assert_eq!(red_color.a, 0.25);This will return a red color with 25% opacity.
Example:
use gpui::hsla;
let color = hsla(0.7, 1.0, 0.5, 0.7); // A saturated blue
let faded_color = color.alpha(0.25);
assert_eq!(faded_color.a, 0.25);This will return a blue color with 25% opacity.
Trait Implementations§
Source§impl Clone for ThemeToken
impl Clone for ThemeToken
Source§fn clone(&self) -> ThemeToken
fn clone(&self) -> ThemeToken
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ThemeToken
Source§impl Debug for ThemeToken
impl Debug for ThemeToken
Source§impl Default for ThemeToken
impl Default for ThemeToken
Source§fn default() -> ThemeToken
fn default() -> ThemeToken
Source§impl Deref for ThemeToken
impl Deref for ThemeToken
Source§impl<'de> Deserialize<'de> for ThemeToken
impl<'de> Deserialize<'de> for ThemeToken
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<Hsla> for ThemeToken
impl From<Hsla> for ThemeToken
Source§impl From<ThemeToken> for Hsla
impl From<ThemeToken> for Hsla
Source§fn from(token: ThemeToken) -> Self
fn from(token: ThemeToken) -> Self
Source§impl From<ThemeToken> for Background
impl From<ThemeToken> for Background
Source§fn from(token: ThemeToken) -> Self
fn from(token: ThemeToken) -> Self
Source§impl From<ThemeToken> for Fill
impl From<ThemeToken> for Fill
Source§fn from(token: ThemeToken) -> Self
fn from(token: ThemeToken) -> Self
Source§impl JsonSchema for ThemeToken
impl JsonSchema for ThemeToken
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for ThemeToken
impl PartialEq for ThemeToken
Source§impl Serialize for ThemeToken
impl Serialize for ThemeToken
impl StructuralPartialEq for ThemeToken
Auto Trait Implementations§
impl Freeze for ThemeToken
impl RefUnwindSafe for ThemeToken
impl Send for ThemeToken
impl Sync for ThemeToken
impl Unpin for ThemeToken
impl UnsafeUnpin for ThemeToken
impl UnwindSafe for ThemeToken
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().