Skip to content

Commit

Permalink
MGTK: Ensure TrackThumb reports no move if thumb doesn't move
Browse files Browse the repository at this point in the history
When TrackThumb completes it calculates a new thumbpos, and tests
if the pos changed. If it didn't change, it shouldn't report a move.
But this calculation is lossy and can end up reporting a move when
the thumb wasn't moved at all, causing the thumb to jump unexpectedly.

Verify that the thumb really did move before signaling a move.

Fixes #778
  • Loading branch information
inexorabletash committed Dec 26, 2023
1 parent c8ad2ae commit 61ab027
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Project Page: https://github.com/a2stuff/a2d
* Added Dutch (`nl`) localization. ([#767](https://github.com/a2stuff/a2d/issues/767))
* Improve sound played when entering/exiting Mouse Keys mode.
* Improve window title bar apperance.
* Prevent scrollbar thumb jumping when not moved. ([#778](https://github.com/a2stuff/a2d/issues/778))

### Launcher
* If starting from a folder, brand it as a system folder.
Expand Down
39 changes: 32 additions & 7 deletions mgtk/mgtk.s
Original file line number Diff line number Diff line change
Expand Up @@ -9318,6 +9318,19 @@ got_ctl:lda params::which_ctl
EXIT_CALL MGTK::Error::no_active_window

: jsr GetThumbRect

;; Stash initial position, to detect no-op
initial_pos := $8A

ldx #0
bit which_control
bpl :+
ldx #2
: lda winrect,x
sta initial_pos
lda winrect+1,x
sta initial_pos+1

jsr SaveParamsAndStack
jsr SetDesktopPort

Expand Down Expand Up @@ -9397,6 +9410,21 @@ drag_done:
jsr FrameWinRect
jsr ShowCursorAndRestore

;; Did position change?
ldx #0
bit which_control
bpl :+
ldx #2
: lda winrect,x
cmp initial_pos
bne :+
lda winrect+1,x
cmp initial_pos+1
bne :+
lda thumb_pos ; (out) thumbpos = original value
ldx #0 ; (out) thumbmoved = 0
beq store ; always
:
jsr SetUpThumbDivision

jsr FixedDiv
Expand All @@ -9411,13 +9439,10 @@ drag_done:

ldx fixed_div_quotient+1 ; 0.8 fractional part
jsr GetThumbCoord

: ldx #1
cmp fixed_div_quotient+2
bne :+
dex

: ldy #params::thumbpos - params
:
ldx #1 ; (out) thumbmoved
store:
ldy #params::thumbpos - params
jmp store_xa_at_y
.endproc ; TrackThumbImpl

Expand Down
2 changes: 1 addition & 1 deletion res/notes/testplan.md
Original file line number Diff line number Diff line change
Expand Up @@ -763,13 +763,13 @@ Text File:
* Verify that Solid-Apple plus Up/Down Arrow keys scroll by page.
* Verify that Open-Apple plus Solid-Apple plus Up/Down Arrow keys scroll to start/end.
* Click the Proportional/Fixed button on the title bar. Verify that the view is scrolled to the top.
* Scroll somewhere in the file. Click the scrollbar thumb without moving it. Verify the thumb doesn't move and the content doesn't scroll.
* Preview a long text file, e.g. 2000 lines. Verify that dragging the scroll thumb to the middle shows approximately the middle of the file.
* Preview a long text file, e.g. 2000 lines. Verify that Up/Down Arrow keys scroll by one line consistently.
* Preview a text file with a tab character in the first line. Verify that the file displays all lines correctly.
* Preview a long text file. Verify that the first page of content appears immediately, and that the watch cursor is shown while the rest of the file is parsed. With any acceleration disabled, use Open-Apple+Solid-Apple+Down to jump to the bottom of the file. Verify that the view is displayed without undue delay.
* Download SUDOKU.dsk from www.michaeljmahon.com/Sudoku.html and mount it. Open the SUDOKU.STORY text file. Click on "Proportional" to change to "Fixed" font. Scroll down using down arrow key until bottom line reads "with". Scroll down again using down arrow key. Verify that the file correctly scrolled down one line. Scroll to the bottom of the file. Ensure the entire file is visible.


Image File:
* Verify that Escape key exits.
* Verify that Apple+W exits.
Expand Down

0 comments on commit 61ab027

Please sign in to comment.