GUI2/Listbox: added select_last_row wrapper
This commit is contained in:
parent
a986ca1fc2
commit
7bb4977cee
6 changed files with 15 additions and 6 deletions
|
@ -143,7 +143,7 @@ void campaign_difficulty::pre_show(window& window)
|
|||
grid& grid = list.add_row(data);
|
||||
|
||||
if(d["default"].to_bool(false)) {
|
||||
list.select_row(list.get_item_count() - 1);
|
||||
list.select_last_row();
|
||||
}
|
||||
|
||||
widget* widget = grid.find("victory", false);
|
||||
|
|
|
@ -123,7 +123,7 @@ void editor_generate_map::pre_show(window& window)
|
|||
list.add_row(lrow);
|
||||
|
||||
if(gen.get() == last_map_generator_) {
|
||||
list.select_row(list.get_item_count() - 1);
|
||||
list.select_last_row();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -540,7 +540,6 @@ void file_dialog::push_fileview_row(listbox& filelist, const std::string& name,
|
|||
data["file"]["label"] = label;
|
||||
|
||||
grid& last_grid = filelist.add_row(data);
|
||||
const unsigned last_pos = filelist.get_item_count() - 1;
|
||||
|
||||
//
|
||||
// Crummy hack around the lack of an option to hook into row double click
|
||||
|
@ -551,7 +550,7 @@ void file_dialog::push_fileview_row(listbox& filelist, const std::string& name,
|
|||
.set_retval(FILE_DIALOG_ITEM_RETVAL);
|
||||
|
||||
if(check_selection && name == current_entry_) {
|
||||
filelist.select_row(last_pos, true);
|
||||
filelist.select_last_row(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ void language_selection::pre_show(window& window)
|
|||
|
||||
list.add_row(data);
|
||||
if(lang == current_language) {
|
||||
list.select_row(list.get_item_count() - 1);
|
||||
list.select_last_row();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ void unit_create::pre_show(window& window)
|
|||
|
||||
// Select the previous choice, if any.
|
||||
if(choice_.empty() != true && choice_ == i.first) {
|
||||
list.select_row(list.get_item_count() - 1);
|
||||
list.select_last_row();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -186,6 +186,16 @@ public:
|
|||
*/
|
||||
bool select_row(const unsigned row, const bool select = true);
|
||||
|
||||
/**
|
||||
* Does exactly as advertised: selects the list's last row.
|
||||
*
|
||||
* @param select Select or deselect the row.
|
||||
*/
|
||||
bool select_last_row(const bool select = true)
|
||||
{
|
||||
return select_row(get_item_count() - 1, select);
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects a row at the given position, regardless of sorting order.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue