Add panel background color edit in sandbox
This commit is contained in:
parent
85e1fbd6b6
commit
a477c3c385
|
@ -33,6 +33,7 @@ struct App {
|
||||||
last_update: Instant,
|
last_update: Instant,
|
||||||
protocol_buf: String,
|
protocol_buf: String,
|
||||||
bind_message_buf: String,
|
bind_message_buf: String,
|
||||||
|
panel_bg: egui::Color32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
|
@ -49,6 +50,7 @@ impl App {
|
||||||
last_update: Instant::now(),
|
last_update: Instant::now(),
|
||||||
protocol_buf: String::new(),
|
protocol_buf: String::new(),
|
||||||
bind_message_buf: String::new(),
|
bind_message_buf: String::new(),
|
||||||
|
panel_bg: egui::Color32::TRANSPARENT,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,6 +60,8 @@ impl eframe::App for App {
|
||||||
ctx.request_repaint();
|
ctx.request_repaint();
|
||||||
|
|
||||||
egui::SidePanel::left("left_panel").show(ctx, |ui| {
|
egui::SidePanel::left("left_panel").show(ctx, |ui| {
|
||||||
|
ui.heading("New Panel");
|
||||||
|
|
||||||
ui.label("Protocol name:");
|
ui.label("Protocol name:");
|
||||||
ui.text_edit_singleline(&mut self.protocol_buf);
|
ui.text_edit_singleline(&mut self.protocol_buf);
|
||||||
|
|
||||||
|
@ -81,6 +85,14 @@ impl eframe::App for App {
|
||||||
|
|
||||||
self.panels.push(panel);
|
self.panels.push(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui.separator();
|
||||||
|
ui.heading("Global Settings");
|
||||||
|
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
ui.label("Panel background color: ");
|
||||||
|
ui.color_edit_button_srgba(&mut self.panel_bg);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
let dt = self.last_update.elapsed().as_secs_f32();
|
let dt = self.last_update.elapsed().as_secs_f32();
|
||||||
|
@ -88,7 +100,7 @@ impl eframe::App for App {
|
||||||
|
|
||||||
for panel in self.panels.iter_mut() {
|
for panel in self.panels.iter_mut() {
|
||||||
panel.panel.update(dt);
|
panel.panel.update(dt);
|
||||||
panel.show(ctx);
|
panel.show(self.panel_bg, ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,9 +114,13 @@ pub struct PanelWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PanelWindow {
|
impl PanelWindow {
|
||||||
pub fn show(&mut self, ctx: &egui::Context) {
|
pub fn show(&mut self, bg: egui::Color32, ctx: &egui::Context) {
|
||||||
|
let frame = egui::Frame::window(&ctx.style()).fill(bg);
|
||||||
let window_id = egui::Id::new(format!("panel_{}", self.index));
|
let window_id = egui::Id::new(format!("panel_{}", self.index));
|
||||||
egui::Window::new("Panel").id(window_id).show(ctx, |ui| {
|
egui::Window::new("Panel")
|
||||||
|
.frame(frame)
|
||||||
|
.id(window_id)
|
||||||
|
.show(ctx, |ui| {
|
||||||
egui::menu::bar(ui, |ui| {
|
egui::menu::bar(ui, |ui| {
|
||||||
ui.checkbox(&mut self.show_msg, "Show Message Editor");
|
ui.checkbox(&mut self.show_msg, "Show Message Editor");
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue