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: StringThe component’s token name (tab, list-row).
data: ComponentKit§shape: StringThe handler’s name (tab.shape).
Implementations§
Source§impl Component
impl Component
pub fn measure(&self, label: Vec2) -> Vec2
Sourcepub fn paint_label(&self, cx: &KitCx<'_>, part: &Part<'_>)
pub fn paint_label(&self, cx: &KitCx<'_>, part: &Part<'_>)
Paints a part’s label.
Sourcepub fn paint_part(&self, cx: &KitCx<'_>, part: &Part<'_>)
pub fn paint_part(&self, cx: &KitCx<'_>, part: &Part<'_>)
Paints a part, box then label (a widget with nothing of its own between them).
Sourcepub fn label_rect(&self, part: &Part<'_>, size: Vec2) -> Rect
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.
Sourcepub fn border_room(&self, ppp: f32) -> f32
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.
Sourcepub fn style_toned(&self, tone: Tone, state: State) -> &BoxStyle
pub fn style_toned(&self, tone: Tone, state: State) -> &BoxStyle
The box of a state in a tone.
pub fn hit(&self, rect: Rect, pos: Pos2) -> bool
Sourcepub fn frame(&self, state: State, ppp: f32) -> Frame
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).
Sourcepub fn show<R>(
&self,
ui: &mut Ui,
state: State,
shadow: Shadow,
add: impl FnOnce(&mut Ui) -> R,
) -> InnerResponse<R>
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.
Sourcepub fn paint_under(
&self,
ui: &Ui,
slot: ShapeIdx,
part: &Part<'_>,
first: Option<Shape>,
)
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§
Auto Trait Implementations§
impl Freeze for Component
impl !RefUnwindSafe for Component
impl Send for Component
impl Sync for Component
impl Unpin for Component
impl UnsafeUnpin for Component
impl !UnwindSafe for Component
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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