[][src]Trait kas::draw::SizeHandle

pub trait SizeHandle {
    pub fn scale_factor(&self) -> f32;
pub fn frame(&self) -> Size;
pub fn menu_frame(&self) -> Size;
pub fn inner_margin(&self) -> Size;
pub fn outer_margins(&self) -> Margins;
pub fn line_height(&self, class: TextClass) -> u32;
pub fn text_bound(
        &mut self,
        text: &mut dyn TextApi,
        class: TextClass,
        axis: AxisInfo
    ) -> SizeRules;
pub fn edit_marker_width(&self) -> f32;
pub fn button_surround(&self) -> (Size, Size);
pub fn edit_surround(&self) -> (Size, Size);
pub fn checkbox(&self) -> Size;
pub fn radiobox(&self) -> Size;
pub fn scrollbar(&self) -> (Size, u32);
pub fn slider(&self) -> (Size, u32); }

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]

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 Sizes. 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 Sizes. 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 scrollbar
  • min_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 slider
  • min_len: minimum length for the whole bar

Required bound: min_len >= size.0.

Loading content...

Implementations on Foreign Types

impl<S: SizeHandle> SizeHandle for Box<S>[src]

impl<S> SizeHandle for ValueA<dyn SizeHandle, S> where
    S: Default + Copy + AsRef<[usize]> + AsMut<[usize]>, 
[src]

Loading content...

Implementors

Loading content...