Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
95 user(s) are online (34 user(s) are browsing Forums)

Members: 1
Guests: 94

PixelHi, more...

Support us!

Headlines

 
  Register To Post  

Scroll bars
Quite a regular
Quite a regular


See User information
Hi all,

I am trying to program a scroll bar into Jack, but struggling with the formula I thought this would be straightforward however I am struggling.

The bar either stops short of the bottom or goes too far. ^.^

I thought it would be just a case of dividing the available space by the number of elements shown in scroll area with respect to the size of the bar to get a base adjustment value, but no such luck! :(

Variables:

Vertical scroll bars begins 102 pxs from top edge of window, the maximum size of the bar is 287 px. I have already taken of calculating the size of the bar.

Meaning there 185 pixels of available space, so if for example if there 100 elements in the list that equates to 8.5 pixels per element so thats the base adjustment value. Of course there is no such thing as a half a pixel so I have to round it up (or down?) and this is probably where I am going wrong.

Anyone got a handy formula for this?

Puzzled. :S

Go to top
Re: Scroll bars
Not too shy to talk
Not too shy to talk


See User information
Are you using float variables for dividing up your space? Maybe you've got a float/integer issue here, meaning that fractions of your elements are being forgotten...

185 pixels is fine, 100 elements in your list means though that you should have the scroll bar divided into 1.85 pixels per element, not 8.5. If you round that 1.85, it's a pretty large error indeed. If you do it this way, you should keep everything in floating point format for everything, and only round when it comes to the actual rendering of pixels. That way the error is only a maximum of 1 pixel, which you can account for separately.

Go to top
Re: Scroll bars
Quite a regular
Quite a regular


See User information
Sorry I meant 1.85.

Go to top
Re: Scroll bars
Not too shy to talk
Not too shy to talk


See User information

I really wonder what you are trying to calculate there.

If you have 1000 pieces of whatever in your list, you set PGA_Total to 1000. If your window fits 200 of these pieces, you set PGA_Visible to 200 and if the 500th of these pieces currently is at the top of the window, you set PGA_Top to 500. Everything else is done by the propgadget. You don't need to mess around with pixels.

Go to top
Re: Scroll bars
Quite a regular
Quite a regular


See User information
Jack is written in Hollywood and has no access to gadtools/mui/reaction gadgets so I have take care of gui elements myself.

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project