Skip to content

Instantly share code, notes, and snippets.

@meijeru
Created April 27, 2020 13:49
Show Gist options
  • Save meijeru/784691e2da859a7d1ae5c452c3f2b7d7 to your computer and use it in GitHub Desktop.
Save meijeru/784691e2da859a7d1ae5c452c3f2b7d7 to your computer and use it in GitHub Desktop.
Parametrized scroller: function to make a pane with a scroller of a given vertical size
make-scroller: func [
{makes a pane with a scroller of given length;
based on original work by @toomasv}
len [integer!]
/local sc
][
sc: first layout/only compose/deep [
panel (as-pair 17 len) [
origin 0x0 space 0x-1
below
button 17x20 "^(25B2)"
base 220.220.220 (as-pair 17 len - 40) with [
pane: layout/only compose [
at 1x0 box silver loose (as-pair 15 len - 40 / 5)
]
]
pad 0x-1
; lower button
button 17x20 "^(25BC)"
]
]
sc/pane/1/actors: object [
on-click: func [face event /local desc][
desc: face/parent/pane/2/pane/1
desc/offset/y: min desc/parent/size/y - desc/size/y max 0 desc/offset/y - (desc/parent/size/y / 20)
]
]
sc/pane/3/actors: object [
on-click: func [face event /local desc][
desc: face/parent/pane/2/pane/1
desc/offset/y: min desc/parent/size/y - desc/size/y max 0 desc/offset/y + (desc/parent/size/y / 20)
]
]
sc/pane/2/actors: object [
on-down: func [face event /local desc step][
desc: face/pane/1
step: face/size/y / 20
desc/offset/y: min face/size/y - desc/size/y max 0 desc/offset/y + either event/offset/y > desc/offset/y [step][negate step]
]
]
sc/pane/2/pane/1/actors: object [
on-drag: func [face event ][
face/offset: as-pair 1 min face/parent/size/y - face/size/y max 0 face/offset/y
]
]
sc
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment