Skip to content

Commit 7348f3e

Browse files
authored
Fix table colors in light mode (#9988)
### Related * #9953
1 parent f8f4e47 commit 7348f3e

File tree

5 files changed

+56
-12
lines changed

5 files changed

+56
-12
lines changed

crates/utils/re_log/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,11 @@ const CRATES_AT_WARN_LEVEL: &[&str] = &[
7171
];
7272

7373
/// Never log anything less serious than a `INFO` from these crates.
74+
///
75+
/// These creates are quite spammy on debug, drowning out what we care about:
7476
const CRATES_AT_INFO_LEVEL: &[&str] = &[
75-
// These are quite spammy on debug, drowning out what we care about:
77+
"datafusion_optimizer",
78+
"datafusion",
7679
"h2",
7780
"hyper",
7881
"prost_build",

crates/viewer/re_dataframe_ui/src/table_utils.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use ahash::HashSet;
22
use egui::{Context, Frame, Id, Margin, RichText, Stroke, Style};
3-
use re_ui::{Scale, UiExt as _, design_tokens_of, icons};
3+
use re_ui::{UiExt as _, design_tokens_of, icons};
44

55
pub const CELL_MARGIN: Margin = Margin::symmetric(8, 6);
66

@@ -18,11 +18,13 @@ pub fn apply_table_style_fixes(style: &mut Style) {
1818
let design_tokens = design_tokens_of(theme);
1919

2020
style.visuals.widgets.hovered.bg_stroke =
21-
Stroke::new(1.0, design_tokens.color_table.gray(Scale::S300));
21+
Stroke::new(1.0, design_tokens.table_interaction_hovered_bg_stroke());
2222
style.visuals.widgets.active.bg_stroke =
23-
Stroke::new(1.0, design_tokens.color_table.gray(Scale::S350));
24-
style.visuals.widgets.noninteractive.bg_stroke =
25-
Stroke::new(1.0, design_tokens.color_table.gray(Scale::S200));
23+
Stroke::new(1.0, design_tokens.table_interaction_active_bg_stroke());
24+
style.visuals.widgets.noninteractive.bg_stroke = Stroke::new(
25+
1.0,
26+
design_tokens.table_interaction_noninteractive_bg_stroke(),
27+
);
2628
}
2729

2830
pub fn header_title(ui: &mut egui::Ui, title: impl Into<RichText>) -> egui::Response {
@@ -38,7 +40,7 @@ pub fn header_ui<R>(
3840
) -> egui::InnerResponse<R> {
3941
let response = Frame::new()
4042
.inner_margin(CELL_MARGIN)
41-
.fill(ui.design_tokens().color_table.gray(Scale::S150))
43+
.fill(ui.design_tokens().table_header_bg_fill())
4244
.show(ui, |ui| {
4345
ui.set_width(ui.available_width());
4446
content(ui)
@@ -49,7 +51,7 @@ pub fn header_ui<R>(
4951
ui.painter().hline(
5052
rect.x_range(),
5153
rect.max.y - 1.0, // - 1.0 prevents it from being overdrawn by the following row
52-
Stroke::new(1.0, ui.design_tokens().color_table.gray(Scale::S300)),
54+
Stroke::new(1.0, ui.design_tokens().table_header_stroke_color()),
5355
);
5456

5557
response
@@ -69,7 +71,11 @@ pub fn cell_ui<R>(
6971
ui.painter().hline(
7072
rect.x_range(),
7173
rect.max.y - 1.0, // - 1.0 prevents it from being overdrawn by the following row
72-
Stroke::new(1.0, ui.design_tokens().color_table.gray(Scale::S200)),
74+
Stroke::new(
75+
1.0,
76+
ui.design_tokens()
77+
.table_interaction_noninteractive_bg_stroke(),
78+
),
7379
);
7480

7581
response

crates/viewer/re_ui/src/design_token_colors.rs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl DesignTokens {
8282
//TODO(ab): as per figma, use design tokens instead
8383
match self.theme {
8484
Theme::Dark => Color32::WHITE.gamma_multiply(0.04),
85-
Theme::Light => Color32::BLACK.gamma_multiply(0.05),
85+
Theme::Light => self.color(ColorToken::gray(S850)),
8686
}
8787
}
8888

@@ -101,4 +101,39 @@ impl DesignTokens {
101101
Theme::Light => self.color(ColorToken::gray(S800)),
102102
}
103103
}
104+
105+
pub fn table_header_bg_fill(&self) -> Color32 {
106+
match self.theme {
107+
Theme::Dark => self.color(ColorToken::gray(S150)),
108+
Theme::Light => self.color(ColorToken::gray(S850)),
109+
}
110+
}
111+
112+
pub fn table_header_stroke_color(&self) -> Color32 {
113+
match self.theme {
114+
Theme::Dark => self.color(ColorToken::gray(S300)),
115+
Theme::Light => self.color(ColorToken::gray(S700)),
116+
}
117+
}
118+
119+
pub fn table_interaction_hovered_bg_stroke(&self) -> Color32 {
120+
match self.theme {
121+
Theme::Dark => self.color_table.gray(S300),
122+
Theme::Light => self.color_table.gray(S700),
123+
}
124+
}
125+
126+
pub fn table_interaction_active_bg_stroke(&self) -> Color32 {
127+
match self.theme {
128+
Theme::Dark => self.color_table.gray(S350),
129+
Theme::Light => self.color_table.gray(S650),
130+
}
131+
}
132+
133+
pub fn table_interaction_noninteractive_bg_stroke(&self) -> Color32 {
134+
match self.theme {
135+
Theme::Dark => self.color_table.gray(S200),
136+
Theme::Light => self.color_table.gray(S800),
137+
}
138+
}
104139
}

crates/viewer/re_ui/src/design_tokens.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct DesignTokens {
2121
/// Color table for all colors used in the UI.
2222
///
2323
/// Loaded at startup from `design_tokens.json`.
24-
pub color_table: ColorTable,
24+
pub(crate) color_table: ColorTable, // Not public, because all colors should go via design_token_colors.rs
2525

2626
// TODO(ab): get rid of these, they should be function calls like the rest.
2727
pub top_bar_color: Color32,

crates/viewer/re_viewer/src/navigation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl Navigation {
2929

3030
pub fn replace(&mut self, display_mode: DisplayMode) -> Option<DisplayMode> {
3131
let previous = self.history.pop();
32-
re_log::debug!("Replaced `{:?}` with `{:?}`", previous, display_mode);
32+
re_log::trace!("Navigated from {previous:?} to {display_mode:?}");
3333
self.history.push(display_mode);
3434
previous
3535
}

0 commit comments

Comments
 (0)