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:
Self::size_handle
provides access to aSizeHandle
Self::draw_device
provides a lower-level interface for draw operationsSelf::new_pass
,DrawHandleExt::with_clip_region
,DrawHandleExt::with_overlay
construct new draw passesSelf::get_clip_rect
returns the clip rect
See also SizeHandle
.
Required methods
fn size_handle(&mut self) -> &mut dyn SizeHandle
fn size_handle(&mut self) -> &mut dyn SizeHandle
Access a SizeHandle
fn draw_device(&mut self) -> &mut dyn Draw
fn draw_device(&mut self) -> &mut dyn Draw
Access the low-level draw device
fn get_clip_rect(&self) -> Rect
fn get_clip_rect(&self) -> Rect
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.
fn outer_frame(&mut self, rect: Rect)
fn outer_frame(&mut self, rect: Rect)
Draw a frame inside the given rect
The frame dimensions equal those of SizeHandle::frame
on each side.
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.
fn selection_box(&mut self, rect: Rect)
fn selection_box(&mut self, rect: Rect)
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.
fn text(
&mut self,
pos: Coord,
text: &TextDisplay,
class: TextClass,
state: InputState
)
fn text(
&mut self,
pos: Coord,
text: &TextDisplay,
class: TextClass,
state: InputState
)
Draw some text using the standard font
The dimensions required for this text may be queried with SizeHandle::text_bound
.
fn text_effects(
&mut self,
pos: Coord,
text: &dyn TextApi,
class: TextClass,
state: InputState
)
fn text_effects(
&mut self,
pos: Coord,
text: &dyn TextApi,
class: TextClass,
state: InputState
)
Draw text with effects
DrawHandle::text
already supports font effects: bold,
emphasis, text size. In addition, this method supports underline and
strikethrough effects.
fn text_accel(
&mut self,
pos: Coord,
text: &Text<AccelString>,
accel: bool,
class: TextClass,
state: InputState
)
fn text_accel(
&mut self,
pos: Coord,
text: &Text<AccelString>,
accel: bool,
class: TextClass,
state: InputState
)
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
.
fn edit_marker(
&mut self,
pos: Coord,
text: &TextDisplay,
class: TextClass,
byte: usize
)
fn edit_marker(
&mut self,
pos: Coord,
text: &TextDisplay,
class: TextClass,
byte: usize
)
Draw an edit marker at the given byte
index on this text
Draw the background of a menu entry
Draw button sides, background and margin-area highlight
Optionally, a specific colour may be used.
fn edit_box(&mut self, rect: Rect, state: InputState)
fn edit_box(&mut self, rect: Rect, state: InputState)
Draw edit box sides, background and margin-area highlight
fn checkbox(&mut self, rect: Rect, checked: bool, state: InputState)
fn checkbox(&mut self, rect: Rect, checked: bool, state: InputState)
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.
fn radiobox(&mut self, rect: Rect, checked: bool, state: InputState)
fn radiobox(&mut self, rect: Rect, checked: bool, state: InputState)
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 handledir
: direction of barstate
: highlighting information
Draw UI element: slider
rect
: area of whole widget (slider track)h_rect
: area of slider handledir
: direction of slider (currently only LTR or TTB)state
: highlighting information
fn progress_bar(
&mut self,
rect: Rect,
dir: Direction,
state: InputState,
value: f32
)
fn progress_bar(
&mut self,
rect: Rect,
dir: Direction,
state: InputState,
value: f32
)
Draw UI element: progress bar
rect
: area of whole widgetdir
: direction of progress barstate
: highlighting informationvalue
: progress value, between 0.0 and 1.0