diff options
Diffstat (limited to 'indra/llui')
57 files changed, 562 insertions, 518 deletions
diff --git a/indra/llui/llaccordionctrl.cpp b/indra/llui/llaccordionctrl.cpp index 4682044d6e..06f7a20add 100644 --- a/indra/llui/llaccordionctrl.cpp +++ b/indra/llui/llaccordionctrl.cpp @@ -379,12 +379,10 @@ void LLAccordionCtrl::initNoTabsWidget(const LLTextBox::Params& tb_params) void LLAccordionCtrl::updateNoTabsHelpTextVisibility() { - bool visible_exists = false; - std::vector<LLAccordionCtrlTab*>::const_iterator it = mAccordionTabs.begin(); - const std::vector<LLAccordionCtrlTab*>::const_iterator it_end = mAccordionTabs.end(); - while (it < it_end) + bool visible_exists{ false }; + for (auto accordion_tab : mAccordionTabs) { - if ((*(it++))->getVisible()) + if (accordion_tab->getVisible()) { visible_exists = true; break; diff --git a/indra/llui/llaccordionctrltab.cpp b/indra/llui/llaccordionctrltab.cpp index 6d58a2545c..ac66525030 100644 --- a/indra/llui/llaccordionctrltab.cpp +++ b/indra/llui/llaccordionctrltab.cpp @@ -602,15 +602,13 @@ void LLAccordionCtrlTab::setSelected(bool is_selected) LLView* LLAccordionCtrlTab::findContainerView() { - child_list_const_iter_t it = getChildList()->begin(), it_end = getChildList()->end(); - while (it != it_end) + for (auto child : *getChildList()) { - LLView* child = *(it++); if (DD_HEADER_NAME != child->getName() && child->getVisible()) return child; } - return NULL; + return nullptr; } void LLAccordionCtrlTab::selectOnFocusReceived() diff --git a/indra/llui/llbadge.cpp b/indra/llui/llbadge.cpp index 3397c97ee1..3ff0617554 100644 --- a/indra/llui/llbadge.cpp +++ b/indra/llui/llbadge.cpp @@ -36,7 +36,7 @@ static LLDefaultChildRegistry::Register<LLBadge> r("badge"); static const S32 BADGE_OFFSET_NOT_SPECIFIED = 0x7FFFFFFF; // Compiler optimization, generate extern template -template class LLBadge* LLView::getChild<class LLBadge>(const std::string& name, bool recurse) const; +template class LLBadge* LLView::getChild<class LLBadge>(std::string_view name, bool recurse) const; LLBadge::Params::Params() @@ -197,10 +197,10 @@ void renderBadgeBackground(F32 centerX, F32 centerY, F32 width, F32 height, cons F32 x = LLFontGL::sCurOrigin.mX + centerX - width * 0.5f; F32 y = LLFontGL::sCurOrigin.mY + centerY - height * 0.5f; - LLRectf screen_rect(ll_round(x), - ll_round(y), - ll_round(x) + width, - ll_round(y) + height); + LLRectf screen_rect((F32)ll_round(x), + (F32)ll_round(y), + (F32)ll_round(x) + width, + (F32)ll_round(y) + height); LLVector3 vertices[4]; vertices[0] = LLVector3(screen_rect.mRight, screen_rect.mTop, 1.0f); @@ -302,7 +302,7 @@ void LLBadge::draw() } else { - badge_center_x = location_offset_horiz; + badge_center_x = (F32)location_offset_horiz; } // Compute y position @@ -319,7 +319,7 @@ void LLBadge::draw() } else { - badge_center_y = location_offset_vert; + badge_center_y = (F32)location_offset_vert; } // diff --git a/indra/llui/llbadge.h b/indra/llui/llbadge.h index a6d584c6d7..77fe76f0da 100644 --- a/indra/llui/llbadge.h +++ b/indra/llui/llbadge.h @@ -171,7 +171,7 @@ private: // Build time optimization, generate once in .cpp file #ifndef LLBADGE_CPP -extern template class LLBadge* LLView::getChild<class LLBadge>(const std::string& name, bool recurse) const; +extern template class LLBadge* LLView::getChild<class LLBadge>(std::string_view name, bool recurse) const; #endif #endif // LL_LLBADGE_H diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index e6c045250e..9e1e3ba120 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -56,7 +56,7 @@ static LLDefaultChildRegistry::Register<LLButton> r("button"); // Compiler optimization, generate extern template template class LLButton* LLView::getChild<class LLButton>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; // globals S32 LLBUTTON_H_PAD = 4; @@ -188,7 +188,7 @@ LLButton::LLButton(const LLButton::Params& p) // Likewise, missing "p.button_flash_rate" is replaced by gSavedSettings.getF32("FlashPeriod"). // Note: flashing should be allowed in settings.xml (boolean key "EnableButtonFlashing"). S32 flash_count = p.button_flash_count.isProvided()? p.button_flash_count : 0; - F32 flash_rate = p.button_flash_rate.isProvided()? p.button_flash_rate : 0.0; + F32 flash_rate = p.button_flash_rate.isProvided()? p.button_flash_rate : 0.0f; mFlashingTimer = new LLFlashTimer ((LLFlashTimer::callback_t)NULL, flash_count, flash_rate); } else @@ -1273,7 +1273,7 @@ void LLButton::setFloaterToggle(LLUICtrl* ctrl, const LLSD& sdname) // Set the button control value (toggle state) to the floater visibility control (Sets the value as well) button->setControlVariable(LLFloater::getControlGroup()->getControl(vis_control_name)); // Set the clicked callback to toggle the floater - button->setClickedCallback(boost::bind(&LLFloaterReg::toggleInstance, sdname, LLSD())); + button->setClickedCallback([=](LLUICtrl* ctrl, const LLSD& param) -> void { LLFloaterReg::toggleInstance(sdname.asString(), LLSD()); }); } // static diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index fed5cdcc50..80a876393e 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -400,7 +400,7 @@ protected: // Build time optimization, generate once in .cpp file #ifndef LLBUTTON_CPP extern template class LLButton* LLView::getChild<class LLButton>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif // LL_LLBUTTON_H diff --git a/indra/llui/llcheckboxctrl.cpp b/indra/llui/llcheckboxctrl.cpp index 3bcf0a6517..dea262942b 100644 --- a/indra/llui/llcheckboxctrl.cpp +++ b/indra/llui/llcheckboxctrl.cpp @@ -45,7 +45,7 @@ static LLDefaultChildRegistry::Register<LLCheckBoxCtrl> r("check_box"); // Compiler optimization, generate extern template template class LLCheckBoxCtrl* LLView::getChild<class LLCheckBoxCtrl>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; void LLCheckBoxCtrl::WordWrap::declareValues() { diff --git a/indra/llui/llcheckboxctrl.h b/indra/llui/llcheckboxctrl.h index 3058e946c3..fc04a8a781 100644 --- a/indra/llui/llcheckboxctrl.h +++ b/indra/llui/llcheckboxctrl.h @@ -151,7 +151,7 @@ protected: // Build time optimization, generate once in .cpp file #ifndef LLCHECKBOXCTRL_CPP extern template class LLCheckBoxCtrl* LLView::getChild<class LLCheckBoxCtrl>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif // LL_LLCHECKBOXCTRL_H diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp index 79dce1c714..ee1700e009 100644 --- a/indra/llui/llcombobox.cpp +++ b/indra/llui/llcombobox.cpp @@ -875,6 +875,20 @@ bool LLComboBox::handleUnicodeCharHere(llwchar uni_char) return result; } +// virtual +bool LLComboBox::handleScrollWheel(S32 x, S32 y, S32 clicks) +{ + if (mList->getVisible()) return mList->handleScrollWheel(x, y, clicks); + if (mAllowTextEntry) // We might be editable + if (!mList->getFirstSelected()) // We aren't in the list, don't kill their text + return false; + + setCurrentByIndex(llclamp(getCurrentIndex() + clicks, 0, getItemCount() - 1)); + prearrangeList(); + onCommit(); + return true; +} + void LLComboBox::setTextEntry(const LLStringExplicit& text) { if (mTextEntry) diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h index cc1c2885fc..9dc6fa9257 100644 --- a/indra/llui/llcombobox.h +++ b/indra/llui/llcombobox.h @@ -114,6 +114,7 @@ public: virtual bool handleToolTip(S32 x, S32 y, MASK mask); virtual bool handleKeyHere(KEY key, MASK mask); virtual bool handleUnicodeCharHere(llwchar uni_char); + virtual bool handleScrollWheel(S32 x, S32 y, S32 clicks); // LLUICtrl interface virtual void clear(); // select nothing diff --git a/indra/llui/llconsole.cpp b/indra/llui/llconsole.cpp index 9fbfb3e5fa..fe4f991921 100644 --- a/indra/llui/llconsole.cpp +++ b/indra/llui/llconsole.cpp @@ -80,7 +80,7 @@ void LLConsole::setLinePersistTime(F32 seconds) void LLConsole::reshape(S32 width, S32 height, bool called_from_parent) { S32 new_width = llmax(50, llmin(getRect().getWidth(), width)); - S32 new_height = llmax(llfloor(mFont->getLineHeight()) + 15, llmin(getRect().getHeight(), height)); + S32 new_height = llmax(mFont->getLineHeight() + 15, llmin(getRect().getHeight(), height)); if ( mConsoleWidth == new_width && mConsoleHeight == new_height ) @@ -186,7 +186,7 @@ void LLConsole::draw() LLColor4 color = LLUIColorTable::instance().getColor("ConsoleBackground"); color.mV[VALPHA] *= console_opacity; - F32 line_height = mFont->getLineHeight(); + F32 line_height = (F32)mFont->getLineHeight(); for(paragraph_it = mParagraphs.rbegin(); paragraph_it != mParagraphs.rend(); paragraph_it++) { diff --git a/indra/llui/llf32uictrl.cpp b/indra/llui/llf32uictrl.cpp index 52954ebbbb..9d041fffb0 100644 --- a/indra/llui/llf32uictrl.cpp +++ b/indra/llui/llf32uictrl.cpp @@ -37,7 +37,7 @@ LLF32UICtrl::LLF32UICtrl(const Params& p) : LLUICtrl(p), - mInitialValue(p.initial_value().asReal()), + mInitialValue((F32)p.initial_value().asReal()), mMinValue(p.min_value), mMaxValue(p.max_value), mIncrement(p.increment) @@ -47,5 +47,5 @@ LLF32UICtrl::LLF32UICtrl(const Params& p) F32 LLF32UICtrl::getValueF32() const { - return mViewModel->getValue().asReal(); + return (F32)mViewModel->getValue().asReal(); } diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp index 1799968afb..53f39766c6 100644 --- a/indra/llui/llflatlistview.cpp +++ b/indra/llui/llflatlistview.cpp @@ -1250,17 +1250,15 @@ void LLFlatListView::detachItems(std::vector<LLPanel*>& detached_items) detached_items.clear(); // Go through items and detach valid items, remove them from items panel // and add to detached_items. - pairs_iterator_t iter = mItemPairs.begin(), iter_end = mItemPairs.end(); - while (iter != iter_end) + for (auto item_pair : mItemPairs) { - LLPanel* pItem = (*iter)->first; + LLPanel* pItem = item_pair->first; if (1 == pItem->notify(action)) { - selectItemPair((*iter), false); + selectItemPair(item_pair, false); mItemsPanel->removeChild(pItem); - detached_items.push_back(pItem); + detached_items.emplace_back(pItem); } - iter++; } if (!detached_items.empty()) { @@ -1268,12 +1266,10 @@ void LLFlatListView::detachItems(std::vector<LLPanel*>& detached_items) if (detached_items.size() == mItemPairs.size()) { // This way will be faster if all items were disconnected - pairs_iterator_t iter = mItemPairs.begin(), iter_end = mItemPairs.end(); - while (iter != iter_end) + for (auto item_pair : mItemPairs) { - (*iter)->first = NULL; - delete *iter; - iter++; + item_pair->first = nullptr; + delete item_pair; } mItemPairs.clear(); // Also set items panel height to zero. @@ -1286,26 +1282,16 @@ void LLFlatListView::detachItems(std::vector<LLPanel*>& detached_items) } else { - std::vector<LLPanel*>::const_iterator - detached_iter = detached_items.begin(), - detached_iter_end = detached_items.end(); - while (detached_iter < detached_iter_end) + for (auto detached_item : detached_items) { - LLPanel* pDetachedItem = *detached_iter; - pairs_iterator_t iter = mItemPairs.begin(), iter_end = mItemPairs.end(); - while (iter != iter_end) + auto found_pos = std::find_if(mItemPairs.begin(), mItemPairs.end(), [detached_item](auto item_pair) { return item_pair->first == detached_item; }); + if (found_pos != mItemPairs.end()) { - item_pair_t* item_pair = *iter; - if (item_pair->first == pDetachedItem) - { - mItemPairs.erase(iter); - item_pair->first = NULL; - delete item_pair; - break; - } - iter++; + mItemPairs.erase(found_pos); + auto item_pair = *found_pos; + item_pair->first = nullptr; + delete item_pair; } - detached_iter++; } rearrangeItems(); } @@ -1412,11 +1398,10 @@ void LLFlatListViewEx::filterItems(bool re_sort, bool notify_parent) action.with("match_filter", cur_filter); mHasMatchedItems = false; - bool visibility_changed = false; - pairs_const_iterator_t iter = getItemPairs().begin(), iter_end = getItemPairs().end(); - while (iter != iter_end) + bool visibility_changed{ false }; + for (auto item_pair : getItemPairs()) { - LLPanel* pItem = (*(iter++))->first; + LLPanel* pItem = item_pair->first; visibility_changed |= updateItemVisibility(pItem, action); } diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index e6ecf3c283..12d5c41de1 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -960,8 +960,8 @@ bool LLFloater::applyRectControl() && !x_control->isDefault() && !y_control->isDefault()) { - mPosition.mX = x_control->getValue().asReal(); - mPosition.mY = y_control->getValue().asReal(); + mPosition.mX = (LL_COORD_FLOATER::value_t)x_control->getValue().asReal(); + mPosition.mY = (LL_COORD_FLOATER::value_t)y_control->getValue().asReal(); mPositioning = LLFloaterEnums::POSITIONING_RELATIVE; applyRelativePosition(); @@ -1205,24 +1205,64 @@ void LLFloater::handleReshape(const LLRect& new_rect, bool by_user) { S32 delta_x = 0; S32 delta_y = 0; + + // take translation of dependee floater into account + delta_x += new_rect.mLeft - old_rect.mLeft; + delta_y += new_rect.mBottom - old_rect.mBottom; + // check to see if it snapped to right or top, and move if dependee floater is resizing LLRect dependent_rect = floaterp->getRect(); - if (dependent_rect.mLeft - getRect().mLeft >= old_rect.getWidth() || // dependent on my right? - dependent_rect.mRight == getRect().mLeft + old_rect.getWidth()) // dependent aligned with my right + if ((dependent_rect.mLeft - getRect().mLeft >= old_rect.getWidth() || // dependent on my right? + dependent_rect.mRight == getRect().mLeft + old_rect.getWidth()) // dependent aligned with my right + && dependent_rect.mBottom <= old_rect.mTop + 1) { // was snapped directly onto right side or aligned with it delta_x += new_rect.getWidth() - old_rect.getWidth(); + + // make sure dependent still touches floater and din't go too high, + // it can go over edge, but should't detach completely + if (delta_y > 0 + && dependent_rect.mBottom + delta_y > new_rect.mTop) + { + delta_y = llmax(new_rect.mTop - dependent_rect.mBottom, 0); + } + } + else if (dependent_rect.mRight == old_rect.mLeft) + { + // make sure dependent still touches floater and don't go too high + if (delta_y > 0 + && dependent_rect.mBottom <= old_rect.mTop + && dependent_rect.mBottom + delta_y > new_rect.mTop) + { + delta_y = llmax(new_rect.mTop - dependent_rect.mBottom, 0); + } } - if (dependent_rect.mBottom - getRect().mBottom >= old_rect.getHeight() || - dependent_rect.mTop == getRect().mBottom + old_rect.getHeight()) + + if ((dependent_rect.mBottom - getRect().mBottom >= old_rect.getHeight() || + dependent_rect.mTop == getRect().mBottom + old_rect.getHeight()) + && dependent_rect.mLeft <= old_rect.mRight + 1) { // was snapped directly onto top side or aligned with it delta_y += new_rect.getHeight() - old_rect.getHeight(); - } - // take translation of dependee floater into account as well - delta_x += new_rect.mLeft - old_rect.mLeft; - delta_y += new_rect.mBottom - old_rect.mBottom; + // make sure dependent still touches floater + // and din't go too far to the right + if (delta_x > 0 + && dependent_rect.mLeft + delta_x > new_rect.mRight) + { + delta_x = llmax(new_rect.mRight - dependent_rect.mLeft, 0); + } + } + else if (dependent_rect.mTop == old_rect.mBottom) + { + // make sure dependent still touches floater and don't go too far to the right + if (delta_x > 0 + && dependent_rect.mLeft <= old_rect.mRight + && dependent_rect.mLeft + delta_x > new_rect.mRight) + { + delta_x = llmax(new_rect.mRight - dependent_rect.mLeft, 0); + } + } dependent_rect.translate(delta_x, delta_y); floaterp->setShape(dependent_rect, by_user); @@ -3618,7 +3658,7 @@ void LLFloater::applyRelativePosition() LLCoordFloater::LLCoordFloater(F32 x, F32 y, LLFloater& floater) -: coord_t((S32)x, (S32)y) +: coord_t(x, y) { mFloater = floater.getHandle(); } @@ -3661,28 +3701,28 @@ LLCoordCommon LL_COORD_FLOATER::convertToCommon() const LLCoordCommon out; if (self.mX < -0.5f) { - out.mX = ll_round(rescale(self.mX, -1.f, -0.5f, snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mLeft)); + out.mX = ll_round(rescale(self.mX, -1.f, -0.5f, (F32)(snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS)), (F32)snap_rect.mLeft)); } else if (self.mX > 0.5f) { - out.mX = ll_round(rescale(self.mX, 0.5f, 1.f, snap_rect.mRight - floater_width, snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS)); + out.mX = ll_round(rescale(self.mX, 0.5f, 1.f, (F32)(snap_rect.mRight - floater_width), (F32)(snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS))); } else { - out.mX = ll_round(rescale(self.mX, -0.5f, 0.5f, snap_rect.mLeft, snap_rect.mRight - floater_width)); + out.mX = ll_round(rescale(self.mX, -0.5f, 0.5f, (F32)snap_rect.mLeft, (F32)(snap_rect.mRight - floater_width))); } if (self.mY < -0.5f) { - out.mY = ll_round(rescale(self.mY, -1.f, -0.5f, snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mBottom)); + out.mY = ll_round(rescale(self.mY, -1.f, -0.5f, (F32)(snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS)), (F32)snap_rect.mBottom)); } else if (self.mY > 0.5f) { - out.mY = ll_round(rescale(self.mY, 0.5f, 1.f, snap_rect.mTop - floater_height, snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS)); + out.mY = ll_round(rescale(self.mY, 0.5f, 1.f, (F32)(snap_rect.mTop - floater_height), (F32)(snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS))); } else { - out.mY = ll_round(rescale(self.mY, -0.5f, 0.5f, snap_rect.mBottom, snap_rect.mTop - floater_height)); + out.mY = ll_round(rescale(self.mY, -0.5f, 0.5f, (F32)snap_rect.mBottom, (F32)(snap_rect.mTop - floater_height))); } // return center point instead of lower left @@ -3709,27 +3749,27 @@ void LL_COORD_FLOATER::convertFromCommon(const LLCoordCommon& from) if (from_x < snap_rect.mLeft) { - self.mX = rescale(from_x, snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mLeft, -1.f, -0.5f); + self.mX = rescale((F32)from_x, (F32)(snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS)), (F32)snap_rect.mLeft, -1.f, -0.5f); } else if (from_x + floater_width > snap_rect.mRight) { - self.mX = rescale(from_x, snap_rect.mRight - floater_width, snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS, 0.5f, 1.f); + self.mX = rescale((F32)from_x, (F32)(snap_rect.mRight - floater_width), (F32)(snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS), 0.5f, 1.f); } else { - self.mX = rescale(from_x, snap_rect.mLeft, snap_rect.mRight - floater_width, -0.5f, 0.5f); + self.mX = rescale((F32)from_x, (F32)snap_rect.mLeft, (F32)(snap_rect.mRight - floater_width), -0.5f, 0.5f); } if (from_y < snap_rect.mBottom) { - self.mY = rescale(from_y, snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mBottom, -1.f, -0.5f); + self.mY = rescale((F32)from_y, (F32)(snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS)), (F32)snap_rect.mBottom, -1.f, -0.5f); } else if (from_y + floater_height > snap_rect.mTop) { - self.mY = rescale(from_y, snap_rect.mTop - floater_height, snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS, 0.5f, 1.f); + self.mY = rescale((F32)from_y, (F32)(snap_rect.mTop - floater_height), (F32)(snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS), 0.5f, 1.f); } else { - self.mY = rescale(from_y, snap_rect.mBottom, snap_rect.mTop - floater_height, -0.5f, 0.5f); + self.mY = rescale((F32)from_y, (F32)snap_rect.mBottom, (F32)(snap_rect.mTop - floater_height), -0.5f, 0.5f); } } diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index fd5a370bc3..a818e72f59 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -40,9 +40,9 @@ LLFloaterReg::instance_list_t LLFloaterReg::sNullInstanceList; LLFloaterReg::instance_map_t LLFloaterReg::sInstanceMap; LLFloaterReg::build_map_t LLFloaterReg::sBuildMap; -std::map<std::string,std::string> LLFloaterReg::sGroupMap; +std::map<std::string, std::string, std::less<>> LLFloaterReg::sGroupMap; bool LLFloaterReg::sBlockShowFloaters = false; -std::set<std::string> LLFloaterReg::sAlwaysShowableList; +std::set<std::string, std::less<>> LLFloaterReg::sAlwaysShowableList; static LLFloaterRegListener sFloaterRegListener; @@ -58,27 +58,31 @@ void LLFloaterReg::add(const std::string& name, const std::string& filename, con } //static -bool LLFloaterReg::isRegistered(const std::string& name) +bool LLFloaterReg::isRegistered(std::string_view name) { return sBuildMap.find(name) != sBuildMap.end(); } //static -LLFloater* LLFloaterReg::getLastFloaterInGroup(const std::string& name) +LLFloater* LLFloaterReg::getLastFloaterInGroup(std::string_view name) { - const std::string& groupname = sGroupMap[name]; - if (!groupname.empty()) + auto it = sGroupMap.find(name); + if (it != sGroupMap.end()) { - instance_list_t& list = sInstanceMap[groupname]; - if (!list.empty()) + const std::string& groupname = it->second; + if (!groupname.empty()) { - for (instance_list_t::reverse_iterator iter = list.rbegin(); iter != list.rend(); ++iter) + instance_list_t& list = sInstanceMap[groupname]; + if (!list.empty()) { - LLFloater* inst = *iter; - - if (inst->getVisible() && !inst->isMinimized()) + for (instance_list_t::reverse_iterator iter = list.rbegin(), end = list.rend(); iter != end; ++iter) { - return inst; + LLFloater* inst = *iter; + + if (inst->getVisible() && !inst->isMinimized()) + { + return inst; + } } } } @@ -99,10 +103,8 @@ LLFloater* LLFloaterReg::getLastFloaterCascading() instance_list_t& instances = sInstanceMap[group_name]; - for (instance_list_t::const_iterator iter = instances.begin(); iter != instances.end(); ++iter) + for (LLFloater* inst : instances) { - LLFloater* inst = *iter; - if (inst->getVisible() && (inst->isPositioning(LLFloaterEnums::POSITIONING_CASCADING) || inst->isPositioning(LLFloaterEnums::POSITIONING_CASCADE_GROUP))) @@ -120,20 +122,23 @@ LLFloater* LLFloaterReg::getLastFloaterCascading() } //static -LLFloater* LLFloaterReg::findInstance(const std::string& name, const LLSD& key) +LLFloater* LLFloaterReg::findInstance(std::string_view name, const LLSD& key) { LLFloater* res = NULL; - const std::string& groupname = sGroupMap[name]; - if (!groupname.empty()) + auto it = sGroupMap.find(name); + if (it != sGroupMap.end()) { - instance_list_t& list = sInstanceMap[groupname]; - for (instance_list_t::iterator iter = list.begin(); iter != list.end(); ++iter) + const std::string& groupname = it->second; + if (!groupname.empty()) { - LLFloater* inst = *iter; - if (inst->matchesKey(key)) + instance_list_t& list = sInstanceMap[groupname]; + for (LLFloater* inst : list) { - res = inst; - break; + if (inst->matchesKey(key)) + { + res = inst; + break; + } } } } @@ -141,47 +146,55 @@ LLFloater* LLFloaterReg::findInstance(const std::string& name, const LLSD& key) } //static -LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) +LLFloater* LLFloaterReg::getInstance(std::string_view name, const LLSD& key) { LLFloater* res = findInstance(name, key); if (!res) { - const LLFloaterBuildFunc& build_func = sBuildMap[name].mFunc; - const std::string& xui_file = sBuildMap[name].mFile; - if (build_func) + auto it = sBuildMap.find(name); + if (it != sBuildMap.end()) { - const std::string& groupname = sGroupMap[name]; - if (!groupname.empty()) + const LLFloaterBuildFunc& build_func = it->second.mFunc; + const std::string& xui_file = it->second.mFile; + if (build_func) { - instance_list_t& list = sInstanceMap[groupname]; - - res = build_func(key); - if (!res) - { - LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL; - return NULL; - } - bool success = res->buildFromFile(xui_file); - if (!success) + auto it = sGroupMap.find(name); + if (it != sGroupMap.end()) { - LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL; - return NULL; + const std::string& groupname = it->second; + if (!groupname.empty()) + { + instance_list_t& list = sInstanceMap[groupname]; + + res = build_func(key); + if (!res) + { + LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL; + return NULL; + } + bool success = res->buildFromFile(xui_file); + if (!success) + { + LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL; + return NULL; + } + + // Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe + if (res->mKey.isUndefined()) + { + res->mKey = key; + } + res->setInstanceName(std::string(name)); + + LLFloater* last_floater = (list.empty() ? NULL : list.back()); + + res->applyControlsAndPosition(last_floater); + + gFloaterView->adjustToFitScreen(res, false); + + list.push_back(res); + } } - - // Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe - if (res->mKey.isUndefined()) - { - res->mKey = key; - } - res->setInstanceName(name); - - LLFloater *last_floater = (list.empty() ? NULL : list.back()); - - res->applyControlsAndPosition(last_floater); - - gFloaterView->adjustToFitScreen(res, false); - - list.push_back(res); } } if (!res) @@ -193,21 +206,25 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) } //static -LLFloater* LLFloaterReg::removeInstance(const std::string& name, const LLSD& key) +LLFloater* LLFloaterReg::removeInstance(std::string_view name, const LLSD& key) { LLFloater* res = NULL; - const std::string& groupname = sGroupMap[name]; - if (!groupname.empty()) + auto it = sGroupMap.find(name); + if (it != sGroupMap.end()) { - instance_list_t& list = sInstanceMap[groupname]; - for (instance_list_t::iterator iter = list.begin(); iter != list.end(); ++iter) + const std::string& groupname = it->second; + if (!groupname.empty()) { - LLFloater* inst = *iter; - if (inst->matchesKey(key)) + instance_list_t& list = sInstanceMap[groupname]; + for (instance_list_t::iterator iter = list.begin(); iter != list.end(); ++iter) { - res = inst; - list.erase(iter); - break; + LLFloater* inst = *iter; + if (inst->matchesKey(key)) + { + res = inst; + list.erase(iter); + break; + } } } } @@ -216,7 +233,7 @@ LLFloater* LLFloaterReg::removeInstance(const std::string& name, const LLSD& key //static // returns true if the instance existed -bool LLFloaterReg::destroyInstance(const std::string& name, const LLSD& key) +bool LLFloaterReg::destroyInstance(std::string_view name, const LLSD& key) { LLFloater* inst = removeInstance(name, key); if (inst) @@ -232,7 +249,7 @@ bool LLFloaterReg::destroyInstance(const std::string& name, const LLSD& key) // Iterators //static -LLFloaterReg::const_instance_list_t& LLFloaterReg::getFloaterList(const std::string& name) +LLFloaterReg::const_instance_list_t& LLFloaterReg::getFloaterList(std::string_view name) { instance_map_t::iterator iter = sInstanceMap.find(name); if (iter != sInstanceMap.end()) @@ -248,7 +265,7 @@ LLFloaterReg::const_instance_list_t& LLFloaterReg::getFloaterList(const std::str // Visibility Management //static -LLFloater* LLFloaterReg::showInstance(const std::string& name, const LLSD& key, bool focus) +LLFloater* LLFloaterReg::showInstance(std::string_view name, const LLSD& key, bool focus) { if( sBlockShowFloaters // see EXT-7090 @@ -266,7 +283,7 @@ LLFloater* LLFloaterReg::showInstance(const std::string& name, const LLSD& key, //static // returns true if the instance exists -bool LLFloaterReg::hideInstance(const std::string& name, const LLSD& key) +bool LLFloaterReg::hideInstance(std::string_view name, const LLSD& key) { LLFloater* instance = findInstance(name, key); if (instance) @@ -278,7 +295,7 @@ bool LLFloaterReg::hideInstance(const std::string& name, const LLSD& key) //static // returns true if the instance is visible when completed -bool LLFloaterReg::toggleInstance(const std::string& name, const LLSD& key) +bool LLFloaterReg::toggleInstance(std::string_view name, const LLSD& key) { LLFloater* instance = findInstance(name, key); if (instance && instance->isShown()) @@ -294,7 +311,7 @@ bool LLFloaterReg::toggleInstance(const std::string& name, const LLSD& key) //static // returns true if the instance exists and is visible (doesnt matter minimized or not) -bool LLFloaterReg::instanceVisible(const std::string& name, const LLSD& key) +bool LLFloaterReg::instanceVisible(std::string_view name, const LLSD& key) { LLFloater* instance = findInstance(name, key); return LLFloater::isVisible(instance); diff --git a/indra/llui/llfloaterreg.h b/indra/llui/llfloaterreg.h index 6a642cbb27..94a67c8d8b 100644 --- a/indra/llui/llfloaterreg.h +++ b/indra/llui/llfloaterreg.h @@ -51,26 +51,26 @@ public: // 2) We can change the key of a floater without altering the list. typedef std::list<LLFloater*> instance_list_t; typedef const instance_list_t const_instance_list_t; - typedef std::map<std::string, instance_list_t> instance_map_t; + typedef std::map<std::string, instance_list_t, std::less<>> instance_map_t; struct BuildData { LLFloaterBuildFunc mFunc; std::string mFile; }; - typedef std::map<std::string, BuildData> build_map_t; + typedef std::map<std::string, BuildData, std::less<>> build_map_t; private: friend class LLFloaterRegListener; static instance_list_t sNullInstanceList; static instance_map_t sInstanceMap; static build_map_t sBuildMap; - static std::map<std::string,std::string> sGroupMap; + static std::map<std::string, std::string, std::less<>> sGroupMap; static bool sBlockShowFloaters; /** * Defines list of floater names that can be shown despite state of sBlockShowFloaters. */ - static std::set<std::string> sAlwaysShowableList; + static std::set<std::string, std::less<>> sAlwaysShowableList; public: // Registration @@ -85,30 +85,30 @@ public: static void add(const std::string& name, const std::string& file, const LLFloaterBuildFunc& func, const std::string& groupname = LLStringUtil::null); - static bool isRegistered(const std::string& name); + static bool isRegistered(std::string_view name); // Helpers - static LLFloater* getLastFloaterInGroup(const std::string& name); + static LLFloater* getLastFloaterInGroup(std::string_view name); static LLFloater* getLastFloaterCascading(); // Find / get (create) / remove / destroy - static LLFloater* findInstance(const std::string& name, const LLSD& key = LLSD()); - static LLFloater* getInstance(const std::string& name, const LLSD& key = LLSD()); - static LLFloater* removeInstance(const std::string& name, const LLSD& key = LLSD()); - static bool destroyInstance(const std::string& name, const LLSD& key = LLSD()); + static LLFloater* findInstance(std::string_view name, const LLSD& key = LLSD()); + static LLFloater* getInstance(std::string_view name, const LLSD& key = LLSD()); + static LLFloater* removeInstance(std::string_view name, const LLSD& key = LLSD()); + static bool destroyInstance(std::string_view name, const LLSD& key = LLSD()); // Iterators - static const_instance_list_t& getFloaterList(const std::string& name); + static const_instance_list_t& getFloaterList(std::string_view name); // Visibility Management // return NULL if instance not found or can't create instance (no builder) - static LLFloater* showInstance(const std::string& name, const LLSD& key = LLSD(), bool focus = false); + static LLFloater* showInstance(std::string_view name, const LLSD& key = LLSD(), bool focus = false); // Close a floater (may destroy or set invisible) // return false if can't find instance - static bool hideInstance(const std::string& name, const LLSD& key = LLSD()); + static bool hideInstance(std::string_view name, const LLSD& key = LLSD()); // return true if instance is visible: - static bool toggleInstance(const std::string& name, const LLSD& key = LLSD()); - static bool instanceVisible(const std::string& name, const LLSD& key = LLSD()); + static bool toggleInstance(std::string_view name, const LLSD& key = LLSD()); + static bool instanceVisible(std::string_view name, const LLSD& key = LLSD()); static void showInitialVisibleInstances(); static void hideVisibleInstances(const std::set<std::string>& exceptions = std::set<std::string>()); @@ -133,19 +133,19 @@ public: // Typed find / get / show template <class T> - static T* findTypedInstance(const std::string& name, const LLSD& key = LLSD()) + static T* findTypedInstance(std::string_view name, const LLSD& key = LLSD()) { return dynamic_cast<T*>(findInstance(name, key)); } template <class T> - static T* getTypedInstance(const std::string& name, const LLSD& key = LLSD()) + static T* getTypedInstance(std::string_view name, const LLSD& key = LLSD()) { return dynamic_cast<T*>(getInstance(name, key)); } template <class T> - static T* showTypedInstance(const std::string& name, const LLSD& key = LLSD(), bool focus = false) + static T* showTypedInstance(std::string_view name, const LLSD& key = LLSD(), bool focus = false) { return dynamic_cast<T*>(showInstance(name, key, focus)); } diff --git a/indra/llui/llfloaterreglistener.cpp b/indra/llui/llfloaterreglistener.cpp index aa3d1a1171..17641b8375 100644 --- a/indra/llui/llfloaterreglistener.cpp +++ b/indra/llui/llfloaterreglistener.cpp @@ -94,22 +94,22 @@ void LLFloaterRegListener::getBuildMap(const LLSD& event) const void LLFloaterRegListener::showInstance(const LLSD& event) const { - LLFloaterReg::showInstance(event["name"], event["key"], event["focus"]); + LLFloaterReg::showInstance(event["name"].asString(), event["key"], event["focus"]); } void LLFloaterRegListener::hideInstance(const LLSD& event) const { - LLFloaterReg::hideInstance(event["name"], event["key"]); + LLFloaterReg::hideInstance(event["name"].asString(), event["key"]); } void LLFloaterRegListener::toggleInstance(const LLSD& event) const { - LLFloaterReg::toggleInstance(event["name"], event["key"]); + LLFloaterReg::toggleInstance(event["name"].asString(), event["key"]); } void LLFloaterRegListener::instanceVisible(const LLSD& event) const { - sendReply(LLSDMap("visible", LLFloaterReg::instanceVisible(event["name"], event["key"])), + sendReply(LLSDMap("visible", LLFloaterReg::instanceVisible(event["name"].asString(), event["key"])), event); } @@ -119,7 +119,7 @@ void LLFloaterRegListener::clickButton(const LLSD& event) const LLReqID reqID(event); LLSD reply(reqID.makeResponse()); - LLFloater* floater = LLFloaterReg::findInstance(event["name"], event["key"]); + LLFloater* floater = LLFloaterReg::findInstance(event["name"].asString(), event["key"]); if (! LLFloater::isShown(floater)) { reply["type"] = "LLFloater"; @@ -131,7 +131,7 @@ void LLFloaterRegListener::clickButton(const LLSD& event) const { // Here 'floater' points to an LLFloater instance with the specified // name and key which isShown(). - LLButton* button = floater->findChild<LLButton>(event["button"]); + LLButton* button = floater->findChild<LLButton>(event["button"].asString()); if (! LLButton::isAvailable(button)) { reply["type"] = "LLButton"; diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 82cd2483e8..4c1733506c 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -950,7 +950,7 @@ void LLFolderViewItem::draw() S32 filter_offset = static_cast<S32>(mViewModelItem->getFilterStringOffset()); if (filter_string_length > 0) { - S32 bottom = llfloor(getRect().getHeight() - font->getLineHeight() - 3 - TOP_PAD); + S32 bottom = getRect().getHeight() - font->getLineHeight() - 3 - TOP_PAD; S32 top = getRect().getHeight() - TOP_PAD; if(mLabelSuffix.empty() || (font == suffix_font)) { @@ -966,8 +966,8 @@ void LLFolderViewItem::draw() S32 label_filter_length = llmin((S32)mLabel.size() - filter_offset, (S32)filter_string_length); if(label_filter_length > 0) { - S32 left = ll_round(text_left) + font->getWidthF32(mLabel, 0, llmin(filter_offset, (S32)mLabel.size())) - 2; - S32 right = left + font->getWidthF32(mLabel, filter_offset, label_filter_length) + 2; + S32 left = (S32)(ll_round(text_left) + font->getWidthF32(mLabel, 0, llmin(filter_offset, (S32)mLabel.size()))) - 2; + S32 right = left + (S32)font->getWidthF32(mLabel, filter_offset, label_filter_length) + 2; LLUIImage* box_image = default_params.selection_image; LLRect box_rect(left, top, right, bottom); box_image->draw(box_rect, sFilterBGColor); @@ -976,8 +976,8 @@ void LLFolderViewItem::draw() if(suffix_filter_length > 0) { S32 suffix_offset = llmax(0, filter_offset - (S32)mLabel.size()); - S32 left = ll_round(text_left) + font->getWidthF32(mLabel, 0, static_cast<S32>(mLabel.size())) + suffix_font->getWidthF32(mLabelSuffix, 0, suffix_offset) - 2; - S32 right = left + suffix_font->getWidthF32(mLabelSuffix, suffix_offset, suffix_filter_length) + 2; + S32 left = (S32)(ll_round(text_left) + font->getWidthF32(mLabel, 0, static_cast<S32>(mLabel.size())) + suffix_font->getWidthF32(mLabelSuffix, 0, suffix_offset))- 2; + S32 right = left + (S32)suffix_font->getWidthF32(mLabelSuffix, suffix_offset, suffix_filter_length) + 2; LLUIImage* box_image = default_params.selection_image; LLRect box_rect(left, top, right, bottom); box_image->draw(box_rect, sFilterBGColor); diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 5e184b5ddb..cc567adb75 100644 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -164,13 +164,13 @@ std::string LLKeywords::getArguments(LLSD& arguments) return argString; } -std::string LLKeywords::getAttribute(const std::string& key) +std::string LLKeywords::getAttribute(std::string_view key) { attribute_iterator_t it = mAttributes.find(key); return (it != mAttributes.end()) ? it->second : ""; } -LLColor4 LLKeywords::getColorGroup(const std::string& key_in) +LLColor4 LLKeywords::getColorGroup(std::string_view key_in) { std::string color_group = "ScriptText"; if (key_in == "functions") @@ -261,7 +261,7 @@ void LLKeywords::processTokens() LL_INFOS("SyntaxLSL") << "Finished processing tokens." << LL_ENDL; } -void LLKeywords::processTokensGroup(const LLSD& tokens, const std::string& group) +void LLKeywords::processTokensGroup(const LLSD& tokens, std::string_view group) { LLColor4 color; LLColor4 color_group; @@ -333,7 +333,7 @@ void LLKeywords::processTokensGroup(const LLSD& tokens, const std::string& group case LLKeywordToken::TT_CONSTANT: if (getAttribute("type").length() > 0) { - color_group = getColorGroup(group + "-" + getAttribute("type")); + color_group = getColorGroup(std::string(group) + "-" + getAttribute("type")); } else { @@ -501,7 +501,7 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW { if( *cur == '\n' ) { - LLTextSegmentPtr text_segment = new LLLineBreakTextSegment(style, cur-base); + LLTextSegmentPtr text_segment = new LLLineBreakTextSegment(style, (S32)(cur - base)); text_segment->setToken( 0 ); insertSegment( *seg_list, text_segment, text_len, style, editor); cur++; @@ -532,13 +532,13 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW LLKeywordToken* cur_token = *iter; if( cur_token->isHead( cur ) ) { - S32 seg_start = cur - base; + S32 seg_start = (S32)(cur - base); while( *cur && *cur != '\n' ) { // skip the rest of the line cur++; } - S32 seg_end = cur - base; + S32 seg_end = (S32)(cur - base); //create segments from seg_start to seg_end insertSegments(wtext, *seg_list,cur_token, text_len, seg_start, seg_end, style, editor); @@ -582,7 +582,7 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW S32 between_delimiters = 0; S32 seg_end = 0; - seg_start = cur - base; + seg_start = (S32)(cur - base); cur += cur_delimiter->getLengthHead(); LLKeywordToken::ETokenType type = cur_delimiter->getType(); @@ -669,7 +669,7 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW { p++; } - S32 seg_len = p - cur; + S32 seg_len = (S32)(p - cur); if( seg_len > 0 ) { WStringMapIndex word( cur, seg_len ); @@ -677,7 +677,7 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW if( map_iter != mWordTokenMap.end() ) { LLKeywordToken* cur_token = map_iter->second; - S32 seg_start = cur - base; + S32 seg_start = (S32)(cur - base); S32 seg_end = seg_start + seg_len; // LL_INFOS("SyntaxLSL") << "Seg: [" << word.c_str() << "]" << LL_ENDL; diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index f498b3ddee..6df2da7cd3 100644 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -111,7 +111,7 @@ public: ~LLKeywords(); void clearLoaded() { mLoaded = false; } - LLColor4 getColorGroup(const std::string& key_in); + LLColor4 getColorGroup(std::string_view key_in); bool isLoaded() const { return mLoaded; } void findSegments(std::vector<LLTextSegmentPtr> *seg_list, @@ -170,7 +170,7 @@ public: #endif protected: - void processTokensGroup(const LLSD& Tokens, const std::string& Group); + void processTokensGroup(const LLSD& Tokens, std::string_view Group); void insertSegment(std::vector<LLTextSegmentPtr>& seg_list, LLTextSegmentPtr new_segment, S32 text_len, @@ -194,10 +194,10 @@ protected: token_list_t mLineTokenList; token_list_t mDelimiterTokenList; - typedef std::map<std::string, std::string> element_attributes_t; + typedef std::map<std::string, std::string, std::less<>> element_attributes_t; typedef element_attributes_t::const_iterator attribute_iterator_t; element_attributes_t mAttributes; - std::string getAttribute(const std::string& key); + std::string getAttribute(std::string_view key); std::string getArguments(LLSD& arguments); }; diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index 6db9f64a97..3a3aa7e4df 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -131,7 +131,7 @@ void LLLayoutPanel::setTargetDim(S32 value) S32 LLLayoutPanel::getVisibleDim() const { - F32 min_dim = getRelevantMinDim(); + F32 min_dim = (F32)getRelevantMinDim(); return ll_round(mVisibleAmt * (min_dim + (((F32)mTargetDim - min_dim) * (1.f - mCollapseAmt)))); @@ -209,7 +209,7 @@ LLLayoutStack::Params::Params() open_time_constant("open_time_constant", 0.02f), close_time_constant("close_time_constant", 0.03f), resize_bar_overlap("resize_bar_overlap", 1), - border_size("border_size", LLCachedControl<S32>(*LLUI::getInstance()->mSettingGroups["config"], "UIResizeBarHeight", 0)), + border_size("border_size", LLUI::getInstance()->mSettingGroups["config"]->getS32("UIResizeBarHeight")), show_drag_handle("show_drag_handle", false), drag_handle_first_indent("drag_handle_first_indent", 0), drag_handle_second_indent("drag_handle_second_indent", 0), @@ -445,7 +445,7 @@ void LLLayoutStack::updateLayout() for (LLLayoutPanel* panelp : mPanels) { - F32 panel_dim = llmax(panelp->getExpandedMinDim(), panelp->mTargetDim); + F32 panel_dim = (F32)llmax(panelp->getExpandedMinDim(), panelp->mTargetDim); LLRect panel_rect; if (mOrientation == HORIZONTAL) @@ -465,7 +465,7 @@ void LLLayoutStack::updateLayout() LLRect resize_bar_rect(panel_rect); F32 panel_spacing = (F32)mPanelSpacing * panelp->getVisibleAmount(); - F32 panel_visible_dim = panelp->getVisibleDim(); + F32 panel_visible_dim = (F32)panelp->getVisibleDim(); S32 panel_spacing_round = (S32)(ll_round(panel_spacing)); if (mOrientation == HORIZONTAL) @@ -548,7 +548,7 @@ LLLayoutPanel* LLLayoutStack::findEmbeddedPanel(LLPanel* panelp) const return NULL; } -LLLayoutPanel* LLLayoutStack::findEmbeddedPanelByName(const std::string& name) const +LLLayoutPanel* LLLayoutStack::findEmbeddedPanelByName(std::string_view name) const { LLLayoutPanel* result = NULL; diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h index 9e5f8048ba..8459921c60 100644 --- a/indra/llui/lllayoutstack.h +++ b/indra/llui/lllayoutstack.h @@ -111,7 +111,7 @@ private: e_panel_list_t mPanels; LLLayoutPanel* findEmbeddedPanel(LLPanel* panelp) const; - LLLayoutPanel* findEmbeddedPanelByName(const std::string& name) const; + LLLayoutPanel* findEmbeddedPanelByName(std::string_view name) const; void updateFractionalSizes(); void normalizeFractionalSizes(); void updatePanelRect( LLLayoutPanel* param1, const LLRect& new_rect ); diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 50bf3f5877..60b6115b34 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -74,7 +74,7 @@ static LLDefaultChildRegistry::Register<LLLineEditor> r1("line_editor"); // Compiler optimization, generate extern template template class LLLineEditor* LLView::getChild<class LLLineEditor>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; // // Member functions @@ -2109,7 +2109,7 @@ void LLLineEditor::draw() if (0 == mText.length() && (mReadOnly || mShowLabelFocused)) { mGLFont->render(mLabel.getWString(), 0, - mTextLeftEdge, (F32)text_bottom, + (F32)mTextLeftEdge, (F32)text_bottom, label_color, LLFontGL::LEFT, LLFontGL::BOTTOM, @@ -2134,7 +2134,7 @@ void LLLineEditor::draw() if (0 == mText.length()) { mGLFont->render(mLabel.getWString(), 0, - mTextLeftEdge, (F32)text_bottom, + (F32)mTextLeftEdge, (F32)text_bottom, label_color, LLFontGL::LEFT, LLFontGL::BOTTOM, diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index e955cbb17d..1cb7cac854 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -466,7 +466,7 @@ private: // Build time optimization, generate once in .cpp file #ifndef LLLINEEDITOR_CPP extern template class LLLineEditor* LLView::getChild<class LLLineEditor>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif // LL_LINEEDITOR_ diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index dffaf69a9f..0038a8ae18 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -988,7 +988,7 @@ LLMenuItemBranchGL::~LLMenuItemBranchGL() // virtual -LLView* LLMenuItemBranchGL::getChildView(const std::string& name, bool recurse) const +LLView* LLMenuItemBranchGL::getChildView(std::string_view name, bool recurse) const { LLMenuGL* branch = getBranch(); if (branch) @@ -1005,7 +1005,7 @@ LLView* LLMenuItemBranchGL::getChildView(const std::string& name, bool recurse) return LLView::getChildView(name, recurse); } -LLView* LLMenuItemBranchGL::findChildView(const std::string& name, bool recurse) const +LLView* LLMenuItemBranchGL::findChildView(std::string_view name, bool recurse) const { LLMenuGL* branch = getBranch(); if (branch) @@ -2752,7 +2752,7 @@ void LLMenuGL::setEnabledSubMenus(bool enable) // setItemEnabled() - pass the label and the enable flag for a menu // item. true will make sure it's enabled, false will disable it. -void LLMenuGL::setItemEnabled( const std::string& name, bool enable ) +void LLMenuGL::setItemEnabled(std::string_view name, bool enable ) { item_list_t::iterator item_iter; for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) @@ -2766,7 +2766,7 @@ void LLMenuGL::setItemEnabled( const std::string& name, bool enable ) } } -void LLMenuGL::setItemVisible( const std::string& name, bool visible ) +void LLMenuGL::setItemVisible(std::string_view name, bool visible ) { item_list_t::iterator item_iter; for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) @@ -3277,7 +3277,7 @@ void LLMenuGL::setVisible(bool visible) } } -LLMenuGL* LLMenuGL::findChildMenuByName(const std::string& name, bool recurse) const +LLMenuGL* LLMenuGL::findChildMenuByName(std::string_view name, bool recurse) const { LLView* view = findChildView(name, recurse); if (view) diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index 51766afe85..66f84393fe 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -456,7 +456,7 @@ public: virtual bool hasAccelerator(const KEY &key, const MASK &mask) const; virtual bool handleAcceleratorKey(KEY key, MASK mask); - LLMenuGL* findChildMenuByName(const std::string& name, bool recurse) const; + LLMenuGL* findChildMenuByName(std::string_view name, bool recurse) const; bool clearHoverItem(); @@ -479,12 +479,12 @@ public: // setItemEnabled() - pass the name and the enable flag for a // menu item. true will make sure it's enabled, false will disable // it. - void setItemEnabled( const std::string& name, bool enable ); + void setItemEnabled(std::string_view name, bool enable ); // propagate message to submenus void setEnabledSubMenus(bool enable); - void setItemVisible( const std::string& name, bool visible); + void setItemVisible(std::string_view name, bool visible); void setItemLabel(const std::string &name, const std::string &label); @@ -687,8 +687,8 @@ public: virtual void openMenu(); - virtual LLView* getChildView(const std::string& name, bool recurse = true) const; - virtual LLView* findChildView(const std::string& name, bool recurse = true) const; + virtual LLView* getChildView(std::string_view name, bool recurse = true) const; + virtual LLView* findChildView(std::string_view name, bool recurse = true) const; private: LLHandle<LLView> mBranchHandle; diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index bee7d5bb3f..cd80e7f63f 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -266,7 +266,7 @@ LLSD LLNotificationForm::asLLSD() const return mFormData; } -LLSD LLNotificationForm::getElement(const std::string& element_name) +LLSD LLNotificationForm::getElement(std::string_view element_name) { for (LLSD::array_const_iterator it = mFormData.beginArray(); it != mFormData.endArray(); @@ -278,7 +278,7 @@ LLSD LLNotificationForm::getElement(const std::string& element_name) } -bool LLNotificationForm::hasElement(const std::string& element_name) const +bool LLNotificationForm::hasElement(std::string_view element_name) const { for (LLSD::array_const_iterator it = mFormData.beginArray(); it != mFormData.endArray(); @@ -301,7 +301,7 @@ void LLNotificationForm::getElements(LLSD& elements, S32 offset) } } -bool LLNotificationForm::getElementEnabled(const std::string& element_name) const +bool LLNotificationForm::getElementEnabled(std::string_view element_name) const { for (LLSD::array_const_iterator it = mFormData.beginArray(); it != mFormData.endArray(); @@ -316,7 +316,7 @@ bool LLNotificationForm::getElementEnabled(const std::string& element_name) cons return false; } -void LLNotificationForm::setElementEnabled(const std::string& element_name, bool enabled) +void LLNotificationForm::setElementEnabled(std::string_view element_name, bool enabled) { for (LLSD::array_iterator it = mFormData.beginArray(); it != mFormData.endArray(); @@ -439,7 +439,7 @@ LLNotificationTemplate::LLNotificationTemplate(const LLNotificationTemplate::Par mSoundName("") { if (p.sound.isProvided() - && LLUI::getInstance()->mSettingGroups["config"]->controlExists(p.sound)) + && LLUI::getInstance()->mSettingGroups["config"]->controlExists(p.sound())) { mSoundName = p.sound; } @@ -769,7 +769,7 @@ bool LLNotification::hasUniquenessConstraints() const return (mTemplatep ? mTemplatep->mUnique : false); } -bool LLNotification::matchesTag(const std::string& tag) +bool LLNotification::matchesTag(std::string_view tag) { bool result = false; @@ -861,7 +861,7 @@ void LLNotification::init(const std::string& template_name, const LLSD& form_ele for (LLStringUtil::format_map_t::const_iterator iter = default_args.begin(); iter != default_args.end(); ++iter) { - mSubstitutions[iter->first] = iter->second; + mSubstitutions[std::string(iter->first)] = iter->second; } mSubstitutions["_URL"] = getURL(); mSubstitutions["_NAME"] = template_name; @@ -1443,11 +1443,12 @@ void LLNotifications::createDefaultChannels() } -LLNotificationTemplatePtr LLNotifications::getTemplate(const std::string& name) +LLNotificationTemplatePtr LLNotifications::getTemplate(std::string_view name) { - if (mTemplates.count(name)) + auto it = mTemplates.find(name); + if (it != mTemplates.end()) { - return mTemplates[name]; + return it->second; } else { @@ -1455,7 +1456,7 @@ LLNotificationTemplatePtr LLNotifications::getTemplate(const std::string& name) } } -bool LLNotifications::templateExists(const std::string& name) +bool LLNotifications::templateExists(std::string_view name) { return (mTemplates.count(name) != 0); } @@ -1740,7 +1741,7 @@ void LLNotifications::cancel(LLNotificationPtr pNotif) } } -void LLNotifications::cancelByName(const std::string& name) +void LLNotifications::cancelByName(std::string_view name) { LLMutexLock lock(&mItemsMutex); std::vector<LLNotificationPtr> notifs_to_cancel; @@ -1815,7 +1816,7 @@ LLNotificationPtr LLNotifications::find(LLUUID uuid) } } -std::string LLNotifications::getGlobalString(const std::string& key) const +std::string LLNotifications::getGlobalString(std::string_view key) const { GlobalStringMap::const_iterator it = mGlobalStrings.find(key); if (it != mGlobalStrings.end()) @@ -1826,7 +1827,7 @@ std::string LLNotifications::getGlobalString(const std::string& key) const { // if we don't have the key as a global, return the key itself so that the error // is self-diagnosing. - return key; + return std::string(key); } } @@ -1839,13 +1840,13 @@ bool LLNotifications::getIgnoreAllNotifications() return mIgnoreAllNotifications; } -void LLNotifications::setIgnored(const std::string& name, bool ignored) +void LLNotifications::setIgnored(std::string_view name, bool ignored) { LLNotificationTemplatePtr templatep = getTemplate(name); templatep->mForm->setIgnored(ignored); } -bool LLNotifications::getIgnored(const std::string& name) +bool LLNotifications::getIgnored(std::string_view name) { LLNotificationTemplatePtr templatep = getTemplate(name); return (mIgnoreAllNotifications) || ( (templatep->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO) && (templatep->mForm->getIgnored()) ); diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index d3615b6601..1a197f8a17 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -251,11 +251,11 @@ public: S32 getNumElements() { return static_cast<S32>(mFormData.size()); } LLSD getElement(S32 index) { return mFormData.get(index); } - LLSD getElement(const std::string& element_name); + LLSD getElement(std::string_view element_name); void getElements(LLSD& elements, S32 offset = 0); - bool hasElement(const std::string& element_name) const; - bool getElementEnabled(const std::string& element_name) const; - void setElementEnabled(const std::string& element_name, bool enabled); + bool hasElement(std::string_view element_name) const; + bool getElementEnabled(std::string_view element_name) const; + void setElementEnabled(std::string_view element_name, bool enabled); void addElement(const std::string& type, const std::string& name, const LLSD& value = LLSD(), bool enabled = true); void formatElements(const LLSD& substitutions); // appends form elements from another form serialized as LLSD @@ -641,7 +641,7 @@ public: bool hasUniquenessConstraints() const; - bool matchesTag(const std::string& tag); + bool matchesTag(std::string_view tag); virtual ~LLNotification() {} }; @@ -926,7 +926,7 @@ public: void add(const LLNotificationPtr pNotif); void load(const LLNotificationPtr pNotif); void cancel(LLNotificationPtr pNotif); - void cancelByName(const std::string& name); + void cancelByName(std::string_view name); void cancelByOwner(const LLUUID ownerId); void update(const LLNotificationPtr pNotif); @@ -934,19 +934,19 @@ public: // This is all stuff for managing the templates // take your template out - LLNotificationTemplatePtr getTemplate(const std::string& name); + LLNotificationTemplatePtr getTemplate(std::string_view name); // get the whole collection typedef std::vector<std::string> TemplateNames; TemplateNames getTemplateNames() const; // returns a list of notification names - typedef std::map<std::string, LLNotificationTemplatePtr> TemplateMap; + typedef std::map<std::string, LLNotificationTemplatePtr, std::less<>> TemplateMap; TemplateMap::const_iterator templatesBegin() { return mTemplates.begin(); } TemplateMap::const_iterator templatesEnd() { return mTemplates.end(); } // test for existence - bool templateExists(const std::string& name); + bool templateExists(std::string_view name); typedef std::list<LLNotificationVisibilityRulePtr> VisibilityRuleList; @@ -956,13 +956,13 @@ public: LLNotificationChannelPtr getChannel(const std::string& channelName); - std::string getGlobalString(const std::string& key) const; + std::string getGlobalString(std::string_view key) const; void setIgnoreAllNotifications(bool ignore); bool getIgnoreAllNotifications(); - void setIgnored(const std::string& name, bool ignored); - bool getIgnored(const std::string& name); + void setIgnored(std::string_view name, bool ignored); + bool getIgnored(std::string_view name); bool isVisibleByRules(LLNotificationPtr pNotification); @@ -988,7 +988,7 @@ private: LLNotificationMap mUniqueNotifications; - typedef std::map<std::string, std::string> GlobalStringMap; + typedef std::map<std::string, std::string, std::less<>> GlobalStringMap; GlobalStringMap mGlobalStrings; bool mIgnoreAllNotifications; diff --git a/indra/llui/llnotificationslistener.cpp b/indra/llui/llnotificationslistener.cpp index ace9e37e25..9c1fc27c51 100644 --- a/indra/llui/llnotificationslistener.cpp +++ b/indra/llui/llnotificationslistener.cpp @@ -191,7 +191,7 @@ void LLNotificationsListener::ignore(const LLSD& params) const if (params["name"].isDefined()) { // ["name"] was passed: ignore just that notification - LLNotificationTemplatePtr templatep = mNotifications.getTemplate(params["name"]); + LLNotificationTemplatePtr templatep = mNotifications.getTemplate(params["name"].asStringRef()); if (templatep) { templatep->mForm->setIgnored(ignore); diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index 468cdb10fb..ab3433af98 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -55,7 +55,7 @@ LLPanel::factory_stack_t LLPanel::sFactoryStack; // Compiler optimization, generate extern template template class LLPanel* LLView::getChild<class LLPanel>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; LLPanel::LocalizedString::LocalizedString() : name("name"), @@ -277,7 +277,7 @@ void LLPanel::setDefaultBtn(LLButton* btn) } } -void LLPanel::setDefaultBtn(const std::string& id) +void LLPanel::setDefaultBtn(std::string_view id) { LLButton *button = getChild<LLButton>(id); if (button) @@ -593,12 +593,12 @@ bool LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu return true; } -bool LLPanel::hasString(const std::string& name) +bool LLPanel::hasString(std::string_view name) { return mUIStrings.find(name) != mUIStrings.end(); } -std::string LLPanel::getString(const std::string& name, const LLStringUtil::format_map_t& args) const +std::string LLPanel::getString(std::string_view name, const LLStringUtil::format_map_t& args) const { ui_string_map_t::const_iterator found_it = mUIStrings.find(name); if (found_it != mUIStrings.end()) @@ -608,7 +608,7 @@ std::string LLPanel::getString(const std::string& name, const LLStringUtil::form formatted_string.setArgList(args); return formatted_string.getString(); } - std::string err_str("Failed to find string " + name + " in panel " + getName()); //*TODO: Translate + std::string err_str("Failed to find string " + std::string(name) + " in panel " + getName()); //*TODO: Translate if(LLUI::getInstance()->mSettingGroups["config"]->getBOOL("QAMode")) { LL_ERRS() << err_str << LL_ENDL; @@ -620,14 +620,14 @@ std::string LLPanel::getString(const std::string& name, const LLStringUtil::form return LLStringUtil::null; } -std::string LLPanel::getString(const std::string& name) const +std::string LLPanel::getString(std::string_view name) const { ui_string_map_t::const_iterator found_it = mUIStrings.find(name); if (found_it != mUIStrings.end()) { return found_it->second; } - std::string err_str("Failed to find string " + name + " in panel " + getName()); //*TODO: Translate + std::string err_str("Failed to find string " + std::string(name) +" in panel " + getName()); //*TODO: Translate if(LLUI::getInstance()->mSettingGroups["config"]->getBOOL("QAMode")) { LL_ERRS() << err_str << LL_ENDL; @@ -640,7 +640,7 @@ std::string LLPanel::getString(const std::string& name) const } -void LLPanel::childSetVisible(const std::string& id, bool visible) +void LLPanel::childSetVisible(std::string_view id, bool visible) { LLView* child = findChild<LLView>(id); if (child) @@ -649,7 +649,7 @@ void LLPanel::childSetVisible(const std::string& id, bool visible) } } -void LLPanel::childSetEnabled(const std::string& id, bool enabled) +void LLPanel::childSetEnabled(std::string_view id, bool enabled) { LLView* child = findChild<LLView>(id); if (child) @@ -658,7 +658,7 @@ void LLPanel::childSetEnabled(const std::string& id, bool enabled) } } -void LLPanel::childSetFocus(const std::string& id, bool focus) +void LLPanel::childSetFocus(std::string_view id, bool focus) { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -667,7 +667,7 @@ void LLPanel::childSetFocus(const std::string& id, bool focus) } } -bool LLPanel::childHasFocus(const std::string& id) +bool LLPanel::childHasFocus(std::string_view id) { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -684,7 +684,7 @@ bool LLPanel::childHasFocus(const std::string& id) // Prefer getChild<LLUICtrl>("foo")->setCommitCallback(boost:bind(...)), // which takes a generic slot. Or use mCommitCallbackRegistrar.add() with // a named callback and reference it in XML. -void LLPanel::childSetCommitCallback(const std::string& id, boost::function<void (LLUICtrl*,void*)> cb, void* data) +void LLPanel::childSetCommitCallback(std::string_view id, boost::function<void (LLUICtrl*,void*)> cb, void* data) { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -693,7 +693,7 @@ void LLPanel::childSetCommitCallback(const std::string& id, boost::function<void } } -void LLPanel::childSetColor(const std::string& id, const LLColor4& color) +void LLPanel::childSetColor(std::string_view id, const LLColor4& color) { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -702,7 +702,7 @@ void LLPanel::childSetColor(const std::string& id, const LLColor4& color) } } -LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(const std::string& id) const +LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(std::string_view id) const { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -712,7 +712,7 @@ LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(const std::string& return NULL; } -LLCtrlListInterface* LLPanel::childGetListInterface(const std::string& id) const +LLCtrlListInterface* LLPanel::childGetListInterface(std::string_view id) const { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -722,7 +722,7 @@ LLCtrlListInterface* LLPanel::childGetListInterface(const std::string& id) const return NULL; } -LLCtrlScrollInterface* LLPanel::childGetScrollInterface(const std::string& id) const +LLCtrlScrollInterface* LLPanel::childGetScrollInterface(std::string_view id) const { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -732,7 +732,7 @@ LLCtrlScrollInterface* LLPanel::childGetScrollInterface(const std::string& id) c return NULL; } -void LLPanel::childSetValue(const std::string& id, LLSD value) +void LLPanel::childSetValue(std::string_view id, LLSD value) { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -741,7 +741,7 @@ void LLPanel::childSetValue(const std::string& id, LLSD value) } } -LLSD LLPanel::childGetValue(const std::string& id) const +LLSD LLPanel::childGetValue(std::string_view id) const { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -752,7 +752,7 @@ LLSD LLPanel::childGetValue(const std::string& id) const return LLSD(); } -bool LLPanel::childSetTextArg(const std::string& id, const std::string& key, const LLStringExplicit& text) +bool LLPanel::childSetTextArg(std::string_view id, const std::string& key, const LLStringExplicit& text) { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -762,7 +762,7 @@ bool LLPanel::childSetTextArg(const std::string& id, const std::string& key, con return false; } -bool LLPanel::childSetLabelArg(const std::string& id, const std::string& key, const LLStringExplicit& text) +bool LLPanel::childSetLabelArg(std::string_view id, const std::string& key, const LLStringExplicit& text) { LLView* child = findChild<LLView>(id); if (child) @@ -772,7 +772,7 @@ bool LLPanel::childSetLabelArg(const std::string& id, const std::string& key, co return false; } -void LLPanel::childSetAction(const std::string& id, const commit_signal_t::slot_type& function) +void LLPanel::childSetAction(std::string_view id, const commit_signal_t::slot_type& function) { LLButton* button = findChild<LLButton>(id); if (button) @@ -781,7 +781,7 @@ void LLPanel::childSetAction(const std::string& id, const commit_signal_t::slot_ } } -void LLPanel::childSetAction(const std::string& id, boost::function<void(void*)> function, void* value) +void LLPanel::childSetAction(std::string_view id, boost::function<void(void*)> function, void* value) { LLButton* button = findChild<LLButton>(id); if (button) diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index 2be5573faf..f6aa91fb30 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -149,7 +149,7 @@ public: void setBackgroundOpaque(bool b) { mBgOpaque = b; } bool isBackgroundOpaque() const { return mBgOpaque; } void setDefaultBtn(LLButton* btn = NULL); - void setDefaultBtn(const std::string& id); + void setDefaultBtn(std::string_view id); void updateDefaultBtn(); void setLabel(const LLStringExplicit& label) { mLabel = label; } std::string getLabel() const { return mLabel; } @@ -169,47 +169,47 @@ public: void initFromParams(const Params& p); bool initPanelXML( LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node, const LLPanel::Params& default_params); - bool hasString(const std::string& name); - std::string getString(const std::string& name, const LLStringUtil::format_map_t& args) const; - std::string getString(const std::string& name) const; + bool hasString(std::string_view name); + std::string getString(std::string_view name, const LLStringUtil::format_map_t& args) const; + std::string getString(std::string_view name) const; // ** Wrappers for setting child properties by name ** -TomY // WARNING: These are deprecated, please use getChild<T>("name")->doStuff() idiom instead // LLView - void childSetVisible(const std::string& name, bool visible); + void childSetVisible(std::string_view name, bool visible); - void childSetEnabled(const std::string& name, bool enabled); - void childEnable(const std::string& name) { childSetEnabled(name, true); } - void childDisable(const std::string& name) { childSetEnabled(name, false); }; + void childSetEnabled(std::string_view name, bool enabled); + void childEnable(std::string_view name) { childSetEnabled(name, true); } + void childDisable(std::string_view name) { childSetEnabled(name, false); }; // LLUICtrl - void childSetFocus(const std::string& id, bool focus = true); - bool childHasFocus(const std::string& id); + void childSetFocus(std::string_view id, bool focus = true); + bool childHasFocus(std::string_view id); // *TODO: Deprecate; for backwards compatability only: // Prefer getChild<LLUICtrl>("foo")->setCommitCallback(boost:bind(...)), // which takes a generic slot. Or use mCommitCallbackRegistrar.add() with // a named callback and reference it in XML. - void childSetCommitCallback(const std::string& id, boost::function<void (LLUICtrl*,void*)> cb, void* data); - void childSetColor(const std::string& id, const LLColor4& color); + void childSetCommitCallback(std::string_view id, boost::function<void (LLUICtrl*,void*)> cb, void* data); + void childSetColor(std::string_view id, const LLColor4& color); - LLCtrlSelectionInterface* childGetSelectionInterface(const std::string& id) const; - LLCtrlListInterface* childGetListInterface(const std::string& id) const; - LLCtrlScrollInterface* childGetScrollInterface(const std::string& id) const; + LLCtrlSelectionInterface* childGetSelectionInterface(std::string_view id) const; + LLCtrlListInterface* childGetListInterface(std::string_view id) const; + LLCtrlScrollInterface* childGetScrollInterface(std::string_view id) const; // This is the magic bullet for data-driven UI - void childSetValue(const std::string& id, LLSD value); - LLSD childGetValue(const std::string& id) const; + void childSetValue(std::string_view id, LLSD value); + LLSD childGetValue(std::string_view id) const; // For setting text / label replacement params, e.g. "Hello [NAME]" // Not implemented for all types, defaults to noop, returns false if not applicaple - bool childSetTextArg(const std::string& id, const std::string& key, const LLStringExplicit& text); - bool childSetLabelArg(const std::string& id, const std::string& key, const LLStringExplicit& text); + bool childSetTextArg(std::string_view id, const std::string& key, const LLStringExplicit& text); + bool childSetLabelArg(std::string_view id, const std::string& key, const LLStringExplicit& text); // LLButton - void childSetAction(const std::string& id, boost::function<void(void*)> function, void* value); - void childSetAction(const std::string& id, const commit_signal_t::slot_type& function); + void childSetAction(std::string_view id, boost::function<void(void*)> function, void* value); + void childSetAction(std::string_view id, const commit_signal_t::slot_type& function); static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node = NULL); @@ -250,7 +250,7 @@ private: LLButton* mDefaultBtn; LLUIString mLabel; - typedef std::map<std::string, std::string> ui_string_map_t; + typedef std::map<std::string, std::string, std::less<>> ui_string_map_t; ui_string_map_t mUIStrings; @@ -259,7 +259,7 @@ private: // Build time optimization, generate once in .cpp file #ifndef LLPANEL_CPP extern template class LLPanel* LLView::getChild<class LLPanel>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif typedef boost::function<LLPanel* (void)> LLPanelClassCreatorFunc; @@ -277,7 +277,7 @@ public: mPanelClassesNames[tag] = func; } - LLPanel* createPanelClass(const std::string& tag) + LLPanel* createPanelClass(std::string_view tag) { param_name_map_t::iterator iT = mPanelClassesNames.find(tag); if(iT == mPanelClassesNames.end()) @@ -292,7 +292,7 @@ public: } private: - typedef std::map< std::string, LLPanelClassCreatorFunc> param_name_map_t; + typedef std::map< std::string, LLPanelClassCreatorFunc, std::less<>> param_name_map_t; param_name_map_t mPanelClassesNames; }; diff --git a/indra/llui/llscrollingpanellist.cpp b/indra/llui/llscrollingpanellist.cpp index b158d7b1b7..7696a27320 100644 --- a/indra/llui/llscrollingpanellist.cpp +++ b/indra/llui/llscrollingpanellist.cpp @@ -84,42 +84,35 @@ void LLScrollingPanelList::removePanel(LLScrollingPanel* panel) if (!mPanelList.empty()) { - for (iter = mPanelList.begin(); iter != mPanelList.end(); ++iter, ++index) - { - if (*iter == panel) - { - break; - } - } + LLScrollingPanelList::panel_list_t::const_iterator iter = + std::find(mPanelList.begin(), mPanelList.end(), panel); if (iter != mPanelList.end()) { - removePanel(index); + removeChild(panel); + mPanelList.erase(iter); + rearrange(); } } } -void LLScrollingPanelList::removePanel( U32 panel_index ) +void LLScrollingPanelList::removePanel(U32 panel_index) { - if ( mPanelList.empty() || panel_index >= mPanelList.size() ) + if (panel_index >= mPanelList.size()) { LL_WARNS() << "Panel index " << panel_index << " is out of range!" << LL_ENDL; return; } - else - { - removeChild( mPanelList.at(panel_index) ); - mPanelList.erase( mPanelList.begin() + panel_index ); - } + LLScrollingPanelList::panel_list_t::const_iterator iter = mPanelList.begin() + panel_index; + removeChild(*iter); + mPanelList.erase(iter); rearrange(); } void LLScrollingPanelList::updatePanels(bool allow_modify) { - for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin(); - iter != mPanelList.end(); ++iter) + for (LLScrollingPanel* childp : mPanelList) { - LLScrollingPanel *childp = *iter; childp->updatePanel(allow_modify); } } @@ -131,10 +124,8 @@ void LLScrollingPanelList::rearrange() if (!mPanelList.empty()) { new_width = new_height = mPadding * 2; - for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin(); - iter != mPanelList.end(); ++iter) + for (LLScrollingPanel* childp : mPanelList) { - LLScrollingPanel* childp = *iter; const LLRect& rect = childp->getRect(); if (mIsHorizontal) { @@ -180,10 +171,8 @@ void LLScrollingPanelList::rearrange() // Reposition each of the child views S32 pos = mIsHorizontal ? mPadding : rc.getHeight() - mPadding; - for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin(); - iter != mPanelList.end(); ++iter) + for (LLScrollingPanel* childp : mPanelList) { - LLScrollingPanel* childp = *iter; const LLRect& rect = childp->getRect(); if (mIsHorizontal) { @@ -211,10 +200,11 @@ void LLScrollingPanelList::updatePanelVisiblilty() getParent()->getRect().getHeight() - mPadding, &parent_screen_rect.mRight, &parent_screen_rect.mTop ); - for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin(); - iter != mPanelList.end(); ++iter) + for (LLScrollingPanel* childp : mPanelList) { - LLScrollingPanel *childp = *iter; + if (childp->isDead()) + continue; + const LLRect& local_rect = childp->getRect(); LLRect screen_rect; childp->localPointToScreen( diff --git a/indra/llui/llscrolllistcell.cpp b/indra/llui/llscrolllistcell.cpp index 403879646d..5dccf9a8ba 100644 --- a/indra/llui/llscrolllistcell.cpp +++ b/indra/llui/llscrolllistcell.cpp @@ -209,7 +209,7 @@ void LLScrollListBar::setValue(const LLSD& value) { if (value.has("ratio")) { - mRatio = value["ratio"].asReal(); + mRatio = (F32)value["ratio"].asReal(); } if (value.has("bottom")) { @@ -239,7 +239,7 @@ S32 LLScrollListBar::getWidth() const void LLScrollListBar::draw(const LLColor4& color, const LLColor4& highlight_color) const { S32 bar_width = getWidth() - mLeftPad - mRightPad; - S32 left = bar_width - bar_width * mRatio; + S32 left = (S32)(bar_width - bar_width * mRatio); left = llclamp(left, mLeftPad, getWidth() - mRightPad - 1); gl_rect_2d(left, mBottom, getWidth() - mRightPad, mBottom - 1, mColor); @@ -637,7 +637,7 @@ void LLScrollListIconText::draw(const LLColor4& color, const LLColor4& highlight switch (mFontAlignment) { case LLFontGL::LEFT: - start_text_x = icon_space + 1; + start_text_x = icon_space + 1.f; start_icon_x = 1; break; case LLFontGL::RIGHT: @@ -647,7 +647,7 @@ void LLScrollListIconText::draw(const LLColor4& color, const LLColor4& highlight case LLFontGL::HCENTER: F32 center = (F32)getWidth()* 0.5f; start_text_x = center + ((F32)icon_space * 0.5f); - start_icon_x = center - (((F32)icon_space + mFont->getWidth(mText.getString())) * 0.5f); + start_icon_x = (S32)(center - (((F32)icon_space + mFont->getWidth(mText.getString())) * 0.5f)); break; } mFont->render(mText.getWString(), 0, diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 74a9641836..8512555b49 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -1479,7 +1479,10 @@ const std::string LLScrollListCtrl::getSelectedItemLabel(S32 column) const item = getFirstSelected(); if (item) { - return item->getColumn(column)->getValue().asString(); + if (LLScrollListCell* cell = item->getColumn(column)) + { + return cell->getValue().asString(); + } } return LLStringUtil::null; @@ -2716,7 +2719,8 @@ struct SameSortColumn bool LLScrollListCtrl::setSort(S32 column_idx, bool ascending) { LLScrollListColumn* sort_column = getColumn(column_idx); - if (!sort_column) return false; + if (!sort_column) + return false; sort_column->mSortDirection = ascending ? LLScrollListColumn::ASCENDING : LLScrollListColumn::DESCENDING; @@ -2729,32 +2733,28 @@ bool LLScrollListCtrl::setSort(S32 column_idx, bool ascending) mSortColumns.push_back(new_sort_column); return true; } - else - { - // grab current sort column - sort_column_t cur_sort_column = mSortColumns.back(); - // remove any existing sort criterion referencing this column - // and add the new one - mSortColumns.erase(remove_if(mSortColumns.begin(), mSortColumns.end(), SameSortColumn(column_idx)), mSortColumns.end()); - mSortColumns.push_back(new_sort_column); + // grab current sort column + sort_column_t cur_sort_column = mSortColumns.back(); - // did the sort criteria change? - return (cur_sort_column != new_sort_column); - } + // remove any existing sort criterion referencing this column + // and add the new one + mSortColumns.erase(remove_if(mSortColumns.begin(), mSortColumns.end(), SameSortColumn(column_idx)), mSortColumns.end()); + mSortColumns.push_back(new_sort_column); + + // did the sort criteria change? + return cur_sort_column != new_sort_column; } S32 LLScrollListCtrl::getLinesPerPage() { - //if mPageLines is NOT provided display all item if (mPageLines) { return mPageLines; } - else - { - return mLineHeight ? mItemListRect.getHeight() / mLineHeight : getItemCount(); - } + + // If mPageLines is NOT provided then display all items + return mLineHeight ? mItemListRect.getHeight() / mLineHeight : getItemCount(); } @@ -2770,7 +2770,7 @@ void LLScrollListCtrl::sortByColumn(const std::string& name, bool ascending) column_map_t::iterator itor = mColumns.find(name); if (itor != mColumns.end()) { - sortByColumnIndex((*itor).second->mIndex, ascending); + sortByColumnIndex(itor->second->mIndex, ascending); } } @@ -3089,8 +3089,7 @@ std::string LLScrollListCtrl::getSortColumnName() { LLScrollListColumn* column = mSortColumns.empty() ? NULL : mColumnsIndexed[mSortColumns.back().first]; - if (column) return column->mName; - else return ""; + return column ? column->mName : LLStringUtil::null; } bool LLScrollListCtrl::hasSortOrder() const diff --git a/indra/llui/llspellcheck.cpp b/indra/llui/llspellcheck.cpp index 1615db5b52..9d8eadfd3f 100644 --- a/indra/llui/llspellcheck.cpp +++ b/indra/llui/llspellcheck.cpp @@ -448,7 +448,7 @@ void LLSpellChecker::removeDictionary(const std::string& dict_language) { LLFile::remove(dict_aff); } - dict_map.erase(it - dict_map.beginArray()); + dict_map.erase((LLSD::Integer)(it - dict_map.beginArray())); break; } } diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index adb1d51813..4273fae71e 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -66,7 +66,7 @@ F32 calc_tick_value(F32 min, F32 max) S32 num_whole_digits = llceil(logf(llabs(min + possible_tick_value)) * OO_LN10); for (S32 digit_count = -(num_whole_digits - 1); digit_count < 6; digit_count++) { - F32 test_tick_value = min + (possible_tick_value * pow(10.0, digit_count)); + F32 test_tick_value = min + (possible_tick_value * (F32)pow(10.0, digit_count)); if (is_approx_equal((F32)(S32)test_tick_value, test_tick_value)) { @@ -99,7 +99,7 @@ void calc_auto_scale_range(F32& min, F32& max, F32& tick) : llceil(logf(llabs(min)) * OO_LN10); const S32 num_digits = llmax(num_digits_max, num_digits_min); - const F32 power_of_10 = pow(10.0, num_digits - 1); + const F32 power_of_10 = (F32)pow(10.0, num_digits - 1); const F32 starting_max = power_of_10 * ((max < 0.f) ? -1 : 1); const F32 starting_min = power_of_10 * ((min < 0.f) ? -1 : 1); @@ -313,13 +313,13 @@ void LLStatBar::draw() const LLTrace::StatType<LLTrace::CountAccumulator>& count_stat = *mStat.countStatp; unit_label = std::string(count_stat.getUnitLabel()) + "/s"; - current = last_frame_recording.getPerSec(count_stat); - min = frame_recording.getPeriodMinPerSec(count_stat, num_frames); - max = frame_recording.getPeriodMaxPerSec(count_stat, num_frames); - mean = frame_recording.getPeriodMeanPerSec(count_stat, num_frames); + current = (F32)last_frame_recording.getPerSec(count_stat); + min = (F32)frame_recording.getPeriodMinPerSec(count_stat, num_frames); + max = (F32)frame_recording.getPeriodMaxPerSec(count_stat, num_frames); + mean = (F32)frame_recording.getPeriodMeanPerSec(count_stat, num_frames); if (mShowMedian) { - display_value = frame_recording.getPeriodMedianPerSec(count_stat, num_frames); + display_value = (F32)frame_recording.getPeriodMedianPerSec(count_stat, num_frames); } else { @@ -332,10 +332,10 @@ void LLStatBar::draw() const LLTrace::StatType<LLTrace::EventAccumulator>& event_stat = *mStat.eventStatp; unit_label = mUnitLabel.empty() ? event_stat.getUnitLabel() : mUnitLabel; - current = last_frame_recording.getLastValue(event_stat); - min = frame_recording.getPeriodMin(event_stat, num_frames); - max = frame_recording.getPeriodMax(event_stat, num_frames); - mean = frame_recording.getPeriodMean(event_stat, num_frames); + current = (F32)last_frame_recording.getLastValue(event_stat); + min = (F32)frame_recording.getPeriodMin(event_stat, num_frames); + max = (F32)frame_recording.getPeriodMax(event_stat, num_frames); + mean = (F32)frame_recording.getPeriodMean(event_stat, num_frames); display_value = mean; } break; @@ -344,15 +344,15 @@ void LLStatBar::draw() const LLTrace::StatType<LLTrace::SampleAccumulator>& sample_stat = *mStat.sampleStatp; unit_label = mUnitLabel.empty() ? sample_stat.getUnitLabel() : mUnitLabel; - current = last_frame_recording.getLastValue(sample_stat); - min = frame_recording.getPeriodMin(sample_stat, num_frames); - max = frame_recording.getPeriodMax(sample_stat, num_frames); - mean = frame_recording.getPeriodMean(sample_stat, num_frames); + current = (F32)last_frame_recording.getLastValue(sample_stat); + min = (F32)frame_recording.getPeriodMin(sample_stat, num_frames); + max = (F32)frame_recording.getPeriodMax(sample_stat, num_frames); + mean = (F32)frame_recording.getPeriodMean(sample_stat, num_frames); num_rapid_changes = calc_num_rapid_changes(frame_recording, sample_stat, RAPID_CHANGE_WINDOW); if (mShowMedian) { - display_value = frame_recording.getPeriodMedian(sample_stat, num_frames); + display_value = (F32)frame_recording.getPeriodMedian(sample_stat, num_frames); } else if (num_rapid_changes / RAPID_CHANGE_WINDOW.value() > MAX_RAPID_CHANGES_PER_SEC) { @@ -450,8 +450,8 @@ void LLStatBar::draw() } F32 span = (mOrientation == HORIZONTAL) - ? (bar_rect.getWidth()) - : (bar_rect.getHeight()); + ? (F32)(bar_rect.getWidth()) + : (F32)(bar_rect.getHeight()); if (mDisplayHistory && mStat.valid) { @@ -471,18 +471,18 @@ void LLStatBar::draw() switch(mStatType) { case STAT_COUNT: - min_value = recording.getPerSec(*mStat.countStatp); + min_value = (F32)recording.getPerSec(*mStat.countStatp); max_value = min_value; num_samples = recording.getSampleCount(*mStat.countStatp); break; case STAT_EVENT: - min_value = recording.getMin(*mStat.eventStatp); - max_value = recording.getMax(*mStat.eventStatp); + min_value = (F32)recording.getMin(*mStat.eventStatp); + max_value = (F32)recording.getMax(*mStat.eventStatp); num_samples = recording.getSampleCount(*mStat.eventStatp); break; case STAT_SAMPLE: - min_value = recording.getMin(*mStat.sampleStatp); - max_value = recording.getMax(*mStat.sampleStatp); + min_value = (F32)recording.getMin(*mStat.sampleStatp); + max_value = (F32)recording.getMax(*mStat.sampleStatp); num_samples = recording.getSampleCount(*mStat.sampleStatp); break; default: diff --git a/indra/llui/llstatgraph.cpp b/indra/llui/llstatgraph.cpp index d37f927073..95a9493323 100644 --- a/indra/llui/llstatgraph.cpp +++ b/indra/llui/llstatgraph.cpp @@ -70,11 +70,11 @@ void LLStatGraph::draw() if (mPerSec) { - mValue = recording.getPerSec(*mNewStatFloatp); + mValue = (F32)recording.getPerSec(*mNewStatFloatp); } else { - mValue = recording.getSum(*mNewStatFloatp); + mValue = (F32)recording.getSum(*mNewStatFloatp); } } diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index 06f584d372..595ab0bd2b 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -315,7 +315,7 @@ void LLTabContainer::reshape(S32 width, S32 height, bool called_from_parent) } //virtual -LLView* LLTabContainer::getChildView(const std::string& name, bool recurse) const +LLView* LLTabContainer::getChildView(std::string_view name, bool recurse) const { tuple_list_t::const_iterator itor; for (itor = mTabList.begin(); itor != mTabList.end(); ++itor) @@ -343,7 +343,7 @@ LLView* LLTabContainer::getChildView(const std::string& name, bool recurse) cons } //virtual -LLView* LLTabContainer::findChildView(const std::string& name, bool recurse) const +LLView* LLTabContainer::findChildView(std::string_view name, bool recurse) const { tuple_list_t::const_iterator itor; for (itor = mTabList.begin(); itor != mTabList.end(); ++itor) @@ -1401,7 +1401,7 @@ S32 LLTabContainer::getIndexForPanel(LLPanel* panel) return -1; } -S32 LLTabContainer::getPanelIndexByTitle(const std::string& title) +S32 LLTabContainer::getPanelIndexByTitle(std::string_view title) { for (S32 index = 0 ; index < (S32)mTabList.size(); index++) { @@ -1413,7 +1413,7 @@ S32 LLTabContainer::getPanelIndexByTitle(const std::string& title) return -1; } -LLPanel* LLTabContainer::getPanelByName(const std::string& name) +LLPanel* LLTabContainer::getPanelByName(std::string_view name) { for (S32 index = 0 ; index < (S32)mTabList.size(); index++) { @@ -1637,7 +1637,7 @@ bool LLTabContainer::setTab(S32 which) return is_visible; } -bool LLTabContainer::selectTabByName(const std::string& name) +bool LLTabContainer::selectTabByName(std::string_view name) { LLPanel* panel = getPanelByName(name); if (!panel) @@ -2189,7 +2189,7 @@ void LLTabContainer::setTabVisibility( LLPanel const *aPanel, bool aVisible ) LLTabTuple const *pTT = *itr; if( pTT->mVisible ) { - this->selectTab( itr - mTabList.begin() ); + this->selectTab((S32)(itr - mTabList.begin())); foundTab = true; break; } diff --git a/indra/llui/lltabcontainer.h b/indra/llui/lltabcontainer.h index b22eec2fe5..40f272ffa8 100644 --- a/indra/llui/lltabcontainer.h +++ b/indra/llui/lltabcontainer.h @@ -149,8 +149,8 @@ public: /*virtual*/ bool handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop, EDragAndDropType type, void* cargo_data, EAcceptance* accept, std::string& tooltip); - /*virtual*/ LLView* getChildView(const std::string& name, bool recurse = true) const; - /*virtual*/ LLView* findChildView(const std::string& name, bool recurse = true) const; + /*virtual*/ LLView* getChildView(std::string_view name, bool recurse = true) const; + /*virtual*/ LLView* findChildView(std::string_view name, bool recurse = true) const; /*virtual*/ void initFromParams(const LLPanel::Params& p); /*virtual*/ bool addChild(LLView* view, S32 tab_group = 0); /*virtual*/ bool postBuild(); @@ -190,8 +190,8 @@ public: S32 getTabCount(); LLPanel* getPanelByIndex(S32 index); S32 getIndexForPanel(LLPanel* panel); - S32 getPanelIndexByTitle(const std::string& title); - LLPanel* getPanelByName(const std::string& name); + S32 getPanelIndexByTitle(std::string_view title); + LLPanel* getPanelByName(std::string_view name); S32 getTotalTabWidth() const; void setCurrentTabName(const std::string& name); @@ -201,7 +201,7 @@ public: void selectPrevTab(); bool selectTabPanel( LLPanel* child ); bool selectTab(S32 which); - bool selectTabByName(const std::string& title); + bool selectTabByName(std::string_view title); void setCurrentPanelIndex(S32 index) { mCurrentTabIdx = index; } bool getTabPanelFlashing(LLPanel* child); diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 1d358a0e9d..8c3b317838 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -401,8 +401,8 @@ std::vector<LLRect> LLTextBase::getSelectionRects() // Use F32 otherwise a string of multiple segments // will accumulate a large error - F32 left_precise = line_iter->mRect.mLeft; - F32 right_precise = line_iter->mRect.mLeft; + F32 left_precise = (F32)line_iter->mRect.mLeft; + F32 right_precise = (F32)line_iter->mRect.mLeft; for (; segment_iter != mSegments.end(); ++segment_iter, segment_offset = 0) { @@ -448,8 +448,8 @@ std::vector<LLRect> LLTextBase::getSelectionRects() } LLRect selection_rect; - selection_rect.mLeft = left_precise; - selection_rect.mRight = right_precise; + selection_rect.mLeft = (S32)left_precise; + selection_rect.mRight = (S32)right_precise; selection_rect.mBottom = line_iter->mRect.mBottom; selection_rect.mTop = line_iter->mRect.mTop; @@ -598,7 +598,7 @@ void LLTextBase::drawCursor() // Make sure the IME is in the right place LLRect screen_pos = calcScreenRect(); - LLCoordGL ime_pos( screen_pos.mLeft + llfloor(cursor_rect.mLeft), screen_pos.mBottom + llfloor(cursor_rect.mTop) ); + LLCoordGL ime_pos( screen_pos.mLeft + cursor_rect.mLeft, screen_pos.mBottom + cursor_rect.mTop ); ime_pos.mX = (S32) (ime_pos.mX * LLUI::getScaleFactor().mV[VX]); ime_pos.mY = (S32) (ime_pos.mY * LLUI::getScaleFactor().mV[VY]); @@ -755,9 +755,9 @@ void LLTextBase::drawText() line_end = next_start; } - LLRectf text_rect(line.mRect.mLeft, line.mRect.mTop, line.mRect.mRight, line.mRect.mBottom); - text_rect.mRight = mDocumentView->getRect().getWidth(); // clamp right edge to document extents - text_rect.translate(mDocumentView->getRect().mLeft, mDocumentView->getRect().mBottom); // adjust by scroll position + LLRectf text_rect((F32)line.mRect.mLeft, (F32)line.mRect.mTop, (F32)line.mRect.mRight, (F32)line.mRect.mBottom); + text_rect.mRight = (F32)mDocumentView->getRect().getWidth(); // clamp right edge to document extents + text_rect.translate((F32)mDocumentView->getRect().mLeft, (F32)mDocumentView->getRect().mBottom); // adjust by scroll position // draw a single line of text S32 seg_start = line_start; @@ -802,13 +802,13 @@ void LLTextBase::drawText() S32 squiggle_start = 0, squiggle_end = 0, pony = 0; cur_segment->getDimensions(seg_start - cur_segment->getStart(), misspell_start - seg_start, squiggle_start, pony); cur_segment->getDimensions(misspell_start - cur_segment->getStart(), misspell_end - misspell_start, squiggle_end, pony); - squiggle_start += text_rect.mLeft; + squiggle_start += (S32)text_rect.mLeft; pony = (squiggle_end + 3) / 6; squiggle_start += squiggle_end / 2 - pony * 3; squiggle_end = squiggle_start + pony * 6; - S32 squiggle_bottom = text_rect.mBottom + (S32)cur_segment->getStyle()->getFont()->getDescenderHeight(); + S32 squiggle_bottom = (S32)text_rect.mBottom + (S32)cur_segment->getStyle()->getFont()->getDescenderHeight(); gGL.color4ub(255, 0, 0, 200); while (squiggle_start + 1 < squiggle_end) @@ -1674,7 +1674,7 @@ void LLTextBase::reflow() segment_set_t::iterator seg_iter = mSegments.begin(); S32 seg_offset = 0; S32 line_start_index = 0; - const F32 text_available_width = mVisibleTextRect.getWidth() - mHPad; // reserve room for margin + const F32 text_available_width = (F32)(mVisibleTextRect.getWidth() - mHPad); // reserve room for margin F32 remaining_pixels = text_available_width; S32 line_count = 0; @@ -1881,7 +1881,7 @@ S32 LLTextBase::getLineNumFromDocIndex( S32 doc_index, bool include_wordwrap) co line_list_t::const_iterator iter = std::upper_bound(mLineInfoList.begin(), mLineInfoList.end(), doc_index, line_end_compare()); if (include_wordwrap) { - return iter - mLineInfoList.begin(); + return (S32)(iter - mLineInfoList.begin()); } else { @@ -1918,7 +1918,7 @@ S32 LLTextBase::getFirstVisibleLine() const // binary search for line that starts before top of visible buffer line_list_t::const_iterator iter = std::lower_bound(mLineInfoList.begin(), mLineInfoList.end(), visible_region.mTop, compare_bottom()); - return iter - mLineInfoList.begin(); + return (S32)(iter - mLineInfoList.begin()); } std::pair<S32, S32> LLTextBase::getVisibleLines(bool require_fully_visible) @@ -1940,7 +1940,7 @@ std::pair<S32, S32> LLTextBase::getVisibleLines(bool require_fully_visible) first_iter = std::upper_bound(mLineInfoList.begin(), mLineInfoList.end(), visible_region.mTop, compare_bottom()); last_iter = std::lower_bound(mLineInfoList.begin(), mLineInfoList.end(), visible_region.mBottom, compare_top()); } - return std::pair<S32, S32>(first_iter - mLineInfoList.begin(), last_iter - mLineInfoList.begin()); + return std::pair<S32, S32>((S32)(first_iter - mLineInfoList.begin()), (S32)(last_iter - mLineInfoList.begin())); } @@ -2608,7 +2608,7 @@ S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, bool round, } S32 pos = getLength(); - F32 start_x = line_iter->mRect.mLeft + doc_rect.mLeft; + F32 start_x = (F32)(line_iter->mRect.mLeft + doc_rect.mLeft); segment_set_t::iterator line_seg_iter; S32 line_seg_offset; @@ -2626,7 +2626,7 @@ S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, bool round, if(newline) { - pos = segment_line_start + segmentp->getOffset(local_x - start_x, line_seg_offset, segment_line_length, round); + pos = segment_line_start + segmentp->getOffset(local_x - (S32)start_x, line_seg_offset, segment_line_length, round); break; } @@ -2656,7 +2656,7 @@ S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, bool round, } else { - offset = segmentp->getOffset(local_x - start_x, line_seg_offset, segment_line_length, round); + offset = segmentp->getOffset(local_x - (S32)start_x, line_seg_offset, segment_line_length, round); } pos = segment_line_start + offset; break; @@ -2703,7 +2703,7 @@ LLRect LLTextBase::getDocRectFromDocIndex(S32 pos) const getSegmentAndOffset(line_iter->mDocIndexStart, &line_seg_iter, &line_seg_offset); getSegmentAndOffset(pos, &cursor_seg_iter, &cursor_seg_offset); - F32 doc_left_precise = line_iter->mRect.mLeft; + F32 doc_left_precise = (F32)line_iter->mRect.mLeft; while(line_seg_iter != mSegments.end()) { @@ -2734,7 +2734,7 @@ LLRect LLTextBase::getDocRectFromDocIndex(S32 pos) const } LLRect doc_rect; - doc_rect.mLeft = doc_left_precise; + doc_rect.mLeft = (S32)doc_left_precise; doc_rect.mBottom = line_iter->mRect.mBottom; doc_rect.mTop = line_iter->mRect.mTop; @@ -3720,7 +3720,7 @@ bool LLInlineViewSegment::getDimensionsF32(S32 first_char, S32 num_chars, F32& w } else { - width = mLeftPad + mRightPad + mView->getRect().getWidth(); + width = (F32)(mLeftPad + mRightPad + mView->getRect().getWidth()); height = mBottomPad + mTopPad + mView->getRect().getHeight(); } @@ -3871,10 +3871,10 @@ F32 LLImageTextSegment::draw(S32 start, S32 end, S32 selection_start, S32 select S32 style_image_width = image->getWidth(); // Text is drawn from the top of the draw_rect downward - S32 text_center = draw_rect.mTop - (draw_rect.getHeight() / 2); + S32 text_center = (S32)(draw_rect.mTop - (draw_rect.getHeight() / 2.f)); // Align image to center of draw rect S32 image_bottom = text_center - (style_image_height / 2); - image->draw(draw_rect.mLeft, image_bottom, + image->draw((S32)draw_rect.mLeft, image_bottom, style_image_width, style_image_height, color); const S32 IMAGE_HPAD = 3; diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index 92551b682c..05af36b71e 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -39,7 +39,7 @@ static LLDefaultChildRegistry::Register<LLTextBox> r("text"); // Compiler optimization, generate extern template template class LLTextBox* LLView::getChild<class LLTextBox>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; LLTextBox::LLTextBox(const LLTextBox::Params& p) : LLTextBase(p), diff --git a/indra/llui/lltextbox.h b/indra/llui/lltextbox.h index c1f829c2b9..a3cde45cd0 100644 --- a/indra/llui/lltextbox.h +++ b/indra/llui/lltextbox.h @@ -81,7 +81,7 @@ protected: // Build time optimization, generate once in .cpp file #ifndef LLTEXTBOX_CPP extern template class LLTextBox* LLView::getChild<class LLTextBox>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index dc3026e14d..3537c764b9 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -71,7 +71,7 @@ static LLDefaultChildRegistry::Register<LLTextEditor> r("simple_text_editor"); // Compiler optimization, generate extern template template class LLTextEditor* LLView::getChild<class LLTextEditor>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; // // Constants @@ -2315,17 +2315,17 @@ void LLTextEditor::drawPreeditMarker() if (mPreeditStandouts[i]) { gl_rect_2d(preedit_left + preedit_standout_gap, - text_rect.mBottom + mFont->getDescenderHeight() - 1, + text_rect.mBottom + (S32)mFont->getDescenderHeight() - 1, preedit_right - preedit_standout_gap - 1, - text_rect.mBottom + mFont->getDescenderHeight() - 1 - preedit_standout_thickness, + text_rect.mBottom + (S32)mFont->getDescenderHeight() - 1 - preedit_standout_thickness, (mCursorColor.get() * preedit_standout_brightness + mWriteableBgColor.get() * (1 - preedit_standout_brightness)).setAlpha(1.0f)); } else { gl_rect_2d(preedit_left + preedit_marker_gap, - text_rect.mBottom + mFont->getDescenderHeight() - 1, + text_rect.mBottom + (S32)mFont->getDescenderHeight() - 1, preedit_right - preedit_marker_gap - 1, - text_rect.mBottom + mFont->getDescenderHeight() - 1 - preedit_marker_thickness, + text_rect.mBottom + (S32)mFont->getDescenderHeight() - 1 - preedit_marker_thickness, (mCursorColor.get() * preedit_marker_brightness + mWriteableBgColor.get() * (1 - preedit_marker_brightness)).setAlpha(1.0f)); } } diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index be7f7cb256..0b5acf19a1 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -345,7 +345,7 @@ private: // Build time optimization, generate once in .cpp file #ifndef LLTEXTEDITOR_CPP extern template class LLTextEditor* LLView::getChild<class LLTextEditor>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif // LL_TEXTEDITOR_H diff --git a/indra/llui/lltrans.cpp b/indra/llui/lltrans.cpp index 6c7e472a87..8410031653 100644 --- a/indra/llui/lltrans.cpp +++ b/indra/llui/lltrans.cpp @@ -65,7 +65,7 @@ bool LLTrans::parseStrings(LLXMLNodePtr &root, const std::set<std::string>& defa if (!root->hasName("strings")) { LL_ERRS() << "Invalid root node name in " << xml_filename - << ": was " << root->getName() << ", expected \"strings\"" << LL_ENDL; + << ": was " << root->getName()->mString << ", expected \"strings\"" << LL_ENDL; } StringTable string_table; @@ -113,7 +113,7 @@ bool LLTrans::parseLanguageStrings(LLXMLNodePtr &root) if (!root->hasName("strings")) { LL_ERRS() << "Invalid root node name in " << xml_filename - << ": was " << root->getName() << ", expected \"strings\"" << LL_ENDL; + << ": was " << root->getName()->mString << ", expected \"strings\"" << LL_ENDL; } StringTable string_table; @@ -143,7 +143,7 @@ bool LLTrans::parseLanguageStrings(LLXMLNodePtr &root) static LLTrace::BlockTimerStatHandle FTM_GET_TRANS("Translate string"); //static -std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& msg_args, bool def_string) +std::string LLTrans::getString(std::string_view xml_desc, const LLStringUtil::format_map_t& msg_args, bool def_string) { // Don't care about time as much as call count. Make sure we're not // calling LLTrans::getString() in an inner loop. JC @@ -167,12 +167,12 @@ std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil:: else { LL_WARNS_ONCE("configuration") << "Missing String in strings.xml: [" << xml_desc << "]" << LL_ENDL; - return "MissingString("+xml_desc+")"; + return "MissingString(" + std::string(xml_desc) + ")"; } } //static -std::string LLTrans::getDefString(const std::string &xml_desc, const LLStringUtil::format_map_t& msg_args) +std::string LLTrans::getDefString(std::string_view xml_desc, const LLStringUtil::format_map_t& msg_args) { template_map_t::iterator iter = sDefaultStringTemplates.find(xml_desc); if (iter != sDefaultStringTemplates.end()) @@ -187,12 +187,12 @@ std::string LLTrans::getDefString(const std::string &xml_desc, const LLStringUti else { LL_WARNS_ONCE("configuration") << "Missing String in strings.xml: [" << xml_desc << "]" << LL_ENDL; - return "MissingString(" + xml_desc + ")"; + return "MissingString(" + std::string(xml_desc) + ")"; } } //static -std::string LLTrans::getString(const std::string &xml_desc, const LLSD& msg_args, bool def_string) +std::string LLTrans::getString(std::string_view xml_desc, const LLSD& msg_args, bool def_string) { // Don't care about time as much as call count. Make sure we're not // calling LLTrans::getString() in an inner loop. JC @@ -213,12 +213,12 @@ std::string LLTrans::getString(const std::string &xml_desc, const LLSD& msg_args else { LL_WARNS_ONCE("configuration") << "Missing String in strings.xml: [" << xml_desc << "]" << LL_ENDL; - return "MissingString("+xml_desc+")"; + return "MissingString(" + std::string(xml_desc) + ")"; } } //static -std::string LLTrans::getDefString(const std::string &xml_desc, const LLSD& msg_args) +std::string LLTrans::getDefString(std::string_view xml_desc, const LLSD& msg_args) { template_map_t::iterator iter = sDefaultStringTemplates.find(xml_desc); if (iter != sDefaultStringTemplates.end()) @@ -230,12 +230,12 @@ std::string LLTrans::getDefString(const std::string &xml_desc, const LLSD& msg_a else { LL_WARNS_ONCE("configuration") << "Missing String in strings.xml: [" << xml_desc << "]" << LL_ENDL; - return "MissingString(" + xml_desc + ")"; + return "MissingString(" + std::string(xml_desc) + ")"; } } //static -bool LLTrans::findString(std::string &result, const std::string &xml_desc, const LLStringUtil::format_map_t& msg_args) +bool LLTrans::findString(std::string &result, std::string_view xml_desc, const LLStringUtil::format_map_t& msg_args) { LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; @@ -257,7 +257,7 @@ bool LLTrans::findString(std::string &result, const std::string &xml_desc, const } //static -bool LLTrans::findString(std::string &result, const std::string &xml_desc, const LLSD& msg_args) +bool LLTrans::findString(std::string &result, std::string_view xml_desc, const LLSD& msg_args) { LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; diff --git a/indra/llui/lltrans.h b/indra/llui/lltrans.h index 4f38ef9067..3492ed0169 100644 --- a/indra/llui/lltrans.h +++ b/indra/llui/lltrans.h @@ -76,12 +76,12 @@ public: * @param args A list of substrings to replace in the string * @returns Translated string */ - static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); - static std::string getDefString(const std::string &xml_desc, const LLStringUtil::format_map_t& args); - static std::string getString(const std::string &xml_desc, const LLSD& args, bool def_string = false); - static std::string getDefString(const std::string &xml_desc, const LLSD& args); - static bool findString(std::string &result, const std::string &xml_desc, const LLStringUtil::format_map_t& args); - static bool findString(std::string &result, const std::string &xml_desc, const LLSD& args); + static std::string getString(std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); + static std::string getDefString(std::string_view xml_desc, const LLStringUtil::format_map_t& args); + static std::string getString(std::string_view xml_desc, const LLSD& args, bool def_string = false); + static std::string getDefString(std::string_view xml_desc, const LLSD& args); + static bool findString(std::string &result, std::string_view xml_desc, const LLStringUtil::format_map_t& args); + static bool findString(std::string &result, std::string_view xml_desc, const LLSD& args); // Returns translated string with [COUNT] replaced with a number, following // special per-language logic for plural nouns. For example, some languages @@ -94,23 +94,22 @@ public: * @param xml_desc String's description * @returns Translated string */ - static std::string getString(const std::string &xml_desc, bool def_string = false) + static std::string getString(std::string_view xml_desc, bool def_string = false) { LLStringUtil::format_map_t empty; return getString(xml_desc, empty); } - static bool findString(std::string &result, const std::string &xml_desc) + static bool findString(std::string &result, std::string_view xml_desc) { LLStringUtil::format_map_t empty; return findString(result, xml_desc, empty); } - static std::string getKeyboardString(const char* keystring) + static std::string getKeyboardString(const std::string_view keystring) { - std::string key_str(keystring); std::string trans_str; - return findString(trans_str, key_str) ? trans_str : key_str; + return findString(trans_str, keystring) ? trans_str : std::string(keystring); } // get the default args @@ -128,7 +127,7 @@ public: } private: - typedef std::map<std::string, LLTransTemplate > template_map_t; + typedef std::map<std::string, LLTransTemplate, std::less<>> template_map_t; static template_map_t sStringTemplates; static template_map_t sDefaultStringTemplates; static LLStringUtil::format_map_t sDefaultArgs; diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 66ec3ad9bd..e3ddd66b58 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -170,11 +170,11 @@ mHelpImpl(NULL) LLUICtrl::CommitCallbackRegistry::Registrar& reg = LLUICtrl::CommitCallbackRegistry::defaultRegistrar(); // Callbacks for associating controls with floater visibility: - reg.add("Floater.Toggle", boost::bind(&LLFloaterReg::toggleInstance, _2, LLSD())); - reg.add("Floater.ToggleOrBringToFront", boost::bind(&LLFloaterReg::toggleInstanceOrBringToFront, _2, LLSD())); - reg.add("Floater.Show", boost::bind(&LLFloaterReg::showInstance, _2, LLSD(), false)); - reg.add("Floater.ShowOrBringToFront", boost::bind(&LLFloaterReg::showInstanceOrBringToFront, _2, LLSD())); - reg.add("Floater.Hide", boost::bind(&LLFloaterReg::hideInstance, _2, LLSD())); + reg.add("Floater.Toggle", [](LLUICtrl* ctrl, const LLSD& param) -> void { LLFloaterReg::toggleInstance(param.asStringRef()); }); + reg.add("Floater.ToggleOrBringToFront", [](LLUICtrl* ctrl, const LLSD& param) -> void { LLFloaterReg::toggleInstanceOrBringToFront(param.asStringRef()); }); + reg.add("Floater.Show", [](LLUICtrl* ctrl, const LLSD& param) -> void { LLFloaterReg::showInstance(param.asStringRef(), LLSD(), false); }); + reg.add("Floater.ShowOrBringToFront", [](LLUICtrl* ctrl, const LLSD& param) -> void { LLFloaterReg::showInstanceOrBringToFront(param.asStringRef(), LLSD()); }); + reg.add("Floater.Hide", [](LLUICtrl* ctrl, const LLSD& param) -> void { LLFloaterReg::hideInstance(param.asStringRef()); }); // Button initialization callback for toggle buttons reg.add("Button.SetFloaterToggle", boost::bind(&LLButton::setFloaterToggle, _1, _2)); @@ -189,8 +189,8 @@ mHelpImpl(NULL) reg.add("Button.ToggleFloater", boost::bind(&LLButton::toggleFloaterAndSetToggleState, _1, _2)); // Used by menus along with Floater.Toggle to display visibility as a check-mark - LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.Visible", boost::bind(&LLFloaterReg::instanceVisible, _2, LLSD())); - LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.IsOpen", boost::bind(&LLFloaterReg::instanceVisible, _2, LLSD())); + LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.Visible", [](LLUICtrl* ctrl, const LLSD& param) -> bool { return LLFloaterReg::instanceVisible(param.asStringRef(), LLSD()); }); + LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.IsOpen", [](LLUICtrl* ctrl, const LLSD& param) -> bool { return LLFloaterReg::instanceVisible(param.asStringRef(), LLSD()); }); // Parse the master list of commands LLCommandManager::load(); @@ -367,7 +367,7 @@ void LLUI::glRectToScreen(const LLRect& gl, LLRect *screen) } -LLControlGroup& LLUI::getControlControlGroup (const std::string& controlname) +LLControlGroup& LLUI::getControlControlGroup (std::string_view controlname) { for (settings_map_t::iterator itor = mSettingGroups.begin(); itor != mSettingGroups.end(); ++itor) @@ -529,7 +529,7 @@ namespace LLInitParam { if (control.isProvided() && !control().empty()) { - updateValue(LLUIColorTable::instance().getColor(control)); + updateValue(LLUIColorTable::instance().getColor(control())); } else { diff --git a/indra/llui/llui.h b/indra/llui/llui.h index 373a358544..f33b43f599 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -115,7 +115,7 @@ typedef void (*LLUIAudioCallback)(const LLUUID& uuid); class LLUI : public LLParamSingleton<LLUI> { public: - typedef std::map<std::string, LLControlGroup*> settings_map_t; + typedef std::map<std::string, LLControlGroup*, std::less<> > settings_map_t; private: LLSINGLETON(LLUI , const settings_map_t &settings, @@ -295,7 +295,7 @@ public: void screenRectToGL(const LLRect& screen, LLRect *gl); void glRectToScreen(const LLRect& gl, LLRect *screen); // Returns the control group containing the control name, or the default group - LLControlGroup& getControlControlGroup (const std::string& controlname); + LLControlGroup& getControlControlGroup (std::string_view controlname); F32 getMouseIdleTime() { return mMouseIdleTimer.getElapsedTimeF32(); } void resetMouseIdleTimer() { mMouseIdleTimer.reset(); } LLWindow* getWindow() { return mWindow; } diff --git a/indra/llui/lluicolortable.cpp b/indra/llui/lluicolortable.cpp index 54f8727fa5..3279926786 100644 --- a/indra/llui/lluicolortable.cpp +++ b/indra/llui/lluicolortable.cpp @@ -63,7 +63,7 @@ void LLUIColorTable::insertFromParams(const Params& p, string_color_map_t& table ColorEntryParams color_entry = *it; if(color_entry.color.value.isChosen()) { - setColor(color_entry.name, color_entry.color.value, table); + setColor(color_entry.name(), color_entry.color.value, table); } else { @@ -176,7 +176,7 @@ void LLUIColorTable::clear() clearTable(mUserSetColors); } -LLUIColor LLUIColorTable::getColor(const std::string& name, const LLColor4& default_color) const +LLUIColor LLUIColorTable::getColor(std::string_view name, const LLColor4& default_color) const { string_color_map_t::const_iterator iter = mUserSetColors.find(name); @@ -196,7 +196,7 @@ LLUIColor LLUIColorTable::getColor(const std::string& name, const LLColor4& defa } // update user color, loaded colors are parsed on initialization -void LLUIColorTable::setColor(const std::string& name, const LLColor4& color) +void LLUIColorTable::setColor(std::string_view name, const LLColor4& color) { setColor(name, color, mUserSetColors); } @@ -258,7 +258,7 @@ void LLUIColorTable::saveUserSettings() const } } -bool LLUIColorTable::colorExists(const std::string& color_name) const +bool LLUIColorTable::colorExists(std::string_view color_name) const { return ((mLoadedColors.find(color_name) != mLoadedColors.end()) || (mUserSetColors.find(color_name) != mUserSetColors.end())); @@ -276,7 +276,7 @@ void LLUIColorTable::clearTable(string_color_map_t& table) // this method inserts a color into the table if it does not exist // if the color already exists it changes the color -void LLUIColorTable::setColor(const std::string& name, const LLColor4& color, string_color_map_t& table) +void LLUIColorTable::setColor(std::string_view name, const LLColor4& color, string_color_map_t& table) { string_color_map_t::iterator it = table.lower_bound(name); if(it != table.end() diff --git a/indra/llui/lluicolortable.h b/indra/llui/lluicolortable.h index 7232077cab..ca1ca9eaa7 100644 --- a/indra/llui/lluicolortable.h +++ b/indra/llui/lluicolortable.h @@ -42,7 +42,7 @@ class LLUIColorTable : public LLSingleton<LLUIColorTable> LOG_CLASS(LLUIColorTable); // consider using sorted vector, can be much faster - typedef std::map<std::string, LLUIColor> string_color_map_t; + typedef std::map<std::string, LLUIColor, std::less<>> string_color_map_t; public: struct ColorParams : LLInitParam::ChoiceBlock<ColorParams> @@ -75,13 +75,13 @@ public: void clear(); // color lookup - LLUIColor getColor(const std::string& name, const LLColor4& default_color = LLColor4::magenta) const; + LLUIColor getColor(std::string_view name, const LLColor4& default_color = LLColor4::magenta) const; // if the color is in the table, it's value is changed, otherwise it is added - void setColor(const std::string& name, const LLColor4& color); + void setColor(std::string_view name, const LLColor4& color); // returns true if color_name exists in the table - bool colorExists(const std::string& color_name) const; + bool colorExists(std::string_view color_name) const; // loads colors from settings files bool loadFromSettings(); @@ -95,7 +95,7 @@ private: void insertFromParams(const Params& p, string_color_map_t& table); void clearTable(string_color_map_t& table); - void setColor(const std::string& name, const LLColor4& color, string_color_map_t& table); + void setColor(std::string_view name, const LLColor4& color, string_color_map_t& table); string_color_map_t mLoadedColors; string_color_map_t mUserSetColors; diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index 52c5f72a45..cb86a79407 100644 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -44,7 +44,7 @@ F32 LLUICtrl::sInactiveControlTransparency = 1.0f; // Compiler optimization, generate extern template template class LLUICtrl* LLView::getChild<class LLUICtrl>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; LLUICtrl::CallbackParam::CallbackParam() : name("name"), @@ -135,7 +135,7 @@ void LLUICtrl::initFromParams(const Params& p) { if (p.enabled_controls.enabled.isChosen()) { - LLControlVariable* control = findControl(p.enabled_controls.enabled); + LLControlVariable* control = findControl(p.enabled_controls.enabled()); if (control) { setEnabledControlVariable(control); @@ -149,7 +149,7 @@ void LLUICtrl::initFromParams(const Params& p) } else if(p.enabled_controls.disabled.isChosen()) { - LLControlVariable* control = findControl(p.enabled_controls.disabled); + LLControlVariable* control = findControl(p.enabled_controls.disabled()); if (control) { setDisabledControlVariable(control); @@ -166,7 +166,7 @@ void LLUICtrl::initFromParams(const Params& p) { if (p.controls_visibility.visible.isChosen()) { - LLControlVariable* control = findControl(p.controls_visibility.visible); + LLControlVariable* control = findControl(p.controls_visibility.visible()); if (control) { setMakeVisibleControlVariable(control); @@ -180,7 +180,7 @@ void LLUICtrl::initFromParams(const Params& p) } else if (p.controls_visibility.invisible.isChosen()) { - LLControlVariable* control = findControl(p.controls_visibility.invisible); + LLControlVariable* control = findControl(p.controls_visibility.invisible()); if (control) { setMakeInvisibleControlVariable(control); diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index c56c3c43a4..fb8fc0c5ea 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -335,7 +335,7 @@ private: // Build time optimization, generate once in .cpp file #ifndef LLUICTRL_CPP extern template class LLUICtrl* LLView::getChild<class LLUICtrl>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif // LL_LLUICTRL_H diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index a07f9b7dae..75e7e396bc 100644 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -182,10 +182,10 @@ fail: } template<class T> - static T* getDefaultWidget(const std::string& name) + static T* getDefaultWidget(std::string_view name) { typename T::Params widget_params; - widget_params.name = name; + widget_params.name = std::string(name); return create<T>(widget_params); } diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 441b7d6a6c..7d6c937b85 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -85,7 +85,7 @@ bool LLView::sIsDrawing = false; // Compiler optimization, generate extern template template class LLView* LLView::getChild<class LLView>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; static LLDefaultChildRegistry::Register<LLView> r("view"); @@ -729,7 +729,7 @@ void LLView::logMouseEvent() } template <typename METHOD, typename CHARTYPE> -LLView* LLView::childrenHandleCharEvent(const std::string& desc, const METHOD& method, +LLView* LLView::childrenHandleCharEvent(std::string_view desc, const METHOD& method, CHARTYPE c, MASK mask) { if ( getVisible() && getEnabled() ) @@ -1613,7 +1613,7 @@ bool LLView::hasAncestor(const LLView* parentp) const //----------------------------------------------------------------------------- -bool LLView::childHasKeyboardFocus( const std::string& childname ) const +bool LLView::childHasKeyboardFocus(std::string_view childname) const { LLView *focus = dynamic_cast<LLView *>(gFocusMgr.getKeyboardFocus()); @@ -1632,7 +1632,7 @@ bool LLView::childHasKeyboardFocus( const std::string& childname ) const //----------------------------------------------------------------------------- -bool LLView::hasChild(const std::string& childname, bool recurse) const +bool LLView::hasChild(std::string_view childname, bool recurse) const { return findChildView(childname, recurse) != NULL; } @@ -1640,12 +1640,12 @@ bool LLView::hasChild(const std::string& childname, bool recurse) const //----------------------------------------------------------------------------- // getChildView() //----------------------------------------------------------------------------- -LLView* LLView::getChildView(const std::string& name, bool recurse) const +LLView* LLView::getChildView(std::string_view name, bool recurse) const { return getChild<LLView>(name, recurse); } -LLView* LLView::findChildView(const std::string& name, bool recurse) const +LLView* LLView::findChildView(std::string_view name, bool recurse) const { LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; @@ -2312,18 +2312,20 @@ LLView* LLView::findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESna //----------------------------------------------------------------------------- -LLControlVariable *LLView::findControl(const std::string& name) +LLControlVariable *LLView::findControl(std::string_view name) { + auto uiInst = LLUI::getInstance(); // parse the name to locate which group it belongs to std::size_t key_pos= name.find("."); - if(key_pos!= std::string::npos ) + if(key_pos != std::string_view::npos ) { - std::string control_group_key = name.substr(0, key_pos); + std::string_view control_group_key = name.substr(0, key_pos); LLControlVariable* control; // check if it's in the control group that name indicated - if(LLUI::getInstance()->mSettingGroups[control_group_key]) + auto it = uiInst->mSettingGroups.find(control_group_key); + if(it != uiInst->mSettingGroups.end() && it->second) { - control = LLUI::getInstance()->mSettingGroups[control_group_key]->getControl(name); + control = it->second->getControl(name); if (control) { return control; @@ -2331,7 +2333,7 @@ LLControlVariable *LLView::findControl(const std::string& name) } } - LLControlGroup& control_group = LLUI::getInstance()->getControlControlGroup(name); + LLControlGroup& control_group = uiInst->getControlControlGroup(name); return control_group.getControl(name); } diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 3ce7243370..710ec3d05e 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -341,8 +341,8 @@ public: S32 getChildCount() const { return (S32)mChildList.size(); } template<class _Pr3> void sortChildren(_Pr3 _Pred) { mChildList.sort(_Pred); } bool hasAncestor(const LLView* parentp) const; - bool hasChild(const std::string& childname, bool recurse = false) const; - bool childHasKeyboardFocus( const std::string& childname ) const; + bool hasChild(std::string_view childname, bool recurse = false) const; + bool childHasKeyboardFocus( std::string_view childname ) const; // these iterators are used for collapsing various tree traversals into for loops typedef LLTreeDFSIter<LLView, child_list_const_iter_t> tree_iterator_t; @@ -416,7 +416,7 @@ public: void screenRectToLocal( const LLRect& screen, LLRect* local ) const; void localRectToScreen( const LLRect& local, LLRect* screen ) const; - LLControlVariable *findControl(const std::string& name); + LLControlVariable *findControl(std::string_view name); const child_list_t* getChildList() const { return &mChildList; } child_list_const_iter_t beginChild() const { return mChildList.begin(); } @@ -452,24 +452,24 @@ public: // static method handles NULL pointer too static std::string getPathname(const LLView*); - template <class T> T* findChild(const std::string& name, bool recurse = true) const + template <class T> T* findChild(std::string_view name, bool recurse = true) const { LLView* child = findChildView(name, recurse); T* result = dynamic_cast<T*>(child); return result; } - template <class T> T* getChild(const std::string& name, bool recurse = true) const; + template <class T> T* getChild(std::string_view name, bool recurse = true) const; - template <class T> T& getChildRef(const std::string& name, bool recurse = true) const + template <class T> T& getChildRef(std::string_view name, bool recurse = true) const { return *getChild<T>(name, recurse); } - virtual LLView* getChildView(const std::string& name, bool recurse = true) const; - virtual LLView* findChildView(const std::string& name, bool recurse = true) const; + virtual LLView* getChildView(std::string_view name, bool recurse = true) const; + virtual LLView* findChildView(std::string_view name, bool recurse = true) const; - template <class T> T* getDefaultWidget(const std::string& name) const + template <class T> T* getDefaultWidget(std::string_view name) const { LLView* widgetp = getDefaultWidgetContainer().findChildView(name); return dynamic_cast<T*>(widgetp); @@ -576,7 +576,7 @@ private: LLView* childrenHandleMouseEvent(const METHOD& method, S32 x, S32 y, XDATA extra, bool allow_mouse_block = true); template <typename METHOD, typename CHARTYPE> - LLView* childrenHandleCharEvent(const std::string& desc, const METHOD& method, + LLView* childrenHandleCharEvent(std::string_view desc, const METHOD& method, CHARTYPE c, MASK mask); // adapter to blur distinction between handleKey() and handleUnicodeChar() @@ -696,7 +696,7 @@ struct TypeValues<LLView::EOrientation> : public LLInitParam::TypeValuesHelper<L }; } -template <class T> T* LLView::getChild(const std::string& name, bool recurse) const +template <class T> T* LLView::getChild(std::string_view name, bool recurse) const { LLView* child = findChildView(name, recurse); T* result = dynamic_cast<T*>(child); @@ -731,7 +731,7 @@ template <class T> T* LLView::getChild(const std::string& name, bool recurse) co // require explicit specialization. See llbutton.cpp for an example. #ifndef LLVIEW_CPP extern template class LLView* LLView::getChild<class LLView>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif //LL_LLVIEW_H diff --git a/indra/llui/llvirtualtrackball.cpp b/indra/llui/llvirtualtrackball.cpp index 8166afc89b..273a1d7bde 100644 --- a/indra/llui/llvirtualtrackball.cpp +++ b/indra/llui/llvirtualtrackball.cpp @@ -217,19 +217,19 @@ void LLVirtualTrackball::draw() S32 halfwidth = mTouchArea->getRect().getWidth() / 2; S32 halfheight = mTouchArea->getRect().getHeight() / 2; - draw_point.mV[VX] = (draw_point.mV[VX] + 1.0) * halfwidth + mTouchArea->getRect().mLeft; - draw_point.mV[VY] = (draw_point.mV[VY] + 1.0) * halfheight + mTouchArea->getRect().mBottom; + draw_point.mV[VX] = (draw_point.mV[VX] + 1.0f) * halfwidth + mTouchArea->getRect().mLeft; + draw_point.mV[VY] = (draw_point.mV[VY] + 1.0f) * halfheight + mTouchArea->getRect().mBottom; bool upper_hemisphere = (draw_point.mV[VZ] >= 0.f); mImgSphere->draw(mTouchArea->getRect(), upper_hemisphere ? UI_VERTEX_COLOR : UI_VERTEX_COLOR % 0.5f); - drawThumb(draw_point.mV[VX], draw_point.mV[VY], mThumbMode, upper_hemisphere); + drawThumb((S32)draw_point.mV[VX], (S32)draw_point.mV[VY], mThumbMode, upper_hemisphere); if (LLView::sDebugRects) { gGL.color4fv(LLColor4::red.mV); - gl_circle_2d(mTouchArea->getRect().getCenterX(), mTouchArea->getRect().getCenterY(), mImgSphere->getWidth() / 2, 60, false); - gl_circle_2d(draw_point.mV[VX], draw_point.mV[VY], mImgSunFront->getWidth() / 2, 12, false); + gl_circle_2d((F32)mTouchArea->getRect().getCenterX(), (F32)mTouchArea->getRect().getCenterY(), (F32)mImgSphere->getWidth() / 2.f, 60, false); + gl_circle_2d(draw_point.mV[VX], draw_point.mV[VY], (F32)mImgSunFront->getWidth() / 2.f, 12, false); } // hide the direction labels when disabled @@ -392,20 +392,20 @@ bool LLVirtualTrackball::handleHover(S32 x, S32 y, MASK mask) { // trackball (move to roll) mode LLQuaternion delta; - F32 rotX = x - mPrevX; - F32 rotY = y - mPrevY; + F32 rotX = (F32)(x - mPrevX); + F32 rotY = (F32)(y - mPrevY); if (abs(rotX) > 1) { - F32 direction = (rotX < 0) ? -1 : 1; - delta.setAngleAxis(mIncrementMouse * abs(rotX), 0, direction, 0); // changing X - rotate around Y axis + F32 direction = (rotX < 0) ? -1.f : 1.f; + delta.setAngleAxis(mIncrementMouse * abs(rotX), 0.f, direction, 0.f); // changing X - rotate around Y axis mValue *= delta; } if (abs(rotY) > 1) { - F32 direction = (rotY < 0) ? 1 : -1; // reverse for Y (value increases from bottom to top) - delta.setAngleAxis(mIncrementMouse * abs(rotY), direction, 0, 0); // changing Y - rotate around X axis + F32 direction = (rotY < 0) ? 1.f : -1.f; // reverse for Y (value increases from bottom to top) + delta.setAngleAxis(mIncrementMouse * abs(rotY), direction, 0.f, 0.f); // changing Y - rotate around X axis mValue *= delta; } } @@ -416,10 +416,10 @@ bool LLVirtualTrackball::handleHover(S32 x, S32 y, MASK mask) return true; // don't drag outside the circle } - F32 radius = mTouchArea->getRect().getWidth() / 2; - F32 xx = x - mTouchArea->getRect().getCenterX(); - F32 yy = y - mTouchArea->getRect().getCenterY(); - F32 dist = sqrt(pow(xx, 2) + pow(yy, 2)); + F32 radius = (F32)mTouchArea->getRect().getWidth() / 2.f; + F32 xx = (F32)(x - mTouchArea->getRect().getCenterX()); + F32 yy = (F32)(y - mTouchArea->getRect().getCenterY()); + F32 dist = (F32)(sqrt(pow(xx, 2) + pow(yy, 2))); F32 azimuth = llclamp(acosf(xx / dist), 0.0f, F_PI); F32 altitude = llclamp(acosf(dist / radius), 0.0f, F_PI_BY_TWO); diff --git a/indra/llui/llxyvector.cpp b/indra/llui/llxyvector.cpp index 19bd8465b9..1521823ce2 100644 --- a/indra/llui/llxyvector.cpp +++ b/indra/llui/llxyvector.cpp @@ -159,15 +159,15 @@ void drawArrow(S32 tailX, S32 tailY, S32 tipX, S32 tipY, LLColor4 color) S32 arrowLength = (abs(dx) < ARROW_LENGTH_LONG && abs(dy) < ARROW_LENGTH_LONG) ? ARROW_LENGTH_SHORT : ARROW_LENGTH_LONG; - F32 theta = std::atan2(dy, dx); + F32 theta = (F32)std::atan2(dy, dx); - F32 rad = ARROW_ANGLE * std::atan(1) * 4 / 180; + F32 rad = (F32)(ARROW_ANGLE * std::atan(1) * 4 / 180); F32 x = tipX - arrowLength * cos(theta + rad); F32 y = tipY - arrowLength * sin(theta + rad); - F32 rad2 = -1 * ARROW_ANGLE * std::atan(1) * 4 / 180; + F32 rad2 = (F32)(-1 * ARROW_ANGLE * std::atan(1) * 4 / 180); F32 x2 = tipX - arrowLength * cos(theta + rad2); F32 y2 = tipY - arrowLength * sin(theta + rad2); - gl_triangle_2d(tipX, tipY, x, y, x2, y2, color, true); + gl_triangle_2d(tipX, tipY, (S32)x, (S32)y, (S32)x2, (S32)y2, color, true); } void LLXYVector::draw() @@ -179,18 +179,18 @@ void LLXYVector::draw() if (mLogarithmic) { - pointX = (log(llabs(mValueX) + 1)) / mLogScaleX; + pointX = (S32)((log(llabs(mValueX) + 1)) / mLogScaleX); pointX *= (mValueX < 0) ? -1 : 1; pointX += centerX; - pointY = (log(llabs(mValueY) + 1)) / mLogScaleY; + pointY = (S32)((log(llabs(mValueY) + 1)) / mLogScaleY); pointY *= (mValueY < 0) ? -1 : 1; pointY += centerY; } else // linear { - pointX = centerX + (mValueX * mTouchArea->getRect().getWidth() / (2 * mMaxValueX)); - pointY = centerY + (mValueY * mTouchArea->getRect().getHeight() / (2 * mMaxValueY)); + pointX = centerX + (S32)(mValueX * mTouchArea->getRect().getWidth() / (2 * mMaxValueX)); + pointY = centerY + (S32)(mValueY * mTouchArea->getRect().getHeight() / (2 * mMaxValueY)); } // fill @@ -223,7 +223,7 @@ void LLXYVector::draw() } // draw center circle - gl_circle_2d(centerX, centerY, CENTER_CIRCLE_RADIUS, 12, true); + gl_circle_2d((F32)centerX, (F32)centerY, CENTER_CIRCLE_RADIUS, 12, true); LLView::draw(); } @@ -232,7 +232,7 @@ void LLXYVector::onEditChange() { if (getEnabled()) { - setValueAndCommit(mXEntry->getValue().asReal(), mYEntry->getValue().asReal()); + setValueAndCommit((F32)mXEntry->getValue().asReal(), (F32)mYEntry->getValue().asReal()); } } @@ -240,7 +240,7 @@ void LLXYVector::setValue(const LLSD& value) { if (value.isArray()) { - setValue(value[0].asReal(), value[1].asReal()); + setValue((F32)value[0].asReal(), (F32)value[1].asReal()); } } |