Skip to main content

Component

Struct Component 

Source
pub struct Component {
    pub name: String,
    pub data: ComponentKit,
    pub shape: String,
    /* private fields */
}
Expand description

A component’s data and the handler that draws it.

Fields§

§name: String

The component’s token name (tab, list-row).

§data: ComponentKit§shape: String

The handler’s name (tab.shape).

Implementations§

Source§

impl Component

Source

pub fn measure(&self, label: Vec2) -> Vec2

Source

pub fn paint(&self, cx: &KitCx<'_>, part: &Part<'_>)

Paints a part’s box.

Source

pub fn paint_label(&self, cx: &KitCx<'_>, part: &Part<'_>)

Paints a part’s label.

Source

pub fn paint_part(&self, cx: &KitCx<'_>, part: &Part<'_>)

Paints a part, box then label (a widget with nothing of its own between them).

Source

pub fn label_rect(&self, part: &Part<'_>, size: Vec2) -> Rect

Where the default label painting puts a label of size (label_rect): a widget gives it to assistive technology.

Source

pub fn border_room(&self, ppp: f32) -> f32

The room a part keeps for its border at ppp physical pixels per point, whatever its state: its widest border (States::widest_border) on whole physical pixels, zero when no state gives one. A widget laying out content in the part insets it by this, never by the current state’s border.

Source

pub fn style(&self, state: State) -> &BoxStyle

The box of a state (in the tone it carries).

Source

pub fn style_toned(&self, tone: Tone, state: State) -> &BoxStyle

The box of a state in a tone.

Source

pub fn hit(&self, rect: Rect, pos: Pos2) -> bool

Source

pub fn frame(&self, state: State, ppp: f32) -> Frame

The box of a state as an egui [Frame] at ppp physical pixels per point: its fill, its border (its width snapped to whole physical pixels, as the kit’s own painting does) and corner radius, the padding (padding-x, padding-y) as its inner margin. No shadow: egui’s own, from Visuals, is the caller’s to add. For a container that takes a frame in one state; a part egui lays out around its content is better shown with Component::show, which also paints the focus ring, honours a handler of the theme’s and keeps the content in place across states (this frame’s border is its state’s own, so its size follows the state’s border width).

Source

pub fn show<R>( &self, ui: &mut Ui, state: State, shadow: Shadow, add: impl FnOnce(&mut Ui) -> R, ) -> InnerResponse<R>

Shows add inside the component’s box in state, laid out by egui (the part is as large as its content, its padding and its border), with egui’s shadow under it ([Shadow::NONE] for none).

The layout keeps room for the widest border of any state (Component::border_room): the state restyles the box by paint alone, and the content never moves when the state changes.

The built-in card handler is egui’s [Frame] of the box, then the state’s focus ring, when the state’s border is the widest. Otherwise the handler paints once the content is laid out, its shapes moved under the content: what it draws needs one allocation per part and frame, which egui’s frame does not.

Source

pub fn paint_under( &self, ui: &Ui, slot: ShapeIdx, part: &Part<'_>, first: Option<Shape>, )

Paints a part’s box into slot, a shape reserved (Shape::Noop) before the widget drew its content: the box ends up under the content although it is painted after it, once the part’s rectangle and state are known. first goes under the box (a shadow). One allocation per part and frame. The ui’s opacity (a disabled or fading ui) applies once, when the box is set into its slot.

Trait Implementations§

Source§

impl Clone for Component

Source§

fn clone(&self) -> Component

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Component

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,