Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle switch now becomes blue when ON #6494

Merged
merged 6 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
19 changes: 13 additions & 6 deletions crates/re_ui/src/ui_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -876,20 +876,27 @@ pub trait UiExt {
let how_on = ui.ctx().animate_bool(response.id, *on);
let visuals = ui.style().interact(&response);
let expanded_rect = visual_rect.expand(visuals.expansion);
let fg_fill = visuals.bg_fill;
let bg_fill = visuals.text_color();
let fg_fill_off = visuals.bg_fill;
let fg_fill_on = egui::Color32::from_rgba_premultiplied(0, 128, 255, 255);
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();
ui.painter()
.rect(expanded_rect, rounding, bg_fill, egui::Stroke::NONE);
.rect_filled(expanded_rect, rounding, bg_fill_off);
let circle_x = egui::lerp(
(expanded_rect.left() + rounding)..=(expanded_rect.right() - rounding),
how_on,
);

let circle_center = egui::pos2(circle_x, expanded_rect.center().y);
let circle_radius = 0.3 * expanded_rect.height();
ui.painter()
.circle(circle_center, circle_radius, fg_fill, egui::Stroke::NONE);
let circle_radius_off = 0.3 * expanded_rect.height();
let circle_radius_on = 0.35 * expanded_rect.height();
ui.painter().circle_filled(
circle_center,
egui::lerp(circle_radius_off..=circle_radius_on, how_on),
fg_fill,
);
}

response
Expand Down
Loading