[−][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
pub fn scale_factor(&self) -> f32
[src]
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
.
pub fn frame(&self) -> Size
[src]
Size of a frame around child widget(s)
Returns dimensions of the frame on each side.
pub fn menu_frame(&self) -> Size
[src]
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.
pub fn inner_margin(&self) -> Size
[src]
The margin around content within a widget
This area may be used to draw focus indicators.
pub fn outer_margins(&self) -> Margins
[src]
The margin between UI elements, where desired
pub fn line_height(&self, class: TextClass) -> u32
[src]
The height of a line of text
pub fn text_bound(
&mut self,
text: &mut dyn TextApi,
class: TextClass,
axis: AxisInfo
) -> SizeRules
[src]
&mut self,
text: &mut dyn TextApi,
class: TextClass,
axis: AxisInfo
) -> SizeRules
Update a Text
and get a size bound
First, this method updates the text's Environment
: bounds
, dpp
and pt_size
are set. Second, the text is prepared (which is necessary
to calculate size requirements). Finally, this converts the requirements
to a SizeRules
value and returns it.
Usually this method is used in Layout::size_rules
, then
TextApiExt::update_env
is used in Layout::set_rect
.
pub fn edit_marker_width(&self) -> f32
[src]
Width of an edit marker
pub fn button_surround(&self) -> (Size, Size)
[src]
Size of the sides of a button.
Returns (top_left, bottom_right)
dimensions as two Size
s.
Excludes size of content area.
pub fn edit_surround(&self) -> (Size, Size)
[src]
Size of the sides of an edit box.
Returns (top_left, bottom_right)
dimensions as two Size
s.
Excludes size of content area.
pub fn checkbox(&self) -> Size
[src]
Size of the element drawn by DrawHandle::checkbox
.
pub fn radiobox(&self) -> Size
[src]
Size of the element drawn by DrawHandle::radiobox
.
pub fn scrollbar(&self) -> (Size, u32)
[src]
Dimensions for a scrollbar
Returns:
size
: minimum size of handle in horizontal orientation;size.1
is also the width of the scrollbarmin_len
: minimum length for the whole bar
Required bound: min_len >= size.0
.
pub fn slider(&self) -> (Size, u32)
[src]
Dimensions for a slider
Returns:
size
: minimum size of handle in horizontal orientation;size.1
is also the width 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]
pub fn scale_factor(&self) -> f32
[src]
pub fn frame(&self) -> Size
[src]
pub fn menu_frame(&self) -> Size
[src]
pub fn inner_margin(&self) -> Size
[src]
pub fn outer_margins(&self) -> Margins
[src]
pub fn line_height(&self, class: TextClass) -> u32
[src]
pub fn text_bound(
&mut self,
text: &mut dyn TextApi,
class: TextClass,
axis: AxisInfo
) -> SizeRules
[src]
&mut self,
text: &mut dyn TextApi,
class: TextClass,
axis: AxisInfo
) -> SizeRules
pub fn edit_marker_width(&self) -> f32
[src]
pub fn button_surround(&self) -> (Size, Size)
[src]
pub fn edit_surround(&self) -> (Size, Size)
[src]
pub fn checkbox(&self) -> Size
[src]
pub fn radiobox(&self) -> Size
[src]
pub fn scrollbar(&self) -> (Size, u32)
[src]
pub 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]>,
pub fn scale_factor(&self) -> f32
[src]
pub fn frame(&self) -> Size
[src]
pub fn menu_frame(&self) -> Size
[src]
pub fn inner_margin(&self) -> Size
[src]
pub fn outer_margins(&self) -> Margins
[src]
pub fn line_height(&self, class: TextClass) -> u32
[src]
pub fn text_bound(
&mut self,
text: &mut dyn TextApi,
class: TextClass,
axis: AxisInfo
) -> SizeRules
[src]
&mut self,
text: &mut dyn TextApi,
class: TextClass,
axis: AxisInfo
) -> SizeRules