mirror of
https://github.com/narrrl/proton-stream.git
synced 2026-11-03 16:41:26 +01:00
fixed some ui issues (rounded corners)
This commit is contained in:
1 parent
6e127d2de8
commit
0a9bc30b72
2 files changed
+50
-17
No files matched your search
@@ -230,19 +230,22 @@ pub fn card(ui: &mut egui::Ui, card: Card<'_>) -> egui::Response {
|
|||||||
match &card.art {
|
match &card.art {
|
||||||
Some((texture, ArtShape::Landscape)) => {
|
Some((texture, ArtShape::Landscape)) => {
|
||||||
let size = texture.size_vec2();
|
let size = texture.size_vec2();
|
||||||
painter.image(
|
painter.add(
|
||||||
texture.id(),
|
egui::epaint::RectShape::filled(image_rect, radius, Color32::WHITE)
|
||||||
image_rect,
|
.with_texture(texture.id(), cover_uv(size, image_rect.size())),
|
||||||
cover_uv(size, image_rect.size()),
|
|
||||||
Color32::WHITE,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Some((texture, ArtShape::Portrait)) => {
|
Some((texture, ArtShape::Portrait)) => {
|
||||||
painter.image(
|
painter.add(
|
||||||
texture.id(),
|
egui::epaint::RectShape::filled(
|
||||||
contain_rect(texture.size_vec2(), image_rect),
|
contain_rect(texture.size_vec2(), image_rect),
|
||||||
Rect::from_min_max(egui::pos2(0.0, 0.0), egui::pos2(1.0, 1.0)),
|
radius,
|
||||||
Color32::WHITE,
|
Color32::WHITE,
|
||||||
|
)
|
||||||
|
.with_texture(
|
||||||
|
texture.id(),
|
||||||
|
Rect::from_min_max(egui::pos2(0.0, 0.0), egui::pos2(1.0, 1.0)),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
@@ -276,14 +279,38 @@ pub fn card(ui: &mut egui::Ui, card: Card<'_>) -> egui::Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(progress) = card.progress {
|
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),
|
image_rect.left_bottom() - Vec2::new(0.0, 4.0),
|
||||||
Vec2::new(width, 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;
|
let mut played = track;
|
||||||
played.set_width(track.width() * progress.clamp(0.0, 1.0));
|
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 {
|
if hovered {
|
||||||
|
|||||||
@@ -230,11 +230,17 @@ fn play_pause(ui: &mut egui::Ui, playback: &Playback, actions: &mut Vec<Action>,
|
|||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
// Pause is symmetric, so it is centred the ordinary way.
|
// Pause is symmetric, so it is centred the ordinary way.
|
||||||
let (bar, height, gap) = (size * 0.09, size * 0.32, size * 0.10);
|
let bar = (size * 0.09).round();
|
||||||
for side in [-1.0f32, 1.0] {
|
let height = (size * 0.32).round();
|
||||||
let x = centre.x + side * (gap / 2.0 + bar / 2.0);
|
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(
|
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),
|
CornerRadius::same((bar / 2.0).round() as u8),
|
||||||
theme::on_accent(),
|
theme::on_accent(),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user