Struct kas::layout::SolveCache
source · pub struct SolveCache { /* private fields */ }
Expand description
Size solver
This struct is used to solve widget layout, read size constraints and cache the results until the next solver run.
SolveCache::find_constraints
constructs an instance of this struct,
solving for size constraints.
SolveCache::apply_rect
accepts a Rect
, updates constraints as
necessary and sets widget positions within this rect
.
Implementations§
source§impl SolveCache
impl SolveCache
sourcepub fn min(&self, inner_margin: bool) -> Size
pub fn min(&self, inner_margin: bool) -> Size
Get the minimum size
If inner_margin
is true, margins are included in the result.
sourcepub fn ideal(&self, inner_margin: bool) -> Size
pub fn ideal(&self, inner_margin: bool) -> Size
Get the ideal size
If inner_margin
is true, margins are included in the result.
sourcepub fn find_constraints(widget: Node<'_>, sizer: SizeCx<'_>) -> SolveCache
pub fn find_constraints(widget: Node<'_>, sizer: SizeCx<'_>) -> SolveCache
Calculate required size of widget
Assumes no explicit alignment.
sourcepub fn invalidate_rule_cache(&mut self)
pub fn invalidate_rule_cache(&mut self)
Force updating of size rules
This should be called whenever widget size rules have been changed. It
forces SolveCache::apply_rect
to recompute these rules when next
called.
sourcepub fn apply_rect(
&mut self,
widget: Node<'_>,
cx: &mut ConfigCx<'_>,
rect: Rect,
inner_margin: bool
)
pub fn apply_rect( &mut self, widget: Node<'_>, cx: &mut ConfigCx<'_>, rect: Rect, inner_margin: bool )
Apply layout solution to a widget
The widget’s layout is solved for the given rect
and assigned.
If inner_margin
is true, margins are internal to this rect
; if not,
the caller is responsible for handling margins.
If SolveCache::invalidate_rule_cache
was called since rules were
last calculated then this method will recalculate all rules; otherwise
it will only do so if necessary (when dimensions do not match those
last used).
sourcepub fn print_widget_heirarchy(&mut self, widget: &dyn Layout)
pub fn print_widget_heirarchy(&mut self, widget: &dyn Layout)
Print widget heirarchy in the trace log
This is sometimes called after Self::apply_rect
.
Auto Trait Implementations§
impl RefUnwindSafe for SolveCache
impl Send for SolveCache
impl Sync for SolveCache
impl Unpin for SolveCache
impl UnwindSafe for SolveCache
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
§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
§fn cast_approx(self) -> T
fn cast_approx(self) -> T
§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
§fn cast_floor(self) -> T
fn cast_floor(self) -> T
§fn try_cast_trunc(self) -> Result<T, Error>
fn try_cast_trunc(self) -> Result<T, Error>
§fn try_cast_nearest(self) -> Result<T, Error>
fn try_cast_nearest(self) -> Result<T, Error>
§fn try_cast_floor(self) -> Result<T, Error>
fn try_cast_floor(self) -> Result<T, Error>
§fn try_cast_ceil(self) -> Result<T, Error>
fn try_cast_ceil(self) -> Result<T, Error>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.