[−][src]Trait kas::draw::DrawHandle
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]
&mut self,
rect: Rect,
offset: Coord,
class: ClipRegion,
f: &mut dyn FnMut(&mut dyn DrawHandle)
)
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]
&mut self,
pos: Coord,
bounds: Vec2,
offset: Coord,
text: &TextDisplay,
class: TextClass
)
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]
&mut self,
pos: Coord,
offset: Coord,
text: &dyn TextApi,
class: TextClass
)
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]
&mut self,
pos: Coord,
text: &Text<AccelString>,
state: bool,
class: TextClass
)
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]
&mut self,
pos: Coord,
bounds: Vec2,
offset: Coord,
text: &TextDisplay,
class: TextClass,
byte: usize
)
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]
&mut self,
rect: Rect,
h_rect: Rect,
dir: Direction,
state: InputState
)
Draw UI element: scrollbar
rect
: area of whole widget (slider track)h_rect
: area of slider handledir
: direction of barstate
: highlighting information
pub fn slider(
&mut self,
rect: Rect,
h_rect: Rect,
dir: Direction,
state: InputState
)
[src]
&mut self,
rect: Rect,
h_rect: Rect,
dir: Direction,
state: InputState
)
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
Implementations on Foreign Types
impl<H: DrawHandle> DrawHandle for Box<H>
[src]
pub fn size_handle_dyn(&mut self, f: &mut dyn FnMut(&mut dyn SizeHandle))
[src]
pub fn draw_device(&mut self) -> (Pass, Coord, &mut dyn Draw)
[src]
pub fn clip_region(
&mut self,
rect: Rect,
offset: Coord,
class: ClipRegion,
f: &mut dyn FnMut(&mut dyn DrawHandle)
)
[src]
&mut self,
rect: Rect,
offset: Coord,
class: ClipRegion,
f: &mut dyn FnMut(&mut dyn DrawHandle)
)
pub fn target_rect(&self) -> Rect
[src]
pub fn outer_frame(&mut self, rect: Rect)
[src]
pub fn menu_frame(&mut self, rect: Rect)
[src]
pub fn separator(&mut self, rect: Rect)
[src]
pub fn text_offset(
&mut self,
pos: Coord,
bounds: Vec2,
offset: Coord,
text: &TextDisplay,
class: TextClass
)
[src]
&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
)
[src]
&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
)
[src]
&mut self,
pos: Coord,
text: &Text<AccelString>,
state: bool,
class: TextClass
)
pub fn text_selected_range(
&mut self,
pos: Coord,
bounds: Vec2,
offset: Coord,
text: &TextDisplay,
range: Range<usize>,
class: TextClass
)
[src]
&mut self,
pos: Coord,
bounds: Vec2,
offset: Coord,
text: &TextDisplay,
range: Range<usize>,
class: TextClass
)
pub fn edit_marker(
&mut self,
pos: Coord,
bounds: Vec2,
offset: Coord,
text: &TextDisplay,
class: TextClass,
byte: usize
)
[src]
&mut self,
pos: Coord,
bounds: Vec2,
offset: Coord,
text: &TextDisplay,
class: TextClass,
byte: usize
)
pub fn menu_entry(&mut self, rect: Rect, state: InputState)
[src]
pub fn button(&mut self, rect: Rect, state: InputState)
[src]
pub fn edit_box(&mut self, rect: Rect, state: InputState)
[src]
pub fn checkbox(&mut self, rect: Rect, checked: bool, state: InputState)
[src]
pub fn radiobox(&mut self, rect: Rect, checked: bool, state: InputState)
[src]
pub fn scrollbar(
&mut self,
rect: Rect,
h_rect: Rect,
dir: Direction,
state: InputState
)
[src]
&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
)
[src]
&mut self,
rect: Rect,
h_rect: Rect,
dir: Direction,
state: InputState
)
impl<S> DrawHandle for ValueA<dyn DrawHandle, S> where
S: Default + Copy + AsRef<[usize]> + AsMut<[usize]>,
[src]
S: Default + Copy + AsRef<[usize]> + AsMut<[usize]>,
pub fn size_handle_dyn(&mut self, f: &mut dyn FnMut(&mut dyn SizeHandle))
[src]
pub fn draw_device(&mut self) -> (Pass, Coord, &mut dyn Draw)
[src]
pub fn clip_region(
&mut self,
rect: Rect,
offset: Coord,
class: ClipRegion,
f: &mut dyn FnMut(&mut dyn DrawHandle)
)
[src]
&mut self,
rect: Rect,
offset: Coord,
class: ClipRegion,
f: &mut dyn FnMut(&mut dyn DrawHandle)
)
pub fn target_rect(&self) -> Rect
[src]
pub fn outer_frame(&mut self, rect: Rect)
[src]
pub fn menu_frame(&mut self, rect: Rect)
[src]
pub fn separator(&mut self, rect: Rect)
[src]
pub fn text_offset(
&mut self,
pos: Coord,
bounds: Vec2,
offset: Coord,
text: &TextDisplay,
class: TextClass
)
[src]
&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
)
[src]
&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
)
[src]
&mut self,
pos: Coord,
text: &Text<AccelString>,
state: bool,
class: TextClass
)
pub fn text_selected_range(
&mut self,
pos: Coord,
bounds: Vec2,
offset: Coord,
text: &TextDisplay,
range: Range<usize>,
class: TextClass
)
[src]
&mut self,
pos: Coord,
bounds: Vec2,
offset: Coord,
text: &TextDisplay,
range: Range<usize>,
class: TextClass
)
pub fn edit_marker(
&mut self,
pos: Coord,
bounds: Vec2,
offset: Coord,
text: &TextDisplay,
class: TextClass,
byte: usize
)
[src]
&mut self,
pos: Coord,
bounds: Vec2,
offset: Coord,
text: &TextDisplay,
class: TextClass,
byte: usize
)
pub fn menu_entry(&mut self, rect: Rect, state: InputState)
[src]
pub fn button(&mut self, rect: Rect, state: InputState)
[src]
pub fn edit_box(&mut self, rect: Rect, state: InputState)
[src]
pub fn checkbox(&mut self, rect: Rect, checked: bool, state: InputState)
[src]
pub fn radiobox(&mut self, rect: Rect, checked: bool, state: InputState)
[src]
pub fn scrollbar(
&mut self,
rect: Rect,
h_rect: Rect,
dir: Direction,
state: InputState
)
[src]
&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
)
[src]
&mut self,
rect: Rect,
h_rect: Rect,
dir: Direction,
state: InputState
)