diff --git a/egui_demo_lib/src/apps/demo/widget_gallery.rs b/egui_demo_lib/src/apps/demo/widget_gallery.rs index 0165a1d55..db49d0a80 100644 --- a/egui_demo_lib/src/apps/demo/widget_gallery.rs +++ b/egui_demo_lib/src/apps/demo/widget_gallery.rs @@ -33,10 +33,14 @@ impl super::Demo for WidgetGallery { } fn show(&mut self, ctx: &egui::CtxRef, open: &mut bool) { - egui::Window::new(self.name()).open(open).show(ctx, |ui| { - use super::View; - self.ui(ui); - }); + egui::Window::new(self.name()) + .open(open) + .default_width(200.0) + .resizable(false) + .show(ctx, |ui| { + use super::View; + self.ui(ui); + }); } } @@ -126,8 +130,20 @@ impl super::View for WidgetGallery { ui.label("Separator:"); ui.separator(); ui.end_row(); + + ui.label("CollapsingHeader:"); + ui.collapsing("Click to see what is hidden!", |ui| { + ui.horizontal_wrapped_for_text(egui::TextStyle::Body, |ui| { + ui.label( + "Not much, as it turns out, but here is a gold star for you for checking:", + ); + ui.colored_label(egui::Color32::GOLD, "☆"); + }); + }); + ui.end_row(); }); + ui.separator(); ui.vertical_centered(|ui| { ui.add(crate::__egui_github_link_file!()); }); diff --git a/epaint/src/color.rs b/epaint/src/color.rs index 073a8dea1..a39abc7cc 100644 --- a/epaint/src/color.rs +++ b/epaint/src/color.rs @@ -36,10 +36,11 @@ impl Color32 { pub const GRAY: Color32 = Color32::from_rgb(160, 160, 160); pub const WHITE: Color32 = Color32::from_rgb(255, 255, 255); pub const RED: Color32 = Color32::from_rgb(255, 0, 0); + pub const YELLOW: Color32 = Color32::from_rgb(255, 255, 0); pub const GREEN: Color32 = Color32::from_rgb(0, 255, 0); pub const BLUE: Color32 = Color32::from_rgb(0, 0, 255); - pub const YELLOW: Color32 = Color32::from_rgb(255, 255, 0); pub const LIGHT_BLUE: Color32 = Color32::from_rgb(140, 160, 255); + pub const GOLD: Color32 = Color32::from_rgb(255, 215, 0); pub const fn from_rgb(r: u8, g: u8, b: u8) -> Self { Self([r, g, b, 255]) @@ -117,10 +118,12 @@ impl Color32 { Rgba::from(self).to_opaque().into() } + /// Premultiplied RGBA pub fn to_array(&self) -> [u8; 4] { [self.r(), self.g(), self.b(), self.a()] } + /// Premultiplied RGBA pub fn to_tuple(&self) -> (u8, u8, u8, u8) { (self.r(), self.g(), self.b(), self.a()) }