summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorAlexander Gavriliuk <alexandrgproductengine@lindenlab.com>2024-05-08 23:32:58 +0200
committerAndrew Meadows <andrew.l.meadows@gmail.com>2024-10-03 09:02:09 -0700
commit2daf175650cdda7cc8f820b6cb17b1475496e7ac (patch)
tree0ece9bb592a922fbcb3f4532aee10941e307f44f /indra/llui
parentec39ac89e8529da206dafd519d75ad5944888076 (diff)
Add GameControl UI for per device settings
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llcombobox.cpp52
-rw-r--r--indra/llui/llcombobox.h1
-rw-r--r--indra/llui/llscrolllistctrl.cpp111
-rw-r--r--indra/llui/llscrolllistctrl.h1
4 files changed, 76 insertions, 89 deletions
diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp
index f3876ef695..da63003f39 100644
--- a/indra/llui/llcombobox.cpp
+++ b/indra/llui/llcombobox.cpp
@@ -120,7 +120,6 @@ LLComboBox::LLComboBox(const LLComboBox::Params& p)
mButton = LLUICtrlFactory::create<LLButton>(button_params);
-
if (mAllowTextEntry)
{
//redo to compensate for button hack that leaves space for a character
@@ -142,16 +141,12 @@ LLComboBox::LLComboBox(const LLComboBox::Params& p)
// Grab the mouse-up event and make sure the button state is correct
mList->setMouseUpCallback(boost::bind(&LLComboBox::onListMouseUp, this));
- for (LLInitParam::ParamIterator<ItemParams>::const_iterator it = p.items.begin();
- it != p.items.end();
- ++it)
+ for (LLComboBox::ItemParams item_params : p.items)
{
- LLScrollListItem::Params item_params = *it;
- if (it->label.isProvided())
+ if (item_params.label.isProvided())
{
- item_params.columns.add().value(it->label());
+ item_params.columns.add().value(item_params.label());
}
-
mList->addRow(item_params);
}
@@ -235,7 +230,7 @@ void LLComboBox::onCommit()
bool LLComboBox::isDirty() const
{
bool grubby = false;
- if ( mList )
+ if (mList)
{
grubby = mList->isDirty();
}
@@ -243,9 +238,9 @@ bool LLComboBox::isDirty() const
}
// virtual Clear dirty state
-void LLComboBox::resetDirty()
+void LLComboBox::resetDirty()
{
- if ( mList )
+ if (mList)
{
mList->resetDirty();
}
@@ -256,6 +251,11 @@ bool LLComboBox::itemExists(const std::string& name)
return mList->getItemByLabel(name);
}
+std::vector<LLScrollListItem*> LLComboBox::getAllData() const
+{
+ return mList->getAllData();
+}
+
// add item "name" to menu
LLScrollListItem* LLComboBox::add(const std::string& name, EAddPosition pos, bool enabled)
{
@@ -299,7 +299,7 @@ LLScrollListItem* LLComboBox::add(const std::string& name, void* userdata, EAddP
{
LLScrollListItem* item = mList->addSimpleElement(name, pos);
item->setEnabled(enabled);
- item->setUserdata( userdata );
+ item->setUserdata(userdata);
if (!mAllowTextEntry && mLabel.empty())
{
if (mControlVariable)
@@ -343,7 +343,6 @@ void LLComboBox::sortByName(bool ascending)
mList->sortOnce(0, ascending);
}
-
// Choose an item with a given name in the menu.
// Returns true if the item was found.
bool LLComboBox::setSimple(const LLStringExplicit& name)
@@ -369,11 +368,9 @@ void LLComboBox::setValue(const LLSD& value)
return;
}
- bool found = mList->selectByValue(value);
- if (found)
+ if (mList->selectByValue(value))
{
- LLScrollListItem* item = mList->getFirstSelected();
- if (item)
+ if (mList->getFirstSelected())
{
updateLabel();
}
@@ -404,7 +401,8 @@ const std::string LLComboBox::getSelectedItemLabel(S32 column) const
// virtual
LLSD LLComboBox::getValue() const
{
- if (LLScrollListItem* item = mList->getFirstSelected())
+ LLScrollListItem* item = mList->getFirstSelected();
+ if(item)
{
return item->getValue();
}
@@ -590,8 +588,7 @@ bool LLComboBox::selectPrevItem()
void LLComboBox::setEnabledByValue(const LLSD& value, bool enabled)
{
- LLScrollListItem *found = mList->getItem(value);
- if (found)
+ if (LLScrollListItem* found = mList->getItem(value))
{
found->setEnabled(enabled);
}
@@ -654,7 +651,7 @@ void LLComboBox::setLeftTextPadding(S32 pad)
void* LLComboBox::getCurrentUserdata()
{
LLScrollListItem* item = mList->getFirstSelected();
- if( item )
+ if (item)
{
return item->getUserdata();
}
@@ -760,15 +757,19 @@ void LLComboBox::hideList()
if (mList->getVisible())
{
// assert selection in list
- if(mAllowNewValues)
+ if (mAllowNewValues)
{
// mLastSelectedIndex = -1 means that we entered a new value, don't select
// any of existing items in this case.
- if(mLastSelectedIndex >= 0)
+ if (mLastSelectedIndex >= 0)
+ {
mList->selectNthItem(mLastSelectedIndex);
+ }
}
- else if(mLastSelectedIndex >= 0)
+ else if (mLastSelectedIndex >= 0)
+ {
mList->selectNthItem(mLastSelectedIndex);
+ }
mButton->setToggleState(false);
mList->setVisible(false);
@@ -854,7 +855,7 @@ bool LLComboBox::handleToolTip(S32 x, S32 y, MASK mask)
{
std::string tool_tip;
- if(LLUICtrl::handleToolTip(x, y, mask))
+ if (LLUICtrl::handleToolTip(x, y, mask))
{
return true;
}
@@ -871,6 +872,7 @@ bool LLComboBox::handleToolTip(S32 x, S32 y, MASK mask)
.message(tool_tip)
.sticky_rect(calcScreenRect()));
}
+
return true;
}
diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h
index 8be3eb57e4..06687e9368 100644
--- a/indra/llui/llcombobox.h
+++ b/indra/llui/llcombobox.h
@@ -144,6 +144,7 @@ public:
bool remove( S32 index ); // remove item by index, return true if found and removed
void removeall() { clearRows(); }
bool itemExists(const std::string& name);
+ std::vector<LLScrollListItem*> getAllData() const;
void sortByName(bool ascending = true); // Sort the entries in the combobox by name
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));
}
}
diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h
index 1f04100306..bfae08ab5b 100644
--- a/indra/llui/llscrolllistctrl.h
+++ b/indra/llui/llscrolllistctrl.h
@@ -290,6 +290,7 @@ public:
// iterate over all items
LLScrollListItem* getFirstData() const;
LLScrollListItem* getLastData() const;
+ LLScrollListItem* getNthData(size_t index) const;
std::vector<LLScrollListItem*> getAllData() const;
LLScrollListItem* getItem(const LLSD& sd) const;