From ff6b697d63bc17c0d39b84f1b46002a9dc27ff59 Mon Sep 17 00:00:00 2001 From: Joey Pollack Date: Fri, 19 Apr 2024 17:32:13 -0400 Subject: [PATCH] Basic dynamic text size adjustment if the song title is too long --- src/main.rs | 10 +++++++++- src/player_interface.rs | 7 ++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9d5f95f..1d0f4ef 100644 --- a/src/main.rs +++ b/src/main.rs @@ -73,9 +73,17 @@ impl eframe::App for JpmmvApp ); }); + let mut title_text_size = 24.0; + + let title_len = self.current_metadata.name.len() as f32; + if title_len > 44.0 + { + title_text_size -= (title_len as f32 - 44.0) / 2.0; + } + ui.style_mut().text_styles.insert( egui::TextStyle::Body, - egui::FontId::new(24.0, eframe::epaint::FontFamily::Proportional), + egui::FontId::new(title_text_size, eframe::epaint::FontFamily::Proportional), ); ui.vertical(|ui| { diff --git a/src/player_interface.rs b/src/player_interface.rs index cb1374a..5927a27 100644 --- a/src/player_interface.rs +++ b/src/player_interface.rs @@ -52,11 +52,8 @@ pub fn get_song_metadata() -> SongMetadata sm.album = split[2].to_string(); sm.art_url = split[3].to_string(); sm.art_url = sm.art_url.trim().to_string(); - sm.is_playing = if status == "paused" { - false - } else { - true - }; + sm.is_playing = if status == "paused" || status == "stopped" + { false } else { true }; // let test_url = sm.art_url.trim_start_matches("file://").to_string();