diff --git a/crates/viewer/re_ui/src/context_ext.rs b/crates/viewer/re_ui/src/context_ext.rs index aa97f735fe3b..7d83f269cbdd 100644 --- a/crates/viewer/re_ui/src/context_ext.rs +++ b/crates/viewer/re_ui/src/context_ext.rs @@ -59,17 +59,26 @@ pub trait ContextExt { // egui::Stroke::new(stroke_width, color) } + /// Text colored to indicate success. #[must_use] fn success_text(&self, text: impl Into) -> egui::RichText { egui::RichText::new(text).color(SUCCESS_COLOR) } + /// Text colored to indicate a warning. + /// + /// For most cases, you should use [`crate::UiExt::warning_label`] instead, + /// which has a nice fat border around it. #[must_use] fn warning_text(&self, text: impl Into) -> egui::RichText { let style = self.ctx().style(); egui::RichText::new(text).color(style.visuals.warn_fg_color) } + /// Text colored to indicate an error. + /// + /// For most cases, you should use [`crate::UiExt::error_label`] instead, + /// which has a nice fat border around it. #[must_use] fn error_text(&self, text: impl Into) -> egui::RichText { let style = self.ctx().style(); diff --git a/crates/viewer/re_ui/src/design_tokens.rs b/crates/viewer/re_ui/src/design_tokens.rs index 5105f28299cf..274d20f0c567 100644 --- a/crates/viewer/re_ui/src/design_tokens.rs +++ b/crates/viewer/re_ui/src/design_tokens.rs @@ -243,6 +243,7 @@ impl DesignTokens { egui_style.visuals.image_loading_spinners = false; egui_style.visuals.error_fg_color = egui::Color32::from_rgb(0xAB, 0x01, 0x16); + egui_style.visuals.warn_fg_color = egui::Color32::from_rgb(0xFF, 0x7A, 0x0C); ctx.set_style(egui_style); } diff --git a/crates/viewer/re_ui/src/ui_ext.rs b/crates/viewer/re_ui/src/ui_ext.rs index aaca109cf04f..e678b4169750 100644 --- a/crates/viewer/re_ui/src/ui_ext.rs +++ b/crates/viewer/re_ui/src/ui_ext.rs @@ -53,23 +53,26 @@ pub trait UiExt { fn ui(&self) -> &egui::Ui; fn ui_mut(&mut self) -> &mut egui::Ui; - /// Show the label with a success color. - fn success_label(&mut self, text: &str) -> egui::Response { - let label = egui::Label::new(self.ui().ctx().success_text(text)); - self.ui_mut().add(label) - } - - /// Shows a warning label. + /// Shows a warning label with a large border. + /// + /// If you don't want a border, use [`crate::ContextExt::warning_text`]. fn warning_label(&mut self, warning_text: &str) -> egui::Response { - let label = egui::Label::new(self.ui().ctx().warning_text(warning_text)); - self.ui_mut().add(label) + let ui = self.ui_mut(); + warning_or_error_label( + ui, + ui.style().visuals.warn_fg_color, + warning_text, + warning_text, + ) } - /// Shows a small error label with the given text on hover and copies the text to the clipboard on click. + /// Shows a small error label with the given text on hover and copies the text to the clipboard on click with a large border. + /// + /// This has a large border! If you don't want a border, use [`crate::ContextExt::error_text`]. fn error_with_details_on_hover(&mut self, error_text: &str) -> egui::Response { let ui = self.ui_mut(); warning_or_error_label(ui, ui.style().visuals.error_fg_color, "Error", error_text) - } + } fn error_label_background_color(&self) -> egui::Color32 { error_label_bg_color(self.ui().style().visuals.error_fg_color) @@ -79,6 +82,8 @@ pub trait UiExt { /// /// Use this only if the error message is short, or you have a lot of room. /// Otherwise, use [`Self::error_with_details_on_hover`]. + /// + /// This has a large border! If you don't want a border, use [`crate::ContextExt::error_text`]. fn error_label(&mut self, error_text: &str) -> egui::Response { let ui = self.ui_mut(); warning_or_error_label(