Struct kas_core::layout::FrameStorage
source · Expand description
Layout storage for frame layout
Fields§
§size: Size
Size used by frame (sum of widths of borders)
offset: Offset
Offset of frame contents from parent position
Implementations§
source§impl FrameStorage
impl FrameStorage
sourcepub fn child_axis(&self, axis: AxisInfo) -> AxisInfo
pub fn child_axis(&self, axis: AxisInfo) -> AxisInfo
Calculate child’s “other axis” size
Examples found in repository?
src/layout/visitor.rs (line 241)
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
fn size_rules_(&mut self, mgr: SizeMgr, axis: AxisInfo) -> SizeRules {
match &mut self.layout {
LayoutType::None => SizeRules::EMPTY,
LayoutType::Component(component) => component.size_rules(mgr, axis),
LayoutType::BoxComponent(component) => component.size_rules(mgr, axis),
LayoutType::Single(child) => child.size_rules(mgr, axis),
LayoutType::AlignSingle(child, hints) => {
child.size_rules(mgr, axis.with_align_hints(*hints))
}
LayoutType::Align(layout, hints) => {
layout.size_rules_(mgr, axis.with_align_hints(*hints))
}
LayoutType::Pack(layout, stor, hints) => {
let rules = layout.size_rules_(mgr, stor.apply_align(axis, *hints));
stor.size.set_component(axis, rules.ideal_size());
rules
}
LayoutType::Margins(child, dirs, margins) => {
let mut child_rules = child.size_rules_(mgr.re(), axis);
if dirs.intersects(Directions::from(axis)) {
let mut rule_margins = child_rules.margins();
let margins = mgr.margins(*margins).extract(axis);
if dirs.intersects(Directions::LEFT | Directions::UP) {
rule_margins.0 = margins.0;
}
if dirs.intersects(Directions::RIGHT | Directions::DOWN) {
rule_margins.1 = margins.1;
}
child_rules.set_margins(rule_margins);
}
child_rules
}
LayoutType::Frame(child, storage, style) => {
let child_rules = child.size_rules_(mgr.re(), storage.child_axis(axis));
storage.size_rules(mgr, axis, child_rules, *style)
}
LayoutType::Button(child, storage, _) => {
let child_rules = child.size_rules_(mgr.re(), storage.child_axis_centered(axis));
storage.size_rules(mgr, axis, child_rules, FrameStyle::Button)
}
}
}
sourcepub fn child_axis_centered(&self, axis: AxisInfo) -> AxisInfo
pub fn child_axis_centered(&self, axis: AxisInfo) -> AxisInfo
Calculate child’s “other axis” size, forcing center-alignment of content
Examples found in repository?
src/layout/visitor.rs (line 245)
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
fn size_rules_(&mut self, mgr: SizeMgr, axis: AxisInfo) -> SizeRules {
match &mut self.layout {
LayoutType::None => SizeRules::EMPTY,
LayoutType::Component(component) => component.size_rules(mgr, axis),
LayoutType::BoxComponent(component) => component.size_rules(mgr, axis),
LayoutType::Single(child) => child.size_rules(mgr, axis),
LayoutType::AlignSingle(child, hints) => {
child.size_rules(mgr, axis.with_align_hints(*hints))
}
LayoutType::Align(layout, hints) => {
layout.size_rules_(mgr, axis.with_align_hints(*hints))
}
LayoutType::Pack(layout, stor, hints) => {
let rules = layout.size_rules_(mgr, stor.apply_align(axis, *hints));
stor.size.set_component(axis, rules.ideal_size());
rules
}
LayoutType::Margins(child, dirs, margins) => {
let mut child_rules = child.size_rules_(mgr.re(), axis);
if dirs.intersects(Directions::from(axis)) {
let mut rule_margins = child_rules.margins();
let margins = mgr.margins(*margins).extract(axis);
if dirs.intersects(Directions::LEFT | Directions::UP) {
rule_margins.0 = margins.0;
}
if dirs.intersects(Directions::RIGHT | Directions::DOWN) {
rule_margins.1 = margins.1;
}
child_rules.set_margins(rule_margins);
}
child_rules
}
LayoutType::Frame(child, storage, style) => {
let child_rules = child.size_rules_(mgr.re(), storage.child_axis(axis));
storage.size_rules(mgr, axis, child_rules, *style)
}
LayoutType::Button(child, storage, _) => {
let child_rules = child.size_rules_(mgr.re(), storage.child_axis_centered(axis));
storage.size_rules(mgr, axis, child_rules, FrameStyle::Button)
}
}
}
sourcepub fn size_rules(
&mut self,
mgr: SizeMgr<'_>,
axis: AxisInfo,
child_rules: SizeRules,
style: FrameStyle
) -> SizeRules
pub fn size_rules(
&mut self,
mgr: SizeMgr<'_>,
axis: AxisInfo,
child_rules: SizeRules,
style: FrameStyle
) -> SizeRules
Generate SizeRules
Examples found in repository?
src/layout/visitor.rs (line 242)
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
fn size_rules_(&mut self, mgr: SizeMgr, axis: AxisInfo) -> SizeRules {
match &mut self.layout {
LayoutType::None => SizeRules::EMPTY,
LayoutType::Component(component) => component.size_rules(mgr, axis),
LayoutType::BoxComponent(component) => component.size_rules(mgr, axis),
LayoutType::Single(child) => child.size_rules(mgr, axis),
LayoutType::AlignSingle(child, hints) => {
child.size_rules(mgr, axis.with_align_hints(*hints))
}
LayoutType::Align(layout, hints) => {
layout.size_rules_(mgr, axis.with_align_hints(*hints))
}
LayoutType::Pack(layout, stor, hints) => {
let rules = layout.size_rules_(mgr, stor.apply_align(axis, *hints));
stor.size.set_component(axis, rules.ideal_size());
rules
}
LayoutType::Margins(child, dirs, margins) => {
let mut child_rules = child.size_rules_(mgr.re(), axis);
if dirs.intersects(Directions::from(axis)) {
let mut rule_margins = child_rules.margins();
let margins = mgr.margins(*margins).extract(axis);
if dirs.intersects(Directions::LEFT | Directions::UP) {
rule_margins.0 = margins.0;
}
if dirs.intersects(Directions::RIGHT | Directions::DOWN) {
rule_margins.1 = margins.1;
}
child_rules.set_margins(rule_margins);
}
child_rules
}
LayoutType::Frame(child, storage, style) => {
let child_rules = child.size_rules_(mgr.re(), storage.child_axis(axis));
storage.size_rules(mgr, axis, child_rules, *style)
}
LayoutType::Button(child, storage, _) => {
let child_rules = child.size_rules_(mgr.re(), storage.child_axis_centered(axis));
storage.size_rules(mgr, axis, child_rules, FrameStyle::Button)
}
}
}
Trait Implementations§
source§impl Clone for FrameStorage
impl Clone for FrameStorage
source§fn clone(&self) -> FrameStorage
fn clone(&self) -> FrameStorage
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for FrameStorage
impl Debug for FrameStorage
source§impl Default for FrameStorage
impl Default for FrameStorage
source§fn default() -> FrameStorage
fn default() -> FrameStorage
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl RefUnwindSafe for FrameStorage
impl Send for FrameStorage
impl Sync for FrameStorage
impl Unpin for FrameStorage
impl UnwindSafe for FrameStorage
Blanket Implementations§
source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Cast to integer, truncating Read more
source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Cast to the nearest integer Read more
source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
Cast the floor to an integer Read more