Changeset 112 for widgets/slider.r

Show
Ignore:
Timestamp:
12/31/07 22:18:08 (11 months ago)
Author:
ashley
Message:

Added pill.r
Scroller fixes
Major color / theme management changes (in progress)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • widgets/slider.r

    r111 r112  
    1212                        'arrows adds an arrow to each end of the slider creating a scroller 
    1313                        'together forces the arrows to appear together 
    14                         [ratio n] where n has the same value as face/data above but indicates the initial dragger size 
     14                        [ratio n] where n indicates the initial dragger size 
    1515        } 
    1616        size:   5x50 
    1717        data:   0 
    18         color:  colors/window 
     18        color:  colors/outline-light 
    1919        effect: [ 
    2020                draw [ 
    21                         pen colors/edge fill-pen colors/btn-up box 0x0 10x10 ; dragger 
     21                        pen colors/outline-dark fill-pen colors/theme-light box 0x0 10x10 ; dragger 
    2222                        ; 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 
    2728                ] 
    2829        ] 
     
    3334        state:  none 
    3435        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        ] 
    3544 
    3645        feel:   make default-feel [ 
     
    6978                                                arrow-blk/10: arrow-blk/9 + arrow-size 
    7079 
    71                                                 arrow-blk/14: arrow-blk/4 + (width * 0.1 * either axis = 'y [5x2][2x5]) 
    72                                                 arrow-blk/15: arrow-blk/4 + (width * 0.1 * either axis = 'y [2x7][7x8]) 
    73                                                 arrow-blk/16: arrow-blk/4 + (width * 0.1 * either axis = 'y [8x7][7x2]) 
    74  
    75                                                 arrow-blk/20: arrow-blk/9 + (width * 0.1 * either axis = 'y [5x8][8x5]) 
    76                                                 arrow-blk/21: arrow-blk/9 + (width * 0.1 * either axis = 'y [8x3][3x2]) 
    77                                                 arrow-blk/22: 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]) 
    7887                                        ][ 
    79                                                 repeat pos [4 5 9 10 14 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] 
    8089                                        ] 
    8190 
     
    96105                                        ] 
    97106                                ] 
    98                         ] 
    99                 ] 
    100                 set-data: make function! [face [object!] data [number!] /local old][ 
    101                         old: face/data 
    102                         face/data: min 1 max 0 data 
    103                         if face/data <> old [ 
    104                                 show face ; (face/action is done in redraw) 
    105107                        ] 
    106108                ] 
     
    136138                                        freedom > 0  
    137139                                ][ 
    138                                         set-data face (offset - face/hold / (dragdom * freedom)) 
     140                                        face/set-data (offset - face/hold / (dragdom * freedom)) 
    139141                                ] 
    140142                                exit 
     
    149151                                                ; clicked on dragger 
    150152                                                face/hold: offset - (dragdom * (freedom * face/data)) 
    151                                                 face/effect/draw/4: colors/btn-down show face 
     153                                                face/effect/draw/4: colors/state-light show face 
    152154                                        ] 
    153155                                ][ 
     
    158160                                                        if act = 'down [ 
    159161                                                                face/hold: 'top-arrow 
    160                                                                 face/effect/draw/9: colors/btn-down show face 
     162                                                                face/effect/draw/9: colors/state-light show face 
    161163                                                        ] 
    162164                                                        if face/hold = 'top-arrow [ 
    163                                                                 set-data face (face/data - face/step) 
     165                                                                face/set-data (face/data - face/step) 
    164166                                                        ] 
    165167                                                ] 
     
    169171                                                        if act = 'down [ 
    170172                                                                face/hold: 'top-arrow 
    171                                                                 face/effect/draw/9: colors/btn-down show face 
     173                                                                face/effect/draw/9: colors/state-light show face 
    172174                                                        ] 
    173175                                                        if face/hold = 'top-arrow [ 
    174                                                                 set-data face (face/data - face/step) 
     176                                                                face/set-data (face/data - face/step) 
    175177                                                        ] 
    176178                                                ] 
     
    180182                                                        if act = 'down [ 
    181183                                                                face/hold: 'bottom-arrow 
    182                                                                 face/effect/draw/14: colors/btn-down show face 
     184                                                                face/effect/draw/14: colors/state-light show face 
    183185                                                        ] 
    184186                                                        if face/hold = 'bottom-arrow [ 
    185                                                                 set-data face (face/data + face/step) 
     187                                                                face/set-data (face/data + face/step) 
    186188                                                        ] 
    187189                                                ] 
     
    192194                                                        if face/hold = 'page [ 
    193195                                                                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]) 
    195197                                                        ] 
    196198                                                ] 
     
    200202                        if act = 'up [ 
    201203                                face/rate: none face/hold: none  
    202                                 face/effect/draw/4: face/effect/draw/9: face/effect/draw/14: colors/btn-up show face 
     204                                face/effect/draw/4: face/effect/draw/9: face/effect/draw/14: colors/theme-light show face 
    203205                        ] 
    204206                ] 
    205207        ] 
    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] 
    223209        init:   make function! [] [ 
    224210                all [number? data data: min 1 max 0 data]