Changeset 112 for widgets/slider.r
- Timestamp:
- 12/31/07 22:18:08 (11 months ago)
- Files:
-
- 1 modified
-
widgets/slider.r (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
widgets/slider.r
r111 r112 12 12 'arrows adds an arrow to each end of the slider creating a scroller 13 13 'together forces the arrows to appear together 14 [ratio n] where n has the same value as face/data above butindicates the initial dragger size14 [ratio n] where n indicates the initial dragger size 15 15 } 16 16 size: 5x50 17 17 data: 0 18 color: colors/ window18 color: colors/outline-light 19 19 effect: [ 20 20 draw [ 21 pen colors/ edge fill-pen colors/btn-upbox 0x0 10x10 ; dragger21 pen colors/outline-dark fill-pen colors/theme-light box 0x0 10x10 ; dragger 22 22 ; arrow buttons 23 fill-pen colors/btn-up box 0x0 0x0 24 fill-pen colors/btn-up box 0x0 0x0 25 fill-pen black triangle 0x0 0x0 0x0 26 fill-pen black triangle 0x0 0x0 0x0 23 fill-pen colors/theme-light box 0x0 0x0 24 fill-pen colors/theme-light box 0x0 0x0 25 pen colors/page 26 fill-pen colors/page triangle 0x0 0x0 0x0 27 fill-pen colors/page triangle 0x0 0x0 0x0 27 28 ] 28 29 ] … … 33 34 state: none 34 35 flags: none 36 37 set-data: make function! [new [integer! decimal! pair!] /local old][ 38 old: data 39 data: min 1 max 0 either pair? new [ 40 data + either negative? new/y [negate step] [step] 41 ] [new] 42 all [data <> old show self] ; (face/action is done in redraw) 43 ] 35 44 36 45 feel: make default-feel [ … … 69 78 arrow-blk/10: arrow-blk/9 + arrow-size 70 79 71 arrow-blk/1 4: arrow-blk/4 + (width * 0.1 * either axis = 'y [5x2][2x5])72 arrow-blk/1 5: arrow-blk/4 + (width * 0.1 * either axis = 'y [2x7][7x8])73 arrow-blk/1 6: arrow-blk/4 + (width * 0.1 * either axis = 'y [8x7][7x2])74 75 arrow-blk/2 0: arrow-blk/9 + (width * 0.1 * either axis = 'y [5x8][8x5])76 arrow-blk/2 1: arrow-blk/9 + (width * 0.1 * either axis = 'y [8x3][3x2])77 arrow-blk/2 2: arrow-blk/9 + (width * 0.1 * either axis = 'y [2x3][3x8])80 arrow-blk/16: arrow-blk/4 + (width * 0.1 * either axis = 'y [5x2][2x5]) 81 arrow-blk/17: arrow-blk/4 + (width * 0.1 * either axis = 'y [2x7][7x8]) 82 arrow-blk/18: arrow-blk/4 + (width * 0.1 * either axis = 'y [8x7][7x2]) 83 84 arrow-blk/22: arrow-blk/9 + (width * 0.1 * either axis = 'y [5x8][8x5]) 85 arrow-blk/23: arrow-blk/9 + (width * 0.1 * either axis = 'y [8x3][3x2]) 86 arrow-blk/24: arrow-blk/9 + (width * 0.1 * either axis = 'y [2x3][3x8]) 78 87 ][ 79 repeat pos [4 5 9 10 1 4 15 16 20 21 22][arrow-blk/:pos: 0x0]88 repeat pos [4 5 9 10 16 17 18 22 23 24][arrow-blk/:pos: 0x0] 80 89 ] 81 90 … … 96 105 ] 97 106 ] 98 ]99 ]100 set-data: make function! [face [object!] data [number!] /local old][101 old: face/data102 face/data: min 1 max 0 data103 if face/data <> old [104 show face ; (face/action is done in redraw)105 107 ] 106 108 ] … … 136 138 freedom > 0 137 139 ][ 138 set-data face(offset - face/hold / (dragdom * freedom))140 face/set-data (offset - face/hold / (dragdom * freedom)) 139 141 ] 140 142 exit … … 149 151 ; clicked on dragger 150 152 face/hold: offset - (dragdom * (freedom * face/data)) 151 face/effect/draw/4: colors/ btn-downshow face153 face/effect/draw/4: colors/state-light show face 152 154 ] 153 155 ][ … … 158 160 if act = 'down [ 159 161 face/hold: 'top-arrow 160 face/effect/draw/9: colors/ btn-downshow face162 face/effect/draw/9: colors/state-light show face 161 163 ] 162 164 if face/hold = 'top-arrow [ 163 set-data face(face/data - face/step)165 face/set-data (face/data - face/step) 164 166 ] 165 167 ] … … 169 171 if act = 'down [ 170 172 face/hold: 'top-arrow 171 face/effect/draw/9: colors/ btn-downshow face173 face/effect/draw/9: colors/state-light show face 172 174 ] 173 175 if face/hold = 'top-arrow [ 174 set-data face(face/data - face/step)176 face/set-data (face/data - face/step) 175 177 ] 176 178 ] … … 180 182 if act = 'down [ 181 183 face/hold: 'bottom-arrow 182 face/effect/draw/14: colors/ btn-downshow face184 face/effect/draw/14: colors/state-light show face 183 185 ] 184 186 if face/hold = 'bottom-arrow [ 185 set-data face(face/data + face/step)187 face/set-data (face/data + face/step) 186 188 ] 187 189 ] … … 192 194 if face/hold = 'page [ 193 195 page: any [all [freedom = 0 0] face/ratio / freedom] 194 set-data face (face/data + either more? [page][-page])196 face/set-data (face/data + either more? [page] [negate page]) 195 197 ] 196 198 ] … … 200 202 if act = 'up [ 201 203 face/rate: none face/hold: none 202 face/effect/draw/4: face/effect/draw/9: face/effect/draw/14: colors/ btn-upshow face204 face/effect/draw/4: face/effect/draw/9: face/effect/draw/14: colors/theme-light show face 203 205 ] 204 206 ] 205 207 ] 206 ; action: make default-action [ 207 ; on-click: make function! [face] [system/view/focal-face: face] 208 ; on-scroll: make function! [face scroll /page] [ 209 ; either page [ 210 ; all [ 211 ; face/size/x > face/size/y 212 ; set-data face face/data + either negative? scroll/y [negate face/step] [face/step] 213 ; ] 214 ; ][ 215 ; all [ 216 ; face/size/y > face/size/x 217 ; set-data face face/data + either negative? scroll/y [negate face/step] [face/step] 218 ; ] 219 ; ] 220 ; ] 221 ; ] 222 rebind: make function! [] [color: colors/window] 208 rebind: make function! [] [color: colors/outline-light] 223 209 init: make function! [] [ 224 210 all [number? data data: min 1 max 0 data]
