2021-09-20 15:09:55 +07:00
|
|
|
use crate::button;
|
|
|
|
|
use crate::checkbox;
|
|
|
|
|
use crate::pane_grid;
|
|
|
|
|
use crate::progress_bar;
|
|
|
|
|
use crate::radio;
|
2021-10-14 16:59:19 +07:00
|
|
|
use crate::renderer::{self, Renderer};
|
2021-09-20 15:09:55 +07:00
|
|
|
use crate::slider;
|
|
|
|
|
use crate::text;
|
|
|
|
|
use crate::text_input;
|
|
|
|
|
use crate::toggler;
|
2021-10-14 17:15:29 +07:00
|
|
|
use crate::{Font, Padding, 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-14 16:59:19 +07:00
|
|
|
fn fill_text(&mut self, _text: renderer::text::Section<'_, Self::Font>) {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl text::Renderer for Null {
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl text_input::Renderer for Null {
|
2020-01-01 18:26:49 +01:00
|
|
|
type Style = ();
|
|
|
|
|
|
2020-01-27 04:28:40 +09:00
|
|
|
fn measure_value(&self, _value: &str, _size: u16, _font: Font) -> f32 {
|
2019-12-05 03:09:39 +01:00
|
|
|
0.0
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-21 05:30:48 +01:00
|
|
|
fn offset(
|
|
|
|
|
&self,
|
|
|
|
|
_text_bounds: Rectangle,
|
2020-03-25 13:57:02 +01:00
|
|
|
_font: Font,
|
2019-12-21 05:30:48 +01:00
|
|
|
_size: u16,
|
|
|
|
|
_value: &text_input::Value,
|
|
|
|
|
_state: &text_input::State,
|
|
|
|
|
) -> f32 {
|
|
|
|
|
0.0
|
|
|
|
|
}
|
2019-11-21 13:47:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl radio::Renderer for Null {
|
2020-01-07 02:25:57 +01:00
|
|
|
type Style = ();
|
|
|
|
|
|
2020-05-15 11:27:24 +09:00
|
|
|
const DEFAULT_SIZE: u16 = 20;
|
|
|
|
|
const DEFAULT_SPACING: u16 = 15;
|
2019-11-21 13:47:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl checkbox::Renderer for Null {
|
2020-01-07 02:54:54 +01:00
|
|
|
type Style = ();
|
|
|
|
|
|
2020-02-18 02:28:15 +01:00
|
|
|
const DEFAULT_SIZE: u16 = 20;
|
|
|
|
|
const DEFAULT_SPACING: u16 = 15;
|
2019-11-21 13:47:20 +01:00
|
|
|
}
|
2020-01-07 00:28:08 +01:00
|
|
|
|
|
|
|
|
impl slider::Renderer for Null {
|
|
|
|
|
type Style = ();
|
|
|
|
|
|
2020-08-01 08:18:52 +02:00
|
|
|
const DEFAULT_HEIGHT: u16 = 30;
|
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-06-10 16:27:28 +02:00
|
|
|
impl pane_grid::Renderer for Null {
|
2021-01-01 15:28:38 +01:00
|
|
|
type Style = ();
|
2020-06-10 16:27:28 +02:00
|
|
|
}
|
2020-09-19 18:44:27 +02:00
|
|
|
|
|
|
|
|
impl toggler::Renderer for Null {
|
|
|
|
|
type Style = ();
|
|
|
|
|
|
|
|
|
|
const DEFAULT_SIZE: u16 = 20;
|
|
|
|
|
}
|