Skip to content
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
11 changes: 10 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::analytics;
use crate::computed::{ComputedChannel, ComputedChannelLibrary, FormulaEditorState};
use crate::parsers::{Aim, EcuMaster, EcuType, Haltech, Link, Parseable, RomRaider, Speeduino};
use crate::state::{
ActiveTool, CacheKey, LoadResult, LoadedFile, LoadingState, ScatterPlotConfig,
ActiveTool, CacheKey, FontScale, LoadResult, LoadedFile, LoadingState, ScatterPlotConfig,
ScatterPlotState, SelectedChannel, Tab, ToastType, CHART_COLORS, COLORBLIND_COLORS,
MAX_CHANNELS,
};
Expand Down Expand Up @@ -74,6 +74,8 @@ pub struct UltraLogApp {
// === Unit Preferences ===
/// User preferences for display units
pub(crate) unit_preferences: UnitPreferences,
/// User preference for UI font size scaling
pub(crate) font_scale: FontScale,
// === Custom Field Normalization ===
/// Custom user-defined field name mappings (source name -> normalized name)
pub(crate) custom_normalizations: HashMap<String, String>,
Expand Down Expand Up @@ -151,6 +153,7 @@ impl Default for UltraLogApp {
field_normalization: true, // Enabled by default for better readability
initial_view_seconds: 60.0, // Start with 60 second view
unit_preferences: UnitPreferences::default(),
font_scale: FontScale::default(),
custom_normalizations: HashMap::new(),
show_normalization_editor: false,
norm_editor_extend_source: String::new(),
Expand Down Expand Up @@ -230,6 +233,12 @@ impl UltraLogApp {
palette[color_index % palette.len()]
}

/// Get a scaled font size based on user's font scale preference
#[inline]
pub fn scaled_font(&self, base_size: f32) -> f32 {
(base_size * self.font_scale.multiplier()).round()
}

// ========================================================================
// File Loading
// ========================================================================
Expand Down
26 changes: 26 additions & 0 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,32 @@ impl ActiveTool {
}
}

/// Font scale preference for UI elements
#[derive(Clone, Copy, PartialEq, Eq, Default, Debug)]
pub enum FontScale {
/// Smaller fonts (0.85x)
Small,
/// Default size (1.0x)
#[default]
Medium,
/// Larger fonts (1.2x)
Large,
/// Extra large fonts (1.4x)
ExtraLarge,
}

impl FontScale {
/// Get the multiplier for this font scale
pub fn multiplier(&self) -> f32 {
match self {
FontScale::Small => 0.85,
FontScale::Medium => 1.0,
FontScale::Large => 1.2,
FontScale::ExtraLarge => 1.4,
}
}
}

/// A selected point on a heatmap
#[derive(Clone, Default)]
pub struct SelectedHeatmapPoint {
Expand Down
59 changes: 42 additions & 17 deletions src/ui/channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ use crate::state::MAX_CHANNELS;
impl UltraLogApp {
/// Render channel selection panel - fills available space
pub fn render_channel_selection(&mut self, ui: &mut egui::Ui) {
ui.heading("Channels");
// Pre-compute scaled font sizes
let font_14 = self.scaled_font(14.0);
let font_16 = self.scaled_font(16.0);
let font_18 = self.scaled_font(18.0);

ui.label(egui::RichText::new("Channels").heading().size(font_18));
ui.separator();

// Get active tab info
Expand All @@ -31,7 +36,7 @@ impl UltraLogApp {

// Computed Channels button
if ui
.button("+ Computed Channels")
.button(egui::RichText::new("+ Computed Channels").size(font_14))
.on_hover_text("Create virtual channels from mathematical formulas")
.clicked()
{
Expand All @@ -44,7 +49,7 @@ impl UltraLogApp {
let mut search_text = current_search;
let mut search_changed = false;
ui.horizontal(|ui| {
ui.label("Search:");
ui.label(egui::RichText::new("Search:").size(font_14));
let response = ui
.add(egui::TextEdit::singleline(&mut search_text).desired_width(f32::INFINITY));
search_changed = response.changed();
Expand All @@ -58,10 +63,13 @@ impl UltraLogApp {
ui.add_space(5.0);

// Channel count
ui.label(format!(
"Selected: {} / {} | Total: {}",
selected_count, MAX_CHANNELS, channel_count
));
ui.label(
egui::RichText::new(format!(
"Selected: {} / {} | Total: {}",
selected_count, MAX_CHANNELS, channel_count
))
.size(font_14),
);

ui.separator();

Expand Down Expand Up @@ -173,7 +181,8 @@ impl UltraLogApp {
"📊 Channels with Data ({})",
channels_with.len()
))
.strong(),
.strong()
.size(font_16),
)
.default_open(true)
.show(ui, |ui| {
Expand Down Expand Up @@ -203,7 +212,8 @@ impl UltraLogApp {
"📭 Empty Channels ({})",
channels_without.len()
))
.color(egui::Color32::GRAY),
.color(egui::Color32::GRAY)
.size(font_16),
)
.default_open(false) // Collapsed by default
.show(ui, |ui| {
Expand Down Expand Up @@ -234,15 +244,26 @@ impl UltraLogApp {
ui.label(
egui::RichText::new("Select a file to view channels")
.italics()
.color(egui::Color32::GRAY),
.color(egui::Color32::GRAY)
.size(font_16),
);
});
}
}

/// Render selected channel cards
pub fn render_selected_channels(&mut self, ui: &mut egui::Ui) {
ui.heading("Selected Channels");
// Pre-compute scaled font sizes
let font_12 = self.scaled_font(12.0);
let font_14 = self.scaled_font(14.0);
let font_16 = self.scaled_font(16.0);
let font_18 = self.scaled_font(18.0);

ui.label(
egui::RichText::new("Selected Channels")
.heading()
.size(font_18),
);
ui.separator();

let use_normalization = self.field_normalization;
Expand Down Expand Up @@ -391,7 +412,8 @@ impl UltraLogApp {
ui.label(
egui::RichText::new(&card.display_name)
.strong()
.color(card.color),
.color(card.color)
.size(font_14),
);
let close_btn = ui.small_button("x");
if close_btn.clicked() {
Expand All @@ -408,11 +430,12 @@ impl UltraLogApp {
ui.label(
egui::RichText::new("Min:")
.color(egui::Color32::GRAY)
.small(),
.size(font_12),
);
ui.label(
egui::RichText::new(min_str)
.color(egui::Color32::LIGHT_GRAY),
.color(egui::Color32::LIGHT_GRAY)
.size(font_14),
);
if let (Some(record), Some(time)) =
(card.min_record, card.min_time)
Expand All @@ -438,11 +461,12 @@ impl UltraLogApp {
ui.label(
egui::RichText::new("Max:")
.color(egui::Color32::GRAY)
.small(),
.size(font_12),
);
ui.label(
egui::RichText::new(max_str)
.color(egui::Color32::LIGHT_GRAY),
.color(egui::Color32::LIGHT_GRAY)
.size(font_14),
);
if let (Some(record), Some(time)) =
(card.max_record, card.max_time)
Expand Down Expand Up @@ -488,7 +512,8 @@ impl UltraLogApp {
ui.label(
egui::RichText::new("Click channels to add them to the chart")
.italics()
.color(egui::Color32::GRAY),
.color(egui::Color32::GRAY)
.size(font_16),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl UltraLogApp {
ui.centered_and_justified(|ui| {
ui.label(
egui::RichText::new("Select channels to display chart")
.size(20.0)
.size(self.scaled_font(20.0))
.color(egui::Color32::GRAY),
);
});
Expand Down
Loading
Loading