Ellpeck/MLEM

Allow dropdowns to have scrollable panels

Monniasza opened this issue · 17 comments

Hi. I'm using MLEM in my upcoming remake of MultiMachineBuilder.
I'll want to make an inventory list, but there are no list controls.
Please add a scrollable list with customizable rendering and model types

Hi, what you're looking for is a Panel. You can optionally allow it to scroll and add elements to it as you wish.

For more info on basic components, I recommend checking out the UI demo's code!

Maybe dropdowns are better for this?

What do you mean?

MLEM.Ui also has the Dropdown component which displays a Panel when opened as well. There's currently no built-in way to make that panel able to scroll (other than adding a second panel with a null Texture into it), but if you want that feature added, I can definitely do so!

I'd like to have scrollable dropdowns. They can be then turned into scrollable lists

I've got this in the dropdown. The names of the blocks are single column
image

You likely didn't set their width high enough. If you set their width to 1, they'll automatically have the same size as the panel's content. I recommend checking out the demo project linked above, as well as the introductory documentation on sizing.

I've fixed then and they look great
image

And now the list panel works correctly
image

I'll trash the old, broken scrollable list

How can I implement a list with selectable items?

Hi, what do you mean by a list?

As I said at the top, a Panel supports the ability to have a scroll bar in it. Any element type can be made selectable by setting its CanBeSelected to true, and if you want an element to react to clicks and gamepad/touch interactions, you can subscribe to its OnPressed or OnSecondaryPressed events.

If you want to use the new feature that allows dropdowns to contain scrollabel content, you can install the latest development version of MLEM.Ui from https://nuget.ellpeck.de/ and update your Dropdown's constructor accordingly.

Have you checked out the UI demo yet? It contains a lot of examples of simple & complex UI setups, including dropdowns, scrollable lists, and even nested scrollable lists.

How do I select elements?

If an element has CanBeSelected set to true, gamepad navigation and keyboard navigation (controls for both of which can be found and changed in UiControls) allow for the element to be selected.

When using mouse or touch controls, the most recently clicked element also counts as selected, but a selection indicator is not displayed there by default. You can change that behavior by subscribing to (or overwriting) the UiSystem.OnSelectedElementDrawn event.

If you want to set an element to be selected programmatically, you can do so using your ui system's UiControls' SelectElement method, or the element's Root's SelectElement method.

I've implemented lists for my game, and the work well, but no mutiple selection is supported.
Could I submit code for them so they gen integrated into MLEM?

As I said numerous times, various types of lists are already supported by MLEM. There are currently no plans to add further default elements, as the existing elements cover a broad range of use cases.

Please explain what you mean by "lists".

My implementation is a list which generates and manages elements as needed using a listenable list

Ah! I don't think an implementation like that is currently required as part of the MLEM.Ui package, since it is rather easy to implement and often depends on the way the developer intends for the list to work. Thanks though!