Skip to main content

ferroui_base/rendering/
i_presentation_source.rs

1use super::{IHitTester, IRenderer};
2use crate::input::IInputRoot;
3use crate::layout::ILayoutRoot;
4use crate::platform::IPlatformSettings;
5use crate::{PixelPoint, Point, Ref, Size, Visual};
6use std::rc::Rc;
7
8/// The host of a visual tree: connects the tree to its renderer, layout root
9/// and input root.
10pub trait IPresentationSource {
11    /// The root visual of the tree.
12    fn root_visual(&self) -> Option<Ref<Visual>>;
13
14    /// The scaling factor to use in rendering.
15    fn render_scaling(&self) -> f64;
16
17    /// The renderer of the tree.
18    fn renderer(&self) -> Rc<dyn IRenderer>;
19
20    /// The layout root of the tree.
21    fn layout_root(&self) -> Rc<dyn ILayoutRoot>;
22
23    /// The size of the client area, in device-independent pixels.
24    fn client_size(&self) -> Size;
25
26    /// The platform settings of the host, if it has any.
27    fn platform_settings(&self) -> Option<Rc<dyn IPlatformSettings>> {
28        None
29    }
30
31    /// The hit tester of the tree.
32    fn hit_tester(&self) -> Rc<dyn IHitTester>;
33
34    /// The input root of the tree.
35    fn input_root(&self) -> Rc<dyn IInputRoot>;
36
37    /// Converts a point from client to screen coordinates, if the host is
38    /// on a screen.
39    fn point_to_screen(&self, _point: Point) -> Option<PixelPoint> {
40        None
41    }
42
43    /// Converts a point from screen to client coordinates, if the host is
44    /// on a screen.
45    fn point_to_client(&self, _point: PixelPoint) -> Option<Point> {
46        None
47    }
48}