MCPcopy Index your code
hub / github.com/encounter/objdiff / appearance_window

Function appearance_window

objdiff-gui/src/views/appearance.rs:285–341  ·  view source on GitHub ↗
(ctx: &egui::Context, show: &mut bool, appearance: &mut Appearance)

Source from the content-addressed store, hash-verified

283}
284
285pub fn appearance_window(ctx: &egui::Context, show: &mut bool, appearance: &mut Appearance) {
286 egui::Window::new("Appearance").open(show).show(ctx, |ui| {
287 egui::ComboBox::from_label("Theme")
288 .selected_text(format!("{:?}", appearance.theme))
289 .show_ui(ui, |ui| {
290 ui.selectable_value(&mut appearance.theme, egui::Theme::Dark, "Dark");
291 ui.selectable_value(&mut appearance.theme, egui::Theme::Light, "Light");
292 });
293 ui.separator();
294 appearance.next_ui_font =
295 font_id_ui(ui, "UI font:", appearance.ui_font.clone(), DEFAULT_UI_FONT, appearance);
296 ui.separator();
297 appearance.next_code_font = font_id_ui(
298 ui,
299 "Code font:",
300 appearance.code_font.clone(),
301 DEFAULT_CODE_FONT,
302 appearance,
303 );
304 ui.separator();
305 ui.horizontal(|ui| {
306 ui.label("Diff fill color:");
307 let mut diff_bg_color =
308 appearance.diff_bg_color.unwrap_or_else(|| match appearance.theme {
309 egui::Theme::Dark => egui::Visuals::dark().faint_bg_color,
310 egui::Theme::Light => egui::Visuals::light().faint_bg_color,
311 });
312 if ui.color_edit_button_srgba(&mut diff_bg_color).changed() {
313 appearance.diff_bg_color = Some(diff_bg_color);
314 }
315 if ui.button("Reset").clicked() {
316 appearance.diff_bg_color = None;
317 }
318 });
319 ui.separator();
320 ui.label("Diff colors:");
321 if ui.button("Reset").clicked() {
322 appearance.diff_colors = DEFAULT_COLOR_ROTATION.to_vec();
323 }
324 let mut remove_at: Option<usize> = None;
325 let num_colors = appearance.diff_colors.len();
326 for (idx, color) in appearance.diff_colors.iter_mut().enumerate() {
327 ui.horizontal(|ui| {
328 ui.color_edit_button_srgba(color);
329 if num_colors > 1 && ui.small_button("-").clicked() {
330 remove_at = Some(idx);
331 }
332 });
333 }
334 if let Some(idx) = remove_at {
335 appearance.diff_colors.remove(idx);
336 }
337 if ui.small_button("+").clicked() {
338 appearance.diff_colors.push(Color32::BLACK);
339 }
340 });
341}

Callers 1

updateMethod · 0.85

Calls 5

font_id_uiFunction · 0.85
iter_mutMethod · 0.80
removeMethod · 0.80
pushMethod · 0.80
separatorMethod · 0.45

Tested by

no test coverage detected