-
Notifications
You must be signed in to change notification settings - Fork 386
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
ButtonGroup and TabBar: support for tiled layouts #1732
Comments
If |
I didn't realize it uses FlowLayout in that situation. In this case I'm looking for an easy way to control the exact number of buttons per row and column. We have a layout that requires a set of four buttons to be arranged in a 2x2 grid. Only one button can be selected at a time, so I'm using a TabBar. The layout of other elements on the screen depends on the width of the TabBar, so we want the width of the TabBar to be calculated from having two columns, rather than setting an explicit width and letting it wrap buttons into a second row. Obviously there are other ways to duplicate this behavior (e.g. adding four toggle buttons to a LayoutGroup, giving the LayoutGroup a TiledRowsLayout, and adding the buttons to a ToggleGroup, but that requires a lot of extra boilerplate that isn't necessary when using a TabBar. Is there a reason that ButtonGroup and TabBar have the |
It's been years since I first implemented these components. I guess I didn't consider custom layouts important at the time. The vast majority of tab bars in UI are vertical or horizontal in one row, so that's how I originally designed the component. Occasionally, I would receive a request for multiple rows, but it wasn't common. Luckily, I figured out how to implement it without making breaking changes. If supporting multiple rows would have broken something, I probably wouldn't have added it. Another option that you might consider is to use a List with item renderers styled to look like tabs/buttons. It has selection built in, so it shouldn't be too much different than using a TabBar. A List seems like your best option, if you want to avoid the LayoutGroup/ToggleGroup way of doing it. |
I'm not sure if there's a specific reason that
ButtonGroup
andTabBar
currently only support horizontal and vertical layouts, but it would be nice for them to support tiled layouts as well. Currently this has to be done by overriding the layout functions in child classes.The text was updated successfully, but these errors were encountered: