Skip to content

Commit 6d9fff8

Browse files
Adds UI font scaling to make the app more accessible
Signed-off-by: Cole Gentry <peapod2007@gmail.com>
1 parent cd0c987 commit 6d9fff8

13 files changed

Lines changed: 287 additions & 118 deletions

src/app.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::analytics;
1616
use crate::computed::{ComputedChannel, ComputedChannelLibrary, FormulaEditorState};
1717
use crate::parsers::{Aim, EcuMaster, EcuType, Haltech, Link, Parseable, RomRaider, Speeduino};
1818
use crate::state::{
19-
ActiveTool, CacheKey, LoadResult, LoadedFile, LoadingState, ScatterPlotConfig,
19+
ActiveTool, CacheKey, FontScale, LoadResult, LoadedFile, LoadingState, ScatterPlotConfig,
2020
ScatterPlotState, SelectedChannel, Tab, ToastType, CHART_COLORS, COLORBLIND_COLORS,
2121
MAX_CHANNELS,
2222
};
@@ -74,6 +74,8 @@ pub struct UltraLogApp {
7474
// === Unit Preferences ===
7575
/// User preferences for display units
7676
pub(crate) unit_preferences: UnitPreferences,
77+
/// User preference for UI font size scaling
78+
pub(crate) font_scale: FontScale,
7779
// === Custom Field Normalization ===
7880
/// Custom user-defined field name mappings (source name -> normalized name)
7981
pub(crate) custom_normalizations: HashMap<String, String>,
@@ -151,6 +153,7 @@ impl Default for UltraLogApp {
151153
field_normalization: true, // Enabled by default for better readability
152154
initial_view_seconds: 60.0, // Start with 60 second view
153155
unit_preferences: UnitPreferences::default(),
156+
font_scale: FontScale::default(),
154157
custom_normalizations: HashMap::new(),
155158
show_normalization_editor: false,
156159
norm_editor_extend_source: String::new(),
@@ -230,6 +233,12 @@ impl UltraLogApp {
230233
palette[color_index % palette.len()]
231234
}
232235

236+
/// Get a scaled font size based on user's font scale preference
237+
#[inline]
238+
pub fn scaled_font(&self, base_size: f32) -> f32 {
239+
(base_size * self.font_scale.multiplier()).round()
240+
}
241+
233242
// ========================================================================
234243
// File Loading
235244
// ========================================================================

src/state.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,32 @@ impl ActiveTool {
195195
}
196196
}
197197

198+
/// Font scale preference for UI elements
199+
#[derive(Clone, Copy, PartialEq, Eq, Default, Debug)]
200+
pub enum FontScale {
201+
/// Smaller fonts (0.85x)
202+
Small,
203+
/// Default size (1.0x)
204+
#[default]
205+
Medium,
206+
/// Larger fonts (1.2x)
207+
Large,
208+
/// Extra large fonts (1.4x)
209+
ExtraLarge,
210+
}
211+
212+
impl FontScale {
213+
/// Get the multiplier for this font scale
214+
pub fn multiplier(&self) -> f32 {
215+
match self {
216+
FontScale::Small => 0.85,
217+
FontScale::Medium => 1.0,
218+
FontScale::Large => 1.2,
219+
FontScale::ExtraLarge => 1.4,
220+
}
221+
}
222+
}
223+
198224
/// A selected point on a heatmap
199225
#[derive(Clone, Default)]
200226
pub struct SelectedHeatmapPoint {

src/ui/channels.rs

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ use crate::state::MAX_CHANNELS;
99
impl UltraLogApp {
1010
/// Render channel selection panel - fills available space
1111
pub fn render_channel_selection(&mut self, ui: &mut egui::Ui) {
12-
ui.heading("Channels");
12+
// Pre-compute scaled font sizes
13+
let font_14 = self.scaled_font(14.0);
14+
let font_16 = self.scaled_font(16.0);
15+
let font_18 = self.scaled_font(18.0);
16+
17+
ui.label(egui::RichText::new("Channels").heading().size(font_18));
1318
ui.separator();
1419

1520
// Get active tab info
@@ -31,7 +36,7 @@ impl UltraLogApp {
3136

3237
// Computed Channels button
3338
if ui
34-
.button("+ Computed Channels")
39+
.button(egui::RichText::new("+ Computed Channels").size(font_14))
3540
.on_hover_text("Create virtual channels from mathematical formulas")
3641
.clicked()
3742
{
@@ -44,7 +49,7 @@ impl UltraLogApp {
4449
let mut search_text = current_search;
4550
let mut search_changed = false;
4651
ui.horizontal(|ui| {
47-
ui.label("Search:");
52+
ui.label(egui::RichText::new("Search:").size(font_14));
4853
let response = ui
4954
.add(egui::TextEdit::singleline(&mut search_text).desired_width(f32::INFINITY));
5055
search_changed = response.changed();
@@ -58,10 +63,13 @@ impl UltraLogApp {
5863
ui.add_space(5.0);
5964

6065
// Channel count
61-
ui.label(format!(
62-
"Selected: {} / {} | Total: {}",
63-
selected_count, MAX_CHANNELS, channel_count
64-
));
66+
ui.label(
67+
egui::RichText::new(format!(
68+
"Selected: {} / {} | Total: {}",
69+
selected_count, MAX_CHANNELS, channel_count
70+
))
71+
.size(font_14),
72+
);
6573

6674
ui.separator();
6775

@@ -173,7 +181,8 @@ impl UltraLogApp {
173181
"📊 Channels with Data ({})",
174182
channels_with.len()
175183
))
176-
.strong(),
184+
.strong()
185+
.size(font_16),
177186
)
178187
.default_open(true)
179188
.show(ui, |ui| {
@@ -203,7 +212,8 @@ impl UltraLogApp {
203212
"📭 Empty Channels ({})",
204213
channels_without.len()
205214
))
206-
.color(egui::Color32::GRAY),
215+
.color(egui::Color32::GRAY)
216+
.size(font_16),
207217
)
208218
.default_open(false) // Collapsed by default
209219
.show(ui, |ui| {
@@ -234,15 +244,26 @@ impl UltraLogApp {
234244
ui.label(
235245
egui::RichText::new("Select a file to view channels")
236246
.italics()
237-
.color(egui::Color32::GRAY),
247+
.color(egui::Color32::GRAY)
248+
.size(font_16),
238249
);
239250
});
240251
}
241252
}
242253

243254
/// Render selected channel cards
244255
pub fn render_selected_channels(&mut self, ui: &mut egui::Ui) {
245-
ui.heading("Selected Channels");
256+
// Pre-compute scaled font sizes
257+
let font_12 = self.scaled_font(12.0);
258+
let font_14 = self.scaled_font(14.0);
259+
let font_16 = self.scaled_font(16.0);
260+
let font_18 = self.scaled_font(18.0);
261+
262+
ui.label(
263+
egui::RichText::new("Selected Channels")
264+
.heading()
265+
.size(font_18),
266+
);
246267
ui.separator();
247268

248269
let use_normalization = self.field_normalization;
@@ -391,7 +412,8 @@ impl UltraLogApp {
391412
ui.label(
392413
egui::RichText::new(&card.display_name)
393414
.strong()
394-
.color(card.color),
415+
.color(card.color)
416+
.size(font_14),
395417
);
396418
let close_btn = ui.small_button("x");
397419
if close_btn.clicked() {
@@ -408,11 +430,12 @@ impl UltraLogApp {
408430
ui.label(
409431
egui::RichText::new("Min:")
410432
.color(egui::Color32::GRAY)
411-
.small(),
433+
.size(font_12),
412434
);
413435
ui.label(
414436
egui::RichText::new(min_str)
415-
.color(egui::Color32::LIGHT_GRAY),
437+
.color(egui::Color32::LIGHT_GRAY)
438+
.size(font_14),
416439
);
417440
if let (Some(record), Some(time)) =
418441
(card.min_record, card.min_time)
@@ -438,11 +461,12 @@ impl UltraLogApp {
438461
ui.label(
439462
egui::RichText::new("Max:")
440463
.color(egui::Color32::GRAY)
441-
.small(),
464+
.size(font_12),
442465
);
443466
ui.label(
444467
egui::RichText::new(max_str)
445-
.color(egui::Color32::LIGHT_GRAY),
468+
.color(egui::Color32::LIGHT_GRAY)
469+
.size(font_14),
446470
);
447471
if let (Some(record), Some(time)) =
448472
(card.max_record, card.max_time)
@@ -488,7 +512,8 @@ impl UltraLogApp {
488512
ui.label(
489513
egui::RichText::new("Click channels to add them to the chart")
490514
.italics()
491-
.color(egui::Color32::GRAY),
515+
.color(egui::Color32::GRAY)
516+
.size(font_16),
492517
);
493518
}
494519
}

src/ui/chart.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl UltraLogApp {
1717
ui.centered_and_justified(|ui| {
1818
ui.label(
1919
egui::RichText::new("Select channels to display chart")
20-
.size(20.0)
20+
.size(self.scaled_font(20.0))
2121
.color(egui::Color32::GRAY),
2222
);
2323
});

0 commit comments

Comments
 (0)