mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 02:39:28 +00:00

... which uses an intermediate drawing backend to skip the text on the axis, as that requires TrueType fonts form the filesystem.
109 lines
3.1 KiB
Rust
109 lines
3.1 KiB
Rust
/* LICENSE BEGIN
|
|
This file is part of the SixtyFPS Project -- https://sixtyfps.io
|
|
Copyright (c) 2021 Olivier Goffart <olivier.goffart@sixtyfps.io>
|
|
Copyright (c) 2021 Simon Hausmann <simon.hausmann@sixtyfps.io>
|
|
|
|
SPDX-License-Identifier: GPL-3.0-only
|
|
This file is also available under commercial licensing terms.
|
|
Please contact info@sixtyfps.io for more information.
|
|
LICENSE END */
|
|
use plotters_backend::*;
|
|
|
|
pub struct BackendWithoutText<ForwardedBackend: DrawingBackend> {
|
|
pub backend: ForwardedBackend,
|
|
}
|
|
|
|
impl<ForwardedBackend: DrawingBackend> DrawingBackend for BackendWithoutText<ForwardedBackend> {
|
|
type ErrorType = ForwardedBackend::ErrorType;
|
|
|
|
fn get_size(&self) -> (u32, u32) {
|
|
self.backend.get_size()
|
|
}
|
|
|
|
fn ensure_prepared(&mut self) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
|
|
self.backend.ensure_prepared()
|
|
}
|
|
|
|
fn present(&mut self) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
|
|
self.backend.present()
|
|
}
|
|
|
|
fn draw_pixel(
|
|
&mut self,
|
|
point: BackendCoord,
|
|
color: BackendColor,
|
|
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
|
|
self.backend.draw_pixel(point, color)
|
|
}
|
|
|
|
fn draw_line<S: BackendStyle>(
|
|
&mut self,
|
|
from: BackendCoord,
|
|
to: BackendCoord,
|
|
style: &S,
|
|
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
|
|
self.backend.draw_line(from, to, style)
|
|
}
|
|
|
|
fn draw_rect<S: BackendStyle>(
|
|
&mut self,
|
|
upper_left: BackendCoord,
|
|
bottom_right: BackendCoord,
|
|
style: &S,
|
|
fill: bool,
|
|
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
|
|
self.backend.draw_rect(upper_left, bottom_right, style, fill)
|
|
}
|
|
|
|
fn draw_path<S: BackendStyle, I: IntoIterator<Item = BackendCoord>>(
|
|
&mut self,
|
|
path: I,
|
|
style: &S,
|
|
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
|
|
self.backend.draw_path(path, style)
|
|
}
|
|
|
|
fn draw_circle<S: BackendStyle>(
|
|
&mut self,
|
|
center: BackendCoord,
|
|
radius: u32,
|
|
style: &S,
|
|
fill: bool,
|
|
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
|
|
self.backend.draw_circle(center, radius, style, fill)
|
|
}
|
|
|
|
fn fill_polygon<S: BackendStyle, I: IntoIterator<Item = BackendCoord>>(
|
|
&mut self,
|
|
vert: I,
|
|
style: &S,
|
|
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
|
|
self.backend.fill_polygon(vert, style)
|
|
}
|
|
|
|
fn draw_text<TStyle: BackendTextStyle>(
|
|
&mut self,
|
|
_text: &str,
|
|
_style: &TStyle,
|
|
_pos: BackendCoord,
|
|
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
|
|
Ok(())
|
|
}
|
|
|
|
fn estimate_text_size<TStyle: BackendTextStyle>(
|
|
&self,
|
|
_text: &str,
|
|
_style: &TStyle,
|
|
) -> Result<(u32, u32), DrawingErrorKind<Self::ErrorType>> {
|
|
Ok((0, 0))
|
|
}
|
|
|
|
fn blit_bitmap<'b>(
|
|
&mut self,
|
|
pos: BackendCoord,
|
|
(iw, ih): (u32, u32),
|
|
src: &'b [u8],
|
|
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
|
|
self.backend.blit_bitmap(pos, (iw, ih), src)
|
|
}
|
|
}
|