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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
//! Profile badge appearance section for the edit view.
use super::ProfileModalUI;
use crate::section::collapsing_section;
use std::collections::HashSet;
impl ProfileModalUI {
/// Render the badge appearance collapsing section (profile-level overrides).
pub(super) fn render_badge_section(
&mut self,
ui: &mut egui::Ui,
collapsed: &mut HashSet<String>,
) {
collapsing_section(
ui,
"Badge Appearance",
"profile_badge_appearance",
false,
collapsed,
|ui| {
egui::Grid::new("profile_form_badge_appearance")
.num_columns(2)
.spacing([10.0, 8.0])
.show(ui, |ui| {
// Badge color
ui.label("Color:");
ui.horizontal(|ui| {
let mut use_custom = self.temp_badge_color.is_some();
if ui.checkbox(&mut use_custom, "").changed() {
if use_custom {
self.temp_badge_color = Some([255, 0, 0]); // Default red
} else {
self.temp_badge_color = None;
}
}
if let Some(ref mut color) = self.temp_badge_color {
let mut egui_color =
egui::Color32::from_rgb(color[0], color[1], color[2]);
if egui::color_picker::color_edit_button_srgba(
ui,
&mut egui_color,
egui::color_picker::Alpha::Opaque,
)
.changed()
{
*color = [egui_color.r(), egui_color.g(), egui_color.b()];
}
} else {
ui.label(
egui::RichText::new("(use global)")
.small()
.color(egui::Color32::GRAY),
);
}
});
ui.end_row();
// Badge alpha/opacity
ui.label("Opacity:");
ui.horizontal(|ui| {
let mut use_custom = self.temp_badge_color_alpha.is_some();
if ui.checkbox(&mut use_custom, "").changed() {
if use_custom {
self.temp_badge_color_alpha = Some(0.5);
} else {
self.temp_badge_color_alpha = None;
}
}
if let Some(ref mut alpha) = self.temp_badge_color_alpha {
ui.add(egui::Slider::new(alpha, 0.0..=1.0).step_by(0.05));
} else {
ui.label(
egui::RichText::new("(use global)")
.small()
.color(egui::Color32::GRAY),
);
}
});
ui.end_row();
// Badge font
ui.label("Font:");
ui.horizontal(|ui| {
ui.text_edit_singleline(&mut self.temp_badge_font);
ui.label(
egui::RichText::new("(blank = global)")
.small()
.color(egui::Color32::GRAY),
);
});
ui.end_row();
// Badge font bold
ui.label("Bold:");
ui.horizontal(|ui| {
let mut use_custom = self.temp_badge_font_bold.is_some();
if ui.checkbox(&mut use_custom, "").changed() {
if use_custom {
self.temp_badge_font_bold = Some(true);
} else {
self.temp_badge_font_bold = None;
}
}
if let Some(ref mut bold) = self.temp_badge_font_bold {
ui.checkbox(bold, "Bold text");
} else {
ui.label(
egui::RichText::new("(use global)")
.small()
.color(egui::Color32::GRAY),
);
}
});
ui.end_row();
// Badge top margin
ui.label("Top Margin:");
ui.horizontal(|ui| {
let mut use_custom = self.temp_badge_top_margin.is_some();
if ui.checkbox(&mut use_custom, "").changed() {
if use_custom {
self.temp_badge_top_margin = Some(0.0);
} else {
self.temp_badge_top_margin = None;
}
}
if let Some(ref mut margin) = self.temp_badge_top_margin {
ui.add(
egui::DragValue::new(margin)
.range(0.0..=100.0)
.suffix(" px"),
);
} else {
ui.label(
egui::RichText::new("(use global)")
.small()
.color(egui::Color32::GRAY),
);
}
});
ui.end_row();
// Badge right margin
ui.label("Right Margin:");
ui.horizontal(|ui| {
let mut use_custom = self.temp_badge_right_margin.is_some();
if ui.checkbox(&mut use_custom, "").changed() {
if use_custom {
self.temp_badge_right_margin = Some(16.0);
} else {
self.temp_badge_right_margin = None;
}
}
if let Some(ref mut margin) = self.temp_badge_right_margin {
ui.add(
egui::DragValue::new(margin)
.range(0.0..=100.0)
.suffix(" px"),
);
} else {
ui.label(
egui::RichText::new("(use global)")
.small()
.color(egui::Color32::GRAY),
);
}
});
ui.end_row();
// Badge max width
ui.label("Max Width:");
ui.horizontal(|ui| {
let mut use_custom = self.temp_badge_max_width.is_some();
if ui.checkbox(&mut use_custom, "").changed() {
if use_custom {
self.temp_badge_max_width = Some(0.5);
} else {
self.temp_badge_max_width = None;
}
}
if let Some(ref mut width) = self.temp_badge_max_width {
ui.add(
egui::Slider::new(width, 0.1..=1.0)
.step_by(0.05)
.custom_formatter(|v, _| format!("{:.0}%", v * 100.0)),
);
} else {
ui.label(
egui::RichText::new("(use global)")
.small()
.color(egui::Color32::GRAY),
);
}
});
ui.end_row();
// Badge max height
ui.label("Max Height:");
ui.horizontal(|ui| {
let mut use_custom = self.temp_badge_max_height.is_some();
if ui.checkbox(&mut use_custom, "").changed() {
if use_custom {
self.temp_badge_max_height = Some(0.2);
} else {
self.temp_badge_max_height = None;
}
}
if let Some(ref mut height) = self.temp_badge_max_height {
ui.add(
egui::Slider::new(height, 0.05..=0.5)
.step_by(0.05)
.custom_formatter(|v, _| format!("{:.0}%", v * 100.0)),
);
} else {
ui.label(
egui::RichText::new("(use global)")
.small()
.color(egui::Color32::GRAY),
);
}
});
ui.end_row();
});
ui.add_space(4.0);
ui.label(
egui::RichText::new(
"Check boxes to override global badge settings for this profile.",
)
.small()
.color(egui::Color32::GRAY),
);
},
);
}
/// Render the SSH connection collapsing section.
pub(super) fn render_ssh_section(
&mut self,
ui: &mut egui::Ui,
collapsed: &mut HashSet<String>,
) {
collapsing_section(
ui,
"SSH Connection",
"profile_ssh_connection",
false,
collapsed,
|ui| {
ui.horizontal(|ui| {
ui.label("Host:");
ui.text_edit_singleline(&mut self.temp_ssh_host);
});
ui.horizontal(|ui| {
ui.label("User:");
ui.text_edit_singleline(&mut self.temp_ssh_user);
});
ui.horizontal(|ui| {
ui.label("Port:");
ui.add(egui::TextEdit::singleline(&mut self.temp_ssh_port).desired_width(60.0));
});
ui.horizontal(|ui| {
ui.label("Identity File:");
ui.text_edit_singleline(&mut self.temp_ssh_identity_file);
});
ui.horizontal(|ui| {
ui.label("Extra Args:");
ui.text_edit_singleline(&mut self.temp_ssh_extra_args);
});
ui.add_space(4.0);
ui.label(
egui::RichText::new(
"When SSH Host is set, opening this profile connects via SSH instead of launching a shell.",
)
.weak()
.size(11.0),
);
},
);
}
}