pub struct Palette {
pub colors: HashMap<Arc<str>, Color>,
}Expand description
Named-color palette modeled on libadwaita’s @accent_color,
@window_bg_color, … bus. Keys are stable Adwaita role names
stored as Arc<str> so repeated lookups share one allocation.
Override individual roles with Self::with before feeding
Self::root_vars into the loader, or build one from scratch with
Self::new, to change just accent_color without restating the
whole table. See the module doc comment for what “feeding the loader”
means today and what it does not yet do.
Fields§
§colors: HashMap<Arc<str>, Color>Role-name -> Color map. Names follow libadwaita’s
@accent_color, @window_bg_color, … convention (no leading
@; the parser strips it before lookup).
Implementations§
Source§impl Palette
impl Palette
Sourcepub fn new() -> Self
pub fn new() -> Self
Empty palette. Useful as a base before Self::with chains.
Sourcepub fn adwaita_light() -> Self
pub fn adwaita_light() -> Self
Default light palette from libadwaita defaults-light.css.
Values mirror libadwaita 1.5 defaults; alpha-bearing roles
(@shade_color, @scrollbar_outline_color, @borders) use
the alpha(...) channel libadwaita ships, baked at table-init
time. The Adwaita @card_bg_color is alpha(@window_fg, 0.05);
here it is pre-resolved against the light @window_fg_color.
Sourcepub fn adwaita_dark() -> Self
pub fn adwaita_dark() -> Self
Default dark palette from libadwaita defaults-dark.css.
Sourcepub fn with(self, name: impl Into<Arc<str>>, color: impl Into<Color>) -> Self
pub fn with(self, name: impl Into<Arc<str>>, color: impl Into<Color>) -> Self
Register or override a named color and return self so calls
can chain. Names should match libadwaita’s
@accent_color / @window_bg_color / … convention.
Accepts anything Into<Color> - hex literal ("#rrggbb"), RGB
tuple (u8, u8, u8), or an explicit Color.
Sourcepub fn lookup(&self, name: &str) -> Option<Color>
pub fn lookup(&self, name: &str) -> Option<Color>
Look up a named color. name matches with or without the
leading @ so callers can pass "accent_color" (from a parser
that already stripped the sigil) or "@accent_color" (raw token)
interchangeably.
Sourcepub fn root_vars(&self) -> HashMap<String, String>
pub fn root_vars(&self) -> HashMap<String, String>
Every named color as a CSS custom-property name (---free, matching
the CSS var() resolver’s key convention in lumen-ir) mapped to
its #rrggbbaa hex value: "accent_color" becomes "accent-color"
(hyphenated, the standard CSS custom-property spelling), values
unchanged otherwise. Lossless and mechanical - this does not rename
any role onto Lumen’s own --lumen-* vocabulary, which is a
separate, opinionated mapping this method deliberately leaves
undecided.
The runtime’s app loader (lumen-runtime, which depends on this
crate - not the other way around, so it cannot be linked from here)
merges the result as the lowest-precedence :root layer: beneath
the always-on UA baseline, beneath any opted-in skin, and beneath
the app’s own main.css. So var(--accent-color) resolves
wherever a --lumen-* token does, and a skin or app that
redeclares the same name still wins.
Trait Implementations§
Source§impl Component for Palette
impl Component for Palette
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::SparseSet
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::SparseSet
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
_requiree: ComponentId,
required_components: &mut RequiredComponentsRegistrator<'_, '_>,
)
fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
ComponentRelationshipAccessor] required for working with relationships in dynamic contexts. Read more§fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreimpl Resource for Palette
impl StructuralPartialEq for Palette
Auto Trait Implementations§
impl Freeze for Palette
impl RefUnwindSafe for Palette
impl Send for Palette
impl Sync for Palette
impl Unpin for Palette
impl UnsafeUnpin for Palette
impl UnwindSafe for Palette
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
§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
§unsafe fn get_components(
ptr: MovingPtr<'_, C>,
func: &mut impl FnMut(StorageType, OwningPtr<'_>),
) -> <C as DynamicBundle>::Effect
unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect
§unsafe fn apply_effect(
_ptr: MovingPtr<'_, MaybeUninit<C>>,
_entity: &mut EntityWorldMut<'_>,
)
unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )
§impl<T> FromTemplate for T
impl<T> FromTemplate for T
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
§impl<T> Template for T
impl<T> Template for T
§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
entity context to produce a Template::Output.§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.