Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow horizontal scrollbar for ListView items #147

Merged
merged 5 commits into from Sep 26, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 29 additions & 0 deletions include/TGUI/Widgets/ListView.hpp
Expand Up @@ -70,6 +70,7 @@ namespace tgui
{
float width = 0;
float designWidth = 0;
float maxItemWidth = 0;
Text text;
ColumnAlignment alignment = ColumnAlignment::Left;
};
Expand Down Expand Up @@ -884,6 +885,27 @@ namespace tgui
void updateSelectedItem(int item);


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Update the maximum item width of the last column by recalculating all items' widths.
// Returns whether the max item width was changed.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool updateLastColumnMaxItemWidth();


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Update the maximum item width of the last column based on the addition of an Item.
// Returns true if the maximum item width was changed.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool updateLastColumnMaxItemWidthWithNewItem(const Item& item);


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Update the maximum item width of the last column based on the modification of an Item.
// Returns true if the maximum item width was changed.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool updateLastColumnMaxItemWidthWithModifiedItem(const Item& modifiedItem, float oldDesiredWidthInLastColumn);


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add item to selected set
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -908,6 +930,12 @@ namespace tgui
unsigned int getTotalSeparatorWidth() const;


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Returns the total width an Item takes up at some column, assuming it will not be cut off by the column.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
float getItemTotalWidth(const Item& item, std::size_t columnIndex) const;


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Found out which column is located below the mouse. The mouseLeft is relative to the widget position.
// This function should only be called after checking that the mouse is positioned on top of the header.
Expand Down Expand Up @@ -986,6 +1014,7 @@ namespace tgui
unsigned int m_gridLinesWidth = 1;
unsigned int m_iconCount = 0;
float m_maxIconWidth = 0;
float m_maxItemWidth = 0; // If there are no columns, this is the maximum width from all items
bool m_headerVisible = true;
bool m_showHorizontalGridLines = false;
bool m_showVerticalGridLines = true;
Expand Down