Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Dynamic scroller step adjustment

 [1/4] from: gerardcote::sympatico::ca at: 25-Feb-2004 11:05


Hello list, Can somebody help me to find how to dynamically adjust the horizontal and vertical steps (here xs and ys) of scrollers (or sliders) so they fit themselves with the real length contents of the area (i.e. a function of the real number of lines and number of columns contained inside the area to be scrolled - or even some number of pixels but since we can have proportional fonts here this will require additional calculations). As you'll find when trying the following demo, when the number of lines is small, may be 10 lines or so, the -1 part of the ys vertical scroll seems to work fine since I can display all the data but when the number of lines goes up to 100 or so lines, then I have to change the value -1 to -15 to let the user see all the data enclosed and then generally when the end of data is crossed the scroller doesn't really indicate visually that there is no more data to come since the bar is not placed at the end either.. So is there any mean to keep this value dynamically dependant of the real contents of the area or not ? and if yes how to proceed ? I suppose I should go and work within the System/view object to adapt the scroll step after the content of the area is known but where and how do I do this if necessary ? ... Here is the small script I use to experiment scroll bars: win: layout [ across a: area 300x100 edge [ size: 2x2 ] para [ scroll: 0x0 ] s: scroller 15x100 [ ys: -1 * (to-integer (s/data * 100)) a/para/scroll: make pair! reduce [ 0 ys ] show a ] return s2: scroller 300x15 [ xs: -1 * (to-integer (s2/data * 100)) a/para/scroll: make pair! reduce [ xs 0 ] show a ] ] ys:0 a/text: copy {} for Ligne 1 100 1 [ append a/text reduce ["Ligne " Ligne " : "] for Col 1 20 1 [ append a/text reduce [ Col " "] ] append a/text reduce [ "^/" ] ] view win Thanks for any cue, Gerard

 [2/4] from: brett:codeconscious at: 26-Feb-2004 20:37


Hi Gerard, Try the Scroll-para function. I've changed your code to use it. By the way, in an action block, the Face variable refers to the face of the action. win: layout [ across a: area 300x100 edge [ size: 2x2 ] para [ scroll: 0x0 ] s: scroller 15x100 [scroll-para a face] return s2: scroller 300x15 [scroll-para a face] ] a/text: copy {} for Ligne 1 10 1 [ append a/text reduce ["Ligne " Ligne " : "] for Col 1 20 1 [ append a/text reduce [Col " "] ] append a/text reduce ["^/"] ] view win Regards, Brett.

 [3/4] from: antonr:iinet:au at: 27-Feb-2004 0:18


ratio is your friend. For example, to set ratio of a vertical scroller vscroll: vscroll/ratio: visible / total-height and here's a cutting, showing how to set the step: ; step = 1 / (total rows - visible rows) use [y][ y: max 0 ((length? list-data) - rows) vscroll/step: either 0 = y [1][1 / y] ; prevent division by zero ] Anton.

 [4/4] from: gerardcote:sympatico:ca at: 29-Feb-2004 14:34


Hi Anton and Brett, Thanks for your respective reply. Both suggested ways will be useful since I now have something near the original answer I was waiting for and in the same time I also have a neat solution that works easily as is. For now I'll study the first but also use the second until I get the first one working too. Hope this will be available to work on older REBOL versions too but for now I'm using View 1.2.8 and 1.2.24 so it really doesn't matter to me if 'scroll-para doesn't work on older ones. Looking at its source it is somewhat different from the Anton's suggestion but nevertheless I will try to study and understand both. Regards, Gerard