summaryrefslogtreecommitdiffstats
path: root/core/src/renderer
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/renderer')
-rw-r--r--core/src/renderer/null.rs137
1 files changed, 110 insertions, 27 deletions
diff --git a/core/src/renderer/null.rs b/core/src/renderer/null.rs
index 5d49699e..da0f32de 100644
--- a/core/src/renderer/null.rs
+++ b/core/src/renderer/null.rs
@@ -1,6 +1,7 @@
+use crate::alignment;
use crate::renderer::{self, Renderer};
use crate::text::{self, Text};
-use crate::{Background, Font, Point, Rectangle, Size, Vector};
+use crate::{Background, Color, Font, Pixels, Point, Rectangle, Size, Vector};
use std::borrow::Cow;
@@ -41,6 +42,8 @@ impl Renderer for Null {
impl text::Renderer for Null {
type Font = Font;
+ type Paragraph = ();
+ type Editor = ();
const ICON_FONT: Font = Font::DEFAULT;
const CHECKMARK_ICON: char = '0';
@@ -50,37 +53,117 @@ impl text::Renderer for Null {
Font::default()
}
- fn default_size(&self) -> f32 {
- 16.0
+ fn default_size(&self) -> Pixels {
+ Pixels(16.0)
}
fn load_font(&mut self, _font: Cow<'static, [u8]>) {}
- fn measure(
- &self,
- _content: &str,
- _size: f32,
- _line_height: text::LineHeight,
- _font: Font,
- _bounds: Size,
- _shaping: text::Shaping,
- ) -> Size {
- Size::new(0.0, 20.0)
- }
-
- fn hit_test(
- &self,
- _contents: &str,
- _size: f32,
- _line_height: text::LineHeight,
- _font: Self::Font,
- _bounds: Size,
- _shaping: text::Shaping,
- _point: Point,
- _nearest_only: bool,
- ) -> Option<text::Hit> {
+ fn fill_paragraph(
+ &mut self,
+ _paragraph: &Self::Paragraph,
+ _position: Point,
+ _color: Color,
+ ) {
+ }
+
+ fn fill_editor(
+ &mut self,
+ _editor: &Self::Editor,
+ _position: Point,
+ _color: Color,
+ ) {
+ }
+
+ fn fill_text(
+ &mut self,
+ _paragraph: Text<'_, Self::Font>,
+ _position: Point,
+ _color: Color,
+ ) {
+ }
+}
+
+impl text::Paragraph for () {
+ type Font = Font;
+
+ fn with_text(_text: Text<'_, Self::Font>) -> Self {}
+
+ fn resize(&mut self, _new_bounds: Size) {}
+
+ fn compare(&self, _text: Text<'_, Self::Font>) -> text::Difference {
+ text::Difference::None
+ }
+
+ fn horizontal_alignment(&self) -> alignment::Horizontal {
+ alignment::Horizontal::Left
+ }
+
+ fn vertical_alignment(&self) -> alignment::Vertical {
+ alignment::Vertical::Top
+ }
+
+ fn grapheme_position(&self, _line: usize, _index: usize) -> Option<Point> {
+ None
+ }
+
+ fn min_bounds(&self) -> Size {
+ Size::ZERO
+ }
+
+ fn hit_test(&self, _point: Point) -> Option<text::Hit> {
+ None
+ }
+}
+
+impl text::Editor for () {
+ type Font = Font;
+
+ fn with_text(_text: &str) -> Self {}
+
+ fn cursor(&self) -> text::editor::Cursor {
+ text::editor::Cursor::Caret(Point::ORIGIN)
+ }
+
+ fn cursor_position(&self) -> (usize, usize) {
+ (0, 0)
+ }
+
+ fn selection(&self) -> Option<String> {
+ None
+ }
+
+ fn line(&self, _index: usize) -> Option<&str> {
None
}
- fn fill_text(&mut self, _text: Text<'_, Self::Font>) {}
+ fn line_count(&self) -> usize {
+ 0
+ }
+
+ fn perform(&mut self, _action: text::editor::Action) {}
+
+ fn bounds(&self) -> Size {
+ Size::ZERO
+ }
+
+ fn update(
+ &mut self,
+ _new_bounds: Size,
+ _new_font: Self::Font,
+ _new_size: Pixels,
+ _new_line_height: text::LineHeight,
+ _new_highlighter: &mut impl text::Highlighter,
+ ) {
+ }
+
+ fn highlight<H: text::Highlighter>(
+ &mut self,
+ _font: Self::Font,
+ _highlighter: &mut H,
+ _format_highlight: impl Fn(
+ &H::Highlight,
+ ) -> text::highlighter::Format<Self::Font>,
+ ) {
+ }
}