Commit Graph

1608 Commits

Author SHA1 Message Date
Kartik K. Agaram 2477e2a603 document Show_menu variable 2023-12-04 22:17:53 -08:00
Kartik K. Agaram 966f8a15bf simplify state management for menus 2023-12-04 22:09:47 -08:00
Kartik K. Agaram e93d43253d close all menus when tapping any button
I think I'm least likely to break something if I do this as explicitly
as possible rather than trying to figure out the right helper to put it
in once and for all. So just add some boilerplate to reset all state at
the start of each onpress1 handler. This seems like a good choice since
we aren't planning to add a lot more menus that would quadratically
explode the boilerplate.
2023-12-04 21:34:39 -08:00
Kartik K. Agaram 8e17a56232 clean up some debug drawing 2023-12-03 15:53:39 -08:00
Kartik K. Agaram 42cc608d06 bugfix: only check for settings menu when open
Scenario I was seeing:
* on an Android phone
* when font size is small
* if I scrolled down a bit
* and then tapped on the editor

Then before this commit, the scrollbar would move. Even though I was
tapping nowhere near the scrollbar. Or even the settings area!

I carefully bisected this down to commit 7ca2006145 and this code in
on.mouse_release:

  if on_area(Settings_menu_area, x,y) then
    return
  end

What was actually going on in the above scenario:
* on a device with a small screen
* after I open the settings menu once
* the scrollbar overlaps the erstwhile setting menu, so that dragging
  the scrollbar doesn't trigger on.mouse_receive
* as a result the scrollbar is still active when I tap the editor.

Holy smokes!
2023-12-03 15:43:27 -08:00
Kartik K. Agaram eb9bafa5b5 Merge template-live-editor-mobile 2023-12-03 13:26:49 -08:00
Kartik K. Agaram 373a976ed1 bugfix: LÖVE v12 is not supported yet on mobile devices 2023-12-03 13:23:35 -08:00
Kartik K. Agaram db2529c37e Merge template-live-editor 2023-12-03 13:22:57 -08:00
Kartik K. Agaram cdbbe56519 Merge text0 2023-12-03 13:21:55 -08:00
Kartik K. Agaram 20d2b3e460 Merge text.love 2023-12-03 13:18:22 -08:00
Kartik K. Agaram 67eb28ef1c Merge lines.love 2023-12-03 13:01:49 -08:00
Kartik K. Agaram f6bc670ef6 yet another bugfix to the version check
We could now get test failures before the version check, which might be
confusing.
2023-12-03 12:30:16 -08:00
Kartik K. Agaram f37b45196a speculatively recommend new LÖVE v11.5 in all forks 2023-12-03 12:12:56 -08:00
Kartik K. Agaram 9993014904 bugfix: version check 2023-12-03 12:11:17 -08:00
Kartik K. Agaram 5cea394a37 Merge template-live-editor-mobile 2023-12-03 11:46:17 -08:00
Kartik K. Agaram a2d6a99d13 Merge template-live-editor 2023-12-03 11:44:10 -08:00
Kartik K. Agaram d58c733a30 Merge text0 2023-12-03 11:43:26 -08:00
Kartik K. Agaram 0ec556deec Merge text.love 2023-12-03 11:41:48 -08:00
Kartik K. Agaram df2cfb820d Merge lines.love 2023-12-03 11:25:16 -08:00
Kartik K. Agaram 0d3db19c85 clearing starty is redundant in mutations
We'll end up calling Text.redraw_all anyway, which will clear starty and
much more besides.

