Commit Graph

327 Commits

Author SHA1 Message Date
Isaiah Odhner
0decdb06d7 DRY polygon/curve undo state creation 2023-04-25 15:41:24 -04:00
Isaiah Odhner
8472b37859 Keep Curve/Polygon preview when mouse leaves the canvas 2023-04-25 15:41:24 -04:00
Isaiah Odhner
8c932ea53f Fix dragging selection by top left corner
I recognized this as another Offset -> bool coercion issue.
2023-04-25 14:39:59 -04:00
Isaiah Odhner
b46273cf9f Add a threshold to Color Eraser, comparing color components 2023-04-25 13:51:48 -04:00
Isaiah Odhner
84af26c0a2 Implement Color Eraser feature 2023-04-25 13:27:54 -04:00
Isaiah Odhner
f5ea658848 Fix CharInput interfering with Text tool 2023-04-24 23:28:36 -04:00
Isaiah Odhner
f8cfcb0f6e Make text tool use selected colors
This is a little weird because the selected background color is
analogous to the foreground color in MS Paint, for the other tools,
with the foreground color having no equivalent as it's just pixels
instead of character cells.
So with the default white canvas and black "background color",
this now draws a black text box, unlike MS Paint's default behavior
for the text tool of drawing a white text box.
2023-04-24 23:14:46 -04:00
Isaiah Odhner
fdca36daa1 Allow setting text color with Ctrl+click 2023-04-24 22:52:24 -04:00
Isaiah Odhner
61227597f8 Fix flood fill infinite loop when color under cursor matches fill color 2023-04-24 22:18:48 -04:00
Isaiah Odhner
a91dd25996 Use interpolation feature of my localization function 2023-04-24 21:14:35 -04:00
Isaiah Odhner
cfc82a55c1 Fix unlocalized save changes prompt 2023-04-24 21:13:26 -04:00
Isaiah Odhner
de1a77036b Bind F1 to Help Topics 2023-04-24 20:43:11 -04:00
Isaiah Odhner
9c4728c483 Improve layout of Custom Zoom window 2023-04-24 20:33:12 -04:00
Isaiah Odhner
4608c73219 Make undo/redo cancel in-progress tool usage 2023-04-24 15:46:17 -04:00
Isaiah Odhner
5bf2280569 Fix cycling characters in CharInput due to events queuing 2023-04-24 15:30:08 -04:00
Isaiah Odhner
9a45b3c839 Disable and hide hotkeys for top level menus since I can't detect Alt 2023-04-24 15:08:45 -04:00
Isaiah Odhner
3a0adb3c94 Fix deselection by clicking outside canvas 2023-04-24 12:54:06 -04:00
Isaiah Odhner
889d1b5636 Invert underlying colors for Free-Form Select preview, don't use selected color 2023-04-24 12:48:49 -04:00
Isaiah Odhner
b7aabd642c Refactor shared conditional to early return in stamp_char 2023-04-24 12:16:22 -04:00
Isaiah Odhner
1a135c4153 Rename a variable that is inside is_inside_polygon
This is an AI-offered function... so I'm sort of guessing here.

This fixes a spell checker issue but there's also a "possibly unbound"
type checker issue here.
2023-04-24 03:09:06 -04:00
Isaiah Odhner
23352d64ac Fix "incompatible" override type checker errors
Method "watch_value" overrides class "Input" in an incompatible manner
  Return type mismatch: base method returns type "Coroutine[Any, Any, None]", override returns type "None"
    Type "None" cannot be assigned to type "Coroutine[Any, Any, None]"PylancereportIncompatibleMethodOverride

Method "validate_cursor_position" overrides class "Input" in an incompatible manner
  Parameter 2 name mismatch: base parameter is named "cursor_position", override parameter is named "position"PylancereportIncompatibleMethodOverride

These wouldn't actually be problems, due to the nature of the reactive properties system, but whatever, I can make it match, no problem.
2023-04-24 03:07:19 -04:00
Isaiah Odhner
6259d11ec5 Switch to previous tool only on mouse up (for Magnifier)
This fixes accidentally activating the other tool when using the Magnifier, and matches the behavior of MS Paint.
2023-04-24 02:16:40 -04:00
Isaiah Odhner
961dfe8039 Add some type hints to variables
I don't know what all should have type annotations, and honestly it's
pretty confusing how these are used. For instance, `selecting_text`
goes from:
    (variable) selecting_text: bool
to:
    (variable) selecting_text: Literal[False]
when annotating it as a bool, looking at the hover text in VS Code
with Pylance language server.
2023-04-24 02:08:48 -04:00
Isaiah Odhner
0c42edce9c Fix cells stroked outside the mouse's path
Use absolute positions instead of delta coordinates.

