|
Revision 75, 1.2 kB
(checked in by ashley, 18 months ago)
|
|
Fixes for problems introduced in build 74
Widget documentation improved
|
| Line | |
|---|
| 1 | led-group: make rebface [
|
|---|
| 2 | tip: {
|
|---|
| 3 | USAGE:
|
|---|
| 4 | led-group data ["Option-1" true "Option-2" false "Option-3" none]
|
|---|
| 5 |
|
|---|
| 6 | DESCRIPTION:
|
|---|
| 7 | Group of LED indicators.
|
|---|
| 8 | Alignment is vertical unless height is specified as line height.
|
|---|
| 9 | At runtime face/data is a block of logic (or none) indicating state of each LED indicator.
|
|---|
| 10 | }
|
|---|
| 11 | size: 50x-1
|
|---|
| 12 | pane: []
|
|---|
| 13 | feel: make default-feel [
|
|---|
| 14 | redraw: make function! [face act pos] [
|
|---|
| 15 | if act = 'show [
|
|---|
| 16 | face/data: reduce face/data
|
|---|
| 17 | repeat i length? face/pane [
|
|---|
| 18 | face/pane/:i/data: pick face/data i
|
|---|
| 19 | ]
|
|---|
| 20 | ]
|
|---|
| 21 | ]
|
|---|
| 22 | ]
|
|---|
| 23 | init: make function! [/local off siz pos last-pane] [
|
|---|
| 24 | data: reduce data
|
|---|
| 25 | all [negative? size/y size/y: .5 * sizes/line * length? data]
|
|---|
| 26 | off: either size/y > sizes/line [
|
|---|
| 27 | siz: as-pair size/x sizes/line
|
|---|
| 28 | as-pair 0 sizes/line
|
|---|
| 29 | ][
|
|---|
| 30 | siz: as-pair 2 * size/x / length? data sizes/line
|
|---|
| 31 | as-pair siz/x 0
|
|---|
| 32 | ]
|
|---|
| 33 | pos: 0x0
|
|---|
| 34 | foreach [label state] data [
|
|---|
| 35 | insert tail pane make led [
|
|---|
| 36 | tip: none
|
|---|
| 37 | offset: pos
|
|---|
| 38 | size: siz
|
|---|
| 39 | text: label
|
|---|
| 40 | data: state
|
|---|
| 41 | ]
|
|---|
| 42 | pos: pos + off
|
|---|
| 43 | last-pane: last pane
|
|---|
| 44 | last-pane/init
|
|---|
| 45 | last-pane/init: none
|
|---|
| 46 | ]
|
|---|
| 47 | clear data
|
|---|
| 48 | foreach led pane [insert tail data led/data]
|
|---|
| 49 | ]
|
|---|
| 50 | ] |
|---|