2021-09-20 15:09:55 +07:00
|
|
|
use crate::pane_grid;
|
|
|
|
|
use crate::progress_bar;
|
2021-10-14 16:59:19 +07:00
|
|
|
use crate::renderer::{self, Renderer};
|
2021-09-20 15:09:55 +07:00
|
|
|
use crate::text;
|
|
|
|
|
use crate::toggler;
|
2021-10-20 15:50:42 +07:00
|
|
|
use crate::{Font, Point, Rectangle, Size, Vector};
|
2019-11-21 13:47:20 +01:00
|
|
|
|
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!
|
2019-11-22 21:16:40 +01:00
|
|
|
#[derive(Debug, Clone, Copy)]
|
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 {
|
2021-10-14 17:15:29 +07:00
|
|
|
fn with_layer(
|
|
|
|
|
&mut self,
|
|
|
|
|
_bounds: Rectangle,
|
|
|
|
|
_offset: Vector<u32>,
|
|
|
|
|
_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
|
|
|
|
|
|
|
|
fn fill_rectangle(&mut self, _quad: renderer::Quad) {}
|
2019-11-21 13:47:20 +01:00
|
|
|
}
|
|
|
|
|
|
2021-10-14 16:59:19 +07:00
|
|
|
impl renderer::Text for Null {
|
2020-04-23 22:17:11 +02:00
|
|
|
type Font = Font;
|
|
|
|
|
|
2021-10-21 19:06:22 +07:00
|
|
|
const ICON_FONT: Font = Font::Default;
|
|
|
|
|
const CHECKMARK_ICON: char = '0';
|
|
|
|
|
const ARROW_DOWN_ICON: char = '0';
|
|
|
|
|
|
2020-06-19 00:08:28 +02:00
|
|
|
fn default_size(&self) -> u16 {
|
|
|
|
|
20
|
|
|
|
|
}
|
2019-11-21 13:47:20 +01:00
|
|
|
|
|
|
|
|
fn measure(
|
|
|
|
|
&self,
|
|
|
|
|
_content: &str,
|
|
|
|
|
_size: u16,
|
|
|
|
|
_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-20 18:40:39 +07:00
|
|
|
fn fill_text(&mut self, _text: renderer::text::Section<'_, Self::Font>) {}
|
2019-11-21 13:47:20 +01:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 01:53:26 +01:00
|
|
|
impl progress_bar::Renderer for Null {
|
|
|
|
|
type Style = ();
|
|
|
|
|
|
|
|
|
|
const DEFAULT_HEIGHT: u16 = 30;
|
2020-01-07 00:28:08 +01:00
|
|
|
}
|
2020-06-05 14:02:29 +02:00
|
|
|
|
2020-09-19 18:44:27 +02:00
|
|
|
impl toggler::Renderer for Null {
|
|
|
|
|
type Style = ();
|
|
|
|
|
|
|
|
|
|
const DEFAULT_SIZE: u16 = 20;
|
|
|
|
|
}
|