Commit Graph

344 Commits

Author SHA1 Message Date
Isaiah Odhner
3b3950cc0b Sync symbols list with code comment 2023-04-11 12:09:08 -04:00
Isaiah Odhner
5340539133 Refactor bresenham_walk into a generator 2023-04-11 12:01:40 -04:00
Isaiah Odhner
a66df997bb Toggle the color palette with Ctrl+W
Doesn't work in VS Code's terminal, but that's OK.
It works in Ubuntu's Terminal app.
2023-04-11 11:48:08 -04:00
Isaiah Odhner
4d2b667ecb Toggle the tools box with Ctrl+T 2023-04-11 11:40:47 -04:00
Isaiah Odhner
ae73fab2f4 Widen color wells
It could go either way, but I guess 4 is more consistent proportionally.
2023-04-11 11:20:51 -04:00
Isaiah Odhner
d64a011bb8 Remove extraneous refresh on mount 2023-04-11 11:08:12 -04:00
Isaiah Odhner
ab76aacff3 Stop bubbling of canvas tool events 2023-04-11 11:02:09 -04:00
Isaiah Odhner
c7e27bc3cb Cache canvas widget reference 2023-04-11 11:02:09 -04:00
Isaiah Odhner
ad111e5d6c Refactor: extract tool handling from Canvas
I wanted to avoid duplicating tool-related state between PaintApp and
Canvas, and prepare for adding different tools with more state and which
will want to live in a separate file.

This makes it slower, when running with `textual run --dev paint.py`;
when running with `python3 paint.py`, it's fine.
When running in dev mode with `textual console` devtool connected, it's
extremely much slower. But if it was faster, you'd have more messages
to scroll through, ha. So it's a tradeoff.*
*Ideally you want it to be fast and for the logs to be compacted.

In the future, I could bypass the message system for performance, but
for now I think it's better to stay idiomatic.
2023-04-11 11:02:09 -04:00
Isaiah Odhner
338d438470 VS Code: disable CSS linting
It doesn't understand the syntax or supported properties of the Textual stylesheets.
2023-04-11 09:31:01 -04:00
Isaiah Odhner
cb37f50564 Fix mouse move event coordinates 2023-04-11 08:48:02 -04:00
Isaiah Odhner
e2c9b4b66c Improve layout 2023-04-11 08:47:47 -04:00
Isaiah Odhner
7d1afed296 Define dimensions for Canvas widget 2023-04-11 08:46:57 -04:00
Isaiah Odhner
abd6468ce8 Refactor related image data into a class 2023-04-11 08:07:02 -04:00
Isaiah Odhner
e19cdff5e7 Exit with Ctrl+Q, in preparation for overriding Ctrl+C 2023-04-11 07:52:26 -04:00
Isaiah Odhner
3844667ff7 Hide characters, use only colors on canvas 2023-04-11 00:48:29 -04:00
Isaiah Odhner
32ac1bd92c Make drawing responsive! 2023-04-11 00:46:07 -04:00
Isaiah Odhner
c3035d171f Fix up the app layout scrollbar situation
- Remove scrollbar from root
- Fix extra height below color palette due to vertical layout giving even heights
- Add container around canvas to make canvas scrollable
2023-04-11 00:19:07 -04:00
Isaiah Odhner
ba0d80bc0d Implement color selection 2023-04-10 23:56:53 -04:00
Isaiah Odhner
1811e1c41c Add palette 2023-04-10 23:56:53 -04:00
Isaiah Odhner
7b44defde2 Add VS Code launch task 2023-04-10 23:14:22 -04:00
Isaiah Odhner
43b827720b Use Bresenham's line algorithm 2023-04-10 22:24:22 -04:00
Isaiah Odhner
f6e9d6676e Capture the mouse when drawing on the canvas 2023-04-10 22:16:50 -04:00
Isaiah Odhner
f4eb6eb1f0 Add bounds checks 2023-04-10 22:16:33 -04:00
Isaiah Odhner
61a25a85bf Rename width/height properties 2023-04-10 22:07:25 -04:00
Isaiah Odhner
8168ef78a3 Fix timing of update_canvas on mouse down 2023-04-10 22:03:31 -04:00
Isaiah Odhner
42ae61c9ab Add color support to the canvas, very inefficiently 2023-04-10 21:51:26 -04:00
Isaiah Odhner
ffca83c1c6 Support drawing, basically 2023-04-10 21:30:11 -04:00
Isaiah Odhner
69ca7eefdb Add a Canvas widget 2023-04-10 21:25:31 -04:00
Isaiah Odhner
6863a1b2c4 Tweak selected tool button style 2023-04-10 21:04:08 -04:00
Isaiah Odhner
cf8acc4f94 Disable focus highlight on tool buttons 2023-04-10 20:59:59 -04:00
Isaiah Odhner
b64869eae4 Let buttons fall back to the original color when deselected 2023-04-10 20:52:01 -04:00
Isaiah Odhner
3f8a652fe2 Implement selected_tool state 2023-04-10 19:27:11 -04:00
Isaiah Odhner
78e326377d Add to prior art (See Also) section 2023-04-10 18:44:31 -04:00
Isaiah Odhner
f79ebcd7d0 Fix missing URLs 2023-04-10 18:31:41 -04:00
Isaiah Odhner
6ecdfe3532 Move tool buttons into a ToolsBox container and improve layout 2023-04-10 18:21:09 -04:00
Isaiah Odhner
e6db039d99 Remove dead whitespace 2023-04-10 18:06:41 -04:00
Isaiah Odhner
43169d7df2 Make buttons gray instead of blue 2023-04-10 17:46:08 -04:00
Isaiah Odhner
d09080eec3 Update layout to a two-column toolbar 2023-04-10 17:45:54 -04:00
Isaiah Odhner
99fcda2c53 Remove calculator logic/UI 2023-04-10 17:40:59 -04:00
Isaiah Odhner
ad4c94097a Add buttons for Paint tools 2023-04-10 17:29:04 -04:00
Isaiah Odhner
642bf3812c Rename calculator -> paint 2023-04-10 16:54:36 -04:00
Isaiah Odhner
f19b7ceced Add calculator example from Textual 2023-04-10 16:51:53 -04:00
Isaiah Odhner
787dc676db Initial commit 2023-04-10 16:51:39 -04:00