pub struct Builder { /* private fields */ }Expand description
A builder to generate custom Themes.
Example
use pix_engine::gui::theme::*;
fn main() -> PixResult<()> {
let theme = Theme::builder()
.with_font_size(16)
.with_font(
FontType::Body,
Font::from_file("Some font", "./some_font.ttf"),
FontStyle::ITALIC,
)
.with_font(
FontType::Heading,
Font::NOTO,
FontStyle::BOLD | FontStyle::UNDERLINE
)
.with_color(ColorType::OnBackground, Color::BLACK)
.with_color(ColorType::Background, Color::DARK_GRAY)
.with_spacing(
Spacing::builder()
.frame_pad(10, 10)
.item_pad(5, 5)
.build()
)
.build();
let mut engine = PixEngine::builder()
.with_theme(theme)
.build()?;
let mut app = MyApp;
engine.run(&mut app)
}Implementations
sourceimpl Builder
impl Builder
sourcepub fn with_font_size(&mut self, size: u32) -> &mut Self
pub fn with_font_size(&mut self, size: u32) -> &mut Self
Set font size.
sourcepub fn with_font(
&mut self,
font_type: FontType,
font: Font,
style: FontStyle
) -> &mut Self
pub fn with_font(
&mut self,
font_type: FontType,
font: Font,
style: FontStyle
) -> &mut Self
Set font theme values for a given FontType.
sourcepub fn with_color<C: Into<Color>>(
&mut self,
color_type: ColorType,
color: C
) -> &mut Self
pub fn with_color<C: Into<Color>>(
&mut self,
color_type: ColorType,
color: C
) -> &mut Self
Set color theme for a given ColorType.
sourcepub fn with_spacing(&mut self, spacing: Spacing) -> &mut Self
pub fn with_spacing(&mut self, spacing: Spacing) -> &mut Self
Set element padding space.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Builder
impl<'de> Deserialize<'de> for Builder
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Builder
impl StructuralEq for Builder
impl StructuralPartialEq for Builder
Auto Trait Implementations
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more