Struct RuleBuilder

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

Builder that adds style declarations to a selected rule.

Implementations§

Source§

impl RuleBuilder

Source

pub fn new<S: AsRef<str>>(selector: S) -> Self

Constructs a new RuleBuilder for the given selector. The selector must follow the same syntax as the .pwss file format.

Panics if the selector can’t be parsed.

use pixel_widgets::prelude::*;

// Sets the background of the first direct child of any window widget
RuleBuilder::new("window > * :nth-child(0)").background_color(Color::red());
Source

pub fn background_none(self) -> Self

Clears the background

Source

pub fn background_color(self, color: Color) -> Self

Sets the background to a color

Source

pub fn background_image(self, image_data: ImageId, color: Color) -> Self

Sets the background to a colored image

Source

pub fn background_patch(self, patch: PatchId, color: Color) -> Self

Sets the background to a colored patch

Source

pub fn font(self, value: FontId) -> Self

Sets the font

Source

pub fn color(self, value: Color) -> Self

Sets the foreground color

Source

pub fn padding(self, value: Rectangle) -> Self

Sets padding

Source

pub fn padding_all(self, value: f32) -> Self

Sets all padding values to the same value

Source

pub fn padding_horizontal(self, value: f32) -> Self

Sets horizontal padding values to the same value

Source

pub fn padding_vertical(self, value: f32) -> Self

Sets vertical padding values to the same value

Source

pub fn padding_left(self, value: f32) -> Self

Sets left padding

Source

pub fn padding_right(self, value: f32) -> Self

Sets right padding

Source

pub fn padding_top(self, value: f32) -> Self

Sets top padding

Source

pub fn padding_bottom(self, value: f32) -> Self

Sets bottom padding

Source

pub fn margin(self, value: Rectangle) -> Self

Sets the margins

Source

pub fn margin_all(self, value: f32) -> Self

Sets all margin values to the same value

Source

pub fn margin_horizontal(self, value: f32) -> Self

Sets horizontal margin values to the same value

Source

pub fn margin_vertical(self, value: f32) -> Self

Sets vertical margin values to the same value

Source

pub fn margin_left(self, value: f32) -> Self

Sets the left margin

Source

pub fn margin_right(self, value: f32) -> Self

Sets the right margin

Source

pub fn margin_top(self, value: f32) -> Self

Sets the top margin

Source

pub fn margin_bottom(self, value: f32) -> Self

Sets the bottom margin

Source

pub fn text_size(self, value: f32) -> Self

Sets the text size

Source

pub fn text_wrap(self, value: TextWrap) -> Self

Sets the way text wraps

Source

pub fn width(self, value: impl Into<Size>) -> Self

Sets the preferred width

Source

pub fn fill_width(self) -> Self

Sets the preferred width to Size::Fill(1)

Source

pub fn height(self, value: impl Into<Size>) -> Self

Sets the preferred height

Source

pub fn fill_height(self) -> Self

Sets the preferred height to Size::Fill(1)

Source

pub fn layout_direction(self, value: Direction) -> Self

Sets the direction for layouting

Source

pub fn align_horizontal(self, value: Align) -> Self

Sets the horizontal alignment

Source

pub fn align_vertical(self, value: Align) -> Self

Sets the vertical alignment

Source

pub fn add_flag(self, value: String) -> Self

Adds a flag to the stylesheet

Source

pub fn remove_flag(self, value: String) -> Self

Removes a flag from the stylesheet

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>