[−][src]Trait kas::draw::SizeHandle
Handle passed to objects during draw and sizing operations
This handle is provided by the toolkit (usually via a theme implementation)
in order to provide sizing information of the elements drawn by
DrawHandle
.
Required methods
fn scale_factor(&self) -> f32
Get the scale (DPI) factor
"Traditional" PC screens have a scale factor of 1; high-DPI screens may have a factor of 2 or higher; this may be fractional. It is recommended to calculate sizes as follows:
let size = (100.0 * scale_factor).round() as u32;
This value may change during a program's execution (e.g. when a window
is moved to a different monitor); in this case all widgets will be
resized via kas::Layout::size_rules
.
fn frame(&self) -> Size
Size of a frame around child widget(s)
Returns dimensions of the frame on each side.
fn menu_frame(&self) -> Size
Menu frame
Menu items have a larger-than-usual margin / invisible frame around
them. This should be drawn with DrawHandle::menu_frame
,
though likely the theme will only draw when highlighted.
Like SizeHandle::frame
this method returns the frame on each side.
fn inner_margin(&self) -> Size
The margin around content within a widget
This area may be used to draw focus indicators.
fn outer_margins(&self) -> Margins
The margin between UI elements, where desired
fn line_height(&self, class: TextClass) -> u32
The height of a line of text
fn text_bound(
&mut self,
text: &str,
class: TextClass,
axis: AxisInfo
) -> SizeRules
&mut self,
text: &str,
class: TextClass,
axis: AxisInfo
) -> SizeRules
Get a text label size bound
Sizing requirements of DrawHandle::text
.
fn button_surround(&self) -> (Size, Size)
Size of the sides of a button.
Returns (top_left, bottom_right)
dimensions as two Size
s.
Excludes size of content area.
fn edit_surround(&self) -> (Size, Size)
Size of the sides of an edit box.
Returns (top_left, bottom_right)
dimensions as two Size
s.
Excludes size of content area.
fn checkbox(&self) -> Size
Size of the element drawn by DrawHandle::checkbox
.
fn radiobox(&self) -> Size
Size of the element drawn by DrawHandle::radiobox
.
fn scrollbar(&self) -> (Size, u32)
Dimensions for a scrollbar
Returns:
size
: minimum size of handle in horizontal orientation;size.1
is also the dimension of the scrollbarmin_len
: minimum length for the whole bar
Required bound: min_len >= size.0
.
fn slider(&self) -> (Size, u32)
Dimensions for a slider
Returns:
size
: minimum size of handle in horizontal orientation;size.1
is also the dimension of the slidermin_len
: minimum length for the whole bar
Required bound: min_len >= size.0
.
Implementations on Foreign Types
impl<S: SizeHandle> SizeHandle for Box<S>
[src]
fn scale_factor(&self) -> f32
[src]
fn frame(&self) -> Size
[src]
fn menu_frame(&self) -> Size
[src]
fn inner_margin(&self) -> Size
[src]
fn outer_margins(&self) -> Margins
[src]
fn line_height(&self, class: TextClass) -> u32
[src]
fn text_bound(
&mut self,
text: &str,
class: TextClass,
axis: AxisInfo
) -> SizeRules
[src]
&mut self,
text: &str,
class: TextClass,
axis: AxisInfo
) -> SizeRules
fn button_surround(&self) -> (Size, Size)
[src]
fn edit_surround(&self) -> (Size, Size)
[src]
fn checkbox(&self) -> Size
[src]
fn radiobox(&self) -> Size
[src]
fn scrollbar(&self) -> (Size, u32)
[src]
fn slider(&self) -> (Size, u32)
[src]
impl<S> SizeHandle for ValueA<dyn SizeHandle, S> where
S: Default + Copy + AsRef<[usize]> + AsMut<[usize]>,
[src]
S: Default + Copy + AsRef<[usize]> + AsMut<[usize]>,
fn scale_factor(&self) -> f32
[src]
fn frame(&self) -> Size
[src]
fn menu_frame(&self) -> Size
[src]
fn inner_margin(&self) -> Size
[src]
fn outer_margins(&self) -> Margins
[src]
fn line_height(&self, class: TextClass) -> u32
[src]
fn text_bound(
&mut self,
text: &str,
class: TextClass,
axis: AxisInfo
) -> SizeRules
[src]
&mut self,
text: &str,
class: TextClass,
axis: AxisInfo
) -> SizeRules