Struct kas_widgets::adapter::Reserve [−][src]
pub struct Reserve<W: Widget, R: FnMut(&mut dyn SizeHandle, AxisInfo) -> SizeRules + 'static> {
pub inner: W,
// some fields omitted
}
Expand description
A generic widget for size reservations
In a few cases it is desirable to reserve more space for a widget than required for the current content, e.g. if a label’s text may change. This widget can be used for this by wrapping the base widget.
Fields
inner: W
Implementations
Construct a reserve
The closure reserve
should generate SizeRules
on request, just like
Layout::size_rules
. This can be done by instantiating a temporary
widget, for example:
use kas_widgets::adapter::Reserve;
use kas_widgets::Label;
use kas::prelude::*;
let label = Reserve::new(Label::new("0"), |size_handle, axis| {
Label::new("00000").size_rules(size_handle, axis)
});
Alternatively one may use virtual pixels:
use kas_widgets::adapter::Reserve;
use kas_widgets::Filler;
use kas::prelude::*;
let label = Reserve::new(Filler::new(), |size_handle, axis| {
let size = i32::conv_ceil(size_handle.scale_factor() * 100.0);
SizeRules::fixed(size, (0, 0))
});
The resulting SizeRules
will be the max of those for the inner widget
and the result of the reserve
closure.
Trait Implementations
Set accel string
impl<W: Widget, R: FnMut(&mut dyn SizeHandle, AxisInfo) -> SizeRules + 'static> WidgetChildren for Reserve<W, R>
impl<W: Widget, R: FnMut(&mut dyn SizeHandle, AxisInfo) -> SizeRules + 'static> WidgetChildren for Reserve<W, R>
Get the number of child widgets
Get a reference to a child widget by index, or None
if the index is
out of bounds. Read more
Mutable variant of get Read more
Record first identifier Read more
Check whether id
is a descendant Read more
Find the child which is an ancestor of this id
, if any Read more
Find the leaf (lowest descendant) with this id
, if any Read more
Find the leaf (lowest descendant) with this id
, if any Read more
Walk through all widgets, calling f
once on each. Read more
Walk through all widgets, calling f
once on each. Read more
impl<W: Widget, R: FnMut(&mut dyn SizeHandle, AxisInfo) -> SizeRules + 'static> WidgetConfig for Reserve<W, R>
impl<W: Widget, R: FnMut(&mut dyn SizeHandle, AxisInfo) -> SizeRules + 'static> WidgetConfig for Reserve<W, R>
impl<W: Widget, R: FnMut(&mut dyn SizeHandle, AxisInfo) -> SizeRules + 'static> WidgetCore for Reserve<W, R>
impl<W: Widget, R: FnMut(&mut dyn SizeHandle, AxisInfo) -> SizeRules + 'static> WidgetCore for Reserve<W, R>
Get self as type Any
(mutable)
Get the name of the widget struct
Erase type
Erase type
Get whether the widget is disabled
Set the disabled state of a widget Read more
Set disabled state (chaining) Read more
Construct InputState
Read more
Auto Trait Implementations
impl<W, R> RefUnwindSafe for Reserve<W, R> where
R: RefUnwindSafe,
W: RefUnwindSafe,
impl<W, R> UnwindSafe for Reserve<W, R> where
R: UnwindSafe,
W: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn cast_trunc(self) -> T
pub fn cast_trunc(self) -> T
Cast to integer, truncating Read more
pub fn cast_nearest(self) -> T
pub fn cast_nearest(self) -> T
Cast to the nearest integer Read more
pub fn cast_floor(self) -> T
pub fn cast_floor(self) -> T
Cast the floor to an integer Read more
pub fn try_cast_trunc(self) -> Result<T, Error>
pub fn try_cast_trunc(self) -> Result<T, Error>
Try converting to integer with truncation Read more
pub fn try_cast_nearest(self) -> Result<T, Error>
pub fn try_cast_nearest(self) -> Result<T, Error>
Try converting to the nearest integer Read more
pub fn try_cast_floor(self) -> Result<T, Error>
pub fn try_cast_floor(self) -> Result<T, Error>
Try converting the floor to an integer Read more
pub fn try_cast_ceil(self) -> Result<T, Error>
pub fn try_cast_ceil(self) -> Result<T, Error>
Try convert the ceiling to an integer Read more
Get the scale (DPI) factor Read more
Convert a size in font Points to physical pixels
Convert a size in font Em to physical pixels Read more
Size of a frame around child widget(s) Read more
Frame/margin around a menu entry
Size of a navigation highlight margin around a child widget
The margin around content within a widget Read more
The margin between UI elements, where desired Read more
The margin around frames and separators
The margin around text elements Read more
The height of a line of text
pub fn text_bound(
&self,
text: &mut dyn TextApi,
class: TextClass,
axis: AxisInfo
) -> SizeRules
pub fn text_bound(
&self,
text: &mut dyn TextApi,
class: TextClass,
axis: AxisInfo
) -> SizeRules
Update a [Text
] and get a size bound Read more
Width of an edit marker
Size of the sides of a button.
Size of the frame around an edit box, including margin Read more
Size of the element drawn by DrawHandle::checkbox
.
Size of the element drawn by DrawHandle::radiobox
.
Dimensions for a progress bar Read more
Convert a size in virtual pixels to physical pixels