use std::sync::Arc;
use crate::{ Color, Element, ImageData, ThemeMode, WallpaperBundle };
pub fn set_default_theme( mode: ThemeMode ) -> Result<(), String>
{
let doc = crate::ThemeDocument::find( "default" ).map_err( |e| format!( "{e}" ) )?;
crate::set_active_document( doc );
crate::set_active_mode( mode );
Ok( () )
}
pub fn theme_logo_rgba( size: u32 ) -> Option<ImageData>
{
let path = crate::theme_logo_horizontal()?;
let bytes = std::fs::read( &path ).ok()?;
crate::decode_svg_bytes( &bytes, size )
}
pub fn theme_icon_tinted( name: &str, size: u32, tint: Color ) -> Option<ImageData>
{
let ( rgba, w, h ) = crate::theme_icon_rgba( name, size )?;
Some( ( Arc::new( crate::tint_symbolic( &rgba, tint ) ), w, h ) )
}
pub fn branding_bundle_or_solid( name: &str ) -> WallpaperBundle
{
let path = crate::theme_branding_image( name, 0, 0 );
let bg = crate::theme_palette().bg;
WallpaperBundle::from_path_or_solid(
path.as_deref(),
( bg.r * 255.0 ) as u8,
( bg.g * 255.0 ) as u8,
( bg.b * 255.0 ) as u8,
)
}
pub fn wallpaper_bundle_or_solid() -> WallpaperBundle
{
branding_bundle_or_solid( "wallpaper" )
}
pub fn backdrop<M: Clone>( content: Element<M>, wallpaper: &WallpaperBundle, w: u32, h: u32 ) -> Element<M>
{
let ( rgba, iw, ih ) = wallpaper.for_size( w, h );
crate::stack::<M>()
.push( crate::img_widget( rgba, iw, ih ) )
.push( content )
.into()
}