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

pub trait DrawHandle {
Show 20 methods fn size_handle(&mut self) -> &mut dyn SizeHandle;
fn draw_device(&mut self) -> &mut dyn Draw;
fn get_clip_rect(&self) -> Rect;
fn outer_frame(&mut self, rect: Rect);
fn separator(&mut self, rect: Rect);
fn nav_frame(&mut self, rect: Rect, state: InputState);
fn selection_box(&mut self, rect: Rect);
fn text(
        &mut self,
        pos: Coord,
        text: &TextDisplay,
        class: TextClass,
        state: InputState
    );
fn text_effects(
        &mut self,
        pos: Coord,
        text: &dyn TextApi,
        class: TextClass,
        state: InputState
    );
fn text_accel(
        &mut self,
        pos: Coord,
        text: &Text<AccelString>,
        accel: bool,
        class: TextClass,
        state: InputState
    );
fn edit_marker(
        &mut self,
        pos: Coord,
        text: &TextDisplay,
        class: TextClass,
        byte: usize
    );
fn menu_entry(&mut self, rect: Rect, state: InputState);
fn button(&mut self, rect: Rect, col: Option<Rgb>, state: InputState);
fn edit_box(&mut self, rect: Rect, state: InputState);
fn checkbox(&mut self, rect: Rect, checked: bool, state: InputState);
fn radiobox(&mut self, rect: Rect, checked: bool, state: InputState);
fn scrollbar(
        &mut self,
        rect: Rect,
        h_rect: Rect,
        dir: Direction,
        state: InputState
    );
fn slider(
        &mut self,
        rect: Rect,
        h_rect: Rect,
        dir: Direction,
        state: InputState
    );
fn progress_bar(
        &mut self,
        rect: Rect,
        dir: Direction,
        state: InputState,
        value: f32
    );
fn image(&mut self, id: ImageId, rect: Rect);
}
Expand description

A handle to the active theme, used for drawing

The shell provides widgets a &dyn DrawHandle in crate::Layout::draw. The extension trait DrawHandleExt provides some additional methods on draw handles.

Most methods draw some feature. Exceptions:

See also SizeHandle.

Required methods

Access a SizeHandle

Access the low-level draw device

Target area for drawing

Drawing is restricted to this Rect, which may be the whole window, a clip region or an overlay. This may be used to cull hidden items from lists inside a scrollable view.

Draw a frame inside the given rect

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

Draw a separator in the given rect

Draw a navigation highlight frame in the given rect

This is a margin area which may have a some type of navigation highlight drawn in it, or may be empty.

Draw a selection box

This appears as a dashed box or similar around this rect. Note that the selection indicator is drawn outside of this rect, within a margin of size inner_margin that is expected to be present around this box.

Draw some text using the standard font

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

Draw text with effects

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

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.

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

fn menu_entry(&mut self, rect: Rect, state: InputState)

Draw the background of a menu entry

Draw button sides, background and margin-area highlight

Optionally, a specific colour may be used.

Draw edit box sides, background and margin-area highlight

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.

Draw UI element: radiobox

This is similar in appearance to a checkbox.

Draw UI element: scrollbar

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

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

Draw UI element: progress bar

  • rect: area of whole widget
  • dir: direction of progress bar
  • state: highlighting information
  • value: progress value, between 0.0 and 1.0

Draw an image

Implementations on Foreign Types

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

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

Implementors