Struct StyleBuilder

Source
pub struct StyleBuilder { /* private fields */ }
Expand description

Builds a style.

Implementations§

Source§

impl StyleBuilder

Source

pub fn rule(self, builder: RuleBuilder) -> Self

Add a rule defined in a RuleBuilder to the StyleBuilder.

Source

pub fn scope<S: AsRef<str>>(self, selector: S) -> Self

Prepend the given selector to all rules in this StyleBuilder.

Source

pub fn merge(self, builder: StyleBuilder) -> Self

Merge with another StyleBuilder.

Source

pub fn component<C: Component>(self) -> Self

Include the scoped style of a Component in this StyleBuilder.

Source

pub async fn from_read_fn<P, R>(path: P, read: R) -> Result<Self>
where P: AsRef<Path>, R: ReadFn,

Asynchronously load a stylesheet from a .pwss file. See the style module documentation on how to write .pwss files.

Source

pub fn from_file<P>(path: P) -> Result<Self>
where P: AsRef<Path>,

Synchronously load a stylesheet from a .pwss file. See the style module documentation on how to write .pwss files.

Source

pub fn load_image( &mut self, key: impl Into<String>, load: impl FnOnce() -> Result<RgbaImage> + 'static, ) -> ImageId

Returns an ImageId for the key. When the style is built, the image is loaded using the closure.

Source

pub fn load_patch( &mut self, key: impl Into<String>, load: impl FnOnce() -> Result<RgbaImage> + 'static, ) -> PatchId

Returns a PatchId for the key. When the style is built, the 9-patch is loaded using the closure.

Source

pub fn load_font( &mut self, key: impl Into<String>, load: impl FnOnce() -> Result<Vec<u8>> + 'static, ) -> FontId

Returns a FontId for the key. When the style is built, the font is loaded using the closure. The closure must return the bytes of a .ttf file.

Source

pub fn load_image_async( &mut self, key: impl Into<String>, fut: impl Future<Output = Result<RgbaImage>> + 'static, ) -> ImageId

Returns an ImageId for the key. When the style is built, the image is loaded by awaiting the future.

Source

pub fn load_patch_async( &mut self, key: impl Into<String>, fut: impl Future<Output = Result<RgbaImage>> + 'static, ) -> PatchId

Returns a PatchId for the key. When the style is built, the 9-patch is loaded by awaiting the future.

Source

pub fn load_font_async( &mut self, key: impl Into<String>, fut: impl Future<Output = Result<Vec<u8>>> + 'static, ) -> FontId

Returns a FontId for the key. When the style is built, the font is loaded by awaiting the future. The future must output the bytes of a .ttf file.

Source

pub async fn build_async(self) -> Result<Style>

Builds the Style. All loading of images, 9 patches and fonts happens in this method. If any of them fail, an error is returned.

Source

pub fn build(self) -> Result<Style>

Builds the Style. All loading of images, 9 patches and fonts happens in this method. If any of them fail, an error is returned.

Trait Implementations§

Source§

impl Default for StyleBuilder

Source§

fn default() -> StyleBuilder

Returns the “default value” for a type. Read more
Source§

impl TryInto<Style> for StyleBuilder

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<Style>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>