Before, the horizontal scrollbar went below the caption, offsetting it,
although the caption didn't scroll with the content, to be clear.
At any rate, it looks much better for the caption to stay in one place,
and be grouped outside the scrollable container which doesn't scroll it.
The dict is sparse, so its indices are not always the gallery's indices.
This fixes the behavior when passing a file as an argument.
(I already fixed this code and must've undone it somehow! I was losing my mind over here!)
- Make it more efficient by loading files progressively.
- Remove the HorizontalScroll, and instead position items absolutely, animating offsets to imitate the movement of scrolling horizontally.
- This fixes the left/right bindings not showing in the footer, due to ScrollableContainer's hidden left/right bindings.
- This also removes the possibility of scrolling half-way away from an item.
- This also fixes a problem where you could lose track of the currently viewed item when resizing the terminal, due to the 100% width of gallery items not jiving with the absolute notion of scroll position. (If the scroll position were stored as a fraction, it wouldn't have been a problem.)
- Simplify the keyboard navigation logic by storing an index into the gallery, instead of having to figure out what item is centered.
This could make debugging less confusing if the nearby debugging code were enabled and there were no paths found, but also I'm planning on changing how gallery items are loaded, making it load progressively, and decoupling this logic from the UI helps prepare for that.
I don't really like the style of wrapping to different points depending
on where the opening parenthesis is, especially when it wraps for just
one item, and these changes may remove some semantic grouping or
ordering (i.e. by importance), but I don't think I put THAT much thought
into it, and I think I can accept some lack of control, to freely use
the Organize Imports command in VS Code, which does nicely automate
grouping imports of different types.
With `textual run --dev "src.textual_paint.gallery foobar"` it output:
Folder not found: foobar
Not a folder: foobar
No ANSI art (*.ans, *.txt) found in folder: foobar
NOTE: 3 errors shown above.
Now it correctly outputs only:
Folder not found: foobar
This fixes the gallery app's --help, because before it was importing the "paint" module, which imported "args", which parsed arguments for the paint app instead of the gallery app.
This is also a refactor I've been meaning to do — since the very beginning, really — and it would've been a lot less trouble if I could've done it from the beginning, but I couldn't get imports to work. Yeah, really. Sounds pretty stupid 'cause it is. Python's module system is terrible.
This fixes "NameError: name 'PaintApp' is not defined"
PaintApp is only defined during type checking (i.e. if TYPE_CHECKING).
It would be nice if the type checker warned about usage of such vars outside of type annotations.
I believe the scrollable container's left/right bindings are winning
in terms of display in the Footer, even though mine have priority
in terms of functionality.
In the normal scrollbar render implementation, which uses fractional block characters, thumb_size makes sense as a float, but here, it can lead to cases where the scrollbar thumb takes up the entire scrollbar even though scrolling is possible, if it's not snapped to an integer number of cells. (In the original implementation, perhaps it can still run into such cases, but it would need a more extreme fraction?)