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)
This commit is contained in:
parent
10efcfef8a
commit
66c9f61ddc
|
@ -23,8 +23,9 @@ on.mouse_press = function(x,y, mouse_button)
|
|||
if Show_code then
|
||||
if on_editor_scrollbar(Current_pane.editor_state, x,y) then
|
||||
Current_pane.editor_state.scrollbar_drag = true
|
||||
local sbtop = compute_scrollbar(Current_pane.editor_state)
|
||||
Current_pane.editor_state.scrollbar_offset = y - sbtop
|
||||
local sbtopy = compute_scrollbar_topy(Current_pane.editor_state)
|
||||
Current_pane.editor_state.scrollbar_offset = y - sbtopy
|
||||
print(y, sbtopy, y-sbtopy)
|
||||
elseif on_editor_scrollbar_area(Current_pane.editor_state, x,y) then
|
||||
-- nothing
|
||||
elseif x < Current_pane.editor_state.right + 15 - 5 and y < Current_pane.editor_state.bottom + 5 + 10 - 5 then
|
||||
|
@ -32,7 +33,7 @@ on.mouse_press = function(x,y, mouse_button)
|
|||
edit.mouse_press(Current_pane.editor_state, x,y, mouse_button)
|
||||
elseif on_editor_scrollbar(Current_pane.output_editor_state, x,y) then
|
||||
Current_pane.output_editor_state.scrollbar_drag = true
|
||||
local sbtop = compute_scrollbar(Current_pane.output_editor_state)
|
||||
local sbtopy = compute_scrollbar_topy(Current_pane.output_editor_state)
|
||||
Current_pane.output_editor_state.scrollbar_offset = y - sbtop
|
||||
elseif on_editor_scrollbar_area(Current_pane.output_editor_state, x,y) then
|
||||
-- nothing
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
adjust_scrollbar = function(state, y)
|
||||
local s = (y-state.scrollbar_offset-state.top) / (state.bottom-state.top)
|
||||
if state.scrollbar_offset then
|
||||
-- dragging
|
||||
y = y-state.scrollbar_offset
|
||||
end
|
||||
local s = (y-state.top) / (state.bottom-state.top)
|
||||
local screen_line = s*state.screen_line_count
|
||||
local line = 1
|
||||
for i=1,#state.lines do
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
compute_scrollbar_topy = function(state)
|
||||
local f = compute_scrollbar(state)
|
||||
return state.top + f*(state.bottom - state.top)
|
||||
end
|
Loading…
Reference in New Issue