The deltas would sometimes give points "jutting out" — only by a pixel,
but confusing when trying to do pixel art. You might not even notice it
but it might make you feel like a bad artist until you do.
2023-04-24 01:41:18 -04:00
Isaiah Odhner
dc02833f3f Shorten selected tool condition (DRY) 2023-04-24 01:27:28 -04:00
Isaiah Odhner
a875c61fff Fix mouse coordinates with a better workaround 2023-04-24 01:25:07 -04:00
Isaiah Odhner
bcb26707ef Merge Hovered and Closed events; clear text when mouse leaves menu item 2023-04-24 01:13:04 -04:00
Isaiah Odhner
c12036880e Show menu item descriptions in the status bar 2023-04-24 00:43:50 -04:00
Isaiah Odhner
d62b320ede Add default status text "For Help, click Help Topics on the Help Menu." 2023-04-24 00:03:05 -04:00
Isaiah Odhner
14ca88ba5b Show dimensions in status bar, and coords in more cases 2023-04-24 00:02:50 -04:00
Isaiah Odhner
c10f2788c1 Remove outdated comment 2023-04-23 23:05:52 -04:00
Isaiah Odhner
76e578cf4a Show mouse coords in status bar 2023-04-23 22:30:16 -04:00
Isaiah Odhner
b7d14f02bd Add an empty status bar 2023-04-23 22:22:28 -04:00
Isaiah Odhner
eb3b93d454 Require both clicks to be on the same button for a double click 2023-04-23 21:51:44 -04:00
Isaiah Odhner
8136383bca Return to previous tool after using Magnifier or Pick Color tool 2023-04-23 19:51:12 -04:00
Isaiah Odhner
70cb60218f Close menus if clicking outside the menus 2023-04-23 19:42:49 -04:00
Isaiah Odhner
fc35e34153 Use Binding(...) for all bindings, for easy access to priority/show args 2023-04-23 17:22:12 -04:00
Isaiah Odhner
d411b84605 Fix CharInput blocking Ctrl+A, Ctrl+W, etc. 2023-04-23 17:20:08 -04:00
Isaiah Odhner
cde031f70d Restore Ctrl+C to quit (for now) 2023-04-23 15:42:12 -04:00
Isaiah Odhner
138776456d Combine bindings, using comma separation 2023-04-23 15:41:41 -04:00
Isaiah Odhner
286852616b Remove meta+q binding for Quit
I was going to include meta as an alternative for all shortcuts, for
macOS, but I don't know if this works, and it's a little silly having
just one shortcut with meta like this.
2023-04-23 15:41:41 -04:00
Isaiah Odhner
0e1e43a67b Enable bindings for unimplemented actions
Might as well show the "Not implemented" dialog for keyboard shortcuts.
2023-04-23 15:02:50 -04:00
Isaiah Odhner
f93a884e74 Update the palette when double clicking to edit a color 2023-04-23 14:58:17 -04:00
Isaiah Odhner
1b76caa23e Fix double click detection in color palette
Duh, just use the button press handler.
2023-04-23 14:36:05 -04:00
Isaiah Odhner
22547da2b2 Start making Edit Colors dialog
It's just a larger palette so far.
2023-04-23 14:29:51 -04:00
Isaiah Odhner
e76ce9e721 Fix out of bounds array access for Pick Color tool 2023-04-23 13:50:41 -04:00
Isaiah Odhner
f950c9964b Stamp the selection with Ctrl 2023-04-23 02:14:28 -04:00
Isaiah Odhner
4dc7bc08d6 Make paint.py executable 2023-04-23 01:46:49 -04:00
Isaiah Odhner
031a0a3e72 Implement Select All 2023-04-23 01:24:43 -04:00
Isaiah Odhner
f106cc5c35 Gray out unimplemented menu items 2023-04-23 00:51:29 -04:00
Isaiah Odhner
dbce1434cd Constrain selection so it doesn't go completely outside the document bounds 2023-04-23 00:11:17 -04:00
Isaiah Odhner
cb0db3b6e6 Deselect when clicking outside the canvas 2023-04-23 00:01:57 -04:00
Isaiah Odhner
49bd80b17a Fix out of bounds array access for Free-Form Select 2023-04-22 23:51:12 -04:00
Isaiah Odhner
74dceee2f3 Implement Free-Form Select tool 2023-04-22 23:03:09 -04:00
Isaiah Odhner
42fdbe83d7 Fix unused parameter to erase_region
Why wasn't this reported?
2023-04-22 21:57:58 -04:00
Isaiah Odhner
5d778c1879 Annotate **kwargs as Any 2023-04-22 21:44:05 -04:00
Isaiah Odhner
625324e66b Fix BorderDefinition typing 2023-04-22 21:11:47 -04:00
Isaiah Odhner
2d88529bc0 Guess at how to typecheck this parametric event type 2023-04-22 21:08:38 -04:00
Isaiah Odhner
2c8f79e37a Shorten code and help the type checker understand that this isn't None
dhooo short
2023-04-22 21:08:38 -04:00
Isaiah Odhner
3d419f13b3 Remove unused NAME_MAP code from calculator example 2023-04-22 20:53:13 -04:00
Isaiah Odhner
9f06373cb7 Add a bunch more type checking hints/assertions 2023-04-22 20:51:51 -04:00
Isaiah Odhner
2c8d74808a Add a whole bunch more type checking 2023-04-22 18:54:21 -04:00
Isaiah Odhner
2e839b2564 Clean up unused imports 2023-04-22 17:49:15 -04:00
Isaiah Odhner
a8f174eb8e Fix the last type checking error, and simply --reload-on-changes
Hopefully this makes it more robust as well...
2023-04-22 17:29:41 -04:00
Isaiah Odhner
2827457497 Fix default document size
Broken in "Start type checking code" 1b56d78f70
2023-04-22 14:55:22 -04:00
Isaiah Odhner
da62add6c1 Avoid "possibly unbound" errors 2023-04-22 14:24:49 -04:00
Isaiah Odhner
3b2b383595 Assert a few more specific types 2023-04-22 14:24:49 -04:00
Isaiah Odhner
7cd44c0abe Ignore border_title
I found these "type: ignore" comments where border_title is defined,
and copied 'em!
2023-04-22 13:46:02 -04:00
Isaiah Odhner
27c9646b20 DRY window closing and make type checker happy with an assertion 2023-04-22 13:46:02 -04:00
Isaiah Odhner
065c5be2cb Appease the type checker by using maps of buttons 2023-04-22 13:46:02 -04:00
Isaiah Odhner
77295bd622 Int, innit? Init int 2023-04-22 13:11:23 -04:00
Isaiah Odhner
f7b68c7e7a Now do we enter the land of making code worse for the type checker's benefit? 2023-04-22 02:42:20 -04:00
Isaiah Odhner
1b56d78f70 Start type checking code 2023-04-22 02:31:58 -04:00
Isaiah Odhner
27c95a537c Make mouse_at_start an Offset (consistently)
It was already initially defined as an Offset.
2023-04-22 01:12:48 -04:00
Isaiah Odhner
45fb2eb521 Implement polygon tool 2023-04-22 01:07:20 -04:00
Isaiah Odhner
2c469a5ef3 Draw curve preview also on mouse up and mouse down events
It feels more solid now, but it still disappears if the mouse leaves the canvas.
2023-04-21 23:52:23 -04:00
Isaiah Odhner
4f99b9f6a7 Make eraser tool square
I also have an erase_region method I could use now, alternatively.
2023-04-21 23:45:04 -04:00
Isaiah Odhner
6ce1856ec7 Fix brush/pencil/eraser previews 2023-04-21 23:40:48 -04:00
Isaiah Odhner
55e6ed6caf DRY some curve tool preview stuff 2023-04-21 23:38:11 -04:00
Isaiah Odhner
4d86f783be Implement Curve tool 2023-04-21 23:16:58 -04:00
Isaiah Odhner
18b78cea03 Outside the Ministry of Silly Walks's jurisdiction, it's a squaredance. 2023-04-21 23:16:58 -04:00
Isaiah Odhner
cc0bdf0973 Implement Text tool 2023-04-21 22:12:16 -04:00
Isaiah Odhner
7442480979 Optimize/abbreviate repeated integer division by the magnification level 2023-04-21 20:49:41 -04:00
Isaiah Odhner
d602753117 Refactor get_select_region 2023-04-21 20:18:58 -04:00
Isaiah Odhner
d39f491233 Fix selection while zoomed in 2023-04-21 19:45:01 -04:00
Isaiah Odhner
37cdcdfb13 Implement View > Zoom > Custom Zoom 2023-04-21 19:30:37 -04:00
Isaiah Odhner
cbe40406a6 Fix selection region changing on mouse up
It may be wrong (sometimes), but it shouldn't change (on mouse up)!
That's something (not nothing)!
2023-04-21 19:04:50 -04:00
Isaiah Odhner
5b2e4e0f83 Make warning into an assertion 2023-04-21 18:39:18 -04:00
Isaiah Odhner
612bc3d204 Fix: refresh properly when finishing a selection 2023-04-21 18:35:41 -04:00
Isaiah Odhner
c5c9bd9425 Fix dragging selection a second time: Don't replace image data! 2023-04-21 18:25:45 -04:00
Isaiah Odhner
e98931e8ef Implement Edit > Clear Selection (Delete) 2023-04-21 16:45:20 -04:00
Isaiah Odhner
61d3db4714 Fix undo/redo handling for the Select tool 2023-04-21 16:34:38 -04:00
Isaiah Odhner
1eea87c6c9 Fix error if dragging from off the canvas and releasing mouse over it 2023-04-21 16:07:43 -04:00
Isaiah Odhner
e579b005c0 Note difference between tool.name and tool.get_name() 2023-04-21 16:04:33 -04:00
Isaiah Odhner
9932a84554 And the selection tool is working! 2023-04-21 16:04:33 -04:00
Isaiah Odhner
c6873cdde7 Now it feels like progress... 2023-04-21 15:31:38 -04:00
Isaiah Odhner
bbdfa794fc I feel like I made it worse... 2023-04-21 15:24:45 -04:00
Isaiah Odhner
c3280d20d0 WIP: selection tool 2023-04-21 15:05:41 -04:00
Isaiah Odhner
1d8dec4ba4 Implement selection tool preview 2023-04-21 13:11:39 -04:00
Isaiah Odhner
f69f2f0009 Use messages for selecting tools/colors/characters
It's more code, but hopefully separating concerns will be worth it.
2023-04-21 12:26:07 -04:00