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
mod canvas;
mod draw_command;
mod draw_list;
mod input_handler;
mod style;
mod types;
mod ui;
pub mod widgets;
pub use draw_list::{DrawList, Vertex};
pub use input_handler::{InputHandler, KeyCode};
pub use style::Style;
pub use types::{Color, Rect, Vector2};
pub use ui::{Drag, Layout, Ui};
pub type Id = u64;
#[macro_export]
macro_rules! hash {
($s:expr) => {{
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
let id = $s;
let mut s = DefaultHasher::new();
id.hash(&mut s);
s.finish()
}};
() => {{
let id = concat!(file!(), line!(), column!());
hash!(id)
}};
($($s:expr),*) => {{
let mut s: u128 = 0;
$(s += $crate::hash!($s) as u128;)*
$crate::hash!(s)
}};
}
pub struct StorageContext();
pub trait ClipboardObject {
fn get(&self) -> Option<String>;
fn set(&mut self, data: &str);
}
pub(crate) struct LocalClipboard {
data: String,
}
impl LocalClipboard {
fn new() -> LocalClipboard {
LocalClipboard {
data: String::new(),
}
}
}
impl ClipboardObject for LocalClipboard {
fn get(&self) -> Option<String> {
Some(self.data.clone())
}
fn set(&mut self, data: &str) {
self.data = data.to_owned();
}
}