iced-yoda/native/src/renderer/null.rs

82 lines
1.5 KiB
Rust
Raw Normal View History

use crate::pane_grid;
use crate::progress_bar;
2021-10-14 16:59:19 +07:00
use crate::renderer::{self, Renderer};
use crate::text;
use crate::toggler;
use crate::{Font, Point, Rectangle, Size, Vector};
/// A renderer that does nothing.
///
/// It can be useful if you are writing tests!
#[derive(Debug, Clone, Copy)]
pub struct Null;
impl Null {
/// Creates a new [`Null`] renderer.
pub fn new() -> Null {
Null
}
}
impl Renderer for Null {
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) {}
fn fill_rectangle(&mut self, _quad: renderer::Quad) {}
}
2021-10-14 16:59:19 +07:00
impl renderer::Text for Null {
type Font = Font;
const ICON_FONT: Font = Font::Default;
const CHECKMARK_ICON: char = '0';
const ARROW_DOWN_ICON: char = '0';
fn default_size(&self) -> u16 {
20
}
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,
) -> Option<text::Hit> {
None
2021-08-21 10:31:26 -07:00
}
fn fill_text(&mut self, _text: renderer::text::Section<'_, Self::Font>) {}
}
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
}
impl toggler::Renderer for Null {
type Style = ();
const DEFAULT_SIZE: u16 = 20;
}