Jump to content

Scroll Bars


Recommended Posts

Okay so I'm making my own dx GUI system and I'm working on grid lists, an example:

(So far I have windows, tab panels, edit fields, buttons and grid lists)

c36e5be1d0510803f932136a8cdd013b.png

So far you can: 'dxGridListAddColumn' , 'dxGridListAddRow' and 'dxGridListGetSelectedItemText', 'dxGridListSetColumnColour', 'dxGridListSetItemColour'. All work.

Now I'm at the point where if there are too many rows to fit on the gridlist, I want it to make a scrollbar and scroll down.

I need some tips as I'm not sure where to start (I know how to draw a scrollbar), but I don't know how to make it move when you drag it etc. I assume it's onClientClick.

Also I have no idea how to make it render the different items as you scroll down.

Link to comment

I'm working on the scrollbar but I'm having issues.

As the player holds down their mouse, I'm trying to make the scrollbar follow the cursors Y coordinate. I use this to get the absolute position of the cursor's Y:

  
local cX, cY, wX, wY, wZ = getCursorPosition() 
local w, h = guiGetScreenSize() 
  
local absoluteY = cX * h 
  

I then set the scrollbars Y to absoluteY but it bugs out, no errors or anything. It goes slightly below the dxWindow and remains there, even when I try to click/drag it.

Fixed that ^, for future reference absoluteY was supposed to be cY * h not cX.

  • Like 1
Link to comment

Speaking purely theoretical, wouldn't you be able to attach a value to the scrollbar's upper position, 0.

Then if you scroll you increase the value by 1 for example every 10px down (just an example).

Then for the display get the items in the array to be displayed from index scrollbar value till scrollbar value + 10.

I hope you understand what I'm trying to say and I don't know if it'll make sense.

If not, I'll make a drawing supporting my point of view.

Link to comment

Does that make it so it only scrolls down based on how many rows there are? I don't want it so you can scroll down as much as you'd like, only based on how many rows there are.

So far I've made it cut off when the rows reach the bottom of the gridlist:

93912c3d0a9bd49cca2064b7c3f3d2ce.png

What I intend on doing is dividing the extra rows by 100 (gives me how much the scrollbar should go down each time). The scrollbar has an invisible GUI which is how it works, so would making it work with onClientGUIScroll be effective?

Link to comment
  • 3 months later...

Hey now, I wouldn't say it's useless. There's a few ways of dealing with this, one is to use a render target and one is to use tables.

Just think about it logically, you most likely have a table containing the items that should be rendered - right? When you scroll down, you'll want to remove the top-most item which is most likely gonna be the first item in your table.

So, you store those removed items in a 2nd table in case the user decides to scroll back up. It's all a matter of playing around with offsets and whatnot.

Though I believe using a render target would allow for the smoothest transition, it all depends on how you want to approach it.

  • Like 1
Link to comment
  • 4 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...