MCPcopy Create free account
hub / github.com/Kethku/Pando / draw

Method draw

aspen/src/components/editor.rs:707–746  ·  view source on GitHub ↗
(&self, cx: &mut DrawContext)

Source from the content-addressed store, hash-verified

705 }
706
707 fn draw(&self, cx: &mut DrawContext) {
708 let region = cx.region();
709 if cx.is_directly_focused() {
710 cx.mouse_region(region)
711 .on_down(|cx| {
712 cx.with_state(|state: &mut EditorState, cx| {
713 state.move_to_point(cx.mouse_position().unwrap());
714 cx.request_redraw();
715 });
716 })
717 .on_drag(|cx| {
718 cx.with_state(|state: &mut EditorState, cx| {
719 state.extend_selection_to_point(cx.mouse_position().unwrap());
720 cx.request_redraw();
721 });
722 })
723 .with_icon(CursorIcon::Text);
724 } else {
725 cx.mouse_region(region).on_click(move |cx| {
726 cx.focus();
727 });
728 }
729
730 cx.with_state(|state: &mut EditorState, cx| {
731 if cx.is_directly_focused() {
732 state.selection_geometry_with(|rect, _| {
733 cx.set_fill_brush(self.selection_fill.clone());
734 cx.fill(&Rect::new(rect.x0, rect.y0, rect.x1, rect.y1));
735 });
736
737 let cursor = state.cursor_geometry(1.0);
738 cx.set_fill_brush(self.cursor_stroke.clone());
739 cx.fill(&Rect::new(cursor.x0, cursor.y0, cursor.x1, cursor.y1));
740 }
741
742 cx.set_stroke_brush(self.text_stroke.clone());
743 let top_left = region.origin();
744 cx.draw_layout_at(&state.layout, top_left);
745 });
746 }
747}
748
749

Callers

nothing calls this directly

Calls 15

regionMethod · 0.80
is_directly_focusedMethod · 0.80
with_iconMethod · 0.80
on_dragMethod · 0.80
on_downMethod · 0.80
mouse_regionMethod · 0.80
move_to_pointMethod · 0.80
on_clickMethod · 0.80
set_fill_brushMethod · 0.80
fillMethod · 0.80

Tested by

no test coverage detected