News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

[gui] multiple selection for gui_scrolled_list_t

Started by THLeaderH, December 05, 2018, 03:11:32 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

THLeaderH

I implemented multiple selection feature for gui_scrolled_list_t. In a scrolled list, multiple entries can be selected like the image below.


Multiple selection can be done with the shift and ctrl keys. As various file explorers do so, shift key provides continuous selection and ctrl key provides discrete selection.

One of the applications of this feature is the regional construction tool of city buildings. This tweet provides a demo video. Multi-kinds of city buildings can be chosen in the dialogue, and building is randomly chosen for each tile from the chosen building list. This feature is going to be distributed as a new feature of OTRP in a few days.

Multiple selection is disabled by default. Multiple selection feature is enabled by calling the enable_multiple_selection() function. When multiple selection is enabled, selection is handled with vector_tpl variables.

Although it is prohibited by the simutrans coding guideline, type int is used in this patch. This is because type int is frequently used in gui_scrolled_list_t. The parameter type of show_selection and set_selection is already int, not sint32 or uint32, so I set the parameter type of add_selection and other functions int. I thought that replacing all int types by sint32 or uint32 made the diff larger meaninglessly. If it is necessary to replace all int to sint32 or something, please let me know and I'll do so.

Thank you for having an interest in this topic and your responses in advance.

prissi

Ok, I have somehow overlooked this. Is there a patch for this?

Dwachs

I doubt it would work now. I reworked scrolled-list to rely for selection of items on the focus-logic of gui elements.
Parsley, sage, rosemary, and maggikraut.

THLeaderH

The patch is currently unavailable but I already re-implemented this feature for OTRP after the automatic gui patch was applied for the nightly trunk. I'll post the patch in a few days.

THLeaderH

I attached a patch that enables you to select multiple entries in scrolled lists. Multiple selection is disabled by default. To use multiple selection, please call gui_scrolled_list_t::enable_multiple_selection(). Multiple selection can by done with the control and shift keys.

prissi

incorporated with a tiny addition to only transverse the list if there is a focus in r8742