Small Scroll Bar Example

BlitzMax Forums/BlitzMax Programming/Small Scroll Bar Example

Rimmsy(Posted 2006) [#1]
Hi guys, first off: I've tried the new search feature but it's not really helping much. Second, I've had a look in the toolbox but all the GUI examples are too complicated to understand. They're all built together and have dependencies and such.

What I'm looking for is a small example of a scroll bar. It's the maths I'm getting stuck on. I want to be able to click on the middle slider button, hold down and affect the value. I can draw it fine, it's just the maths of what that vertical y position translates to in value terms.

Has anyone got a very simple example of this as some standalone code? Or maybe some tips on the actual maths of it all.

Any help appreciated,
Matt


tonyg(Posted 2006) [#2]
Are you using MaxGUI? If so have you seen this ?
If this is your own code then the trick is to have the slider act from 1-100 (e.g. a percentage) and do the same with whatever it is you're scrolling.
e.g. imagewidth= 256 then each pixel is 2.56% which you map onto your scrollbar (unless I have misunderstood).


Rimmsy(Posted 2006) [#3]
I have MaxGUI but want to program my own for a full screen game. Ahhh!!!! I'm trying to visualise the code but I can't. It's really frustrating when this happens.
local data_height = 500 
local scrollbar_height = 120
local value# = 25.0 ' %
local scroll_value#=(data_height/100.0) * value
' = (500.0/100.0) * 25 = 125
' So...
local scrollButtonY = ... not sure

So, when I'm at 25% scroll the data will be scrolled by 125 pixels. Riiiiight. I'm with it. So how do I translate this into a scroll button like the ones you hold down and move up and down?


Rimmsy(Posted 2006) [#4]
Anyone got any code they'd care to share, please?

Cheers!
Matt


Diablo(Posted 2006) [#5]
Not complety sure what your asking for but heres somting:


Use the up/down arrow keys to 'scroll'. of course it dosent draw the scroll bar correctly but its late and i'll let you try and fix that, or some one else as the case may be.

Play around with it and let us know what you come up with.

also you could check out my gui lib (highgui, link in sig below) for how i did the scroll bars in that.


Rimmsy(Posted 2006) [#6]
Ahhhhhhhhhhhhhhhhhhhhh!!! Help me! I'm slowly going mad. I'm trying to sort out line 35-ish. How do you translate the mouseY() into the value? Ahhh!! Banana crayon! I'm going insane!




REDi(Posted 2006) [#7]



Diablo(Posted 2006) [#8]
he, now i see what he was asking for. :(

Thats a nice scrolly papa.


Rimmsy(Posted 2006) [#9]
Dudes, you both rock. Thank you so much for your help. I see the maths now. Very nice work both of you.

Matt


Diablo(Posted 2006) [#10]
I think papa rocks more.

Btw If you want some 'framework' to base your in-game gui code then check out my
GUI Base Code/GUI Base Code :p

Here Is a Example & full source of how to use it.


Rimmsy(Posted 2006) [#11]
Wow. Sweet resource Diablo. I'll certainly check that out. Thanks for sharing.

Matt