The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: THLeaderH on December 05, 2018, 03:11:32 PM

Title: [gui] multiple selection for gui_scrolled_list_t
Post by: THLeaderH on December 05, 2018, 03:11:32 PM
I implemented multiple selection feature for gui_scrolled_list_t. In a scrolled list, multiple entries can be selected like the image below.
(https://simutrans-germany.com/files/upload/%E3%82%BF%E3%82%99%E3%82%A6%E3%83%B3%E3%83%AD%E3%83%BC%E3%83%88%E3%82%99.gif)

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 (https://twitter.com/himeshi_hob/status/1070265063913603074) 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 (https://github.com/teamhimeh/simutrans/blob/OTRP-distribute/documentation/OTRP_information_en.md) 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.
Title: Re: [gui] multiple selection for gui_scrolled_list_t
Post by: prissi on March 21, 2019, 02:18:06 AM
Ok, I have somehow overlooked this. Is there a patch for this?
Title: Re: [gui] multiple selection for gui_scrolled_list_t
Post by: Dwachs on March 21, 2019, 07:14:29 AM
I doubt it would work now. I reworked scrolled-list to rely for selection of items on the focus-logic of gui elements.
Title: Re: [gui] multiple selection for gui_scrolled_list_t
Post by: THLeaderH on March 21, 2019, 01:59:48 PM
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.
Title: Re: [gui] multiple selection for gui_scrolled_list_t
Post by: THLeaderH on March 23, 2019, 09:00:47 AM
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.
Title: Re: [gui] multiple selection for gui_scrolled_list_t
Post by: prissi on March 30, 2019, 07:19:46 AM
incorporated with a tiny addition to only transverse the list if there is a focus in r8742