simple_render/wayland/
options.rs1use super::runtime::run_inner;
2use super::*;
3
4#[derive(Debug, Clone)]
5pub struct LayerOptions {
6 pub namespace: String,
7 pub width: u32,
8 pub height: u32,
9 pub output: Option<OutputTarget>,
10 pub layer: Layer,
11 pub anchor: Anchor,
12 pub margins: Margins,
13 pub exclusive_zone: i32,
14 pub keyboard_interactivity: KeyboardInteractivity,
15}
16
17impl Default for LayerOptions {
18 fn default() -> Self {
19 Self {
20 namespace: "simple-render".to_owned(),
21 width: 256,
22 height: 256,
23 output: None,
24 layer: Layer::Top,
25 anchor: Anchor::Top,
26 margins: Margins::default(),
27 exclusive_zone: 0,
28 keyboard_interactivity: KeyboardInteractivity::None,
29 }
30 }
31}
32
33impl LayerOptions {
34 pub fn show<R>(self, renderer: R) -> Result<()>
35 where
36 R: Renderer + 'static,
37 {
38 run_inner(renderer, Some((DEFAULT_SURFACE_ID, self)), None, true)
39 }
40
41 pub fn show_with_commands<R>(self, renderer: R, receiver: RenderReceiver) -> Result<()>
42 where
43 R: Renderer + 'static,
44 {
45 run_inner(
46 renderer,
47 Some((DEFAULT_SURFACE_ID, self)),
48 Some(receiver),
49 true,
50 )
51 }
52}
53
54#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
55pub struct Margins {
56 pub top: i32,
57 pub right: i32,
58 pub bottom: i32,
59 pub left: i32,
60}
61
62#[derive(Debug, Clone, PartialEq, Eq)]
63pub enum OutputTarget {
64 Any,
65 Id(u32),
66 Name(String),
67}
68
69#[derive(Debug, Clone, Copy, PartialEq, Eq)]
70pub enum Layer {
71 Background,
72 Bottom,
73 Top,
74 Overlay,
75}
76
77#[derive(Debug, Clone, Copy, PartialEq, Eq)]
78pub enum KeyboardInteractivity {
79 None,
80 Exclusive,
81 OnDemand,
82}
83
84#[derive(Debug, Clone, Copy, PartialEq, Eq)]
85pub enum Anchor {
86 Center,
87 Top,
88 TopLeft,
89 TopRight,
90 Bottom,
91 BottomLeft,
92 BottomRight,
93 Left,
94 Right,
95 Fill,
96 Position { x: i32, y: i32 },
97}