[][src]Trait kas::draw::DrawHandle

pub trait DrawHandle {
    pub fn draw_device(&mut self) -> (Pass, Coord, &mut dyn Draw);
pub fn clip_region(
        &mut self,
        rect: Rect,
        offset: Coord,
        class: ClipRegion,
        f: &mut dyn FnMut(&mut dyn DrawHandle)
    );
pub fn target_rect(&self) -> Rect;
pub fn outer_frame(&mut self, rect: Rect);
pub fn menu_frame(&mut self, rect: Rect);
pub fn separator(&mut self, rect: Rect);
pub fn text_offset(
        &mut self,
        pos: Coord,
        bounds: Vec2,
        offset: Coord,
        text: &TextDisplay,
        class: TextClass
    );
pub fn text_effects(
        &mut self,
        pos: Coord,
        offset: Coord,
        text: &dyn TextApi,
        class: TextClass
    );
pub fn text_accel(
        &mut self,
        pos: Coord,
        text: &Text<AccelString>,
        state: bool,
        class: TextClass
    );
pub fn edit_marker(
        &mut self,
        pos: Coord,
        bounds: Vec2,
        offset: Coord,
        text: &TextDisplay,
        class: TextClass,
        byte: usize
    );
pub fn menu_entry(&mut self, rect: Rect, state: InputState);
pub fn button(&mut self, rect: Rect, state: InputState);
pub fn edit_box(&mut self, rect: Rect, state: InputState);
pub fn checkbox(&mut self, rect: Rect, checked: bool, state: InputState);
pub fn radiobox(&mut self, rect: Rect, checked: bool, state: InputState);
pub fn scrollbar(
        &mut self,
        rect: Rect,
        h_rect: Rect,
        dir: Direction,
        state: InputState
    );
pub fn slider(
        &mut self,
        rect: Rect,
        h_rect: Rect,
        dir: Direction,
        state: InputState
    ); }

Handle passed to objects during draw and sizing operations

This handle is provided by the toolkit (usually via a theme implementation) as a high-level drawing interface. See also the extension trait, DrawHandleExt, and the companion trait, SizeHandle.

Required methods

pub fn draw_device(&mut self) -> (Pass, Coord, &mut dyn Draw)[src]

Access the low-level draw device

Returns (pass, offset, draw).

One may use Draw::as_any_mut to downcast the draw object when necessary.

Important: all positions (Rect and Coord) must be adjusted (as below) by the given offset before being passed to the methods of Draw and its extension traits. This offset is used by kas::widget::ScrollRegion to adjust its contents.

let rect = rect + offset;

pub fn clip_region(
    &mut self,
    rect: Rect,
    offset: Coord,
    class: ClipRegion,
    f: &mut dyn FnMut(&mut dyn DrawHandle)
)
[src]

Construct a new draw-handle on a given region and pass to a callback.

This new region uses coordinates relative to offset (i.e. coordinates are subtracted by offset).

All content drawn by the new region is clipped to the given rect (in the current coordinate space, i.e. not translated by offset).

pub fn target_rect(&self) -> Rect[src]

Target area for drawing

If this instance of DrawHandle was created via DrawHandle::clip_region, then this returns the rect passed to that method; otherwise this returns the window's rect.

pub fn outer_frame(&mut self, rect: Rect)[src]

Draw a frame inside the given rect

The frame dimensions equal those of SizeHandle::frame on each side.

pub fn menu_frame(&mut self, rect: Rect)[src]

Draw a menu frame and background inside the given rect

The frame dimensions equal those of SizeHandle::frame on each side.

pub fn separator(&mut self, rect: Rect)[src]

Draw a separator in the given rect

pub fn text_offset(
    &mut self,
    pos: Coord,
    bounds: Vec2,
    offset: Coord,
    text: &TextDisplay,
    class: TextClass
)
[src]

Draw some text using the standard font

The text is drawn within the rect from pos to text.env().bounds, but offset by subtracting offset (allowing scrolling).

The dimensions required for this text may be queried with SizeHandle::text_bound.

pub fn text_effects(
    &mut self,
    pos: Coord,
    offset: Coord,
    text: &dyn TextApi,
    class: TextClass
)
[src]

Draw text with effects

DrawHandle::text_offset already supports font effects: bold, emphasis, text size. In addition, this method supports underline and strikethrough effects.

pub fn text_accel(
    &mut self,
    pos: Coord,
    text: &Text<AccelString>,
    state: bool,
    class: TextClass
)
[src]

Draw an AccelString text

The text is drawn within the rect from pos to text.env().bounds.

The dimensions required for this text may be queried with SizeHandle::text_bound.

pub fn edit_marker(
    &mut self,
    pos: Coord,
    bounds: Vec2,
    offset: Coord,
    text: &TextDisplay,
    class: TextClass,
    byte: usize
)
[src]

Draw an edit marker at the given byte index on this text

pub fn menu_entry(&mut self, rect: Rect, state: InputState)[src]

Draw the background of a menu entry

pub fn button(&mut self, rect: Rect, state: InputState)[src]

Draw button sides, background and margin-area highlight

pub fn edit_box(&mut self, rect: Rect, state: InputState)[src]

Draw edit box sides, background and margin-area highlight

pub fn checkbox(&mut self, rect: Rect, checked: bool, state: InputState)[src]

Draw UI element: checkbox

The checkbox is a small, usually square, box with or without a check mark. A checkbox widget may include a text label, but that label is not part of this element.

pub fn radiobox(&mut self, rect: Rect, checked: bool, state: InputState)[src]

Draw UI element: radiobox

This is similar in appearance to a checkbox.

pub fn scrollbar(
    &mut self,
    rect: Rect,
    h_rect: Rect,
    dir: Direction,
    state: InputState
)
[src]

Draw UI element: scrollbar

  • rect: area of whole widget (slider track)
  • h_rect: area of slider handle
  • dir: direction of bar
  • state: highlighting information

pub fn slider(
    &mut self,
    rect: Rect,
    h_rect: Rect,
    dir: Direction,
    state: InputState
)
[src]

Draw UI element: slider

  • rect: area of whole widget (slider track)
  • h_rect: area of slider handle
  • dir: direction of slider (currently only LTR or TTB)
  • state: highlighting information
Loading content...

Implementations on Foreign Types

impl<H: DrawHandle> DrawHandle for Box<H>[src]

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

Loading content...

Implementors

Loading content...