From 0a9bc30b728082709090ef6bfb0aaa5dd7d0106b Mon Sep 17 00:00:00 2001 From: Nils Pukropp Date: Tue, 4 Aug 2026 09:39:00 +0200 Subject: [PATCH] fixed some ui issues (rounded corners) --- crates/pstr-app/src/ui/mod.rs | 53 ++++++++++++++++++++++------- crates/pstr-app/src/ui/transport.rs | 14 +++++--- 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/crates/pstr-app/src/ui/mod.rs b/crates/pstr-app/src/ui/mod.rs index 0699bca..71e93b0 100644 --- a/crates/pstr-app/src/ui/mod.rs +++ b/crates/pstr-app/src/ui/mod.rs @@ -230,19 +230,22 @@ pub fn card(ui: &mut egui::Ui, card: Card<'_>) -> egui::Response { match &card.art { Some((texture, ArtShape::Landscape)) => { let size = texture.size_vec2(); - painter.image( - texture.id(), - image_rect, - cover_uv(size, image_rect.size()), - Color32::WHITE, + painter.add( + egui::epaint::RectShape::filled(image_rect, radius, Color32::WHITE) + .with_texture(texture.id(), cover_uv(size, image_rect.size())), ); } Some((texture, ArtShape::Portrait)) => { - painter.image( - texture.id(), - contain_rect(texture.size_vec2(), image_rect), - Rect::from_min_max(egui::pos2(0.0, 0.0), egui::pos2(1.0, 1.0)), - Color32::WHITE, + painter.add( + egui::epaint::RectShape::filled( + contain_rect(texture.size_vec2(), image_rect), + radius, + Color32::WHITE, + ) + .with_texture( + texture.id(), + Rect::from_min_max(egui::pos2(0.0, 0.0), egui::pos2(1.0, 1.0)), + ), ); } None => { @@ -276,14 +279,38 @@ pub fn card(ui: &mut egui::Ui, card: Card<'_>) -> egui::Response { } if let Some(progress) = card.progress { - let track = Rect::from_min_size( + let clip_rect = Rect::from_min_size( image_rect.left_bottom() - Vec2::new(0.0, 4.0), Vec2::new(width, 4.0), ); - painter.rect_filled(track, CornerRadius::ZERO, Color32::from_black_alpha(150)); + let clipped_painter = painter.with_clip_rect(clip_rect); + + let track = Rect::from_min_size( + image_rect.left_bottom() - Vec2::new(0.0, 16.0), + Vec2::new(width, 16.0), + ); + let track_radius = CornerRadius { + nw: 0, + ne: 0, + sw: 8, + se: 8, + }; + clipped_painter.rect_filled(track, track_radius, Color32::from_black_alpha(150)); + let mut played = track; played.set_width(track.width() * progress.clamp(0.0, 1.0)); - theme::accent_fill(painter, played, CornerRadius::ZERO, 0.0); + + let played_radius = CornerRadius { + nw: 0, + ne: 0, + sw: 8, + se: if played.max.x >= track.max.x - 0.1 { + 8 + } else { + 0 + }, + }; + theme::accent_fill(&clipped_painter, played, played_radius, 0.0); } if hovered { diff --git a/crates/pstr-app/src/ui/transport.rs b/crates/pstr-app/src/ui/transport.rs index b8cf26a..fcb6e76 100644 --- a/crates/pstr-app/src/ui/transport.rs +++ b/crates/pstr-app/src/ui/transport.rs @@ -230,11 +230,17 @@ fn play_pause(ui: &mut egui::Ui, playback: &Playback, actions: &mut Vec, )); } else { // Pause is symmetric, so it is centred the ordinary way. - let (bar, height, gap) = (size * 0.09, size * 0.32, size * 0.10); - for side in [-1.0f32, 1.0] { - let x = centre.x + side * (gap / 2.0 + bar / 2.0); + let bar = (size * 0.09).round(); + let height = (size * 0.32).round(); + let gap = (size * 0.10).round(); + let y = (centre.y - height / 2.0).round(); + + for x in [ + (centre.x - gap / 2.0 - bar).round(), + (centre.x + gap / 2.0).round(), + ] { painter.rect_filled( - Rect::from_center_size(pos2(x, centre.y), Vec2::new(bar, height)), + Rect::from_min_size(pos2(x, y), Vec2::new(bar, height)), CornerRadius::same((bar / 2.0).round() as u8), theme::on_accent(), );