26 #include <boost/dynamic_bitset.hpp>
33 class selectable_item;
36 struct builder_listbox_base;
95 void remove_row(
const unsigned row,
unsigned count = 1);
140 std::size_t
filter_rows_by(
const std::function<
bool(std::size_t)>& filter);
179 bool select_row(
const unsigned row,
const bool select =
true);
207 bool select_row_at(
const unsigned row,
const bool select =
true);
258 static bool less(
const T& lhs,
const T& rhs) {
return lhs < rhs; }
264 static bool more(
const T& lhs,
const T& rhs) {
return lhs > rhs; }
274 template<std::size_t... Is,
typename... Args>
287 template<
typename Func>
305 template<
typename... Args>
308 set_sorters_impl(std::index_sequence_for<Args...>{}, std::forward<Args>(functors)...);
387 std::vector<std::pair<selectable_item*, generator_sort_array>>
orders_;
409 const int height_modification,
410 const int width_modification_pos = -1,
411 const int height_modification_pos = -1);
430 static const std::string&
type();
464 virtual std::unique_ptr<widget>
build()
const override;
A config object defines a single node in a WML file, with access to child nodes.
Abstract base class for the generator.
std::function< bool(unsigned, unsigned)> order_func
placement
Determines how the items are placed.
void update_layout()
Updates internal layout.
void list_item_clicked(widget &caller)
Function to call after the user clicked on a row.
void mark_as_unsorted()
Deactivates all sorting toggle buttons at the top, making the list look like it's not sorted.
void set_sorters_impl(std::index_sequence< Is... >, Args &&... fs)
Implementation detail of set_sorters.
virtual point calculate_best_size() const override
See widget::calculate_best_size.
bool select_last_row(const bool select=true)
Does exactly as advertised: selects the list's last row.
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
void handle_key_right_arrow(SDL_Keymod modifier, bool &handled) override
Inherited from scrollbar_container.
void set_row_active(const unsigned row, const bool active)
Makes a row active or inactive.
std::vector< std::pair< selectable_item *, generator_sort_array > > orders_
void set_row_shown(const unsigned row, const bool shown)
Makes a row visible or invisible.
void handle_key_left_arrow(SDL_Keymod modifier, bool &handled) override
Inherited from scrollbar_container.
void order_by_column(unsigned column, widget &widget)
void resize_content(const int width_modification, const int height_modification, const int width_modification_pos=-1, const int height_modification_pos=-1)
Resizes the content.
void order_by(const generator_base::order_func &func)
virtual void set_self_active(const bool active) override
See container_base::set_self_active.
grid & add_row(const widget_item &item, const int index=-1)
When an item in the list is selected by the user we need to update the state.
const grid * get_row_grid(const unsigned row) const
Returns the grid of the wanted row.
void set_active_sorter(std::string_view id, sort_order::type order, bool select_first=false)
Sorts the listbox by a pre-set sorting option.
generator_base::placement placement_
virtual void set_content_size(const point &origin, const point &size) override
Inherited from scrollbar_container.
virtual void place(const point &origin, const point &size) override
See widget::place.
void set_sorters(Args &&... functors)
Registers sorting controls using magic index IDs.
friend class debug_layout_graph
void update_visible_area_on_key_event(const KEY_SCROLL_DIRECTION direction)
Helper to update visible area after a key event.
void initialize_sorter(std::string_view id, generator_sort_array &&)
Implementation detail of set_single_sorter.
void set_callback_order_change(std::function< void(unsigned, sort_order::type)> callback)
Registers a callback to be called when the active sorting option changes.
generator_base * generator_
Contains a pointer to the generator.
std::function< void(unsigned, sort_order::type)> callback_order_change_
bool select_row(const unsigned row, const bool select=true)
Selects a row.
bool update_content_size()
Request to update the size of the content after changing the content.
boost::dynamic_bitset get_rows_shown() const
Returns a list of visible rows.
virtual const std::string & get_control_type() const override
Inherited from styled_widget, implemented by REGISTER_WIDGET.
std::size_t filter_rows_by(const std::function< bool(std::size_t)> &filter)
Hides all rows for which the given predicate returns false.
void handle_key_down_arrow(SDL_Keymod modifier, bool &handled) override
Inherited from scrollbar_container.
std::pair< widget *, sort_order::type > get_active_sorter() const
Returns a widget pointer to the active sorter, along with its corresponding order.
void remove_row(const unsigned row, unsigned count=1)
Removes a row in the listbox.
void clear()
Removes all the rows in the listbox, clearing it.
void set_single_sorter(std::string_view id, const Func &f)
Registers a single sorting control by ID.
int get_selected_row() const
Returns the first selected row.
unsigned get_item_count() const
Returns the number of items in the listbox.
bool select_row_at(const unsigned row, const bool select=true)
Selects a row at the given position, regardless of sorting order.
builder_grid_const_ptr list_builder_
Contains the builder for the new items.
bool row_selected(const unsigned row)
Check if a row is selected.
void handle_key_up_arrow(SDL_Keymod modifier, bool &handled) override
Inherited from scrollbar_container.
std::shared_ptr< builder_grid > builder_grid_ptr
std::array< generator_base::order_func, 2 > generator_sort_array
std::map< std::string, widget_item > widget_data
std::map< std::string, t_string > widget_item
std::shared_ptr< const builder_grid > builder_grid_const_ptr
Contains the implementation details for lexical_cast and shouldn't be used directly.
std::size_t size(std::string_view str)
Length in characters of a UTF-8 string.
std::size_t index(std::string_view str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
builder_grid_listbox(const config &cfg)
builder_horizontal_listbox(const config &cfg)
std::vector< widget_data > list_data
Listbox data.
generator_base::placement placement
Flag for vertical, horizontal, or grid placement.
builder_grid_ptr list_builder
virtual std::unique_ptr< widget > build() const override
Inherited from builder_widget.
builder_listbox_base(const config &cfg, const generator_base::placement placement)
builder_listbox(const config &cfg)
static bool less(const T &lhs, const T &rhs)
static bool more(const T &lhs, const T &rhs)
resolution(const config &cfg)
listbox_definition(const config &cfg)