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

pub trait SizeHandle {
    fn scale_factor(&self) -> f32;
fn frame(&self) -> Size;
fn menu_frame(&self) -> Size;
fn inner_margin(&self) -> Size;
fn outer_margins(&self) -> Margins;
fn line_height(&self, class: TextClass) -> u32;
fn text_bound(
        &mut self,
        text: &str,
        class: TextClass,
        axis: AxisInfo
    ) -> SizeRules;
fn button_surround(&self) -> (Size, Size);
fn edit_surround(&self) -> (Size, Size);
fn checkbox(&self) -> Size;
fn radiobox(&self) -> Size;
fn scrollbar(&self) -> (Size, u32);
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

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

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 Sizes. 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 Sizes. 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 scrollbar
  • min_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 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...