-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add row resizing for tables #50
base: main
Are you sure you want to change the base?
Conversation
Just noticed an oversight in where if the elements inside are updated, or the window size is updated, it won't resize. I'll try to fix this tomorrow likely |
Hi, thanks for this. I'm having a look at the moment From what I've read, and can try to understand, the first code finds all cells on the same row by using the LayoutOrder property. Is there a reason the update code is run once for every column, rather than at the end once all the columns are ready? There seems to be a lot of looping to determine the rows, which includes a lot of nested for loops and I'm sure these could be simplifed down, especially since they rely on Then, every frame, it loops through all the cells and updates the rest of the cells if the height is exceeded. As a far as I can see with this code, you loop through all the cells and update every other cell (for loop in a for loop), rather than checking the maximum height first and then updating them all at once? Is there a reason for this? Also, we are going to do a large table redesign for the next update, since they are fairly limited as you have found and there are many edge cases. From my personal opinion of the best way to do this, I would suggest we change it to be row-based, which automatically fixes these issues, because we can then have greater control over the width of the columns. That's not to say that this isn't a helpful fix, but that it might become obsolete with a total table redesign. Would you be able to explain through the code, just so I have a better understanding of your solution? Many thanks. |
Hey Mallard, I have yet to actually try to improve on a lot of this yet, so thanks for pointing out a lot of these issues with the nested for loops, I never had a reason for a lot of them other than I didn't know the best way to approach it at the time. As for the table redesign that you mentioned, I would agree that a row-based system would be much better in preventing this, especially since from what I've seen, the width of columns is static and doesn't autoscale. I will try to improve on a lot of this when I get home later today and hopefully make the code a lot more clean and easy to understand. I'll explain my solution for it after the improvements as well. |
Ready for review! I've cleaned up the UpdateCellSizes function that is run every frame and moved it out of the for loop where the columns are made. On top of that, I've added some optimizations so the cells are only updated when they need to be, which happens when either a child is added to the table, or the window is resized. I'm not sure if my method for checking if the window has resized is the best approach though as it feels sort of hacky, however I couldn't get the How it works now is as follows:
|
Fixes rows not resizing when at least one column has an element bigger than others inside the same row.