mouse events for scrollbar

akkartik
Nov 18, 2023, 1:27 PM
IP4LD33DQFWQ4654YPNJRKQ3CNYSHRZPX6U6ZPY7OLE744XX3MEQC

Dependencies

Change contents

  • edit in README.md at line 68
    [4.65][4.65:106](),[4.107][4.35:36]()
    * No scrollbars yet. That stuff is hard.
  • resolve order conflict in README.md at line 68
    [4.65]
    [4.1120]
  • file addition: 0040-on_editor_scrollbar_area (----------)
    [17.2]
    on_editor_scrollbar_area = function(x,y)
    if x < Editor_state.right+20 then return end
    if x > Editor_state.right+40 then return end
    if y < Editor_state.top then return end
    if y > Editor_state.bottom then return end
    return true
    end
  • file addition: 0038-on_editor_scrollbar (----------)
    [17.2]
    on_editor_scrollbar = function(x,y)
    if x < Editor_state.right+20 then return end
    if x > Editor_state.right+40 then return end
    if y < Editor_scrollbar_top then return end
    if y > Editor_scrollbar_bottom then return end
    return true
    end
  • file addition: 0037-Editor_scrollbar_top (----------)
    [17.2]
    Editor_scrollbar_top = 0 -- in px
    Editor_scrollbar_bottom = 0
  • file addition: 0036-adjust_scrollbar (----------)
    [17.2]
    adjust_scrollbar = function(y)
    local s = (y-Editor_state.top) / (Editor_state.bottom-Editor_state.top)
    local screen_line = s*Editor_state.screen_line_count
    local line = 1
    for i=1,#Editor_state.lines do
    if Editor_state.line_cache[i].start_screen_line_index > screen_line then
    break
    end
    line = i
    end
    Editor_state.screen_top1 = {line=line, pos=1}
    Editor_state.cursor1 = {line=line, pos=1}
    end
  • edit in 0034-draw_scrollbar at line 11
    [3.3107]
    [3.3107]
    Editor_scrollbar_top = topy
    Editor_scrollbar_bottom = boty
  • replacement in 0017-on.mouse_release at line 2
    [4.2259][4.2259:2312]()
    edit.mouse_release(Editor_state, x,y, mouse_button)
    [4.2259]
    [4.2312]
    if Editor_scrollbar_drag then
    adjust_scrollbar(y)
    Editor_scrollbar_drag = nil
    elseif on_editor_scrollbar_area(x,y) then
    adjust_scrollbar(y)
    else
    edit.mouse_release(Editor_state, x,y, mouse_button)
    end
  • replacement in 0016-on.mouse_press at line 5
    [4.1753][4.2409:2460](),[4.2409][4.2409:2460]()
    edit.mouse_press(Editor_state, x,y, mouse_button)
    [4.1753]
    [4.2460]
    if on_editor_scrollbar(x,y) then
    Editor_scrollbar_drag = true
    elseif on_editor_scrollbar_area(x,y) then
    -- nothing
    else
    edit.mouse_press(Editor_state, x,y, mouse_button)
    end
  • replacement in 0004-on.update at line 3
    [2.1760][2.1760:1764]()
    end
    [2.1760]
    if Editor_scrollbar_drag then
    adjust_scrollbar(App.mouse_y())
    end
    end