StefanAlmighty Posted June 10, 2016 Share Posted June 10, 2016 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) 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
Anubhav Posted June 10, 2016 Share Posted June 10, 2016 Dealman told (I am lazy to find that post) that there is a way. dxCreateRenderTarget something like that, and then dxSetRenderTarget and set the clear to true and it will destroy everything else not in render target. Link to comment
StefanAlmighty Posted June 10, 2016 Author Share Posted June 10, 2016 Hmm, so I render it all even if it goes out of the gridlist and then set a render target? I've been reading the wiki about those two functions but not sure how they work exactly. Link to comment
Anubhav Posted June 10, 2016 Share Posted June 10, 2016 Hmm, so I render it all even if it goes out of the gridlist and then set a render target? I've been reading the wiki about those two functions but not sure how they work exactly. I'm not sure either. Contact Dealman. Link to comment
StefanAlmighty Posted June 10, 2016 Author Share Posted June 10, 2016 I've scripted it so if there are too many rows to fit, it draws the scrollbar: The scroll bar does not move yet, working on that now. If anybody knows how I'll make the rows render based on the scrollbars position then I'll be grateful. Link to comment
StefanAlmighty Posted June 10, 2016 Author Share Posted June 10, 2016 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. 1 Link to comment
ViRuZGamiing Posted June 10, 2016 Share Posted June 10, 2016 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
StefanAlmighty Posted June 10, 2016 Author Share Posted June 10, 2016 The values loaded into the grid is loaded from a table called 'rows'. Each value for each column is stored in the table eg there is 4 columns as shown in the image. Row one would be {"1", "Apple", "United States", "Yes"}. A drawing would help since it's pretty complex. Link to comment
StefanAlmighty Posted June 10, 2016 Author Share Posted June 10, 2016 Okay I've made the scrollbar but how do I make the overflowing rows only appear when you scroll? Link to comment
ViRuZGamiing Posted June 11, 2016 Share Posted June 11, 2016 Full size: http://pic.xtream-reallife.de/images/2016/06/11/explained.jpg This is what I ment Link to comment
StefanAlmighty Posted June 11, 2016 Author Share Posted June 11, 2016 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: 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
StefanAlmighty Posted June 11, 2016 Author Share Posted June 11, 2016 Finally after around 4 hours of experimenting I managed to make it work. Scrolls perfectly. Thanks VirusGaming. Link to comment
Tails Posted September 22, 2016 Share Posted September 22, 2016 This thread is so useless. StefanAlmighty, might explaining what you did to fix this? I'm currently facing the same issue. I'll probably figure it out soon but it would have been nice if you had written down what you did to fix the problem. Link to comment
Dealman Posted September 22, 2016 Share Posted September 22, 2016 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. 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now