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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
use eframe::egui;
use egui_plot::{LineStyle, MarkerShape};
#[derive(Debug, Clone)]
pub(crate) struct TraceLook {
pub visible: bool,
// Line style
pub color: egui::Color32,
pub width: f32,
pub style: egui_plot::LineStyle,
// Point style
pub show_points: bool,
pub point_size: f32,
pub marker: egui_plot::MarkerShape,
}
impl Default for TraceLook {
fn default() -> Self {
Self {
visible: true,
color: egui::Color32::WHITE,
width: 1.0,
style: egui_plot::LineStyle::Solid,
show_points: false,
point_size: 2.0,
marker: egui_plot::MarkerShape::Circle,
}
}
}
/// Render an inline editor for a TraceLook.
///
/// Arguments:
/// - ui: egui Ui to render into
/// - allow_points: whether to show point-marker related controls
/// - label_prefix: optional prefix label (e.g., "Line" or "Events") to name sections
impl TraceLook {
pub(crate) fn render_editor(
&mut self,
ui: &mut egui::Ui,
allow_points: bool,
label_prefix: Option<&str>,
hide_color: bool,
lock_color: Option<egui::Color32>,
) {
if let Some(p) = label_prefix {
ui.strong(p);
}
ui.horizontal(|ui| {
if !hide_color {
ui.label("Color");
let mut c = self.color;
if ui.color_edit_button_srgba(&mut c).changed() {
self.color = c;
}
}
ui.label("Width");
ui.add(
egui::DragValue::new(&mut self.width)
.range(0.1..=10.0)
.speed(0.1),
);
});
egui::ComboBox::from_label("Line style")
.selected_text(match self.style {
LineStyle::Solid => "Solid",
LineStyle::Dashed { .. } => "Dashed",
LineStyle::Dotted { .. } => "Dotted",
})
.show_ui(ui, |ui| {
if ui
.selectable_label(matches!(self.style, LineStyle::Solid), "Solid")
.clicked()
{
self.style = LineStyle::Solid;
}
if ui
.selectable_label(matches!(self.style, LineStyle::Dashed { .. }), "Dashed")
.clicked()
{
self.style = LineStyle::Dashed { length: 6.0 };
}
if ui
.selectable_label(matches!(self.style, LineStyle::Dotted { .. }), "Dotted")
.clicked()
{
self.style = LineStyle::Dotted { spacing: 4.0 };
}
});
// Additional controls for dashed/dotted parameters
match &mut self.style {
LineStyle::Dashed { length } => {
ui.horizontal(|ui| {
ui.label("Dash length");
ui.add(egui::DragValue::new(length).range(0.5..=200.0).speed(0.5))
.on_hover_text("Length of dash segments");
});
}
LineStyle::Dotted { spacing } => {
ui.horizontal(|ui| {
ui.label("Dot spacing");
ui.add(egui::DragValue::new(spacing).range(0.5..=200.0).speed(0.5))
.on_hover_text("Space between dots");
});
}
LineStyle::Solid => {}
}
if allow_points {
ui.separator();
ui.checkbox(&mut self.show_points, "Points");
ui.horizontal(|ui| {
ui.label("Size");
ui.add_enabled(
self.show_points,
egui::DragValue::new(&mut self.point_size)
.range(0.5..=10.0)
.speed(0.1),
);
});
ui.add_enabled_ui(self.show_points, |ui| {
egui::ComboBox::from_label("Marker shape")
.selected_text(match self.marker {
MarkerShape::Circle => "Circle",
MarkerShape::Square => "Square",
MarkerShape::Diamond => "Diamond",
MarkerShape::Cross => "Cross",
MarkerShape::Plus => "Plus",
_ => "Other",
})
.show_ui(ui, |ui| {
let current = self.marker;
if ui
.selectable_label(matches!(current, MarkerShape::Circle), "Circle")
.clicked()
{
self.marker = MarkerShape::Circle;
}
if ui
.selectable_label(matches!(current, MarkerShape::Square), "Square")
.clicked()
{
self.marker = MarkerShape::Square;
}
if ui
.selectable_label(matches!(current, MarkerShape::Diamond), "Diamond")
.clicked()
{
self.marker = MarkerShape::Diamond;
}
if ui
.selectable_label(matches!(current, MarkerShape::Cross), "Cross")
.clicked()
{
self.marker = MarkerShape::Cross;
}
if ui
.selectable_label(matches!(current, MarkerShape::Plus), "Plus")
.clicked()
{
self.marker = MarkerShape::Plus;
}
});
});
}
if let Some(c) = lock_color {
self.color = c;
}
}
}
// (legacy free function removed)
// (popup window editor removed; style editing is inline in panels now)