Skip to content

Record origin position of scrollbars to improve grab mechanics - #31

Open
ScoreUnder wants to merge 1 commit into
let-def:masterfrom
ScoreUnder:scrollbox_sensors
Open

Record origin position of scrollbars to improve grab mechanics#31
ScoreUnder wants to merge 1 commit into
let-def:masterfrom
ScoreUnder:scrollbox_sensors

Conversation

@ScoreUnder

@ScoreUnder ScoreUnder commented Oct 16, 2021

Copy link
Copy Markdown
Contributor

Test scrollbars with:

open Nottui

module W = Nottui_widgets

let () =
  W.string "Hello world"
  |> Ui.resize ~w:200 ~h:100
  |> Lwd.pure
  |> W.scrollbox
  |> W.h_pane @@ Lwd.pure Ui.empty
  |> W.v_pane @@ Lwd.pure Ui.empty
  |> Ui_loop.run

@c-cube

c-cube commented Oct 16, 2021

Copy link
Copy Markdown
Contributor

I'm not going to comment on the code, but the behavior on this little test is nice. Maybe there could be a directory of small examples, with this as scrollbox.exe?

Also, unrelated, but the colors are bad, it's nearly impossible to see the cursor with dark grey on light gray. I suggest:

let scrollbar_bg = Notty.A.gray 15
let scrollbar_fg = Notty.A.lightblue

@let-def

let-def commented Oct 18, 2021

Copy link
Copy Markdown
Owner

The behavior would be nice to have, but I am not fond of using permanent_sensor for this use-case.
It will essentially force the renderer to visit sub-trees and update every scrollbar if they move, while we are only interested in their movement if grabbing is on.

In practice, scrolling a list of scroll bars (ok, that does not happen every day) changes from being O(1) to O(n) (wrt to the number of scroll bars).

It would be more elegant to switch the sensor on only when grabbing the control.
I will write a patch later, and maybe rethink the sensor/grabbing mechanism.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants