Struct kas_core::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
sourceimpl 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: &mut dyn Widget, size_mgr: SizeMgr<'_>) -> Self
pub fn find_constraints(widget: &mut dyn Widget, size_mgr: SizeMgr<'_>) -> Self
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: &mut dyn Widget,
mgr: &mut ConfigMgr<'_>,
rect: Rect,
inner_margin: bool,
print_heirarchy: bool
)
pub fn apply_rect(
&mut self,
widget: &mut dyn Widget,
mgr: &mut ConfigMgr<'_>,
rect: Rect,
inner_margin: bool,
print_heirarchy: 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).
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
sourcefn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
Try approximate conversion from Self to T Read more
sourcefn cast_approx(self) -> T
fn cast_approx(self) -> T
Cast approximately from Self to T Read more
sourceimpl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
sourcefn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Cast to integer, truncating Read more
sourcefn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Cast to the nearest integer Read more
sourcefn cast_floor(self) -> T
fn cast_floor(self) -> T
Cast the floor to an integer Read more
sourcefn try_cast_trunc(self) -> Result<T, Error>
fn try_cast_trunc(self) -> Result<T, Error>
Try converting to integer with truncation Read more
sourcefn try_cast_nearest(self) -> Result<T, Error>
fn try_cast_nearest(self) -> Result<T, Error>
Try converting to the nearest integer Read more
sourcefn try_cast_floor(self) -> Result<T, Error>
fn try_cast_floor(self) -> Result<T, Error>
Try converting the floor to an integer Read more
sourcefn try_cast_ceil(self) -> Result<T, Error>
fn try_cast_ceil(self) -> Result<T, Error>
Try convert the ceiling to an integer Read more