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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
mod assets;
#[cfg(any(feature = "glow-backend", feature = "wasm-backend"))]
mod backend_glow;
#[cfg(feature = "glow-backend")]
mod backend_glow_native;
#[cfg(feature = "wasm-backend")]
mod backend_glow_wasm;
mod canvas;
mod color;
mod drawing;
mod event;
mod event_ctx;
mod geom;
mod input;
mod managed;
mod runner;
mod screen_geom;
mod style;
mod svg;
mod text;
mod tools;
mod widgets;
mod backend {
#[cfg(any(feature = "glow-backend", feature = "wasm-backend"))]
pub use crate::backend_glow::*;
}
pub use crate::backend::Drawable;
pub use crate::canvas::{Canvas, HorizontalAlignment, VerticalAlignment};
pub use crate::color::{Color, FancyColor, LinearGradient};
pub use crate::drawing::{GfxCtx, Prerender};
pub use crate::event::{hotkey, hotkeys, lctrl, Event, Key, MultiKey};
pub use crate::event_ctx::{EventCtx, UpdateType};
pub use crate::geom::{GeomBatch, RewriteColor};
pub use crate::input::UserInput;
pub use crate::managed::{Composite, Widget};
pub use crate::runner::{run, Settings, GUI};
pub use crate::screen_geom::{ScreenDims, ScreenPt, ScreenRectangle};
pub use crate::style::Style;
pub use crate::text::{Line, Text, TextExt, TextSpan};
pub use crate::tools::warper::Warper;
pub use crate::widgets::autocomplete::Autocomplete;
pub use crate::widgets::button::Btn;
pub(crate) use crate::widgets::button::Button;
pub use crate::widgets::checkbox::Checkbox;
pub use crate::widgets::compare_times::CompareTimes;
pub(crate) use crate::widgets::dropdown::Dropdown;
pub use crate::widgets::fan_chart::FanChart;
pub use crate::widgets::filler::Filler;
pub use crate::widgets::just_draw::DrawWithTooltips;
pub(crate) use crate::widgets::just_draw::{DeferDraw, JustDraw};
pub use crate::widgets::line_plot::{LinePlot, PlotOptions, Series};
pub use crate::widgets::menu::Menu;
pub use crate::widgets::persistent_split::PersistentSplit;
pub use crate::widgets::scatter_plot::ScatterPlot;
pub use crate::widgets::slider::{AreaSlider, Slider};
pub use crate::widgets::spinner::Spinner;
pub(crate) use crate::widgets::text_box::TextBox;
pub use crate::widgets::{Outcome, WidgetImpl, WidgetOutput};
pub struct Choice<T> {
pub label: String,
pub data: T,
pub(crate) hotkey: Option<MultiKey>,
pub(crate) active: bool,
pub(crate) tooltip: Option<String>,
}
impl<T> Choice<T> {
pub fn new<S: Into<String>>(label: S, data: T) -> Choice<T> {
Choice {
label: label.into(),
data,
hotkey: None,
active: true,
tooltip: None,
}
}
pub fn from(tuples: Vec<(String, T)>) -> Vec<Choice<T>> {
tuples
.into_iter()
.map(|(label, data)| Choice::new(label, data))
.collect()
}
pub fn key(mut self, key: Key) -> Choice<T> {
assert_eq!(self.hotkey, None);
self.hotkey = hotkey(key);
self
}
pub fn multikey(mut self, mk: Option<MultiKey>) -> Choice<T> {
self.hotkey = mk;
self
}
pub fn active(mut self, active: bool) -> Choice<T> {
self.active = active;
self
}
pub fn tooltip<I: Into<String>>(mut self, info: I) -> Choice<T> {
self.tooltip = Some(info.into());
self
}
pub(crate) fn with_value<X>(&self, data: X) -> Choice<X> {
Choice {
label: self.label.clone(),
data,
hotkey: self.hotkey.clone(),
active: self.active,
tooltip: self.tooltip.clone(),
}
}
}
impl Choice<String> {
pub fn string(label: &str) -> Choice<String> {
Choice::new(label.to_string(), label.to_string())
}
pub fn strings<I: Into<String>>(list: Vec<I>) -> Vec<Choice<String>> {
list.into_iter()
.map(|x| {
let x = x.into();
Choice::new(x.clone(), x)
})
.collect()
}
}