Skip to content

Commit

Permalink
Update to last egui for lerp
Browse files Browse the repository at this point in the history
  • Loading branch information
abey79 committed Jun 6, 2024
1 parent 28791b2 commit ae2fab9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 28 deletions.
21 changes: 11 additions & 10 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1564,16 +1564,17 @@ checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30"
[[package]]
name = "ecolor"
version = "0.27.2"
source = "git+https://github.com/emilk/egui.git?rev=cbb5d6aa936c7498214dba03b594fbe75dbe7488#cbb5d6aa936c7498214dba03b594fbe75dbe7488"
source = "git+https://github.com/emilk/egui.git?rev=2545939c150379b85517de691da56a46f5ee0d1d#2545939c150379b85517de691da56a46f5ee0d1d"
dependencies = [
"bytemuck",
"emath",
"serde",
]

[[package]]
name = "eframe"
version = "0.27.2"
source = "git+https://github.com/emilk/egui.git?rev=cbb5d6aa936c7498214dba03b594fbe75dbe7488#cbb5d6aa936c7498214dba03b594fbe75dbe7488"
source = "git+https://github.com/emilk/egui.git?rev=2545939c150379b85517de691da56a46f5ee0d1d#2545939c150379b85517de691da56a46f5ee0d1d"
dependencies = [
"ahash",
"bytemuck",
Expand Down Expand Up @@ -1609,7 +1610,7 @@ dependencies = [
[[package]]
name = "egui"
version = "0.27.2"
source = "git+https://github.com/emilk/egui.git?rev=cbb5d6aa936c7498214dba03b594fbe75dbe7488#cbb5d6aa936c7498214dba03b594fbe75dbe7488"
source = "git+https://github.com/emilk/egui.git?rev=2545939c150379b85517de691da56a46f5ee0d1d#2545939c150379b85517de691da56a46f5ee0d1d"
dependencies = [
"accesskit",
"ahash",
Expand All @@ -1626,7 +1627,7 @@ dependencies = [
[[package]]
name = "egui-wgpu"
version = "0.27.2"
source = "git+https://github.com/emilk/egui.git?rev=cbb5d6aa936c7498214dba03b594fbe75dbe7488#cbb5d6aa936c7498214dba03b594fbe75dbe7488"
source = "git+https://github.com/emilk/egui.git?rev=2545939c150379b85517de691da56a46f5ee0d1d#2545939c150379b85517de691da56a46f5ee0d1d"
dependencies = [
"ahash",
"bytemuck",
Expand All @@ -1645,7 +1646,7 @@ dependencies = [
[[package]]
name = "egui-winit"
version = "0.27.2"
source = "git+https://github.com/emilk/egui.git?rev=cbb5d6aa936c7498214dba03b594fbe75dbe7488#cbb5d6aa936c7498214dba03b594fbe75dbe7488"
source = "git+https://github.com/emilk/egui.git?rev=2545939c150379b85517de691da56a46f5ee0d1d#2545939c150379b85517de691da56a46f5ee0d1d"
dependencies = [
"accesskit_winit",
"ahash",
Expand Down Expand Up @@ -1685,7 +1686,7 @@ dependencies = [
[[package]]
name = "egui_extras"
version = "0.27.2"
source = "git+https://github.com/emilk/egui.git?rev=cbb5d6aa936c7498214dba03b594fbe75dbe7488#cbb5d6aa936c7498214dba03b594fbe75dbe7488"
source = "git+https://github.com/emilk/egui.git?rev=2545939c150379b85517de691da56a46f5ee0d1d#2545939c150379b85517de691da56a46f5ee0d1d"
dependencies = [
"ahash",
"egui",
Expand All @@ -1701,7 +1702,7 @@ dependencies = [
[[package]]
name = "egui_glow"
version = "0.27.2"
source = "git+https://github.com/emilk/egui.git?rev=cbb5d6aa936c7498214dba03b594fbe75dbe7488#cbb5d6aa936c7498214dba03b594fbe75dbe7488"
source = "git+https://github.com/emilk/egui.git?rev=2545939c150379b85517de691da56a46f5ee0d1d#2545939c150379b85517de691da56a46f5ee0d1d"
dependencies = [
"ahash",
"bytemuck",
Expand All @@ -1719,7 +1720,7 @@ dependencies = [
[[package]]
name = "egui_plot"
version = "0.27.2"
source = "git+https://github.com/emilk/egui.git?rev=cbb5d6aa936c7498214dba03b594fbe75dbe7488#cbb5d6aa936c7498214dba03b594fbe75dbe7488"
source = "git+https://github.com/emilk/egui.git?rev=2545939c150379b85517de691da56a46f5ee0d1d#2545939c150379b85517de691da56a46f5ee0d1d"
dependencies = [
"ahash",
"egui",
Expand Down Expand Up @@ -1762,7 +1763,7 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]]
name = "emath"
version = "0.27.2"
source = "git+https://github.com/emilk/egui.git?rev=cbb5d6aa936c7498214dba03b594fbe75dbe7488#cbb5d6aa936c7498214dba03b594fbe75dbe7488"
source = "git+https://github.com/emilk/egui.git?rev=2545939c150379b85517de691da56a46f5ee0d1d#2545939c150379b85517de691da56a46f5ee0d1d"
dependencies = [
"bytemuck",
"serde",
Expand Down Expand Up @@ -1863,7 +1864,7 @@ dependencies = [
[[package]]
name = "epaint"
version = "0.27.2"
source = "git+https://github.com/emilk/egui.git?rev=cbb5d6aa936c7498214dba03b594fbe75dbe7488#cbb5d6aa936c7498214dba03b594fbe75dbe7488"
source = "git+https://github.com/emilk/egui.git?rev=2545939c150379b85517de691da56a46f5ee0d1d#2545939c150379b85517de691da56a46f5ee0d1d"
dependencies = [
"ab_glyph",
"ahash",
Expand Down
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,13 @@ missing_errors_doc = "allow"
# As a last resport, patch with a commit to our own repository.
# ALWAYS document what PR the commit hash is part of, or when it was merged into the upstream trunk.

ecolor = { git = "https://github.com/emilk/egui.git", rev = "cbb5d6aa936c7498214dba03b594fbe75dbe7488" } # egui master 2024-06-05
eframe = { git = "https://github.com/emilk/egui.git", rev = "cbb5d6aa936c7498214dba03b594fbe75dbe7488" } # egui master 2024-06-05
egui = { git = "https://github.com/emilk/egui.git", rev = "cbb5d6aa936c7498214dba03b594fbe75dbe7488" } # egui master 2024-06-05
egui_extras = { git = "https://github.com/emilk/egui.git", rev = "cbb5d6aa936c7498214dba03b594fbe75dbe7488" } # egui master 2024-06-05
egui_plot = { git = "https://github.com/emilk/egui.git", rev = "cbb5d6aa936c7498214dba03b594fbe75dbe7488" } # egui master 2024-06-05
egui-wgpu = { git = "https://github.com/emilk/egui.git", rev = "cbb5d6aa936c7498214dba03b594fbe75dbe7488" } # egui master 2024-06-05
emath = { git = "https://github.com/emilk/egui.git", rev = "cbb5d6aa936c7498214dba03b594fbe75dbe7488" } # egui master 2024-06-05
ecolor = { git = "https://github.com/emilk/egui.git", rev = "2545939c150379b85517de691da56a46f5ee0d1d" } # egui master 2024-06-06
eframe = { git = "https://github.com/emilk/egui.git", rev = "2545939c150379b85517de691da56a46f5ee0d1d" } # egui master 2024-06-06
egui = { git = "https://github.com/emilk/egui.git", rev = "2545939c150379b85517de691da56a46f5ee0d1d" } # egui master 2024-06-06
egui_extras = { git = "https://github.com/emilk/egui.git", rev = "2545939c150379b85517de691da56a46f5ee0d1d" } # egui master 2024-06-06
egui_plot = { git = "https://github.com/emilk/egui.git", rev = "2545939c150379b85517de691da56a46f5ee0d1d" } # egui master 2024-06-06
egui-wgpu = { git = "https://github.com/emilk/egui.git", rev = "2545939c150379b85517de691da56a46f5ee0d1d" } # egui master 2024-06-06
emath = { git = "https://github.com/emilk/egui.git", rev = "2545939c150379b85517de691da56a46f5ee0d1d" } # egui master 2024-06-06

# Useful while developing:
# ecolor = { path = "../../egui/crates/ecolor" }
Expand Down
12 changes: 1 addition & 11 deletions crates/re_ui/src/ui_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,11 +858,6 @@ pub trait UiExt {
///
/// Adapted from `egui_demo_lib/src/demo/toggle_switch.rs`
fn toggle_switch(&mut self, height: f32, on: &mut bool) -> egui::Response {
//TODO(ab): use https://github.com/emilk/egui/pull/4627
fn lerp_u8(a: u8, b: u8, t: f32) -> u8 {
(a as f32 + t * (b as f32 - a as f32)).round() as u8
}

let ui = self.ui_mut();
let width = (height / 2. * 3.).ceil();
let size = egui::vec2(width, height); // 12x7 in figma, but 12x8 looks _much_ better in epaint
Expand All @@ -883,12 +878,7 @@ pub trait UiExt {
let expanded_rect = visual_rect.expand(visuals.expansion);
let fg_fill_off = visuals.bg_fill;
let fg_fill_on = egui::Color32::from_rgba_premultiplied(0, 128, 255, 255);
let fg_fill = egui::Color32::from_rgba_premultiplied(
lerp_u8(fg_fill_off.r(), fg_fill_on.r(), how_on),
lerp_u8(fg_fill_off.g(), fg_fill_on.g(), how_on),
lerp_u8(fg_fill_off.b(), fg_fill_on.b(), how_on),
lerp_u8(fg_fill_off.a(), fg_fill_on.a(), how_on),
);
let fg_fill = fg_fill_off.lerp_to_gamma(fg_fill_on, how_on);
let bg_fill_off = visuals.text_color();

let rounding = 0.5 * expanded_rect.height();
Expand Down

0 comments on commit ae2fab9

Please sign in to comment.