diff options
author | Alexander Gavriliuk <alexandrgproductengine@lindenlab.com> | 2024-05-08 23:32:58 +0200 |
---|---|---|
committer | Andrew Meadows <andrew.l.meadows@gmail.com> | 2024-10-03 09:02:09 -0700 |
commit | 2daf175650cdda7cc8f820b6cb17b1475496e7ac (patch) | |
tree | 0ece9bb592a922fbcb3f4532aee10941e307f44f /indra/llui/llscrolllistctrl.cpp | |
parent | ec39ac89e8529da206dafd519d75ad5944888076 (diff) |
Add GameControl UI for per device settings
Diffstat (limited to 'indra/llui/llscrolllistctrl.cpp')
-rw-r--r-- | indra/llui/llscrolllistctrl.cpp | 111 |
1 files changed, 47 insertions, 64 deletions
diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 8998d965fb..07c4b5681b 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -326,17 +326,11 @@ S32 LLScrollListCtrl::getSearchColumn() } return llclamp(mSearchColumn, 0, getNumColumns()); } -/*virtual*/ + +// virtual bool LLScrollListCtrl::preProcessChildNode(LLXMLNodePtr child) { - if (child->hasName("column") || child->hasName("row")) - { - return true; // skip - } - else - { - return false; - } + return child->hasName("column") || child->hasName("row"); } LLScrollListCtrl::~LLScrollListCtrl() @@ -356,7 +350,6 @@ LLScrollListCtrl::~LLScrollListCtrl() } } - bool LLScrollListCtrl::setMaxItemCount(S32 max_count) { if (max_count >= getItemCount()) @@ -379,10 +372,9 @@ S32 LLScrollListCtrl::getItemCount() const bool LLScrollListCtrl::hasSelectedItem() const { item_list::iterator iter; - for (iter = mItemList.begin(); iter < mItemList.end(); ) + for (LLScrollListItem* item : mItemList) { - LLScrollListItem* itemp = *iter; - if (itemp && itemp->getSelected()) + if (item->getSelected()) { return true; } @@ -396,7 +388,6 @@ void LLScrollListCtrl::clearRows() { std::for_each(mItemList.begin(), mItemList.end(), DeletePointer()); mItemList.clear(); - //mItemCount = 0; // Scroll the bar back up to the top. mScrollbar->setDocParams(0, 0); @@ -407,7 +398,6 @@ void LLScrollListCtrl::clearRows() mDirty = false; } - LLScrollListItem* LLScrollListCtrl::getFirstSelected() const { for (LLScrollListItem* item : mItemList) @@ -444,14 +434,12 @@ S32 LLScrollListCtrl::getNumSelected() const ++numSelected; } } - return numSelected; } S32 LLScrollListCtrl::getFirstSelectedIndex() const { S32 CurSelectedIndex = 0; - // make sure sort is up to date before returning an index updateSort(); @@ -463,7 +451,6 @@ S32 LLScrollListCtrl::getFirstSelectedIndex() const } CurSelectedIndex++; } - return -1; } @@ -477,6 +464,15 @@ LLScrollListItem* LLScrollListCtrl::getLastData() const return mItemList.empty() ? NULL : mItemList.back(); } +LLScrollListItem* LLScrollListCtrl::getNthData(size_t index) const +{ + if (mItemList.size() <= index) + { + return NULL; + } + return mItemList[index]; +} + std::vector<LLScrollListItem*> LLScrollListCtrl::getAllData() const { std::vector<LLScrollListItem*> ret; @@ -1052,7 +1048,7 @@ S32 LLScrollListCtrl::selectMultiple( uuid_vec_t ids ) { LLScrollListItem* item = *iter; uuid_vec_t::iterator iditr; - for(iditr = ids.begin(); iditr != ids.end(); ++iditr) + for (iditr = ids.begin(); iditr != ids.end(); ++iditr) { if (item->getEnabled() && (item->getUUID() == (*iditr))) { @@ -1062,7 +1058,10 @@ S32 LLScrollListCtrl::selectMultiple( uuid_vec_t ids ) break; } } - if(ids.end() != iditr) ids.erase(iditr); + if (ids.end() != iditr) + { + ids.erase(iditr); + } } if (mCommitOnSelectionChange) @@ -1077,11 +1076,9 @@ S32 LLScrollListCtrl::getItemIndex( LLScrollListItem* target_item ) const updateSort(); S32 index = 0; - item_list::const_iterator iter; - for (iter = mItemList.begin(); iter != mItemList.end(); iter++) + for (LLScrollListItem* item : mItemList) { - LLScrollListItem *itemp = *iter; - if (target_item == itemp) + if (target_item == item) { return index; } @@ -1095,11 +1092,9 @@ S32 LLScrollListCtrl::getItemIndex( const LLUUID& target_id ) const updateSort(); S32 index = 0; - item_list::const_iterator iter; - for (iter = mItemList.begin(); iter != mItemList.end(); iter++) + for (LLScrollListItem* item : mItemList) { - LLScrollListItem *itemp = *iter; - if (target_id == itemp->getUUID()) + if (target_id == item->getUUID()) { return index; } @@ -1122,10 +1117,8 @@ void LLScrollListCtrl::selectPrevItem( bool extend_selection) updateSort(); item_list::iterator iter; - for (iter = mItemList.begin(); iter != mItemList.end(); iter++) + for (LLScrollListItem* cur_item : mItemList) { - LLScrollListItem* cur_item = *iter; - if (cur_item->getSelected()) { if (prev_item) @@ -1164,11 +1157,8 @@ void LLScrollListCtrl::selectNextItem( bool extend_selection) { updateSort(); - item_list::reverse_iterator iter; - for (iter = mItemList.rbegin(); iter != mItemList.rend(); iter++) + for (LLScrollListItem* cur_item : mItemList) { - LLScrollListItem* cur_item = *iter; - if (cur_item->getSelected()) { if (next_item) @@ -1197,10 +1187,8 @@ void LLScrollListCtrl::selectNextItem( bool extend_selection) void LLScrollListCtrl::deselectAllItems(bool no_commit_on_change) { - item_list::iterator iter; - for (iter = mItemList.begin(); iter != mItemList.end(); iter++) + for (LLScrollListItem* item : mItemList) { - LLScrollListItem* item = *iter; deselectItem(item); } @@ -2624,7 +2612,9 @@ bool LLScrollListCtrl::isRepeatedChars(const LLWString& string) const void LLScrollListCtrl::selectItem(LLScrollListItem* itemp, S32 cell, bool select_single_item) { - if (itemp && !itemp->getSelected()) + if (!itemp) return; + + if (!itemp->getSelected() || itemp->getSelectedCell() != cell) { if (mLastSelected) { @@ -2900,11 +2890,9 @@ bool LLScrollListCtrl::canCut() const void LLScrollListCtrl::selectAll() { // Deselects all other items - item_list::iterator iter; - for (iter = mItemList.begin(); iter != mItemList.end(); iter++) + for (LLScrollListItem* itemp : mItemList) { - LLScrollListItem *itemp = *iter; - if( itemp->getEnabled() ) + if (itemp->getEnabled()) { selectItem(itemp, -1, false); } @@ -2944,7 +2932,8 @@ void LLScrollListCtrl::addColumn(const LLSD& column, EAddPosition pos) void LLScrollListCtrl::addColumn(const LLScrollListColumn::Params& column_params, EAddPosition pos) { - if (!column_params.validateBlock()) return; + if (!column_params.validateBlock()) + return; std::string name = column_params.name; // if no column name provided, just use ordinal as name @@ -2971,7 +2960,7 @@ void LLScrollListCtrl::addColumn(const LLScrollListColumn::Params& column_params { new_column->setWidth((S32)ll_round(new_column->mRelWidth*mItemListRect.getWidth())); } - else if(new_column->mDynamicWidth) + else if (new_column->mDynamicWidth) { mNumDynamicWidthColumns++; new_column->setWidth((mItemListRect.getWidth() - mTotalStaticColumnWidth - mTotalColumnPadding) / mNumDynamicWidthColumns); @@ -2979,14 +2968,12 @@ void LLScrollListCtrl::addColumn(const LLScrollListColumn::Params& column_params S32 top = mItemListRect.mTop; S32 left = mItemListRect.mLeft; - for (column_map_t::iterator itor = mColumns.begin(); - itor != mColumns.end(); - ++itor) + for (const auto& data_pair : mColumns) { - if (itor->second->mIndex < new_column->mIndex && - itor->second->getWidth() > 0) + if (data_pair.second->mIndex < new_column->mIndex && + data_pair.second->getWidth() > 0) { - left += itor->second->getWidth() + mColumnPadding; + left += data_pair.second->getWidth() + mColumnPadding; } } @@ -3152,17 +3139,16 @@ LLScrollListItem* LLScrollListCtrl::addRow(const LLScrollListItem::Params& item_ LLScrollListItem* LLScrollListCtrl::addRow(LLScrollListItem *new_item, const LLScrollListItem::Params& item_p, EAddPosition pos) { LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; - if (!item_p.validateBlock() || !new_item) return NULL; - new_item->setNumColumns(static_cast<S32>(mColumns.size())); + if (!item_p.validateBlock() || !new_item) + return nullptr; + + new_item->setNumColumns((S32)mColumns.size()); // Add any columns we don't already have S32 col_index = 0; - for(LLInitParam::ParamIterator<LLScrollListCell::Params>::const_iterator itor = item_p.columns.begin(); - itor != item_p.columns.end(); - ++itor) + for (LLScrollListCell::Params cell_p : item_p.columns) { - LLScrollListCell::Params cell_p = *itor; std::string column = cell_p.column; // empty columns strings index by ordinal @@ -3224,8 +3210,7 @@ LLScrollListItem* LLScrollListCtrl::addRow(LLScrollListItem *new_item, const LLS new_item->setNumColumns(static_cast<S32>(mColumns.size())); } - LLScrollListCell* cell = LLScrollListCell::create(LLScrollListCell::Params().value(item_p.value)); - if (cell) + if (LLScrollListCell* cell = LLScrollListCell::create(LLScrollListCell::Params().value(item_p.value))) { LLScrollListColumn* columnp = mColumns.begin()->second; @@ -3240,15 +3225,13 @@ LLScrollListItem* LLScrollListCtrl::addRow(LLScrollListItem *new_item, const LLS } // add dummy cells for missing columns - for (column_map_t::iterator column_it = mColumns.begin(); column_it != mColumns.end(); ++column_it) + for (const auto& column_it : mColumns) { - S32 column_idx = column_it->second->mIndex; + S32 column_idx = column_it.second->mIndex; if (new_item->getColumn(column_idx) == NULL) { - LLScrollListColumn* column_ptr = column_it->second; LLScrollListCell::Params cell_p; - cell_p.width = column_ptr->getWidth(); - + cell_p.width = column_it.second->getWidth(); new_item->setColumn(column_idx, new LLScrollListSpacer(cell_p)); } } |