(&self, cx: &mut DrawContext)
| 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 |
nothing calls this directly
no test coverage detected