1use crate::App;
2
3impl App {
4 #[cfg(not(target_arch = "wasm32"))]
5 pub fn show_update(&self, ui: &mut egui::Ui) {
6 if let Some(update) = &self.state.update {
7 let [maj, min, pat] = update.version;
8 if ui
9 .link(format!("Update v{maj}.{min}.{pat} available!"))
10 .clicked()
11 {
12 ui.ctx()
13 .open_url(egui::OpenUrl::new_tab(update.url.clone()));
14 }
15 }
16 }
17
18 pub fn show_topbar(&mut self, ctx: &egui::Context) {
19 egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
20 egui::MenuBar::new().ui(ui, |ui| {
21 ui.add(egui::Image::from_texture(&self.icon).max_height(16.));
22
23 #[cfg(not(target_arch = "wasm32"))]
24 ui.label("Lutgen Studio");
25 #[cfg(target_arch = "wasm32")]
26 ui.label("Lutgen Studio Web");
27
28 ui.menu_button("File", |ui| {
29 if ui.button("🖻 Open").clicked() {
30 self.open_picker.trigger(self.state.current_image.clone());
31 ui.close();
32 }
33
34 #[cfg(not(target_arch = "wasm32"))]
35 if ui.button("💾 Save As").clicked() {
36 self.save_picker.trigger(self.state.current_image.clone());
37 ui.close();
38 }
39
40 #[cfg(target_arch = "wasm32")]
41 ui.add_enabled_ui(self.state.current_image.is_some(), |ui| {
42 egui::containers::menu::SubMenuButton::new("💾 Export").ui(ui, |ui| {
43 for format in image::ImageFormat::all() {
44 let ext = *format.extensions_str().first().unwrap();
45 if ui.button(ext).clicked() {
46 self.worker.save_as(format);
47 self.state.processing = true;
48 ui.close();
49 }
50 }
51 });
52 });
53
54 ui.menu_button("🎨 Theme", |ui| {
55 egui::widgets::global_theme_preference_buttons(ui);
56 });
57 });
58
59 ui.menu_button("Help", |ui| {
60 if ui.button("ℹ About").clicked() {
61 self.state.show_about = !self.state.show_about;
62 }
63
64 if ui.button("🖹 Docs").clicked() {
65 ui.ctx().open_url(egui::OpenUrl::new_tab("https://lut.sh"));
66 }
67 });
68
69 #[cfg(not(target_arch = "wasm32"))]
70 ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
71 self.show_update(ui);
72 });
73 });
74 });
75 }
76}