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
//! Controls for user interaction with the plot.
/// Configures user interaction behavior for [`crate::PlotWidget`].
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct PlotControls {
/// Controls how panning is performed.
pub pan: PanControls,
/// Controls how zooming is performed.
pub zoom: ZoomControls,
/// Controls how points are picked and cleared.
pub pick: PickControls,
/// Enables point highlighting while hovering.
pub highlight_on_hover: bool,
/// Shows the in-canvas controls/help UI (`?` button).
pub show_controls_help: bool,
}
/// Configures panning interactions.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct PanControls {
/// Enables panning using the mouse wheel or trackpad scroll gesture.
pub scroll_to_pan: bool,
/// Enables panning by dragging with the left mouse button.
pub drag_to_pan: bool,
}
/// Configures zoom interactions.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ZoomControls {
/// Enables box zoom via right-button drag.
pub box_zoom: bool,
/// Enables zooming at cursor while Ctrl is held during scroll.
pub scroll_with_ctrl: bool,
/// Enables double-click reset/autoscale behavior.
pub double_click_autoscale: bool,
}
/// Configures pick interactions.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct PickControls {
/// Enables picking by left-clicking a highlighted point.
pub click_to_pick: bool,
/// Enables clearing picked points with the Escape key.
pub clear_on_escape: bool,
}
// In keeping with our batteries-included philosophy, most everything is enabled by default.
impl Default for PlotControls {
fn default() -> Self {
Self {
pan: PanControls::default(),
zoom: ZoomControls::default(),
pick: PickControls::default(),
highlight_on_hover: true,
show_controls_help: true,
}
}
}
impl Default for ZoomControls {
fn default() -> Self {
Self {
box_zoom: true,
scroll_with_ctrl: true,
double_click_autoscale: true,
}
}
}
impl Default for PanControls {
fn default() -> Self {
Self {
scroll_to_pan: true,
drag_to_pan: true,
}
}
}
impl Default for PickControls {
fn default() -> Self {
Self {
click_to_pick: true,
clear_on_escape: true,
}
}
}