2021-10-14 16:59:19 +07:00
|
|
|
use crate::renderer::{self, Renderer};
|
2021-10-31 16:13:03 +07:00
|
|
|
use crate::text::{self, Text};
|
2023-03-04 05:37:11 +01:00
|
|
|
use crate::{Background, Font, Point, Rectangle, Size, Vector};
|
2019-11-21 13:47:20 +01:00
|
|
|
|
2023-02-04 11:12:15 +01:00
|
|
|
use std::borrow::Cow;
|
|
|
|
|
|
2019-11-22 19:36:57 +01:00
|
|
|
/// A renderer that does nothing.
|
2019-12-30 12:14:26 +01:00
|
|
|
///
|
|
|
|
|
/// It can be useful if you are writing tests!
|
2022-07-09 18:03:59 +02:00
|
|
|
#[derive(Debug, Clone, Copy, Default)]
|
2019-11-21 13:47:20 +01:00
|
|
|
pub struct Null;
|
|
|
|
|
|
2019-12-30 12:14:26 +01:00
|
|
|
impl Null {
|
2020-01-09 18:31:07 +01:00
|
|
|
/// Creates a new [`Null`] renderer.
|
2019-12-30 12:14:26 +01:00
|
|
|
pub fn new() -> Null {
|
|
|
|
|
Null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-21 13:47:20 +01:00
|
|
|
impl Renderer for Null {
|
2023-03-04 05:37:11 +01:00
|
|
|
type Theme = ();
|
2022-05-14 01:47:55 +02:00
|
|
|
|
2021-10-25 16:16:35 +07:00
|
|
|
fn with_layer(&mut self, _bounds: Rectangle, _f: impl FnOnce(&mut Self)) {}
|
|
|
|
|
|
|
|
|
|
fn with_translation(
|
2021-10-14 17:15:29 +07:00
|
|
|
&mut self,
|
2021-10-25 16:16:35 +07:00
|
|
|
_translation: Vector,
|
2021-10-14 17:15:29 +07:00
|
|
|
_f: impl FnOnce(&mut Self),
|
|
|
|
|
) {
|
|
|
|
|
}
|
2021-10-14 16:59:19 +07:00
|
|
|
|
|
|
|
|
fn clear(&mut self) {}
|
2021-10-18 14:47:49 +07:00
|
|
|
|
2021-11-04 19:22:29 +07:00
|
|
|
fn fill_quad(
|
|
|
|
|
&mut self,
|
|
|
|
|
_quad: renderer::Quad,
|
|
|
|
|
_background: impl Into<Background>,
|
|
|
|
|
) {
|
|
|
|
|
}
|
2019-11-21 13:47:20 +01:00
|
|
|
}
|
|
|
|
|
|
2021-10-31 16:13:03 +07:00
|
|
|
impl text::Renderer for Null {
|
2020-04-23 22:17:11 +02:00
|
|
|
type Font = Font;
|
|
|
|
|
|
2023-02-04 07:33:33 +01:00
|
|
|
const ICON_FONT: Font = Font::SansSerif;
|
2021-10-21 19:06:22 +07:00
|
|
|
const CHECKMARK_ICON: char = '0';
|
|
|
|
|
const ARROW_DOWN_ICON: char = '0';
|
|
|
|
|
|
2023-02-04 07:33:33 +01:00
|
|
|
fn default_font(&self) -> Self::Font {
|
|
|
|
|
Font::SansSerif
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-04 16:41:18 +01:00
|
|
|
fn default_size(&self) -> f32 {
|
2023-02-04 07:33:33 +01:00
|
|
|
16.0
|
2020-06-19 00:08:28 +02:00
|
|
|
}
|
2019-11-21 13:47:20 +01:00
|
|
|
|
2023-02-04 11:12:15 +01:00
|
|
|
fn load_font(&mut self, _font: Cow<'static, [u8]>) {}
|
|
|
|
|
|
2019-11-21 13:47:20 +01:00
|
|
|
fn measure(
|
|
|
|
|
&self,
|
|
|
|
|
_content: &str,
|
2023-02-04 16:41:18 +01:00
|
|
|
_size: f32,
|
2019-11-21 13:47:20 +01:00
|
|
|
_font: Font,
|
|
|
|
|
_bounds: Size,
|
|
|
|
|
) -> (f32, f32) {
|
|
|
|
|
(0.0, 20.0)
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-21 10:31:26 -07:00
|
|
|
fn hit_test(
|
|
|
|
|
&self,
|
|
|
|
|
_contents: &str,
|
|
|
|
|
_size: f32,
|
|
|
|
|
_font: Self::Font,
|
|
|
|
|
_bounds: Size,
|
|
|
|
|
_point: Point,
|
|
|
|
|
_nearest_only: bool,
|
2021-09-15 14:49:13 +07:00
|
|
|
) -> Option<text::Hit> {
|
|
|
|
|
None
|
2021-08-21 10:31:26 -07:00
|
|
|
}
|
2019-11-21 13:47:20 +01:00
|
|
|
|
2021-10-31 16:13:03 +07:00
|
|
|
fn fill_text(&mut self, _text: Text<'_, Self::Font>) {}
|
2019-11-21 13:47:20 +01:00
|
|
|
}
|