Add option for gui::dialog::set_menu_items() to (try to) preserve...
...the selected line.
This commit is contained in:
parent
887b552b1b
commit
3eec1b69a7
2 changed files with 8 additions and 4 deletions
|
@ -241,13 +241,17 @@ void dialog::set_menu(const std::vector<std::string> &menu_items, menu::sorter*
|
|||
-1, dialog::max_menu_width, sorter, &menu::default_style, false));
|
||||
}
|
||||
|
||||
void dialog::set_menu_items(const std::vector<std::string> &menu_items)
|
||||
/**
|
||||
* Changes (or sets, if not previously set) the dialog's menu items to the
|
||||
* provided list. If @a keep_selected is true, the selection will remain at
|
||||
* the same index if possible (otherwise it gets reset to zero).
|
||||
*/
|
||||
void dialog::set_menu_items(const std::vector<std::string> &menu_items, bool keep_selection)
|
||||
{
|
||||
if(menu_ == empty_menu) {
|
||||
set_menu(menu_items);
|
||||
} else {
|
||||
menu_->set_items(menu_items);
|
||||
menu_->reset_selection();
|
||||
menu_->set_items(menu_items, true, keep_selection);
|
||||
|
||||
for(pp_iterator i = preview_panes_.begin(); i != preview_panes_.end(); ++i) {
|
||||
(**i).set_selection(menu_->selection());
|
||||
|
|
|
@ -239,7 +239,7 @@ public:
|
|||
void set_image(surface surf, const std::string &caption="");
|
||||
void set_menu(menu *const m) { if(menu_ != empty_menu) delete menu_; menu_ = m; }
|
||||
void set_menu(const std::vector<std::string> & menu_items, menu::sorter* sorter=NULL);
|
||||
void set_menu_items(const std::vector<std::string> &menu_items);
|
||||
void set_menu_items(const std::vector<std::string> &menu_items, bool keep_selection=false);
|
||||
|
||||
//add_pane - preview panes are not currently memory managed
|
||||
//(for backwards compatibility)
|
||||
|
|
Loading…
Add table
Reference in a new issue