14#include <egt/detail/meta.h>
16#include <egt/signal.h>
18#include <egt/string.h>
20#include <egt/widget.h>
53 using ItemArray = std::vector<std::shared_ptr<StringItem>>;
91 auto carea = content_area();
94 m_view.box(to_subordinate(carea));
95 m_sizer.resize(carea.size());
108 EGT_NODISCARD
size_t item_count()
const {
return m_sizer.count_children(); }
113 void add_item(
const std::shared_ptr<StringItem>& item);
118 void add_item_at(
const std::shared_ptr<StringItem>& item,
size_t pos);
134 auto i = std::shared_ptr<StringItem>(&item, [](
StringItem*) {});
155 auto i = std::shared_ptr<StringItem>(&item, [](
StringItem*) {});
162 EGT_NODISCARD std::shared_ptr<StringItem>
item_at(
size_t index)
const;
244 void add_item_private(
const std::shared_ptr<StringItem>& item, ssize_t pos = -1);
437 void selected(
size_t start_index,
size_t end_index);
463 void select(
const std::list<size_t>& indexes);
469 void select(
size_t start_index,
size_t end_index);
490 void deselect(
size_t start_index,
size_t end_index);
505 void toggle(
const std::list<size_t>& indexes);
510 void toggle(
size_t start_index,
size_t end_index);
535 std::list<size_t>& selected_update,
536 std::list<size_t>& deselected_update);
537 bool select(
const std::list<size_t>& indexes,
539 std::list<size_t>& selected_update,
540 std::list<size_t>& deselected_update);
Positions and sizes widgets by Orientation.
Definition sizer.h:49
A Frame is a Widget that has children widgets.
Definition frame.h:45
ListBoxBase is an abstract class that can be used as a base class to implement list boxes.
Definition list.h:34
void add_item_at(const std::shared_ptr< StringItem > &item, size_t pos)
Insert a new item to the list at the specified position.
BoxSizer m_sizer
Internal sizer used to layout items.
Definition list.h:237
void scroll_top()
Scroll all the way to the top of the list.
void orient(Orientation orient)
Set the orientation of the list: either vertical or horizontal.
ScrolledView m_view
View used to contain the possible large sizer.
Definition list.h:234
Signal on_items_changed
Invoked when items are added or removed.
Definition list.h:49
Signal on_selected_changed
Event signal.
Definition list.h:44
EGT_NODISCARD size_t item_count() const
Return the number of items in the list.
Definition list.h:108
void scroll_beginning()
Scroll all the way to the beginning of the list, either horizontally or vertically.
virtual ~ListBoxBase()=default
void scroll_bottom()
Scroll all the way to the bottom of the list.
ListBoxBase(Serializer::Properties &props) noexcept
EGT_NODISCARD Orientation orient() const
Get the orientation of the list: either vertical or horizontal.
Definition list.h:224
std::vector< std::shared_ptr< StringItem > > ItemArray
Item array type.
Definition list.h:53
void resize(const Size &s) override
Resize the widget.
Definition list.h:86
void serialize(Serializer &serializer) const override
Serialize the widget to the specified serializer.
void scroll_offset(int offset)
Scroll an offset value either horizontally or vertically.
void add_item_at(StringItem &item, size_t pos)
Insert a new item to the list at the specified position.
Definition list.h:150
void scroll_end()
Scroll all the way to the end of the list, either horizontally or vertically.
void remove_item(StringItem *item)
Remove an item from the list.
virtual void selected(size_t index)=0
Select an item by index.
void remove_item_at(size_t pos)
Remove the item at the specified position.
void clear()
Remove all items from the list.
void add_item(const std::shared_ptr< StringItem > &item)
Add a new item to the end of the list.
void add_item(StringItem &item)
Add a new item to the end of the list.
Definition list.h:129
ListBoxBase(const ItemArray &items=ItemArray()) noexcept
EGT_NODISCARD std::shared_ptr< StringItem > item_at(size_t index) const
Get the currently selected index item from list.
ListBoxMulti a listbox that manages a selectable list of items and allows multi selection.
Definition list.h:363
void select(const std::list< size_t > &indexes)
Select a list of items by indexes, others items are left unchanged.
void toggle(size_t index)
Toggle an item by index.
void select(size_t index)
Select an item by index, others items are left unchanged.
bool select(const std::list< size_t > &indexes, bool selected, std::list< size_t > &selected_update, std::list< size_t > &deselected_update)
void deselected(size_t index)
Set the deselected item, other items are selected.
void deselect(size_t start_index, size_t end_index)
Deselect a range [start_index, end_index) of items, others items are left unchanged.
void deselect_all()
Deselect all the items.
void selected(size_t start_index, size_t end_index)
Set a range [start_index, end_index) of selected items, other items are deselected.
Signal< std::list< size_t > > on_deselected
Invoked when items are deselected with the list of the indexes of the items deselected.
Definition list.h:380
bool selected(const std::list< size_t > &indexes, bool selected, std::list< size_t > &selected_update, std::list< size_t > &deselected_update)
void deselect(size_t index)
Deselect an item by index, others items are left unchanged.
void select(size_t start_index, size_t end_index)
Select a range [start_index, end_index) of items, others items are left unchanged.
void deselected(const std::list< size_t > &indexes)
Set a list of deselected items, other items are selected.
EGT_NODISCARD std::list< size_t > selected() const
Get the currently selected indexes.
void selected(size_t index) override
Set the selected item, other items are deselected.
Signal< std::list< size_t > > on_selected
Event signal.
Definition list.h:374
void toggle_all()
Toggle all the items.
void toggle(size_t start_index, size_t end_index)
Toggle a range [start_index, end_index) of items.
ListBoxMulti(Serializer::Properties &props, bool is_derived) noexcept
ListBoxMulti(Serializer::Properties &props) noexcept
Definition list.h:410
void selected(const std::list< size_t > &indexes)
Set a list of selected items, other items are deselected.
void toggle(const std::list< size_t > &indexes)
Toggle a list of items by indexes.
ListBoxMulti(const ItemArray &items=ItemArray()) noexcept
void handle(Event &event) override
Handle an event.
EGT_NODISCARD std::list< size_t > deselected() const
Get the currently deselected indexes.
void deselected(size_t start_index, size_t end_index)
Set a range [start_index, end_index) of deselected items, other items are selected.
void select_all()
Select all the items.
void deselect(const std::list< size_t > &indexes)
Deselect a list of items by indexes, others items are left unchanged.
ListBox that manages a selectable list of widgets.
Definition list.h:263
Signal< size_t > on_selected
Event signal.
Definition list.h:273
EGT_NODISCARD ssize_t selected() const
Get the currently selected index.
ListBox(Serializer::Properties &props, bool is_derived) noexcept
void selected(size_t index) override
Select an item by index.
ListBox(const Rect &rect) noexcept
Definition list.h:288
ListBox(Serializer::Properties &props) noexcept
Definition list.h:315
ListBox(const ItemArray &items=ItemArray()) noexcept
Definition list.h:280
void handle(Event &event) override
Handle an event.
ListBox(Frame &parent, const ItemArray &items={}, const Rect &rect={}) noexcept
Definition list.h:307
ListBox(const ItemArray &items, const Rect &rect) noexcept
Definition list.h:297
Abstract base serializer class.
Definition serialize.h:34
std::list< std::tuple< std::string, std::string, Serializer::Attributes > > Properties
Definition serialize.h:47
Signal class used for defining a signal and dispatching events.
Definition signal.h:30
Orientation
Generic orientation flags.
Definition widgetflags.h:679
EGT framework namespace.
Definition animation.h:24
A single event that has information about the event and state for the event.
Definition event.h:255
List string helper.
Definition string.h:34