The International Simutrans Forum


Author Topic: [gui] multiple selection for gui_scrolled_list_t  (Read 185 times)

0 Members and 1 Guest are viewing this topic.

Offline THLeaderH jp

  • Coder/patcher
  • Devotee
  • *
  • Posts: 274
  • Languages: JP,EN
[gui] multiple selection for gui_scrolled_list_t
« 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.

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.
« Last Edit: December 10, 2018, 10:35:59 AM by THLeaderH »