| 1 | splitter: make rebface [
|
|---|
| 2 | tip: {
|
|---|
| 3 | USAGE:
|
|---|
| 4 | area splitter area
|
|---|
| 5 |
|
|---|
| 6 | DESCRIPTION:
|
|---|
| 7 | Placed between two widgets on the same row or column.
|
|---|
| 8 | Allows both to be resized by dragging the splitter left/right or up/down respectively.
|
|---|
| 9 | Its size determines whether it is vertical or horizontal.
|
|---|
| 10 | }
|
|---|
| 11 | size: 1x25
|
|---|
| 12 | color: colors/outline-light
|
|---|
| 13 | feel: make default-feel [
|
|---|
| 14 | redraw: make function! [face act pos /local f p n] [
|
|---|
| 15 | unless face/data [
|
|---|
| 16 | f: find face/parent-face/pane face
|
|---|
| 17 | p: back f
|
|---|
| 18 | n: next f
|
|---|
| 19 | if face/size/y <= face/size/x [
|
|---|
| 20 | while [face/offset/x <> p/1/offset/x] [
|
|---|
| 21 | if head? p [gui-error "Splitter failed to find previous widget"]
|
|---|
| 22 | p: back p
|
|---|
| 23 | ]
|
|---|
| 24 | while [face/offset/x <> n/1/offset/x] [
|
|---|
| 25 | if tail? p [gui-error "Splitter failed to find next widget"]
|
|---|
| 26 | n: next n
|
|---|
| 27 | ]
|
|---|
| 28 | ]
|
|---|
| 29 | face/data: reduce [first p first n]
|
|---|
| 30 | ]
|
|---|
| 31 | ]
|
|---|
| 32 | over: make function! [face act pos] [
|
|---|
| 33 | face/color: either act [colors/state-dark] [colors/outline-light]
|
|---|
| 34 | show face
|
|---|
| 35 | ]
|
|---|
| 36 | engage: make function! [face act event /local p n delta] [
|
|---|
| 37 | if event/type = 'move [
|
|---|
| 38 | p: first face/data
|
|---|
| 39 | n: second face/data
|
|---|
| 40 | either face/size/y > face/size/x [
|
|---|
| 41 | delta: face/offset/x - face/offset/x: min n/offset/x + n/size/x - face/size/x - 1 max p/offset/x + 1 face/offset/x + event/offset/x
|
|---|
| 42 | p/size/x: p/size/x - delta
|
|---|
| 43 | n/size/x: n/size/x + delta
|
|---|
| 44 | n/offset/x: n/offset/x - delta
|
|---|
| 45 | ][
|
|---|
| 46 | delta: face/offset/y - face/offset/y: min n/offset/y + n/size/y - face/size/y - 1 max p/offset/y + 1 face/offset/y + event/offset/y
|
|---|
| 47 | p/size/y: p/size/y - delta
|
|---|
| 48 | n/size/y: n/size/y + delta
|
|---|
| 49 | n/offset/y: n/offset/y - delta
|
|---|
| 50 | ]
|
|---|
| 51 | show [p face n]
|
|---|
| 52 | ]
|
|---|
| 53 | ; reset color if splitter is dragged out of bounds
|
|---|
| 54 | all [act = 'away face/feel/over face false 0x0]
|
|---|
| 55 | ]
|
|---|
| 56 | ]
|
|---|
| 57 | rebind: make function! [] [color: colors/outline-light]
|
|---|
| 58 | ] |
|---|