Skip to content

Commit

Permalink
Show Data::Color as a color in the Ui
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Apr 27, 2022
1 parent f71dc70 commit d26d261
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
10 changes: 5 additions & 5 deletions viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ clap = { version = "3.1.6", features = ["derive"] }
comms = { path = "../comms", features = ["client"] }
log_types = { path = "../log_types", features = ["save", "load"] }

# We use bleeding edge egui, from 2022-04-26
eframe = { git = "https://github.com/emilk/egui", rev = "2fd20308e50c8a3836481b1d08ba9e1d7bacf3af", features = ["dark-light", "persistence"] }
egui = { git = "https://github.com/emilk/egui", rev = "2fd20308e50c8a3836481b1d08ba9e1d7bacf3af", features = ["extra_debug_asserts"] }
egui_extras = { git = "https://github.com/emilk/egui", rev = "2fd20308e50c8a3836481b1d08ba9e1d7bacf3af", features = ["tracing"] }
egui_glow = { git = "https://github.com/emilk/egui", rev = "2fd20308e50c8a3836481b1d08ba9e1d7bacf3af" }
# We use bleeding edge egui, from 2022-04-27
eframe = { git = "https://github.com/emilk/egui", rev = "8e266760e27b12b3b3cd0eacf0df0bb5f0edc8f5", features = ["dark-light", "persistence"] }
egui = { git = "https://github.com/emilk/egui", rev = "8e266760e27b12b3b3cd0eacf0df0bb5f0edc8f5", features = ["extra_debug_asserts"] }
egui_extras = { git = "https://github.com/emilk/egui", rev = "8e266760e27b12b3b3cd0eacf0df0bb5f0edc8f5", features = ["tracing"] }
egui_glow = { git = "https://github.com/emilk/egui", rev = "8e266760e27b12b3b3cd0eacf0df0bb5f0edc8f5" }
# eframe = { path = "../../../egui/eframe", features = ["dark-light", "persistence"] }
# egui = { path = "../../../egui/egui", features = ["extra_debug_asserts"] }
# egui_extras = { path = "../../../egui/egui_extras", features = ["tracing"] }
Expand Down
11 changes: 10 additions & 1 deletion viewer/src/ui/space_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,16 @@ pub(crate) fn ui_data(
match data {
Data::I32(value) => ui.label(value.to_string()),
Data::F32(value) => ui.label(value.to_string()),
Data::Color([r, g, b, a]) => ui.label(format!("#{:02x}{:02x}{:02x}{:02x}", r, g, b, a)),
Data::Color([r, g, b, a]) => {
let color = egui::Color32::from_rgba_unmultiplied(*r, *g, *b, *a);
let response = egui::color_picker::show_color(ui, color, Vec2::new(32.0, 16.0));
ui.painter().rect_stroke(
response.rect,
1.0,
ui.visuals().widgets.noninteractive.fg_stroke,
);
response.on_hover_text(format!("Color #{:02x}{:02x}{:02x}{:02x}", r, g, b, a))
}

Data::Pos2([x, y]) => ui.label(format!("Pos2({x:.1}, {y:.1})")),
Data::LineSegments2D(linesegments) => {
Expand Down

0 comments on commit d26d261

Please sign in to comment.