Struct kas_core::layout::FrameRules

source ·
pub struct FrameRules { /* private fields */ }
Expand description

Frame size rules

This is a special variant of SizeRules for frames. It is assumed that frames are not stretchy (i.e. that min-size equals ideal-size); additionally frame rules have a content offset and a minimum internal margin size.

Implementations§

Construct new FrameRules

All parameters use pairs (first, second) where first is the top/left component. Parameters inner and outer are inner and outer margin sizes respectively while size is the frame size.

If size > 0 then internal margins are the maximum of inner and content margin; generated rules have size content_size + size + inner_margin and outer margin outer.

If size ≤ 0 then the generated rules are simply content rules but with margins the maximum of inner and content margins; outer and size are ignored (other than to enable this mode).

Examples found in repository?
src/layout/size_types.rs (line 332)
331
332
333
    pub const fn new_sym(size: i32, inner: u16, outer: u16) -> Self {
        Self::new(size, (inner, inner), (outer, outer))
    }

Construct (symmetric on axis)

Examples found in repository?
src/layout/size_types.rs (line 309)
309
    pub const ZERO: Self = FrameRules::new_sym(0, 0, 0);

Generate rules for content surrounded by this frame

Returns the tuple (rules, offset, size):

  • the generated rules
  • the content offset within the allocated rect
  • the size consumed by the frame and inner margins (thus the content’s size will be that allocated for this object minus this size value)
Examples found in repository?
src/layout/visitor.rs (line 544)
536
537
538
539
540
541
542
543
544
545
546
547
548
    pub fn size_rules(
        &mut self,
        mgr: SizeMgr,
        axis: AxisInfo,
        child_rules: SizeRules,
        style: FrameStyle,
    ) -> SizeRules {
        let frame_rules = mgr.frame(style, axis);
        let (rules, offset, size) = frame_rules.surround(child_rules);
        self.offset.set_component(axis, offset);
        self.size.set_component(axis, size);
        rules
    }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Cast from Self to T Read more
Try converting from Self to T Read more
Try approximate conversion from Self to T Read more
Cast approximately from Self to T Read more
Cast to integer, truncating Read more
Cast to the nearest integer Read more
Cast the floor to an integer Read more
Cast the ceiling to an integer Read more
Try converting to integer with truncation Read more
Try converting to the nearest integer Read more
Try converting the floor to an integer Read more
Try convert the ceiling to an integer Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.