Skip to content

Commit f8f4e47

Browse files
authored
Small light mode fixes (#9984)
1 parent 2f5fecd commit f8f4e47

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

crates/viewer/re_time_panel/src/data_density_graph.rs

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@
55
66
use std::sync::Arc;
77

8-
use egui::emath::Rangef;
9-
use egui::{Color32, NumExt as _, Rect, Shape, Tooltip, epaint::Vertex, lerp, pos2, remap};
8+
use egui::{Color32, NumExt as _, Rangef, Rect, Shape, Tooltip, epaint::Vertex, lerp, pos2, remap};
109

1110
use re_chunk_store::Chunk;
1211
use re_chunk_store::RangeQuery;
1312
use re_log_types::{ComponentPath, ResolvedTimeRange, TimeInt, TimelineName};
13+
use re_ui::UiExt as _;
1414
use re_viewer_context::{Item, TimeControl, UiLayout, ViewerContext};
1515

16-
use crate::recursive_chunks_per_timeline_subscriber::PathRecursiveChunksPerTimelineStoreSubscriber;
17-
use crate::time_panel::TimePanelItem;
16+
use crate::{
17+
recursive_chunks_per_timeline_subscriber::PathRecursiveChunksPerTimelineStoreSubscriber,
18+
time_panel::TimePanelItem,
19+
};
1820

1921
use super::time_ranges_ui::TimeRangesUi;
2022

@@ -734,11 +736,22 @@ impl<'a> DensityGraphBuilder<'a> {
734736

735737
fn graph_color(ctx: &ViewerContext<'_>, item: &Item, ui: &egui::Ui) -> Color32 {
736738
let is_selected = ctx.selection().contains_item(item);
737-
if is_selected {
738-
make_brighter(ui.visuals().widgets.active.fg_stroke.color)
739-
} else {
740-
//TODO(ab): tokenize that!
741-
Color32::from_gray(225)
739+
740+
match ui.theme() {
741+
egui::Theme::Dark => {
742+
if is_selected {
743+
make_brighter(ui.visuals().widgets.active.fg_stroke.color)
744+
} else {
745+
Color32::from_gray(225) //TODO(ab): tokenize
746+
}
747+
}
748+
egui::Theme::Light => {
749+
if is_selected {
750+
make_darker(ui.visuals().widgets.active.fg_stroke.color)
751+
} else {
752+
Color32::from_gray(64) //TODO(ab): tokenize
753+
}
754+
}
742755
}
743756
}
744757

@@ -750,3 +763,12 @@ fn make_brighter(color: Color32) -> Color32 {
750763
b.saturating_add(64),
751764
)
752765
}
766+
767+
fn make_darker(color: Color32) -> Color32 {
768+
let [r, g, b, _] = color.to_array();
769+
egui::Color32::from_rgb(
770+
r.saturating_sub(64),
771+
g.saturating_sub(64),
772+
b.saturating_sub(64),
773+
)
774+
}

crates/viewer/re_ui/src/syntax_highlighting.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ fn text_format(style: &Style) -> TextFormat {
8383

8484
fn faint_text_format(style: &Style) -> TextFormat {
8585
TextFormat {
86-
color: Color32::WHITE,
86+
color: if style.visuals.dark_mode {
87+
Color32::WHITE
88+
} else {
89+
Color32::BLACK
90+
},
8791

8892
..text_format(style)
8993
}

0 commit comments

Comments
 (0)