Skip to main content

fret_core/
services.rs

1use crate::{MaterialService, PathService, SvgService, TextService};
2
3/// UI runtime services passed to widgets during layout/paint/event handling.
4///
5/// This is intentionally a single `&mut` handle so runtimes can pass a single renderer-owned
6/// service object (similar to how GPUI passes a `Window`/context that provides multiple facilities).
7pub trait UiServices: TextService + PathService + SvgService + MaterialService {}
8
9impl<T> UiServices for T where T: TextService + PathService + SvgService + MaterialService {}
10
11impl dyn UiServices + '_ {
12    pub fn text(&mut self) -> &mut dyn TextService {
13        self
14    }
15
16    pub fn path(&mut self) -> &mut dyn PathService {
17        self
18    }
19
20    pub fn svg(&mut self) -> &mut dyn SvgService {
21        self
22    }
23
24    pub fn materials(&mut self) -> &mut dyn MaterialService {
25        self
26    }
27}