[demo] Add collapsing header to widget gallery
This commit is contained in:
parent
9ce59d747f
commit
6f814b9516
2 changed files with 24 additions and 5 deletions
|
@ -33,10 +33,14 @@ impl super::Demo for WidgetGallery {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show(&mut self, ctx: &egui::CtxRef, open: &mut bool) {
|
fn show(&mut self, ctx: &egui::CtxRef, open: &mut bool) {
|
||||||
egui::Window::new(self.name()).open(open).show(ctx, |ui| {
|
egui::Window::new(self.name())
|
||||||
use super::View;
|
.open(open)
|
||||||
self.ui(ui);
|
.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.label("Separator:");
|
||||||
ui.separator();
|
ui.separator();
|
||||||
ui.end_row();
|
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.vertical_centered(|ui| {
|
||||||
ui.add(crate::__egui_github_link_file!());
|
ui.add(crate::__egui_github_link_file!());
|
||||||
});
|
});
|
||||||
|
|
|
@ -36,10 +36,11 @@ impl Color32 {
|
||||||
pub const GRAY: Color32 = Color32::from_rgb(160, 160, 160);
|
pub const GRAY: Color32 = Color32::from_rgb(160, 160, 160);
|
||||||
pub const WHITE: Color32 = Color32::from_rgb(255, 255, 255);
|
pub const WHITE: Color32 = Color32::from_rgb(255, 255, 255);
|
||||||
pub const RED: Color32 = Color32::from_rgb(255, 0, 0);
|
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 GREEN: Color32 = Color32::from_rgb(0, 255, 0);
|
||||||
pub const BLUE: Color32 = Color32::from_rgb(0, 0, 255);
|
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 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 {
|
pub const fn from_rgb(r: u8, g: u8, b: u8) -> Self {
|
||||||
Self([r, g, b, 255])
|
Self([r, g, b, 255])
|
||||||
|
@ -117,10 +118,12 @@ impl Color32 {
|
||||||
Rgba::from(self).to_opaque().into()
|
Rgba::from(self).to_opaque().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Premultiplied RGBA
|
||||||
pub fn to_array(&self) -> [u8; 4] {
|
pub fn to_array(&self) -> [u8; 4] {
|
||||||
[self.r(), self.g(), self.b(), self.a()]
|
[self.r(), self.g(), self.b(), self.a()]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Premultiplied RGBA
|
||||||
pub fn to_tuple(&self) -> (u8, u8, u8, u8) {
|
pub fn to_tuple(&self) -> (u8, u8, u8, u8) {
|
||||||
(self.r(), self.g(), self.b(), self.a())
|
(self.r(), self.g(), self.b(), self.a())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue