Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 43 additions & 3 deletions include/TGUI/Widgets/ListView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <TGUI/Widgets/Scrollbar.hpp>
#include <TGUI/Renderers/ListViewRenderer.hpp>
#include <TGUI/Text.hpp>
#include <set>

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -318,7 +319,15 @@ namespace tgui


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Deselects the selected item
/// @brief Selects items in the list view
///
/// @param indexes Indexes of the items in the list view
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setSelectedItems(const std::set<std::size_t>& indexes);


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Deselects the selected item or all of them
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void deselectItem();

Expand All @@ -331,6 +340,30 @@ namespace tgui
int getSelectedItemIndex() const;


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Gets the indexes of the selected items
///
/// @return The indexes of the selected items
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
std::set<std::size_t> getSelectedItemIndexes() const;


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Allow multi selection of the items
///
/// @param multiSelect Whether several items can be selected
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setMultiSelect(bool multiSelect);


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns multi selection of the items is allowed
///
/// @return Whether several items can be selected
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool getMultiSelect() const;


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Sets a small icon in front of the item
///
Expand Down Expand Up @@ -797,6 +830,12 @@ namespace tgui
void updateSelectedItem(int item);


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add item to selected
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void addSelectedItem(int item);


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Update on which item the mouse is standing, given the current mouse position
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -873,8 +912,8 @@ namespace tgui

std::vector<Column> m_columns;
std::vector<Item> m_items;
std::set<std::size_t> m_selectedItems;

int m_selectedItem = -1;
int m_hoveredItem = -1;

float m_requestedHeaderHeight = 0;
Expand All @@ -891,14 +930,15 @@ namespace tgui
bool m_showHorizontalGridLines = false;
bool m_showVerticalGridLines = true;
bool m_expandLastColumn = false;
bool m_multiSelect = false;

CopiedSharedPtr<ScrollbarChildWidget> m_horizontalScrollbar;
CopiedSharedPtr<ScrollbarChildWidget> m_verticalScrollbar;
Scrollbar::Policy m_verticalScrollbarPolicy = Scrollbar::Policy::Automatic;
Scrollbar::Policy m_horizontalScrollbarPolicy = Scrollbar::Policy::Automatic;

int m_mouseOnHeaderIndex = -1; // If the left mouse is down, this contains the index of the column if the mouse went down on the header
bool m_possibleDoubleClick = false; // Will be set to true after the first click, but gets reset to false when the second click does not occur soon after
int m_possibleDoubleClick = -1; // Will be set to index of item after the first click, but gets reset to -1 when the second click does not occur soon after
bool m_autoScroll = true; // Should the list view scroll to the bottom when a new item is added?

// Cached renderer properties
Expand Down
Loading