-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathcursors.rs
86 lines (79 loc) · 2.19 KB
/
cursors.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License in the LICENSE-APACHE file or at:
// https://www.apache.org/licenses/LICENSE-2.0
//! Cursor gallery
use kas::event::CursorIcon;
use kas::prelude::*;
use kas::widgets::{Column, Label};
impl_scope! {
#[widget{
Data = ();
layout = self.label;
cursor_icon = self.cursor;
}]
struct CursorWidget {
core: widget_core!(),
#[widget]
label: Label<&'static str>,
cursor: CursorIcon,
}
impl Tile for Self {
fn probe(&mut self, _: Coord) -> Id {
// Steal mouse focus: hover points to self, not self.label
self.id()
}
}
}
// Using a macro lets us stringify! the type name
macro_rules! cursor {
($name: tt) => {
CursorWidget {
core: Default::default(),
label: Label::new(stringify!($name)),
cursor: CursorIcon::$name,
}
};
}
fn main() -> kas::runner::Result<()> {
env_logger::init();
// These are winit::window::CursorIcon enum variants
let column = Column::new([
cursor!(Default),
cursor!(ContextMenu),
cursor!(Help),
cursor!(Pointer),
cursor!(Progress),
cursor!(Wait),
cursor!(Cell),
cursor!(Crosshair),
cursor!(Text),
cursor!(VerticalText),
cursor!(Alias),
cursor!(Copy),
cursor!(Move),
cursor!(NoDrop),
cursor!(NotAllowed),
cursor!(Grab),
cursor!(Grabbing),
cursor!(EResize),
cursor!(NResize),
cursor!(NeResize),
cursor!(NwResize),
cursor!(SResize),
cursor!(SeResize),
cursor!(SwResize),
cursor!(WResize),
cursor!(EwResize),
cursor!(NsResize),
cursor!(NeswResize),
cursor!(NwseResize),
cursor!(ColResize),
cursor!(RowResize),
cursor!(AllScroll),
cursor!(ZoomIn),
cursor!(ZoomOut),
]);
let window = Window::new(column, "Cursor gallery");
kas::runner::Default::new(())?.with(window).run()
}