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§
source§impl FrameRules
impl FrameRules
pub const ZERO: Self = _
sourcepub const fn new(size: i32, inner: (u16, u16), outer: (u16, u16)) -> Self
pub const fn new(size: i32, inner: (u16, u16), outer: (u16, u16)) -> Self
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).
sourcepub fn surround(self, content: SizeRules) -> (SizeRules, i32, i32)
pub fn surround(self, content: SizeRules) -> (SizeRules, i32, i32)
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?
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§
source§impl Clone for FrameRules
impl Clone for FrameRules
source§fn clone(&self) -> FrameRules
fn clone(&self) -> FrameRules
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more