We'll still conservatively continue clearing starty in a few places
where there's a possibility that Text.redraw_all may not be called. This
change is riskier than most.
2023-12-03 10:32:05 -08:00
Kartik K. Agaram 107e41d522 bugfix: typo X-( 2023-12-02 22:27:36 -08:00
Kartik K. Agaram 66c9f61ddc bugfix: tapping in scrollbar area
scenario 1: tap on scrollbar area off scrollbar.
With the previous commit the app would crash.

scenario 2: drag down a bit, then let go, then drag the scrollbar again.
With the previous commit the scrollbar would start again from 0.

Root cause: units mismatch (pixels vs normalized y between 0 and 1)
2023-12-02 18:36:11 -08:00
Kartik K. Agaram 10efcfef8a UI improvement: more stable scrollbar movement
scenario: just tap somewhere on a scrollbar.

There should be no scrolling. But before this commit there would be.
This made the scrollbars feel unstable.

I finally figured this out while noodling over a follow-up question to
the previous commit:

  Why was dragging the scrollbar down ever leaving a trail of more than
  just the top line's `starty`? In other words, why was my example:

    line 1: 30
    line 2: 60
    line 3: 90
    line 4: 30
    line 5: 30
    line 6: 30
    ...

  ..and not:

    line 1: 30
    line 2: 30
    line 3: 30
    line 4: 30
    line 5: 30
    line 6: 30
    ...

  ??

The answer: when I grab a scrollbar it always used to jump down!

Usability issues can either exacerbate bugs or make them harder to
diagnose. If I'd implemented scrollbars like this from the start, we'd
either never have noticed the problem of the previous commit or fixed it
much more quickly.
2023-12-02 17:22:44 -08:00
Kartik K. Agaram 793f0daf44 bugfix: position cursor after dragging scrollbar
scenario:
  drag the editor scrollbar down more than a page
  tap near the bottom of the editor. Tapping works
  tap near the top of the editor. Nothing happens.

The cause: as you drag the scrollbar, starty gets set for lines on
screen. However, the lines going above the screen don't get their starty
reset.

Why even would any tapping work? Answer: dragging the scrollbar is
always contiguous, never random access. So when you drag a little bit,
the top line gets its starty set. When you drag a little more the next
line has its starty set. As a result, the usual pattern with the bug
was something like:
  line 1: 30
  line 2: 60
  line 3: 90
  line 4: 30
  line 5: 30
  line 6: 30
  line 7: 30
  line 8: 30
  ...

As a result, low `y`s (<90 in this made-up example) get caught in those
first few lines, but high `y`s get to the right line below.

Root cause: any time you scroll, you have to call Text.redraw_all. That
will cause `starty`s to look like this:

  line 1: nil
  line 2: nil
  line 3: nil
  line 4: nil
  line 5: nil
  line 6: 30   <== screen_top1
  line 7: 60
  ...
2023-12-02 16:58:20 -08:00
Kartik K. Agaram 19be6bcaf6 isolate editor UI from some app changes
There will probably more such things to add.
2023-12-02 12:54:09 -08:00
Kartik K. Agaram e21f093a10 wire up mouse wheel 2023-12-02 12:01:28 -08:00
Kartik K. Agaram e405a0aa42 a few more abbreviations 2023-12-02 10:05:18 -08:00
Kartik K. Agaram bb9b47fd1a bugfix: loading a file with text selected 2023-12-02 09:32:02 -08:00
Kartik K. Agaram 0862dd2f72 Merge template-live-editor-mobile 2023-12-01 22:26:00 -08:00
Kartik K. Agaram b0c73e3d25 Merge template-live-editor 2023-12-01 22:25:00 -08:00
Kartik K. Agaram 7bbc10fffb Merge text0 2023-12-01 22:24:42 -08:00
Kartik K. Agaram 5a2581bf71 Merge text.love 2023-12-01 22:24:03 -08:00
Kartik K. Agaram 52ffb40d79 Merge lines.love 2023-12-01 22:17:43 -08:00
Kartik K. Agaram 8399c42707 mouse button state in source editor 2023-12-01 22:07:24 -08:00
Kartik K. Agaram 120f4ccf1b Merge text.love 2023-12-01 22:06:34 -08:00
Kartik K. Agaram 61336b491b Merge lines.love 2023-12-01 22:03:36 -08:00
Kartik K. Agaram 8a588880b7 manually maintain mouse button press state
Just checking mouse.isDown works if the editor is the entirety of the
app, as is true in this fork. However, we often want to introduce other
widgets. We'd like tapping on them to not cause the selection to flash:
  https://news.ycombinator.com/context?id=38404923&submission=38397715

The right architecture to enforce this is: have each layer of the UI
maintain its own state machine between mouse_press and mouse_release
events. And only check the state machine in the next level down rather
than lower layers or the bottommost layer of raw LÖVE.
2023-12-01 21:56:35 -08:00
Kartik K. Agaram ca3b15dded rename a function 2023-12-01 21:00:38 -08:00
Kartik K. Agaram 7ca2006145 partition handlers between screen regions
This fixes one bug I know of: dragging the mouse atop the settings menu
was selecting text in the editor underneath.
2023-12-01 20:59:22 -08:00
Kartik K. Agaram e0a0c4f33b check slider state more precisely 2023-12-01 20:53:08 -08:00
Kartik K. Agaram 9b62cf0afc no selection if State didn't receive mouse_press
This change needs to get backported to all the other forks. We want to
retain the ability to draw other UI elements in our apps, and that means
we can't always assume that a mouse press and mouse release will happen
together. Instead, each layer should manage its own state machine, and
only check for events from the immediately lower layer.

This idea generalizes commit c3cdbb52a.
2023-12-01 20:46:45 -08:00
Kartik K. Agaram c3cdbb52a9 set cursor on mouse_press as well as mouse_release
Problem: on mobile devices, tapping on the editor causes the selection
to flash for a second. It looks like there's a longer time between mouse
press and release events.

Scenarios tested with this change:
* click on the editor to move the cursor
* drag-select using the mouse
* shift-select using keyboard
* shift-click to select
2023-12-01 20:26:21 -08:00
Kartik K. Agaram a3fdbaad6d support undo of paste button 2023-12-01 20:22:27 -08:00
Kartik K. Agaram 2ff2692bb4 bugfix: use border color in scrollbars 2023-12-01 20:19:27 -08:00
Kartik K. Agaram 230b903df8 avoid the overflow button in some narrow cases 2023-12-01 20:15:46 -08:00
Kartik K. Agaram 0d2d85d8d7 activate buttons for some time
The active state has 2 uses:
* It gives some visual feedback that a button has been pressed.
  Otherwise, tapping a button gave no feedback that the tap had
  occurred. Particularly on a phone screen where fat-fingering is
  easier, hitting the 'save' button in particular gave no hint that the
  file had actually been saved. Which causes some anxiety.
* It suppresses all mouse taps during the activation time. For example,
  this helps keep tapping say an overflow button from selecting text in
  the editor.
2023-12-01 20:07:20 -08:00
Kartik K. Agaram d85c246cfb bugfix: avoid overflowing 'delete' button in some situations 2023-12-01 19:59:23 -08:00
Kartik K. Agaram d0e2e682c5 bugfix: autosave settings
Before this commit we were only saving settings when explicitly hitting
the 'settings' button to dismiss the menu. But clicking anywhere outside
the menu dismisses it.
2023-12-01 19:55:51 -08:00
Kartik K. Agaram 5875196422 bugfix: hit 'clear' with text selected
Before this commit, selecting some text and then hitting the 'clear'
button would crash the app.
2023-12-01 19:53:14 -08:00
Kartik K. Agaram 750ef9d54d remove warning about persistence from Readme 2023-11-26 13:39:26 -08:00