From d3ba1ca34173fced80713bf292a53b674e8853f6 Mon Sep 17 00:00:00 2001 From: Devan Looches Date: Fri, 5 Aug 2022 09:55:21 -0700 Subject: [PATCH 1/6] Add scrollable/stretchable area with full error --- crates/fj-host/src/lib.rs | 14 +++++++++++++- crates/fj-viewer/src/graphics/renderer.rs | 19 +++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/crates/fj-host/src/lib.rs b/crates/fj-host/src/lib.rs index e76a3b9b2..dbcd4aae4 100644 --- a/crates/fj-host/src/lib.rs +++ b/crates/fj-host/src/lib.rs @@ -91,13 +91,25 @@ impl Model { let command = command_root .arg("build") + .arg("-q") .args(["--manifest-path", &manifest_path]); let exit_status = command.status()?; if exit_status.success() { status.update_status("Model compiled successfully!"); } else { - status.update_status("Error compiling the model!"); + let output = match command.output() { + Ok(output) => { + String::from_utf8(output.stderr).unwrap_or_else(|_| { + String::from("Failed to fetch command output") + }) + } + Err(_) => String::from("Failed to fetch command output"), + }; + status.update_status(&format!( + "Failed to compile model:\n{}", + output + )); return Err(Error::Compile); } diff --git a/crates/fj-viewer/src/graphics/renderer.rs b/crates/fj-viewer/src/graphics/renderer.rs index 3e2dbcfbe..a4f901330 100644 --- a/crates/fj-viewer/src/graphics/renderer.rs +++ b/crates/fj-viewer/src/graphics/renderer.rs @@ -425,15 +425,26 @@ impl Renderer { ); info } + + + egui::SidePanel::right("fj-right-panel").show( + &self.egui.context, + |ui| { + ui.group(|ui| { + egui::ScrollArea::vertical() + .max_height(f32::INFINITY) + .max_width(f32::INFINITY) + .show(ui, |ui| { + ui.label(format!("Status:\n{}", status.status())) + }); + }) + }, + ); let line_drawing_available = self.is_line_drawing_available(); egui::SidePanel::left("fj-left-panel").show(&self.egui.context, |ui| { ui.add_space(16.0); - ui.label(format!("Status Report:\n{}", status.status())); - - ui.add_space(16.0); - ui.group(|ui| { ui.checkbox(&mut config.draw_model, "Render model") .on_hover_text_at_pointer("Toggle with 1"); From 9e61d87d1950fe33f76e57ea803fa5c11b8c6680 Mon Sep 17 00:00:00 2001 From: Devan Looches Date: Fri, 5 Aug 2022 10:00:30 -0700 Subject: [PATCH 2/6] Fix format error --- crates/fj-viewer/src/graphics/renderer.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/fj-viewer/src/graphics/renderer.rs b/crates/fj-viewer/src/graphics/renderer.rs index a4f901330..ec6838248 100644 --- a/crates/fj-viewer/src/graphics/renderer.rs +++ b/crates/fj-viewer/src/graphics/renderer.rs @@ -425,8 +425,7 @@ impl Renderer { ); info } - - + egui::SidePanel::right("fj-right-panel").show( &self.egui.context, |ui| { From 275eae71b4ecfbe7e522a50de113bf95b463c47e Mon Sep 17 00:00:00 2001 From: Devan Looches Date: Fri, 5 Aug 2022 13:07:35 -0700 Subject: [PATCH 3/6] Remove already default options --- crates/fj-viewer/src/graphics/renderer.rs | 11 ++++------- models/star/src/lib.rs | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/crates/fj-viewer/src/graphics/renderer.rs b/crates/fj-viewer/src/graphics/renderer.rs index ec6838248..97c0be630 100644 --- a/crates/fj-viewer/src/graphics/renderer.rs +++ b/crates/fj-viewer/src/graphics/renderer.rs @@ -426,21 +426,18 @@ impl Renderer { info } + let line_drawing_available = self.is_line_drawing_available(); egui::SidePanel::right("fj-right-panel").show( &self.egui.context, |ui| { ui.group(|ui| { - egui::ScrollArea::vertical() - .max_height(f32::INFINITY) - .max_width(f32::INFINITY) - .show(ui, |ui| { - ui.label(format!("Status:\n{}", status.status())) - }); + egui::ScrollArea::vertical().show(ui, |ui| { + ui.label(format!("Status:\n{}", status.status())) + }); }) }, ); - let line_drawing_available = self.is_line_drawing_available(); egui::SidePanel::left("fj-left-panel").show(&self.egui.context, |ui| { ui.add_space(16.0); diff --git a/models/star/src/lib.rs b/models/star/src/lib.rs index 3d1775680..27a8d3f70 100644 --- a/models/star/src/lib.rs +++ b/models/star/src/lib.rs @@ -13,7 +13,7 @@ pub fn model( fj::Angle::from_rad(2. * PI / num_vertices as f64 * i as f64); let radius = if i % 2 == 0 { r1 } else { r2 }; (angle, radius) - }); + }) // Now that we got that iterator prepared, generating the vertices is just a // bit of trigonometry. From 8607b445b1729039ae00affab2397466f35a1c64 Mon Sep 17 00:00:00 2001 From: Devan Looches Date: Fri, 5 Aug 2022 13:08:54 -0700 Subject: [PATCH 4/6] Fix star model error --- models/star/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/star/src/lib.rs b/models/star/src/lib.rs index 27a8d3f70..3d1775680 100644 --- a/models/star/src/lib.rs +++ b/models/star/src/lib.rs @@ -13,7 +13,7 @@ pub fn model( fj::Angle::from_rad(2. * PI / num_vertices as f64 * i as f64); let radius = if i % 2 == 0 { r1 } else { r2 }; (angle, radius) - }) + }); // Now that we got that iterator prepared, generating the vertices is just a // bit of trigonometry. From ad16aa46521a3e510561cbf1c350addf7571d151 Mon Sep 17 00:00:00 2001 From: Devan Looches Date: Fri, 5 Aug 2022 14:48:05 -0700 Subject: [PATCH 5/6] Store status as vector and add clear_status method --- crates/fj-interop/src/status_report.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/fj-interop/src/status_report.rs b/crates/fj-interop/src/status_report.rs index 7478fede1..a50b89111 100644 --- a/crates/fj-interop/src/status_report.rs +++ b/crates/fj-interop/src/status_report.rs @@ -2,25 +2,28 @@ /// Struct to store and update status messages pub struct StatusReport { - status: String, + status: Vec, } impl StatusReport { /// Create a new ``StatusReport`` instance with a blank status pub fn new() -> Self { - Self { - status: String::new(), - } + Self { status: Vec::new() } } /// Update the status pub fn update_status(&mut self, status: &str) { - self.status = status.to_string(); + self.status.push(status.to_string()); } /// Get current status - pub fn status(&self) -> &str { - self.status.as_str() + pub fn status(&self) -> String { + self.status.join("\n") + } + + /// Reset status + pub fn clear_status(&mut self) { + self.status.clear(); } } From 27e405982de189d29a04a203ee00837c6c5f7038 Mon Sep 17 00:00:00 2001 From: Devan Looches Date: Sat, 6 Aug 2022 09:05:46 -0700 Subject: [PATCH 6/6] Make status draggable and store last 5 messages --- crates/fj-interop/src/status_report.rs | 5 ++++- crates/fj-viewer/src/graphics/renderer.rs | 22 ++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/crates/fj-interop/src/status_report.rs b/crates/fj-interop/src/status_report.rs index a50b89111..4329d2867 100644 --- a/crates/fj-interop/src/status_report.rs +++ b/crates/fj-interop/src/status_report.rs @@ -13,6 +13,9 @@ impl StatusReport { /// Update the status pub fn update_status(&mut self, status: &str) { + if self.status.len() >= 5 { + self.clear_status(); + } self.status.push(status.to_string()); } @@ -22,7 +25,7 @@ impl StatusReport { } /// Reset status - pub fn clear_status(&mut self) { + fn clear_status(&mut self) { self.status.clear(); } } diff --git a/crates/fj-viewer/src/graphics/renderer.rs b/crates/fj-viewer/src/graphics/renderer.rs index 97c0be630..a2bef5f7f 100644 --- a/crates/fj-viewer/src/graphics/renderer.rs +++ b/crates/fj-viewer/src/graphics/renderer.rs @@ -427,16 +427,6 @@ impl Renderer { } let line_drawing_available = self.is_line_drawing_available(); - egui::SidePanel::right("fj-right-panel").show( - &self.egui.context, - |ui| { - ui.group(|ui| { - egui::ScrollArea::vertical().show(ui, |ui| { - ui.label(format!("Status:\n{}", status.status())) - }); - }) - }, - ); egui::SidePanel::left("fj-left-panel").show(&self.egui.context, |ui| { ui.add_space(16.0); @@ -581,6 +571,18 @@ impl Renderer { ui.add_space(16.0); }); + egui::Area::new("fj-status-message").show(&self.egui.context, |ui| { + ui.group(|ui| { + ui.add(egui::Label::new( + egui::RichText::new(format!( + "Status:\n{}", + status.status() + )) + .color(egui::Color32::BLACK), + )) + }) + }); + // End the UI frame. We could now handle the output and draw the UI with the backend. let egui_output = self.egui.context.end_frame(); let egui_paint_jobs = self.egui.context.tessellate(egui_output.shapes);