Commit Graph

19 Commits

Author SHA1 Message Date
Kartik K. Agaram c7a81906cc slightly shrink the clickable area for a button
The reason is tooltips for buttons that lie along the left or bottom
edge of the app window. Since adding tooltips I noticed that the tooltip
on the 'next' button (which lies all down the right margin of the
window) would continue to be visible after the mouse moves off the
window. It turns out that LÖVE doesn't disable the mouse position
somehow after it goes off screen. It just remains at 0 or width-1 or
height-1.

Why was I not seeing the same issue with the 'previous' button? Kinda by
happy accident. The checks in button.lua were comparing using < and >,
not <= or >=. And the x coordinate when the mouse goes off window is 0.

So the quick solution is to remove one px of clickable area from the
bottom and right. It doesn't seem too hacky; the icon switches to
resizing the window anyway when you're _right_ at the border.

I'm also focusing now on the fact that pixel values in LÖVE go from 0 to
width-1 in spite of Lua's 1-based indexing in most places.
2024-02-23 15:23:28 -08:00
Kartik K. Agaram 3293f3e139 some keyboard shortcuts on non-mobile devices
Hopefully this is easy to remember from left to right:
- run is F1
- stop is F2
- hide/show is F3
- save is F4
- load is F5

There are also tooltips to introduce these shortcuts to newcomers.

Most of the shortcuts are only enabled when code is visible. In keeping
with existing conventions for mouse events, we leave most event handlers
for the script when code is hidden. The only exception is 'F3' to show
code. So if you want to use a shortcut 'k' when code is hidden, you have
to instead use 'F3 k F3'.

This is all tentative and open to change. But I'll probably grow more
reluctant to change the shortcuts in a few weeks or months.
2024-02-22 18:27:39 -08:00
Kartik K. Agaram 81883d7dca bugfix :( 2023-12-18 21:39:01 -08:00
Kartik K. Agaram 0c4730dffc make button backgrounds optional 2023-12-18 21:33:59 -08:00
Kartik K. Agaram c29be0ffce streamline button.lua 2023-12-16 23:41:10 -08:00
Kartik K. Agaram f61976c61a use color alpha in button backgrounds 2023-10-16 22:59:04 -07:00
Kartik K. Agaram 4b3f359526 clearer API for drawing a button
Make it more obvious that the color passed in is just for the background.
The icon will do the rest.
r/g/b keys are more consistent with App.color().
2023-10-16 22:57:46 -07:00
Kartik K. Agaram 9c72ff1bb4 bugfix: propagate mouse press if any button would
Before this commit I was propagating press events only if _all_ buttons
would.
2022-08-24 13:40:36 -07:00
Kartik K. Agaram b6f42ebf01 pass all button params to the icon 2022-08-23 12:13:22 -07:00
Kartik K. Agaram 8747415461 allow buttons to nest as well 2022-08-23 11:48:52 -07:00
Kartik K. Agaram 468b791050 flip return value of button handlers
This is compatible with Javascript, and it also seems like a better
default; when people forget to think about return values in click
handlers, they should be consumed.
2022-08-23 11:43:10 -07:00
Kartik K. Agaram 8057f3e8fe stop putting button state in a global
Symptom: a test (test_click_to_create_drawing) started randomly failing
after I inserted a `return` 2 commits ago.

Cause: my tests call edit.draw, but button handlers only get cleared in
app.draw. So my tests weren't clearing button handlers, and every call
to edit.draw was accumulating states. Still unclear why those were going
to different state objects after the `return`, but anyway. I'm not going
to understand every last thing that happens when things go wrong, just
guarantee they can't go wrong. And the way to do that is to decentralize
button handlers to each state that receives them.

The State object in buttons.lua doesn't have to be Editor_state. It just
has to be some table that provides a Schelling Point for shared state.
2022-08-23 10:59:58 -07:00
Kartik K. Agaram ce79623231 improve explanation for buttons 2022-08-23 09:44:16 -07:00
Kartik K. Agaram aadc50f3b6 allow buttons to interrupt events
Most button onpress1 handlers will want to return true.
2022-08-23 09:40:48 -07:00
Kartik K. Agaram 490f10c6f8 indent 2022-08-23 09:37:38 -07:00
Kartik K. Agaram dc618a419c highlight another global 2022-05-17 23:24:46 -07:00
Kartik K. Agaram 6e152a9f3f . 2022-05-17 23:18:56 -07:00
Kartik K. Agaram 07e2b7b897 fix a typo 2022-05-12 08:27:41 -07:00
Kartik K. Agaram 475bbd70ef intermingle freehand line drawings with text 2022-05-11 13:01:13 -07:00