psst icon indicating copy to clipboard operation
psst copied to clipboard

Truncate playable widget

Open jacksongoode opened this issue 1 year ago • 10 comments

I'm hoping to solve that issue where long titles and album details are not clipped.

    let mut title_row = Flex::row()
        .with_flex_child(
            Label::raw()
                .with_font(theme::UI_FONT_MEDIUM)
                .with_line_break_mode(LineBreaking::Clip)
                .lens(PlayRow::item.then(Track::name.in_arc()))
                .expand_width(),
            1.0,
        )
        .with_default_spacer()
        // .with_child(playable::is_playing_marker_widget().lens(PlayRow::is_playing))
        .with_default_spacer()
        .must_fill_main_axis(true);

If you uncomment // .with_child(playable::is_playing_marker_widget().lens(PlayRow::is_playing))

You'll see that the whole thing will break. I'm honestly not sure how we get it to where the text of the song title expands and the is_playing_marker_widget fills in the remaining space. No combination I tried of flex/flex or flex/non-flex children work.

Help!

jacksongoode avatar Aug 09 '24 20:08 jacksongoode

@SO9010 If you're bored and want to look at something new, I've been trying to figure our how to get rid of the longstanding bug where long titles and album details don't get clipped. This is as far as I got but I feel like it's really close.

jacksongoode avatar Aug 10 '24 03:08 jacksongoode

I worked it out, the original child (the title child) needed to not be in a flex child as that will then share out the space evenly. I submitted a merge request to this branch.

SO9010 avatar Aug 10 '24 14:08 SO9010

Wait, false alarm! this then makes it so it cant clip, how weird!

SO9010 avatar Aug 10 '24 14:08 SO9010

Darn! Well feel free to submit commits to this branch if you figure something out!

jacksongoode avatar Aug 11 '24 03:08 jacksongoode

I have had a longer look, and it seems like something with the re-implemented logic has caused the issue where it plays that item when you click save on an item. :O

SO9010 avatar Aug 14 '24 14:08 SO9010

Right I think it has, that can be resolved, I know what the issue is there to fix the save play, but the truncation was what I was trying to tackle now.

jacksongoode avatar Aug 14 '24 16:08 jacksongoode

Okay, so I have been reading the documentation. The problem comes from the fact that a non-flex widget has an infinite size. We need either the text or the dots to be a flex widget. Otherwise, they share the space equally, and the dots will never disappear.

It clips well when just the text is in a flex row, with no expanding and no dots. Perhaps there is a way to interrupt the drawing of the text and then append the dots to it? Or maybe we could create a controller that changes a sizedbox depending on screen size, but this causes issues when the time changes.

SO9010 avatar Aug 17 '24 17:08 SO9010

Right, I thought about painting the dots and appending them to the title, which would somewhat solve the issue, because then the title and the dots would truncate as a single item. It's a possibility, but I think it's a little tricky given that we might have to render the text as a painted object. I don't really want to make the text painted.

I think the other option would be to somehow wrap the text and dots in their own flex object. It's just that it's very confusing to me how non-flex and flex objects are able to be truncated. It seems like they would need the expand_width method? It's all very confusing to me...

jacksongoode avatar Aug 19 '24 05:08 jacksongoode

I had a go at wrapping both the text and the dots into a flex widget but all that happened was that the time stamp stayed in one place.

SO9010 avatar Aug 19 '24 13:08 SO9010

Ugh I really want to figure this issue out. But the inclusion of that dotted marker_widget is really confusing since there's no way to maximize the title width and have the remaining width filled by the dots while also allowing the title to be truncatable.

jacksongoode avatar Sep 08 '24 03:09 jacksongoode

@SO9010 I think it works! Could you give it one more review before merging?

jacksongoode avatar Jun 08 '25 16:06 jacksongoode

Of course!!! I will be able to tomorrow!

SO9010 avatar Jun 08 '25 17:06 SO9010

Amazing it looks fantastic!

SO9010 avatar Jun 09 '25 14:06 SO9010

Oh no... It has actually caused an issue with the podcast view.... mistook that for the same issue as #610 -- Before -- Screenshot From 2025-06-09 19-32-53 -- After -- Screenshot From 2025-06-09 19-33-57

Do you know what the issue is? I will revert it for now. :(

SO9010 avatar Jun 09 '25 18:06 SO9010

Ah sorry about that, thanks for the revert, I never used podcasts 😆 so I didn't check!

jacksongoode avatar Jun 09 '25 21:06 jacksongoode