summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/CMakeLists.txt2
-rw-r--r--indra/llui/llaccordionctrl.cpp123
-rw-r--r--indra/llui/llaccordionctrl.h26
-rw-r--r--indra/llui/llaccordionctrltab.cpp6
-rw-r--r--indra/llui/llaccordionctrltab.h4
-rw-r--r--indra/llui/llbadge.cpp58
-rw-r--r--indra/llui/llbadge.h5
-rw-r--r--indra/llui/llbutton.cpp102
-rw-r--r--indra/llui/llbutton.h78
-rw-r--r--indra/llui/llchatentry.cpp17
-rw-r--r--indra/llui/llchatentry.h2
-rw-r--r--indra/llui/llchatmentionhelper.cpp158
-rw-r--r--indra/llui/llchatmentionhelper.h66
-rw-r--r--indra/llui/llcheckboxctrl.cpp6
-rw-r--r--indra/llui/llcheckboxctrl.h14
-rw-r--r--indra/llui/llcombobox.cpp172
-rw-r--r--indra/llui/llcombobox.h6
-rw-r--r--indra/llui/llcommandmanager.cpp2
-rw-r--r--indra/llui/llconsole.cpp7
-rw-r--r--indra/llui/llcontainerview.cpp8
-rw-r--r--indra/llui/llcontainerview.h20
-rw-r--r--indra/llui/lldockablefloater.h4
-rw-r--r--indra/llui/lldockcontrol.cpp9
-rw-r--r--indra/llui/lldockcontrol.h9
-rw-r--r--indra/llui/lldraghandle.h2
-rw-r--r--indra/llui/llemojihelper.cpp15
-rw-r--r--indra/llui/llemojihelper.h7
-rw-r--r--indra/llui/llf32uictrl.cpp4
-rw-r--r--indra/llui/llfiltereditor.h2
-rw-r--r--indra/llui/llflashtimer.cpp4
-rw-r--r--indra/llui/llflashtimer.h4
-rw-r--r--indra/llui/llflatlistview.cpp57
-rw-r--r--indra/llui/llflatlistview.h40
-rw-r--r--indra/llui/llfloater.cpp130
-rw-r--r--indra/llui/llfloater.h45
-rw-r--r--indra/llui/llfloaterreg.cpp165
-rw-r--r--indra/llui/llfloaterreg.h36
-rw-r--r--indra/llui/llfloaterreglistener.cpp12
-rw-r--r--indra/llui/llfloaterreglistener.h1
-rw-r--r--indra/llui/llflyoutbutton.h2
-rw-r--r--indra/llui/llfocusmgr.cpp28
-rw-r--r--indra/llui/llfocusmgr.h3
-rw-r--r--indra/llui/llfolderview.cpp44
-rw-r--r--indra/llui/llfolderview.h32
-rw-r--r--indra/llui/llfolderviewitem.cpp166
-rw-r--r--indra/llui/llfolderviewitem.h30
-rw-r--r--indra/llui/llfolderviewmodel.h1
-rw-r--r--indra/llui/lliconctrl.h2
-rw-r--r--indra/llui/llkeywords.cpp36
-rw-r--r--indra/llui/llkeywords.h24
-rw-r--r--indra/llui/lllayoutstack.cpp65
-rw-r--r--indra/llui/lllayoutstack.h8
-rw-r--r--indra/llui/lllineeditor.cpp136
-rw-r--r--indra/llui/lllineeditor.h25
-rw-r--r--indra/llui/llmenubutton.h4
-rw-r--r--indra/llui/llmenugl.cpp22
-rw-r--r--indra/llui/llmenugl.h12
-rw-r--r--indra/llui/llmultifloater.cpp2
-rw-r--r--indra/llui/llmultifloater.h2
-rw-r--r--indra/llui/llmultislider.h8
-rw-r--r--indra/llui/llmultisliderctrl.cpp6
-rw-r--r--indra/llui/llmultisliderctrl.h13
-rw-r--r--indra/llui/llnotifications.cpp74
-rw-r--r--indra/llui/llnotifications.h36
-rw-r--r--indra/llui/llnotificationslistener.cpp2
-rw-r--r--indra/llui/llpanel.cpp70
-rw-r--r--indra/llui/llpanel.h58
-rw-r--r--indra/llui/llprogressbar.h4
-rw-r--r--indra/llui/llresizebar.h2
-rw-r--r--indra/llui/llresizehandle.h12
-rw-r--r--indra/llui/llrngwriter.h2
-rw-r--r--indra/llui/llscrollbar.cpp24
-rw-r--r--indra/llui/llscrollbar.h3
-rw-r--r--indra/llui/llscrollingpanellist.cpp44
-rw-r--r--indra/llui/llscrolllistcell.cpp91
-rw-r--r--indra/llui/llscrolllistcell.h29
-rw-r--r--indra/llui/llscrolllistctrl.cpp218
-rw-r--r--indra/llui/llscrolllistctrl.h20
-rw-r--r--indra/llui/llsearchablecontrol.h10
-rw-r--r--indra/llui/llsliderctrl.cpp6
-rw-r--r--indra/llui/llsliderctrl.h5
-rw-r--r--indra/llui/llspellcheck.cpp45
-rw-r--r--indra/llui/llspellcheck.h9
-rw-r--r--indra/llui/llspinctrl.cpp2
-rw-r--r--indra/llui/llspinctrl.h5
-rw-r--r--indra/llui/llstatbar.cpp66
-rw-r--r--indra/llui/llstatbar.h2
-rw-r--r--indra/llui/llstatgraph.cpp14
-rw-r--r--indra/llui/llstatgraph.h7
-rw-r--r--indra/llui/llstatview.h1
-rw-r--r--indra/llui/llstyle.cpp19
-rw-r--r--indra/llui/llstyle.h38
-rw-r--r--indra/llui/lltabcontainer.cpp20
-rw-r--r--indra/llui/lltabcontainer.h20
-rw-r--r--indra/llui/lltextbase.cpp505
-rw-r--r--indra/llui/lltextbase.h76
-rw-r--r--indra/llui/lltextbox.cpp5
-rw-r--r--indra/llui/lltextbox.h40
-rw-r--r--indra/llui/lltexteditor.cpp217
-rw-r--r--indra/llui/lltexteditor.h21
-rw-r--r--indra/llui/lltextparser.cpp78
-rw-r--r--indra/llui/lltextparser.h5
-rw-r--r--indra/llui/lltoolbar.cpp2
-rw-r--r--indra/llui/lltoolbar.h4
-rw-r--r--indra/llui/lltooltip.cpp8
-rw-r--r--indra/llui/lltooltip.h30
-rw-r--r--indra/llui/lltrans.cpp40
-rw-r--r--indra/llui/lltrans.h37
-rw-r--r--indra/llui/lltransutil.cpp2
-rw-r--r--indra/llui/llui.cpp28
-rw-r--r--indra/llui/llui.h28
-rw-r--r--indra/llui/lluicolortable.cpp78
-rw-r--r--indra/llui/lluicolortable.h17
-rw-r--r--indra/llui/lluiconstants.h20
-rw-r--r--indra/llui/lluictrl.cpp12
-rw-r--r--indra/llui/lluictrl.h10
-rw-r--r--indra/llui/lluictrlfactory.h6
-rw-r--r--indra/llui/lluistring.cpp6
-rw-r--r--indra/llui/lluistring.h7
-rw-r--r--indra/llui/llundo.h6
-rw-r--r--indra/llui/llurlaction.h2
-rw-r--r--indra/llui/llurlentry.cpp122
-rw-r--r--indra/llui/llurlentry.h49
-rw-r--r--indra/llui/llurlmatch.cpp10
-rw-r--r--indra/llui/llurlmatch.h12
-rw-r--r--indra/llui/llurlregistry.cpp49
-rw-r--r--indra/llui/llurlregistry.h6
-rw-r--r--indra/llui/llview.cpp45
-rw-r--r--indra/llui/llview.h48
-rw-r--r--indra/llui/llviewborder.cpp6
-rw-r--r--indra/llui/llviewborder.h7
-rw-r--r--indra/llui/llviewereventrecorder.cpp6
-rw-r--r--indra/llui/llviewereventrecorder.h2
-rw-r--r--indra/llui/llviewmodel.cpp10
-rw-r--r--indra/llui/llviewmodel.h4
-rw-r--r--indra/llui/llvirtualtrackball.cpp30
-rw-r--r--indra/llui/llvirtualtrackball.h23
-rw-r--r--indra/llui/llwindowshade.cpp46
-rw-r--r--indra/llui/llwindowshade.h9
-rw-r--r--indra/llui/llxuiparser.cpp2
-rw-r--r--indra/llui/llxyvector.cpp22
-rw-r--r--indra/llui/llxyvector.h18
142 files changed, 2956 insertions, 1917 deletions
diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt
index 5991a5b35e..83b3a220a0 100644
--- a/indra/llui/CMakeLists.txt
+++ b/indra/llui/CMakeLists.txt
@@ -18,6 +18,7 @@ set(llui_SOURCE_FILES
llbadgeowner.cpp
llbutton.cpp
llchatentry.cpp
+ llchatmentionhelper.cpp
llcheckboxctrl.cpp
llclipboard.cpp
llcombobox.cpp
@@ -130,6 +131,7 @@ set(llui_HEADER_FILES
llcallbackmap.h
llchatentry.h
llchat.h
+ llchatmentionhelper.h
llcheckboxctrl.h
llclipboard.h
llcombobox.h
diff --git a/indra/llui/llaccordionctrl.cpp b/indra/llui/llaccordionctrl.cpp
index 4682044d6e..495ba2f40f 100644
--- a/indra/llui/llaccordionctrl.cpp
+++ b/indra/llui/llaccordionctrl.cpp
@@ -36,12 +36,12 @@
#include "boost/bind.hpp"
-static const S32 BORDER_MARGIN = 2;
-static const S32 PARENT_BORDER_MARGIN = 5;
-static const S32 VERTICAL_MULTIPLE = 16;
-static const F32 MIN_AUTO_SCROLL_RATE = 120.f;
-static const F32 MAX_AUTO_SCROLL_RATE = 500.f;
-static const F32 AUTO_SCROLL_RATE_ACCEL = 120.f;
+static constexpr S32 BORDER_MARGIN = 2;
+static constexpr S32 PARENT_BORDER_MARGIN = 5;
+static constexpr S32 VERTICAL_MULTIPLE = 16;
+static constexpr F32 MIN_AUTO_SCROLL_RATE = 120.f;
+static constexpr F32 MAX_AUTO_SCROLL_RATE = 500.f;
+static constexpr F32 AUTO_SCROLL_RATE_ACCEL = 120.f;
// LLAccordionCtrl =================================================================|
@@ -49,13 +49,7 @@ static LLDefaultChildRegistry::Register<LLAccordionCtrl> t2("accordion");
LLAccordionCtrl::LLAccordionCtrl(const Params& params):LLPanel(params)
, mFitParent(params.fit_parent)
- , mAutoScrolling( false )
- , mAutoScrollRate( 0.f )
- , mSelectedTab( NULL )
- , mTabComparator( NULL )
- , mNoVisibleTabsHelpText(NULL)
, mNoVisibleTabsOrigString(params.no_visible_tabs_text.initial_value().asString())
- , mSkipScrollToChild(false)
{
initNoTabsWidget(params.no_matched_tabs_text);
@@ -67,10 +61,6 @@ LLAccordionCtrl::LLAccordionCtrl(const Params& params):LLPanel(params)
}
LLAccordionCtrl::LLAccordionCtrl() : LLPanel()
- , mAutoScrolling( false )
- , mAutoScrollRate( 0.f )
- , mSelectedTab( NULL )
- , mNoVisibleTabsHelpText(NULL)
{
initNoTabsWidget(LLTextBox::Params());
@@ -133,11 +123,10 @@ bool LLAccordionCtrl::postBuild()
mScrollbar->setFollowsBottom();
//if it was created from xml...
- std::vector<LLUICtrl*> accordion_tabs;
- for (child_list_const_iter_t it = getChildList()->begin();
- getChildList()->end() != it; ++it)
+ std::vector<LLAccordionCtrlTab*> accordion_tabs;
+ for(LLView* viewp : *getChildList())
{
- LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(*it);
+ LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(viewp);
if (accordion_tab == NULL)
continue;
if (std::find(mAccordionTabs.begin(), mAccordionTabs.end(), accordion_tab) == mAccordionTabs.end())
@@ -146,7 +135,7 @@ bool LLAccordionCtrl::postBuild()
}
}
- for (std::vector<LLUICtrl*>::reverse_iterator it = accordion_tabs.rbegin();
+ for (auto it = accordion_tabs.rbegin();
it < accordion_tabs.rend(); ++it)
{
addCollapsibleCtrl(*it);
@@ -294,11 +283,8 @@ void LLAccordionCtrl::hideScrollbar(S32 width, S32 height)
S32 LLAccordionCtrl::calcRecuiredHeight()
{
S32 rec_height = 0;
-
- std::vector<LLAccordionCtrlTab*>::iterator panel;
- for(panel=mAccordionTabs.begin(); panel!=mAccordionTabs.end(); ++panel)
+ for(LLAccordionCtrlTab* accordion_tab : mAccordionTabs)
{
- LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(*panel);
if(accordion_tab && accordion_tab->getVisible())
{
rec_height += accordion_tab->getRect().getHeight();
@@ -330,9 +316,8 @@ void LLAccordionCtrl::ctrlShiftVertical(LLView* panel, S32 delta)
//---------------------------------------------------------------------------------
-void LLAccordionCtrl::addCollapsibleCtrl(LLView* view)
+void LLAccordionCtrl::addCollapsibleCtrl(LLAccordionCtrlTab* accordion_tab)
{
- LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(view);
if (!accordion_tab)
return;
if (std::find(beginChild(), endChild(), accordion_tab) == endChild())
@@ -343,9 +328,8 @@ void LLAccordionCtrl::addCollapsibleCtrl(LLView* view)
arrange();
}
-void LLAccordionCtrl::removeCollapsibleCtrl(LLView* view)
+void LLAccordionCtrl::removeCollapsibleCtrl(LLAccordionCtrlTab* accordion_tab)
{
- LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(view);
if(!accordion_tab)
return;
@@ -363,7 +347,7 @@ void LLAccordionCtrl::removeCollapsibleCtrl(LLView* view)
}
// if removed is selected - reset selection
- if (mSelectedTab == view)
+ if (mSelectedTab == accordion_tab)
{
mSelectedTab = NULL;
}
@@ -379,12 +363,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;
@@ -403,24 +385,20 @@ void LLAccordionCtrl::arrangeSingle()
S32 collapsed_height = 0;
- for (size_t i = 0; i < mAccordionTabs.size(); ++i)
+ for (LLAccordionCtrlTab* accordion_tab : mAccordionTabs)
{
- LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
-
if (!accordion_tab->getVisible()) // Skip hidden accordion tabs
continue;
if (!accordion_tab->isExpanded() )
{
- collapsed_height+=mAccordionTabs[i]->getRect().getHeight();
+ collapsed_height += accordion_tab->getRect().getHeight();
}
}
S32 expanded_height = getRect().getHeight() - BORDER_MARGIN - collapsed_height;
- for (size_t i = 0; i < mAccordionTabs.size(); ++i)
+ for (LLAccordionCtrlTab* accordion_tab : mAccordionTabs)
{
- LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
-
if (!accordion_tab->getVisible()) // Skip hidden accordion tabs
continue;
if (!accordion_tab->isExpanded() )
@@ -450,8 +428,8 @@ void LLAccordionCtrl::arrangeSingle()
// make sure at least header is shown
panel_height = llmax(panel_height, accordion_tab->getHeaderHeight());
- ctrlSetLeftTopAndSize(mAccordionTabs[i], panel_left, panel_top, panel_width, panel_height);
- panel_top -= mAccordionTabs[i]->getRect().getHeight();
+ ctrlSetLeftTopAndSize(accordion_tab, panel_left, panel_top, panel_width, panel_height);
+ panel_top -= accordion_tab->getRect().getHeight();
}
show_hide_scrollbar(getRect().getWidth(), getRect().getHeight());
@@ -465,17 +443,16 @@ void LLAccordionCtrl::arrangeMultiple()
S32 panel_width = getRect().getWidth() - 4;
//Calculate params
- for (size_t i = 0; i < mAccordionTabs.size(); i++ )
+ for (size_t i = 0, end = mAccordionTabs.size(); i < end; i++)
{
- LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
-
+ LLAccordionCtrlTab* accordion_tab = static_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
if (!accordion_tab->getVisible()) // Skip hidden accordion tabs
continue;
if (!accordion_tab->isExpanded() )
{
- ctrlSetLeftTopAndSize(mAccordionTabs[i], panel_left, panel_top, panel_width, accordion_tab->getRect().getHeight());
- panel_top -= mAccordionTabs[i]->getRect().getHeight();
+ ctrlSetLeftTopAndSize(accordion_tab, panel_left, panel_top, panel_width, accordion_tab->getRect().getHeight());
+ panel_top -= accordion_tab->getRect().getHeight();
}
else
{
@@ -497,13 +474,13 @@ void LLAccordionCtrl::arrangeMultiple()
}
// minimum tab height is equal to header height
- if (mAccordionTabs[i]->getHeaderHeight() > panel_height)
+ if (accordion_tab->getHeaderHeight() > panel_height)
{
- panel_height = mAccordionTabs[i]->getHeaderHeight();
+ panel_height = accordion_tab->getHeaderHeight();
}
}
- ctrlSetLeftTopAndSize(mAccordionTabs[i], panel_left, panel_top, panel_width, panel_height);
+ ctrlSetLeftTopAndSize(accordion_tab, panel_left, panel_top, panel_width, panel_height);
panel_top -= panel_height;
}
@@ -530,7 +507,7 @@ void LLAccordionCtrl::arrange()
S32 panel_top = getRect().getHeight() - BORDER_MARGIN; // Top coordinate of the first panel
S32 panel_width = getRect().getWidth() - 4;
- LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[0]);
+ LLAccordionCtrlTab* accordion_tab = mAccordionTabs[0];
LLRect panel_rect = accordion_tab->getRect();
@@ -640,12 +617,12 @@ void LLAccordionCtrl::updateLayout(S32 width, S32 height)
panel_width -= scrollbar_size;
// set sizes for first panels and dragbars
- for (size_t i = 0; i < mAccordionTabs.size(); ++i)
+ for (LLAccordionCtrlTab* accordion_tab : mAccordionTabs)
{
- if (!mAccordionTabs[i]->getVisible())
+ if (!accordion_tab->getVisible())
continue;
- LLRect panel_rect = mAccordionTabs[i]->getRect();
- ctrlSetLeftTopAndSize(mAccordionTabs[i], panel_rect.mLeft, panel_top, panel_width, panel_rect.getHeight());
+ LLRect panel_rect = accordion_tab->getRect();
+ ctrlSetLeftTopAndSize(accordion_tab, panel_rect.mLeft, panel_top, panel_width, panel_rect.getHeight());
panel_top -= panel_rect.getHeight();
}
}
@@ -687,9 +664,8 @@ void LLAccordionCtrl::onUpdateScrollToChild(const LLUICtrl *cntrl)
void LLAccordionCtrl::onOpen(const LLSD& key)
{
- for (size_t i = 0; i < mAccordionTabs.size(); ++i)
+ for (LLAccordionCtrlTab* accordion_tab : mAccordionTabs)
{
- LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
LLPanel* panel = dynamic_cast<LLPanel*>(accordion_tab->getAccordionView());
if (panel != NULL)
{
@@ -713,7 +689,7 @@ S32 LLAccordionCtrl::notifyParent(const LLSD& info)
{
for (size_t i = 0; i < mAccordionTabs.size(); ++i)
{
- LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
+ LLAccordionCtrlTab* accordion_tab = static_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
if (accordion_tab->hasFocus())
{
while (++i < mAccordionTabs.size())
@@ -723,7 +699,7 @@ S32 LLAccordionCtrl::notifyParent(const LLSD& info)
}
if (i < mAccordionTabs.size())
{
- accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
+ accordion_tab = static_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
accordion_tab->notify(LLSD().with("action","select_first"));
return 1;
}
@@ -736,7 +712,7 @@ S32 LLAccordionCtrl::notifyParent(const LLSD& info)
{
for (size_t i = 0; i < mAccordionTabs.size(); ++i)
{
- LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
+ LLAccordionCtrlTab* accordion_tab = static_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
if (accordion_tab->hasFocus() && i > 0)
{
bool prev_visible_tab_found = false;
@@ -751,7 +727,7 @@ S32 LLAccordionCtrl::notifyParent(const LLSD& info)
if (prev_visible_tab_found)
{
- accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
+ accordion_tab = static_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
accordion_tab->notify(LLSD().with("action","select_last"));
return 1;
}
@@ -889,15 +865,12 @@ void LLAccordionCtrl::setFilterSubString(const std::string& filter_string)
const LLAccordionCtrlTab* LLAccordionCtrl::getExpandedTab() const
{
- typedef std::vector<LLAccordionCtrlTab*>::const_iterator tabs_const_iterator;
-
- const LLAccordionCtrlTab* result = 0;
-
- for (tabs_const_iterator i = mAccordionTabs.begin(); i != mAccordionTabs.end(); ++i)
+ const LLAccordionCtrlTab* result = nullptr;
+ for (LLAccordionCtrlTab* accordion_tab : mAccordionTabs)
{
- if ((*i)->isExpanded())
+ if (accordion_tab->isExpanded())
{
- result = *i;
+ result = accordion_tab;
break;
}
}
@@ -915,11 +888,11 @@ S32 LLAccordionCtrl::calcExpandedTabHeight(S32 tab_index /* = 0 */, S32 availabl
S32 collapsed_tabs_height = 0;
S32 num_expanded = 0;
- for (size_t n = tab_index; n < mAccordionTabs.size(); ++n)
+ for (LLAccordionCtrlTab* tab : mAccordionTabs)
{
- if (!mAccordionTabs[n]->isExpanded())
+ if (!tab->isExpanded())
{
- collapsed_tabs_height += mAccordionTabs[n]->getHeaderHeight();
+ collapsed_tabs_height += tab->getHeaderHeight();
}
else
{
@@ -941,10 +914,8 @@ void LLAccordionCtrl::collapseAllTabs()
{
if (mAccordionTabs.size() > 0)
{
- for (size_t i = 0; i < mAccordionTabs.size(); ++i)
+ for (LLAccordionCtrlTab* tab : mAccordionTabs)
{
- LLAccordionCtrlTab *tab = mAccordionTabs[i];
-
if (tab->getDisplayChildren())
{
tab->setDisplayChildren(false);
diff --git a/indra/llui/llaccordionctrl.h b/indra/llui/llaccordionctrl.h
index 1dfa9100f6..43a33a2b3c 100644
--- a/indra/llui/llaccordionctrl.h
+++ b/indra/llui/llaccordionctrl.h
@@ -57,8 +57,8 @@ public:
class LLTabComparator
{
public:
- LLTabComparator() {};
- virtual ~LLTabComparator() {};
+ LLTabComparator() = default;
+ virtual ~LLTabComparator() = default;
/** Returns true if tab1 < tab2, false otherwise */
virtual bool compare(const LLAccordionCtrlTab* tab1, const LLAccordionCtrlTab* tab2) const = 0;
@@ -103,8 +103,8 @@ public:
// Call reshape after changing splitter's size
virtual void reshape(S32 width, S32 height, bool called_from_parent = true);
- void addCollapsibleCtrl(LLView* view);
- void removeCollapsibleCtrl(LLView* view);
+ void addCollapsibleCtrl(LLAccordionCtrlTab* accordion_tab);
+ void removeCollapsibleCtrl(LLAccordionCtrlTab* accordion_tab);
void arrange();
@@ -180,20 +180,20 @@ private:
private:
LLRect mInnerRect;
- LLScrollbar* mScrollbar;
- bool mSingleExpansion;
- bool mFitParent;
- bool mAutoScrolling;
- F32 mAutoScrollRate;
- LLTextBox* mNoVisibleTabsHelpText;
+ LLScrollbar* mScrollbar = nullptr;
+ bool mSingleExpansion = false;
+ bool mFitParent = false;
+ bool mAutoScrolling = false;
+ F32 mAutoScrollRate = 0.f;
+ LLTextBox* mNoVisibleTabsHelpText = nullptr;
- bool mSkipScrollToChild;
+ bool mSkipScrollToChild = false;
std::string mNoMatchedTabsOrigString;
std::string mNoVisibleTabsOrigString;
- LLAccordionCtrlTab* mSelectedTab;
- const LLTabComparator* mTabComparator;
+ LLAccordionCtrlTab* mSelectedTab = nullptr;
+ const LLTabComparator* mTabComparator = nullptr;
};
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/llaccordionctrltab.h b/indra/llui/llaccordionctrltab.h
index cf3569683e..3fdcf9f7f2 100644
--- a/indra/llui/llaccordionctrltab.h
+++ b/indra/llui/llaccordionctrltab.h
@@ -126,7 +126,7 @@ public:
void setSelected(bool is_selected);
- bool getCollapsible() { return mCollapsible; };
+ bool getCollapsible() const { return mCollapsible; };
void setCollapsible(bool collapsible) { mCollapsible = collapsible; };
void changeOpenClose(bool is_open);
@@ -181,7 +181,7 @@ public:
void setHeaderVisible(bool value);
- bool getHeaderVisible() { return mHeaderVisible;}
+ bool getHeaderVisible() const { return mHeaderVisible;}
S32 mExpandedHeight; // Height of expanded ctrl.
// Used to restore height after expand.
diff --git a/indra/llui/llbadge.cpp b/indra/llui/llbadge.cpp
index 55fbd72165..42b6f1f07b 100644
--- a/indra/llui/llbadge.cpp
+++ b/indra/llui/llbadge.cpp
@@ -27,6 +27,8 @@
#define LLBADGE_CPP
#include "llbadge.h"
+#include "llfontgl.h"
+#include "llfontvertexbuffer.h"
#include "llscrollcontainer.h"
#include "lluictrlfactory.h"
@@ -36,7 +38,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,22 +199,20 @@ 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);
- LLVector4a vertices[6];
- vertices[0].set(screen_rect.mLeft, screen_rect.mTop, 1.0f);
- vertices[1].set(screen_rect.mLeft, screen_rect.mBottom, 1.0f);
- vertices[2].set(screen_rect.mRight, screen_rect.mTop, 1.0f);
- vertices[3].set(screen_rect.mRight, screen_rect.mTop, 1.0f);
- vertices[4].set(screen_rect.mLeft, screen_rect.mBottom, 1.0f);
- vertices[5].set(screen_rect.mRight, screen_rect.mBottom, 1.0f);
+ LLVector4a vertices[4];
+ vertices[0].set(screen_rect.mLeft, screen_rect.mTop, 1.0f);
+ vertices[1].set(screen_rect.mRight, screen_rect.mTop, 1.0f);
+ vertices[2].set(screen_rect.mLeft, screen_rect.mBottom, 1.0f);
+ vertices[3].set(screen_rect.mRight, screen_rect.mBottom, 1.0f);
- gGL.begin(LLRender::TRIANGLES);
+ gGL.begin(LLRender::TRIANGLE_STRIP);
{
- gGL.vertexBatchPreTransformed(vertices, 6);
+ gGL.vertexBatchPreTransformed(vertices, 4);
}
gGL.end();
@@ -233,8 +233,6 @@ void LLBadge::draw()
// Calculate badge size based on label text
//
- LLWString badge_label_wstring = mLabel;
-
S32 badge_label_begin_offset = 0;
S32 badge_char_length = S32_MAX;
S32 badge_pixel_length = S32_MAX;
@@ -242,7 +240,7 @@ void LLBadge::draw()
bool do_not_use_ellipses = false;
F32 badge_width = (2.0f * mPaddingHoriz) +
- mGLFont->getWidthF32(badge_label_wstring.c_str(), badge_label_begin_offset, badge_char_length);
+ mGLFont->getWidthF32(mLabel.getWString().c_str(), badge_label_begin_offset, badge_char_length);
F32 badge_height = (2.0f * mPaddingVert) + mGLFont->getLineHeight();
@@ -304,7 +302,7 @@ void LLBadge::draw()
}
else
{
- badge_center_x = location_offset_horiz;
+ badge_center_x = (F32)location_offset_horiz;
}
// Compute y position
@@ -321,7 +319,7 @@ void LLBadge::draw()
}
else
{
- badge_center_y = location_offset_vert;
+ badge_center_y = (F32)location_offset_vert;
}
//
@@ -355,17 +353,17 @@ void LLBadge::draw()
//
// Draw the label
//
-
- mGLFont->render(badge_label_wstring,
- badge_label_begin_offset,
- badge_center_x + mLabelOffsetHoriz,
- badge_center_y + mLabelOffsetVert,
- mLabelColor % alpha,
- LLFontGL::HCENTER, LLFontGL::VCENTER, // centered around the position
- LLFontGL::NORMAL, // normal text (not bold, italics, etc.)
- LLFontGL::DROP_SHADOW_SOFT,
- badge_char_length, badge_pixel_length,
- right_position_out, do_not_use_ellipses);
+ mFontBuffer.render(mGLFont,
+ mLabel.getWString(),
+ badge_label_begin_offset,
+ badge_center_x + mLabelOffsetHoriz,
+ badge_center_y + mLabelOffsetVert,
+ mLabelColor % alpha,
+ LLFontGL::HCENTER, LLFontGL::VCENTER, // centered around the position
+ LLFontGL::NORMAL, // normal text (not bold, italics, etc.)
+ LLFontGL::DROP_SHADOW_SOFT,
+ badge_char_length, badge_pixel_length,
+ right_position_out, do_not_use_ellipses);
}
}
}
diff --git a/indra/llui/llbadge.h b/indra/llui/llbadge.h
index a6d584c6d7..636e2c9ded 100644
--- a/indra/llui/llbadge.h
+++ b/indra/llui/llbadge.h
@@ -34,12 +34,14 @@
#include "llstring.h"
#include "lluiimage.h"
#include "llview.h"
+#include "llfontvertexbuffer.h"
//
// Declarations
//
class LLFontGL;
+class LLFontVertexBuffer;
class LLScrollContainer;
class LLUICtrlFactory;
@@ -144,6 +146,7 @@ private:
LLUIColor mBorderColor;
const LLFontGL* mGLFont;
+ LLFontVertexBuffer mFontBuffer;
LLPointer< LLUIImage > mImage;
LLUIColor mImageColor;
@@ -171,7 +174,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..d2534b3939 100644
--- a/indra/llui/llbutton.cpp
+++ b/indra/llui/llbutton.cpp
@@ -43,6 +43,8 @@
#include "llfloater.h"
#include "llfloaterreg.h"
#include "llfocusmgr.h"
+#include "llfontgl.h"
+#include "llfontvertexbuffer.h"
#include "llwindow.h"
#include "llnotificationsutil.h"
#include "llrender.h"
@@ -56,7 +58,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;
@@ -120,11 +122,10 @@ LLButton::Params::Params()
LLButton::LLButton(const LLButton::Params& p)
-: LLUICtrl(p),
+ : LLUICtrl(p),
LLBadgeOwner(getHandle()),
mMouseDownFrame(0),
mMouseHeldDownCount(0),
- mBorderEnabled( false ),
mFlashing( false ),
mCurGlowStrength(0.f),
mNeedsHighlight(false),
@@ -188,7 +189,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
@@ -329,6 +330,30 @@ void LLButton::onCommit()
LLUICtrl::onCommit();
}
+void LLButton::setUnselectedLabelColor(const LLUIColor& c)
+{
+ mUnselectedLabelColor = c;
+ mFontBuffer.reset();
+}
+
+void LLButton::setSelectedLabelColor(const LLUIColor& c)
+{
+ mSelectedLabelColor = c;
+ mFontBuffer.reset();
+}
+
+void LLButton::setUseEllipses(bool use_ellipses)
+{
+ mUseEllipses = use_ellipses;
+ mFontBuffer.reset();
+}
+
+void LLButton::setUseFontColor(bool use_font_color)
+{
+ mUseFontColor = use_font_color;
+ mFontBuffer.reset();
+}
+
boost::signals2::connection LLButton::setClickedCallback(const CommitCallbackParam& cb)
{
return setClickedCallback(initCommitCallback(cb));
@@ -396,6 +421,18 @@ bool LLButton::postBuild()
return LLUICtrl::postBuild();
}
+void LLButton::onVisibilityChange(bool new_visibility)
+{
+ mFontBuffer.reset();
+ return LLUICtrl::onVisibilityChange(new_visibility);
+}
+
+void LLButton::dirtyRect()
+{
+ LLUICtrl::dirtyRect();
+ mFontBuffer.reset();
+}
+
bool LLButton::handleUnicodeCharHere(llwchar uni_char)
{
bool handled = false;
@@ -582,19 +619,25 @@ void LLButton::onMouseLeave(S32 x, S32 y, MASK mask)
{
LLUICtrl::onMouseLeave(x, y, mask);
- mNeedsHighlight = false;
+ setHighlight(false);
}
void LLButton::setHighlight(bool b)
{
- mNeedsHighlight = b;
+ if (mNeedsHighlight != b)
+ {
+ mNeedsHighlight = b;
+ mFontBuffer.reset();
+ }
}
bool LLButton::handleHover(S32 x, S32 y, MASK mask)
{
if (isInEnabledChain()
&& (!gFocusMgr.getMouseCapture() || gFocusMgr.getMouseCapture() == this))
- mNeedsHighlight = true;
+ {
+ setHighlight(true);
+ }
if (!childrenHandleHover(x, y, mask))
{
@@ -794,10 +837,7 @@ void LLButton::draw()
// Highlight if needed
if( ll::ui::SearchableControl::getHighlighted() )
- label_color = ll::ui::SearchableControl::getHighlightColor();
-
- // Unselected label assignments
- LLWString label = getCurrentLabel();
+ label_color = ll::ui::SearchableControl::getHighlightFontColor();
// overlay with keyboard focus border
if (hasFocus())
@@ -927,8 +967,9 @@ void LLButton::draw()
}
// Draw label
- if( !label.empty() )
+ if( !getCurrentLabel().empty() ) // Unselected label assignments
{
+ LLWString label = getCurrentLabel();
LLWStringUtil::trim(label);
S32 x;
@@ -956,7 +997,7 @@ void LLButton::draw()
// LLFontGL::render expects S32 max_chars variable but process in a separate way -1 value.
// Due to U32_MAX is equal to S32 -1 value I have rest this value for non-ellipses mode.
// Not sure if it is really needed. Probably S32_MAX should be always passed as max_chars.
- mLastDrawCharsCount = mGLFont->render(label, 0,
+ mLastDrawCharsCount = mFontBuffer.render(mGLFont, label, 0,
(F32)x,
(F32)(getRect().getHeight() / 2 + mBottomVPad),
label_color % alpha,
@@ -998,6 +1039,7 @@ void LLButton::setToggleState(bool b)
setFlashing(false); // stop flash state whenever the selected/unselected state if reset
// Unselected label assignments
autoResize();
+ mFontBuffer.reset();
}
}
@@ -1027,11 +1069,13 @@ bool LLButton::toggleState()
void LLButton::setLabel( const std::string& label )
{
mUnselectedLabel = mSelectedLabel = label;
+ mFontBuffer.reset();
}
void LLButton::setLabel( const LLUIString& label )
{
mUnselectedLabel = mSelectedLabel = label;
+ mFontBuffer.reset();
}
void LLButton::setLabel( const LLStringExplicit& label )
@@ -1045,17 +1089,32 @@ bool LLButton::setLabelArg( const std::string& key, const LLStringExplicit& text
{
mUnselectedLabel.setArg(key, text);
mSelectedLabel.setArg(key, text);
+ mFontBuffer.reset();
return true;
}
void LLButton::setLabelUnselected( const LLStringExplicit& label )
{
mUnselectedLabel = label;
+ mFontBuffer.reset();
}
void LLButton::setLabelSelected( const LLStringExplicit& label )
{
mSelectedLabel = label;
+ mFontBuffer.reset();
+}
+
+void LLButton::setDisabledLabelColor(const LLUIColor& c)
+{
+ mDisabledLabelColor = c;
+ mFontBuffer.reset();
+}
+
+void LLButton::setFont(const LLFontGL* font)
+{
+ mGLFont = (font ? font : LLFontGL::getFontSansSerif());
+ mFontBuffer.reset();
}
bool LLButton::labelIsTruncated() const
@@ -1068,6 +1127,12 @@ const LLUIString& LLButton::getCurrentLabel() const
return getToggleState() ? mSelectedLabel : mUnselectedLabel;
}
+void LLButton::setDropShadowedText(bool b)
+{
+ mDropShadowedText = b;
+ mFontBuffer.reset();
+}
+
void LLButton::setImageUnselected(LLPointer<LLUIImage> image)
{
mImageUnselected = image;
@@ -1082,10 +1147,10 @@ void LLButton::autoResize()
resize(getCurrentLabel());
}
-void LLButton::resize(LLUIString label)
+void LLButton::resize(const LLUIString& label)
{
// get label length
- S32 label_width = mGLFont->getWidth(label.getString());
+ S32 label_width = mGLFont->getWidth(label.getWString().c_str());
// get current btn length
S32 btn_width =getRect().getWidth();
// check if it need resize
@@ -1129,12 +1194,12 @@ void LLButton::setImageSelected(LLPointer<LLUIImage> image)
mImageSelected = image;
}
-void LLButton::setImageColor(const LLColor4& c)
+void LLButton::setImageColor(const LLUIColor& c)
{
mImageColor = c;
}
-void LLButton::setColor(const LLColor4& color)
+void LLButton::setColor(const LLUIColor& color)
{
setImageColor(color);
}
@@ -1151,6 +1216,7 @@ void LLButton::setImageDisabledSelected(LLPointer<LLUIImage> image)
mImageDisabledSelected = image;
mDisabledImageColor = mImageColor;
mFadeWhenDisabled = true;
+ mFontBuffer.reset();
}
void LLButton::setImagePressed(LLPointer<LLUIImage> image)
@@ -1273,7 +1339,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..890e7c2d1e 100644
--- a/indra/llui/llbutton.h
+++ b/indra/llui/llbutton.h
@@ -34,7 +34,6 @@
#include "lluictrl.h"
#include "v4color.h"
#include "llframetimer.h"
-#include "llfontgl.h"
#include "lluiimage.h"
#include "lluistring.h"
@@ -55,6 +54,8 @@ S32 round_up(S32 grid, S32 value);
class LLUICtrlFactory;
+class LLFontGL;
+class LLFontVertexBuffer;
//
// Classes
@@ -156,26 +157,29 @@ public:
void addImageAttributeToXML(LLXMLNodePtr node, const std::string& imageName,
const LLUUID& imageID,const std::string& xmlTagName) const;
- virtual bool handleUnicodeCharHere(llwchar uni_char);
- virtual bool handleKeyHere(KEY key, MASK mask);
- virtual bool handleMouseDown(S32 x, S32 y, MASK mask);
- virtual bool handleMouseUp(S32 x, S32 y, MASK mask);
- virtual bool handleHover(S32 x, S32 y, MASK mask);
- virtual bool handleRightMouseDown(S32 x, S32 y, MASK mask);
- virtual bool handleRightMouseUp(S32 x, S32 y, MASK mask);
- virtual bool handleDoubleClick(S32 x, S32 y, MASK mask);
- virtual void draw();
- /*virtual*/ bool postBuild();
+ virtual bool handleUnicodeCharHere(llwchar uni_char) override;
+ virtual bool handleKeyHere(KEY key, MASK mask) override;
+ virtual bool handleMouseDown(S32 x, S32 y, MASK mask) override;
+ virtual bool handleMouseUp(S32 x, S32 y, MASK mask) override;
+ virtual bool handleHover(S32 x, S32 y, MASK mask) override;
+ virtual bool handleRightMouseDown(S32 x, S32 y, MASK mask) override;
+ virtual bool handleRightMouseUp(S32 x, S32 y, MASK mask) override;
+ virtual bool handleDoubleClick(S32 x, S32 y, MASK mask) override;
+ virtual void draw() override;
+ /*virtual*/ bool postBuild() override;
- virtual void onMouseLeave(S32 x, S32 y, MASK mask);
- virtual void onMouseCaptureLost();
+ void onVisibilityChange(bool visible) override;
+ void dirtyRect() override;
- virtual void onCommit();
+ virtual void onMouseLeave(S32 x, S32 y, MASK mask) override;
+ virtual void onMouseCaptureLost() override;
- void setUnselectedLabelColor( const LLColor4& c ) { mUnselectedLabelColor = c; }
- void setSelectedLabelColor( const LLColor4& c ) { mSelectedLabelColor = c; }
- void setUseEllipses( bool use_ellipses ) { mUseEllipses = use_ellipses; }
- void setUseFontColor( bool use_font_color) { mUseFontColor = use_font_color; }
+ virtual void onCommit() override;
+
+ void setUnselectedLabelColor(const LLUIColor& c);
+ void setSelectedLabelColor(const LLUIColor& c);
+ void setUseEllipses(bool use_ellipses);
+ void setUseFontColor(bool use_font_color);
boost::signals2::connection setClickedCallback(const CommitCallbackParam& cb);
@@ -223,15 +227,14 @@ public:
const std::string getLabelUnselected() const { return wstring_to_utf8str(mUnselectedLabel); }
const std::string getLabelSelected() const { return wstring_to_utf8str(mSelectedLabel); }
- void setImageColor(const std::string& color_control);
- void setImageColor(const LLColor4& c);
- /*virtual*/ void setColor(const LLColor4& c);
+ void setImageColor(const LLUIColor& c);
+ /*virtual*/ void setColor(const LLUIColor& c) override;
void setImages(const std::string &image_name, const std::string &selected_name);
- void setDisabledImageColor(const LLColor4& c) { mDisabledImageColor = c; }
+ void setDisabledImageColor(const LLUIColor& c) { mDisabledImageColor = c; }
- void setDisabledSelectedLabelColor( const LLColor4& c ) { mDisabledSelectedLabelColor = c; }
+ void setDisabledSelectedLabelColor( const LLUIColor& c ) { mDisabledSelectedLabelColor = c; }
void setImageOverlay(const std::string& image_name, LLFontGL::HAlign alignment = LLFontGL::HCENTER, const LLColor4& color = LLColor4::white);
void setImageOverlay(const LLUUID& image_id, LLFontGL::HAlign alignment = LLFontGL::HCENTER, const LLColor4& color = LLColor4::white);
@@ -239,19 +242,18 @@ public:
LLFontGL::HAlign getImageOverlayHAlign() const { return mImageOverlayAlignment; }
void autoResize(); // resize with label of current btn state
- void resize(LLUIString label); // resize with label input
+ void resize(const LLUIString& label); // resize with label input
void setLabel(const std::string& label);
void setLabel(const LLUIString& label);
void setLabel( const LLStringExplicit& label);
- virtual bool setLabelArg( const std::string& key, const LLStringExplicit& text );
+ virtual bool setLabelArg( const std::string& key, const LLStringExplicit& text ) override;
void setLabelUnselected(const LLStringExplicit& label);
void setLabelSelected(const LLStringExplicit& label);
- void setDisabledLabelColor( const LLColor4& c ) { mDisabledLabelColor = c; }
+ void setDisabledLabelColor(const LLUIColor& c);
- void setFont(const LLFontGL *font)
- { mGLFont = ( font ? font : LLFontGL::getFontSansSerif()); }
- const LLFontGL* getFont() const { return mGLFont; }
- const std::string& getText() const { return getCurrentLabel().getString(); }
+ void setFont(const LLFontGL* font);
+ const LLFontGL* getFont() const override { return mGLFont; }
+ const std::string& getText() const override { return getCurrentLabel().getString(); }
S32 getLastDrawCharsCount() const { return mLastDrawCharsCount; }
bool labelIsTruncated() const;
@@ -260,9 +262,7 @@ public:
void setScaleImage(bool scale) { mScaleImage = scale; }
bool getScaleImage() const { return mScaleImage; }
- void setDropShadowedText(bool b) { mDropShadowedText = b; }
-
- void setBorderEnabled(bool b) { mBorderEnabled = b; }
+ void setDropShadowedText(bool b);
void setHoverGlowStrength(F32 strength) { mHoverGlowStrength = strength; }
@@ -278,7 +278,6 @@ public:
void setCommitOnReturn(bool commit) { mCommitOnReturn = commit; }
bool getCommitOnReturn() const { return mCommitOnReturn; }
- static void onHeldDown(void *userdata); // to be called by gIdleCallbacks
static void toggleFloaterAndSetToggleState(LLUICtrl* ctrl, const LLSD& sdname);
static void setFloaterToggle(LLUICtrl* ctrl, const LLSD& sdname);
static void setDockableFloaterToggle(LLUICtrl* ctrl, const LLSD& sdname);
@@ -305,8 +304,6 @@ protected:
commit_signal_t* mMouseUpSignal;
commit_signal_t* mHeldDownSignal;
- const LLFontGL* mGLFont;
-
S32 mMouseDownFrame;
S32 mMouseHeldDownCount; // Counter for parameter passed to held-down callback
F32 mHeldDownDelay; // seconds, after which held-down callbacks get called
@@ -358,7 +355,6 @@ protected:
bool mAutoResize;
bool mUseEllipses;
bool mUseFontColor;
- bool mBorderEnabled;
bool mFlashing;
LLFontGL::HAlign mHAlign;
@@ -390,8 +386,12 @@ protected:
bool mForceFlashing; // Stick flashing color even if button is pressed
bool mHandleRightMouse;
+private:
+ const LLFontGL* mGLFont;
+ LLFontVertexBuffer mFontBuffer;
+
protected:
- virtual std::string _getSearchText() const
+ virtual std::string _getSearchText() const override
{
return getLabelUnselected() + getToolTip();
}
@@ -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/llchatentry.cpp b/indra/llui/llchatentry.cpp
index da5afd0386..7506cd99c0 100644
--- a/indra/llui/llchatentry.cpp
+++ b/indra/llui/llchatentry.cpp
@@ -45,12 +45,14 @@ LLChatEntry::LLChatEntry(const Params& p)
mExpandLinesCount(p.expand_lines_count),
mPrevLinesCount(0),
mSingleLineMode(false),
- mPrevExpandedLineCount(S32_MAX)
+ mPrevExpandedLineCount(S32_MAX),
+ mCurrentInput("")
{
// Initialize current history line iterator
mCurrentHistoryLine = mLineHistory.begin();
mAutoIndent = false;
+ mShowChatMentionPicker = true;
keepSelectionOnReturn(true);
}
@@ -189,6 +191,7 @@ bool LLChatEntry::handleSpecialKey(const KEY key, const MASK mask)
{
needsReflow();
}
+ mCurrentInput = "";
break;
case KEY_UP:
@@ -196,6 +199,11 @@ bool LLChatEntry::handleSpecialKey(const KEY key, const MASK mask)
{
if (!mLineHistory.empty() && mCurrentHistoryLine > mLineHistory.begin())
{
+ if (mCurrentHistoryLine == mLineHistory.end())
+ {
+ mCurrentInput = getText();
+ }
+
setText(*(--mCurrentHistoryLine));
endOfDoc();
}
@@ -210,16 +218,15 @@ bool LLChatEntry::handleSpecialKey(const KEY key, const MASK mask)
case KEY_DOWN:
if (mHasHistory && MASK_CONTROL == mask)
{
- if (!mLineHistory.empty() && mCurrentHistoryLine < (mLineHistory.end() - 1) )
+ if (!mLineHistory.empty() && mCurrentHistoryLine < (mLineHistory.end() - 1))
{
setText(*(++mCurrentHistoryLine));
endOfDoc();
}
- else if (!mLineHistory.empty() && mCurrentHistoryLine == (mLineHistory.end() - 1) )
+ else if (!mLineHistory.empty() && mCurrentHistoryLine == (mLineHistory.end() - 1))
{
mCurrentHistoryLine++;
- std::string empty("");
- setText(empty);
+ setText(mCurrentInput);
needsReflow();
endOfDoc();
}
diff --git a/indra/llui/llchatentry.h b/indra/llui/llchatentry.h
index 5621ede1e7..9a0e8ee91e 100644
--- a/indra/llui/llchatentry.h
+++ b/indra/llui/llchatentry.h
@@ -101,6 +101,8 @@ private:
S32 mExpandLinesCount;
S32 mPrevLinesCount;
S32 mPrevExpandedLineCount;
+
+ std::string mCurrentInput;
};
#endif /* LLCHATENTRY_H_ */
diff --git a/indra/llui/llchatmentionhelper.cpp b/indra/llui/llchatmentionhelper.cpp
new file mode 100644
index 0000000000..5745389a58
--- /dev/null
+++ b/indra/llui/llchatmentionhelper.cpp
@@ -0,0 +1,158 @@
+/**
+* @file llchatmentionhelper.cpp
+*
+* $LicenseInfo:firstyear=2025&license=viewerlgpl$
+* Second Life Viewer Source Code
+* Copyright (C) 2025, Linden Research, Inc.
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation;
+* version 2.1 of the License only.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*
+* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+* $/LicenseInfo$
+*/
+
+#include "linden_common.h"
+
+#include "llchatmentionhelper.h"
+#include "llfloater.h"
+#include "llfloaterreg.h"
+#include "lluictrl.h"
+
+constexpr char CHAT_MENTION_HELPER_FLOATER[] = "chat_mention_picker";
+
+bool LLChatMentionHelper::isActive(const LLUICtrl* ctrl) const
+{
+ return mHostHandle.get() == ctrl;
+}
+
+bool LLChatMentionHelper::isCursorInNameMention(const LLWString& wtext, S32 cursor_pos, S32* mention_start_pos) const
+{
+ if (cursor_pos <= 0 || cursor_pos > static_cast<S32>(wtext.size()))
+ return false;
+
+ // Find the beginning of the current word
+ S32 start = cursor_pos - 1;
+ while (start > 0 && wtext[start - 1] != U32(' ') && wtext[start - 1] != U32('\n'))
+ {
+ --start;
+ }
+
+ if (wtext[start] != U32('@'))
+ return false;
+
+ if (mention_start_pos)
+ *mention_start_pos = start;
+
+ S32 word_length = cursor_pos - start;
+
+ if (word_length == 1)
+ {
+ return true;
+ }
+
+ // Get the name after '@'
+ std::string name = wstring_to_utf8str(wtext.substr(start + 1, word_length - 1));
+ LLStringUtil::toLower(name);
+ for (const auto& av_name : mAvatarNames)
+ {
+ if (av_name == name || av_name.find(name) == 0)
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void LLChatMentionHelper::showHelper(LLUICtrl* host_ctrl, S32 local_x, S32 local_y, const std::string& av_name, std::function<void(std::string)> cb)
+{
+ if (mHelperHandle.isDead())
+ {
+ LLFloater* av_picker_floater = LLFloaterReg::getInstance(CHAT_MENTION_HELPER_FLOATER);
+ mHelperHandle = av_picker_floater->getHandle();
+ mHelperCommitConn = av_picker_floater->setCommitCallback([&](LLUICtrl* ctrl, const LLSD& param) { onCommitName(param.asString()); });
+ }
+ setHostCtrl(host_ctrl);
+ mNameCommitCb = cb;
+
+ S32 floater_x, floater_y;
+ if (!host_ctrl->localPointToOtherView(local_x, local_y, &floater_x, &floater_y, gFloaterView))
+ {
+ LL_WARNS() << "Cannot show helper for non-floater controls." << LL_ENDL;
+ return;
+ }
+
+ LLFloater* av_picker_floater = mHelperHandle.get();
+ LLRect rect = av_picker_floater->getRect();
+ rect.setLeftTopAndSize(floater_x, floater_y + rect.getHeight(), rect.getWidth(), rect.getHeight());
+ av_picker_floater->setRect(rect);
+ if (av_picker_floater->isShown())
+ {
+ av_picker_floater->onOpen(LLSD().with("av_name", av_name));
+ }
+ else
+ {
+ av_picker_floater->openFloater(LLSD().with("av_name", av_name));
+ }
+}
+
+void LLChatMentionHelper::hideHelper(const LLUICtrl* ctrl)
+{
+ if ((ctrl && !isActive(ctrl)))
+ {
+ return;
+ }
+ setHostCtrl(nullptr);
+}
+
+bool LLChatMentionHelper::handleKey(const LLUICtrl* ctrl, KEY key, MASK mask)
+{
+ if (mHelperHandle.isDead() || !isActive(ctrl))
+ {
+ return false;
+ }
+
+ return mHelperHandle.get()->handleKey(key, mask, true);
+}
+
+void LLChatMentionHelper::onCommitName(std::string name_url)
+{
+ if (!mHostHandle.isDead() && mNameCommitCb)
+ {
+ mNameCommitCb(name_url);
+ }
+}
+
+void LLChatMentionHelper::setHostCtrl(LLUICtrl* host_ctrl)
+{
+ const LLUICtrl* pCurHostCtrl = mHostHandle.get();
+ if (pCurHostCtrl != host_ctrl)
+ {
+ mHostCtrlFocusLostConn.disconnect();
+ mHostHandle.markDead();
+ mNameCommitCb = {};
+
+ if (!mHelperHandle.isDead())
+ {
+ mHelperHandle.get()->closeFloater();
+ }
+
+ if (host_ctrl)
+ {
+ mHostHandle = host_ctrl->getHandle();
+ mHostCtrlFocusLostConn = host_ctrl->setFocusLostCallback(std::bind([&]() { hideHelper(getHostCtrl()); }));
+ }
+ }
+}
diff --git a/indra/llui/llchatmentionhelper.h b/indra/llui/llchatmentionhelper.h
new file mode 100644
index 0000000000..5f95d06f31
--- /dev/null
+++ b/indra/llui/llchatmentionhelper.h
@@ -0,0 +1,66 @@
+/**
+* @file llchatmentionhelper.h
+* @brief Header file for LLChatMentionHelper
+*
+* $LicenseInfo:firstyear=2025&license=viewerlgpl$
+* Second Life Viewer Source Code
+* Copyright (C) 2025, Linden Research, Inc.
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation;
+* version 2.1 of the License only.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*
+* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+* $/LicenseInfo$
+*/
+
+#pragma once
+
+#include "llhandle.h"
+#include "llsingleton.h"
+
+#include <boost/signals2.hpp>
+
+class LLFloater;
+class LLUICtrl;
+
+class LLChatMentionHelper : public LLSingleton<LLChatMentionHelper>
+{
+ LLSINGLETON(LLChatMentionHelper) {}
+ ~LLChatMentionHelper() override {}
+
+public:
+
+ bool isActive(const LLUICtrl* ctrl) const;
+ bool isCursorInNameMention(const LLWString& wtext, S32 cursor_pos, S32* mention_start_pos = nullptr) const;
+ void showHelper(LLUICtrl* host_ctrl, S32 local_x, S32 local_y, const std::string& av_name, std::function<void(std::string)> commit_cb);
+ void hideHelper(const LLUICtrl* ctrl = nullptr);
+
+ bool handleKey(const LLUICtrl* ctrl, KEY key, MASK mask);
+ void onCommitName(std::string name_url);
+
+ void updateAvatarList(std::vector<std::string> av_names) { mAvatarNames = av_names; }
+
+protected:
+ void setHostCtrl(LLUICtrl* host_ctrl);
+ LLUICtrl* getHostCtrl() const { return mHostHandle.get(); }
+
+private:
+ LLHandle<LLUICtrl> mHostHandle;
+ LLHandle<LLFloater> mHelperHandle;
+ boost::signals2::connection mHostCtrlFocusLostConn;
+ boost::signals2::connection mHelperCommitConn;
+ std::function<void(std::string)> mNameCommitCb;
+
+ std::vector<std::string> mAvatarNames;
+};
diff --git a/indra/llui/llcheckboxctrl.cpp b/indra/llui/llcheckboxctrl.cpp
index 3bcf0a6517..fc751cfc7f 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()
{
@@ -172,11 +172,11 @@ void LLCheckBoxCtrl::setEnabled(bool b)
if (b)
{
- mLabel->setColor( mTextEnabledColor.get() );
+ mLabel->setColor( mTextEnabledColor );
}
else
{
- mLabel->setColor( mTextDisabledColor.get() );
+ mLabel->setColor( mTextDisabledColor );
}
}
diff --git a/indra/llui/llcheckboxctrl.h b/indra/llui/llcheckboxctrl.h
index 3058e946c3..4068741978 100644
--- a/indra/llui/llcheckboxctrl.h
+++ b/indra/llui/llcheckboxctrl.h
@@ -36,8 +36,8 @@
// Constants
//
-const bool RADIO_STYLE = true;
-const bool CHECK_STYLE = false;
+constexpr bool RADIO_STYLE = true;
+constexpr bool CHECK_STYLE = false;
//
// Classes
@@ -94,7 +94,7 @@ public:
// LLUICtrl interface
virtual void setValue(const LLSD& value );
virtual LLSD getValue() const;
- bool get() { return (bool)getValue().asBoolean(); }
+ bool get() const { return (bool)getValue().asBoolean(); }
void set(bool value) { setValue(value); }
virtual void setTentative(bool b);
@@ -106,12 +106,12 @@ public:
virtual void onCommit();
// LLCheckBoxCtrl interface
- virtual bool toggle() { return mButton->toggleState(); } // returns new state
+ virtual bool toggle() { return mButton->toggleState(); } // returns new state
void setBtnFocus() { mButton->setFocus(true); }
- void setEnabledColor( const LLColor4 &color ) { mTextEnabledColor = color; }
- void setDisabledColor( const LLColor4 &color ) { mTextDisabledColor = color; }
+ void setEnabledColor( const LLUIColor&color ) { mTextEnabledColor = color; }
+ void setDisabledColor( const LLUIColor&color ) { mTextDisabledColor = color; }
void setLabel( const LLStringExplicit& label );
std::string getLabel() const;
@@ -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..f3876ef695 100644
--- a/indra/llui/llcombobox.cpp
+++ b/indra/llui/llcombobox.cpp
@@ -107,7 +107,7 @@ LLComboBox::LLComboBox(const LLComboBox::Params& p)
button_params.follows.flags(FOLLOWS_LEFT|FOLLOWS_BOTTOM|FOLLOWS_RIGHT);
button_params.rect(p.rect);
- if(mAllowTextEntry)
+ if (mAllowTextEntry)
{
button_params.pad_right(2);
}
@@ -121,7 +121,7 @@ LLComboBox::LLComboBox(const LLComboBox::Params& p)
mButton = LLUICtrlFactory::create<LLButton>(button_params);
- if(mAllowTextEntry)
+ if (mAllowTextEntry)
{
//redo to compensate for button hack that leaves space for a character
//unless it is a "minimal combobox"(drop down)
@@ -207,14 +207,27 @@ void LLComboBox::clear()
void LLComboBox::onCommit()
{
- if (mAllowTextEntry && getCurrentIndex() != -1)
+ if (LLScrollListItem* item = mList->getFirstSelected())
{
- // we have selected an existing item, blitz the manual text entry with
- // the properly capitalized item
- mTextEntry->setValue(getSimple());
- mTextEntry->setTentative(false);
+ if (mAllowTextEntry && mTextEntry)
+ {
+ // we have selected an existing item, blitz the manual text entry with
+ // the properly capitalized item
+ LLSD label = item->getColumn(0)->getValue();
+ mTextEntry->setValue(label);
+ mTextEntry->setTentative(false);
+ }
+ setControlValue(item->getValue());
+ }
+ else if (mAllowTextEntry)
+ {
+ setControlValue(mTextEntry->getValue());
+ }
+ else
+ {
+ setControlValue(LLSD());
}
- setControlValue(getValue());
+
LLUICtrl::onCommit();
}
@@ -349,6 +362,13 @@ bool LLComboBox::setSimple(const LLStringExplicit& name)
// virtual
void LLComboBox::setValue(const LLSD& value)
{
+ if (LLScrollListItem* item = mList->getFirstSelected())
+ {
+ LLSD item_value = item->getValue();
+ if (item_value.asString() == value.asString())
+ return;
+ }
+
bool found = mList->selectByValue(value);
if (found)
{
@@ -372,10 +392,8 @@ const std::string LLComboBox::getSimple() const
{
return mTextEntry->getText();
}
- else
- {
- return res;
- }
+
+ return res;
}
const std::string LLComboBox::getSelectedItemLabel(S32 column) const
@@ -386,24 +404,22 @@ const std::string LLComboBox::getSelectedItemLabel(S32 column) const
// virtual
LLSD LLComboBox::getValue() const
{
- LLScrollListItem* item = mList->getFirstSelected();
- if( item )
+ if (LLScrollListItem* item = mList->getFirstSelected())
{
return item->getValue();
}
- else if (mAllowTextEntry)
+
+ if (mAllowTextEntry)
{
return mTextEntry->getValue();
}
- else
- {
- return LLSD();
- }
+
+ return LLSD();
}
void LLComboBox::setLabel(const LLStringExplicit& name)
{
- if ( mTextEntry )
+ if (mTextEntry)
{
mTextEntry->setText(name);
if (mList->selectItemByLabel(name, false))
@@ -498,27 +514,80 @@ void LLComboBox::setButtonVisible(bool visible)
}
}
-bool LLComboBox::setCurrentByIndex( S32 index )
+bool LLComboBox::setCurrentByIndex(S32 index)
{
- bool found = mList->selectNthItem( index );
- if (found)
+ if (LLScrollListItem* item = mList->getItemByIndex(index))
{
- setLabel(getSelectedItemLabel());
- mLastSelectedIndex = index;
+ if (item->getEnabled())
+ {
+ mList->selectItem(item, -1, true);
+ LLSD::String label = item->getColumn(0)->getValue().asString();
+ if (mTextEntry)
+ {
+ mTextEntry->setText(label);
+ mTextEntry->setTentative(false);
+ }
+ if (!mAllowTextEntry)
+ {
+ mButton->setLabel(label);
+ }
+ mLastSelectedIndex = index;
+ return true;
+ }
}
- return found;
+
+ return false;
}
S32 LLComboBox::getCurrentIndex() const
{
- LLScrollListItem* item = mList->getFirstSelected();
- if( item )
+ if (LLScrollListItem* item = mList->getFirstSelected())
{
- return mList->getItemIndex( item );
+ return mList->getItemIndex(item);
}
return -1;
}
+bool LLComboBox::selectNextItem()
+{
+ S32 last_index = getItemCount() - 1;
+ if (last_index < 0)
+ return false;
+
+ S32 current_index = getCurrentIndex();
+ if (current_index >= last_index)
+ return false;
+
+ S32 new_index = llmax(current_index, -1);
+ while (++new_index <= last_index)
+ {
+ if (setCurrentByIndex(new_index))
+ return true;
+ }
+
+ return false;
+}
+
+bool LLComboBox::selectPrevItem()
+{
+ S32 last_index = getItemCount() - 1;
+ if (last_index < 0)
+ return false;
+
+ S32 current_index = getCurrentIndex();
+ if (!current_index)
+ return false;
+
+ S32 new_index = current_index > 0 ? current_index : last_index + 1;
+ while (--new_index >= 0)
+ {
+ if (setCurrentByIndex(new_index))
+ return true;
+ }
+
+ return false;
+}
+
void LLComboBox::setEnabledByValue(const LLSD& value, bool enabled)
{
LLScrollListItem *found = mList->getItem(value);
@@ -875,6 +944,51 @@ 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;
+ }
+ }
+
+ S32 current_index = getCurrentIndex();
+ if (clicks > 0)
+ {
+ for (S32 i = 0; i < clicks; ++i)
+ {
+ if (!selectNextItem())
+ break;
+ }
+ }
+ else
+ {
+ for (S32 i = 0; i < -clicks; ++i)
+ {
+ if (!selectPrevItem())
+ break;
+ }
+ }
+ S32 new_index = getCurrentIndex();
+
+ if (new_index != current_index)
+ {
+ prearrangeList();
+ onCommit();
+ return true;
+ }
+
+ return false;
+}
+
void LLComboBox::setTextEntry(const LLStringExplicit& text)
{
if (mTextEntry)
diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h
index cc1c2885fc..8be3eb57e4 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
@@ -162,9 +163,12 @@ public:
bool remove(const std::string& name); // remove item "name", return true if found and removed
- bool setCurrentByIndex( S32 index );
+ bool setCurrentByIndex(S32 index);
S32 getCurrentIndex() const;
+ bool selectNextItem();
+ bool selectPrevItem();
+
void setEnabledByValue(const LLSD& value, bool enabled);
void createLineEditor(const Params&);
diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp
index 03717da80b..b10ec51f18 100644
--- a/indra/llui/llcommandmanager.cpp
+++ b/indra/llui/llcommandmanager.cpp
@@ -170,12 +170,14 @@ bool LLCommandManager::load()
if (!parser.readXUI(commands_file, commandsParams))
{
+ LLError::LLUserWarningMsg::showMissingFiles();
LL_ERRS() << "Unable to load xml file: " << commands_file << LL_ENDL;
return false;
}
if (!commandsParams.validateBlock())
{
+ LLError::LLUserWarningMsg::showMissingFiles();
LL_ERRS() << "Invalid commands file: " << commands_file << LL_ENDL;
return false;
}
diff --git a/indra/llui/llconsole.cpp b/indra/llui/llconsole.cpp
index 9fbfb3e5fa..91e6f281da 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 )
@@ -183,10 +183,11 @@ void LLConsole::draw()
static LLCachedControl<F32> console_bg_opacity(*LLUI::getInstance()->mSettingGroups["config"], "ConsoleBackgroundOpacity", 0.7f);
F32 console_opacity = llclamp(console_bg_opacity(), 0.f, 1.f);
- LLColor4 color = LLUIColorTable::instance().getColor("ConsoleBackground");
+ static LLUIColor console_color = LLUIColorTable::instance().getColor("ConsoleBackground");
+ LLColor4 color = console_color;
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/llcontainerview.cpp b/indra/llui/llcontainerview.cpp
index 4c2912cde6..b414e4354d 100644
--- a/indra/llui/llcontainerview.cpp
+++ b/indra/llui/llcontainerview.cpp
@@ -46,7 +46,7 @@ static ContainerViewRegistry::Register<LLPanel> r3("panel", &LLPanel::fromXML);
LLContainerView::LLContainerView(const LLContainerView::Params& p)
: LLView(p),
mShowLabel(p.show_label),
- mLabel(p.label),
+ mLabel(utf8str_to_wstring(p.label)),
mDisplayChildren(p.display_children)
{
mScrollContainer = NULL;
@@ -120,8 +120,8 @@ void LLContainerView::draw()
// Draw the label
if (mShowLabel)
{
- LLFontGL::getFontMonospace()->renderUTF8(
- mLabel, 0, 2, getRect().getHeight() - 2, LLColor4(1,1,1,1), LLFontGL::LEFT, LLFontGL::TOP);
+ LLFontGL::getFontMonospace()->render(
+ mLabel, 0, 2.f, (F32)(getRect().getHeight() - 2), LLColor4(1,1,1,1), LLFontGL::LEFT, LLFontGL::TOP);
}
LLView::draw();
@@ -285,7 +285,7 @@ LLRect LLContainerView::getRequiredRect()
void LLContainerView::setLabel(const std::string& label)
{
- mLabel = label;
+ mLabel = utf8str_to_wstring(label);
}
void LLContainerView::setDisplayChildren(bool displayChildren)
diff --git a/indra/llui/llcontainerview.h b/indra/llui/llcontainerview.h
index 319fb7d5e9..2675d21c22 100644
--- a/indra/llui/llcontainerview.h
+++ b/indra/llui/llcontainerview.h
@@ -65,21 +65,21 @@ protected:
public:
~LLContainerView();
- /*virtual*/ bool postBuild();
- /*virtual*/ bool addChild(LLView* view, S32 tab_group = 0);
+ bool postBuild() override;
+ bool addChild(LLView* view, S32 tab_group = 0) override;
- /*virtual*/ bool handleDoubleClick(S32 x, S32 y, MASK mask);
- /*virtual*/ bool handleMouseDown(S32 x, S32 y, MASK mask);
- /*virtual*/ bool handleMouseUp(S32 x, S32 y, MASK mask);
+ bool handleDoubleClick(S32 x, S32 y, MASK mask) override;
+ bool handleMouseDown(S32 x, S32 y, MASK mask) override;
+ bool handleMouseUp(S32 x, S32 y, MASK mask) override;
- /*virtual*/ void draw();
- /*virtual*/ void reshape(S32 width, S32 height, bool called_from_parent = true);
- /*virtual*/ LLRect getRequiredRect(); // Return the height of this object, given the set options.
+ void draw() override;
+ void reshape(S32 width, S32 height, bool called_from_parent = true) override;
+ LLRect getRequiredRect() override; // Return the height of this object, given the set options.
void setLabel(const std::string& label);
void showLabel(bool show) { mShowLabel = show; }
void setDisplayChildren(bool displayChildren);
- bool getDisplayChildren() { return mDisplayChildren; }
+ bool getDisplayChildren() const { return mDisplayChildren; }
void setScrollContainer(LLScrollContainer* scroll) {mScrollContainer = scroll;}
private:
@@ -89,6 +89,6 @@ public:
protected:
bool mDisplayChildren;
- std::string mLabel;
+ LLWString mLabel;
};
#endif // LL_CONTAINERVIEW_
diff --git a/indra/llui/lldockablefloater.h b/indra/llui/lldockablefloater.h
index 3effc977db..9c516e23a4 100644
--- a/indra/llui/lldockablefloater.h
+++ b/indra/llui/lldockablefloater.h
@@ -112,8 +112,8 @@ public:
virtual bool overlapsScreenChannel() { return mOverlapsScreenChannel && getVisible() && isDocked(); }
virtual void setOverlapsScreenChannel(bool overlaps) { mOverlapsScreenChannel = overlaps; }
- bool getUniqueDocking() { return mUniqueDocking; }
- bool getUseTongue() { return mUseTongue; }
+ bool getUniqueDocking() const { return mUniqueDocking; }
+ bool getUseTongue() const { return mUseTongue; }
void setUseTongue(bool use_tongue) { mUseTongue = use_tongue;}
private:
diff --git a/indra/llui/lldockcontrol.cpp b/indra/llui/lldockcontrol.cpp
index bf0862e8a9..1a00c03856 100644
--- a/indra/llui/lldockcontrol.cpp
+++ b/indra/llui/lldockcontrol.cpp
@@ -43,6 +43,8 @@ LLDockControl::LLDockControl(LLView* dockWidget, LLFloater* dockableFloater,
mDockWidgetHandle = dockWidget->getHandle();
}
+ mNonToolbarPanelHandle = mDockableFloater->getRootView()->getChild<LLView>("non_toolbar_panel")->getHandle();
+
if (dockableFloater->isDocked())
{
on();
@@ -97,7 +99,10 @@ void LLDockControl::setDock(LLView* dockWidget)
void LLDockControl::getAllowedRect(LLRect& rect)
{
- rect = mDockableFloater->getRootView()->getChild<LLView>("non_toolbar_panel")->getRect();
+ if(!mNonToolbarPanelHandle.isDead())
+ {
+ rect = mNonToolbarPanelHandle.get()->getRect();
+ }
}
void LLDockControl::repositionDockable()
@@ -151,7 +156,7 @@ void LLDockControl::repositionDockable()
}
}
-bool LLDockControl::isDockVisible()
+bool LLDockControl::isDockVisible() const
{
bool res = true;
diff --git a/indra/llui/lldockcontrol.h b/indra/llui/lldockcontrol.h
index fb0bf7d251..b6ac9c19dd 100644
--- a/indra/llui/lldockcontrol.h
+++ b/indra/llui/lldockcontrol.h
@@ -61,19 +61,19 @@ public:
void off();
void forceRecalculatePosition();
void setDock(LLView* dockWidget);
- LLView* getDock()
+ LLView* getDock() const
{
return mDockWidgetHandle.get();
}
void repositionDockable();
void drawToungue();
- bool isDockVisible();
+ bool isDockVisible() const;
// gets a rect that bounds possible positions for a dockable control (EXT-1111)
void getAllowedRect(LLRect& rect);
- S32 getTongueWidth() { return mDockTongue->getWidth(); }
- S32 getTongueHeight() { return mDockTongue->getHeight(); }
+ S32 getTongueWidth() const { return mDockTongue->getWidth(); }
+ S32 getTongueHeight() const { return mDockTongue->getHeight(); }
private:
virtual void moveDockable();
@@ -84,6 +84,7 @@ private:
bool mDockWidgetVisible;
DocAt mDockAt;
LLHandle<LLView> mDockWidgetHandle;
+ LLHandle<LLView> mNonToolbarPanelHandle;
LLRect mPrevDockRect;
LLRect mRootRect;
LLRect mFloaterRect;
diff --git a/indra/llui/lldraghandle.h b/indra/llui/lldraghandle.h
index a522e63243..73211d5292 100644
--- a/indra/llui/lldraghandle.h
+++ b/indra/llui/lldraghandle.h
@@ -66,7 +66,7 @@ public:
void setMaxTitleWidth(S32 max_width) {mMaxTitleWidth = llmin(max_width, mMaxTitleWidth); }
S32 getMaxTitleWidth() const { return mMaxTitleWidth; }
void setButtonsRect(const LLRect& rect){ mButtonsRect = rect; }
- LLRect getButtonsRect() { return mButtonsRect; }
+ LLRect getButtonsRect() const { return mButtonsRect; }
void setTitleVisible(bool visible);
virtual void setTitle( const std::string& title ) = 0;
diff --git a/indra/llui/llemojihelper.cpp b/indra/llui/llemojihelper.cpp
index fbe313924c..b2c59ce775 100644
--- a/indra/llui/llemojihelper.cpp
+++ b/indra/llui/llemojihelper.cpp
@@ -76,7 +76,9 @@ bool LLEmojiHelper::isCursorInEmojiCode(const LLWString& wtext, S32 cursorPos, S
shortCodePos--;
}
- bool isShortCode = (L':' == wtext[shortCodePos - 1]) && (cursorPos - shortCodePos >= 2);
+ bool isShortCode = (cursorPos - shortCodePos >= 2) && (L':' == wtext[shortCodePos - 1]);
+ if(isShortCode && (shortCodePos >= 2) && isdigit(wtext[shortCodePos - 2])) // <TS:3T> Add qualifier to avoid emoji pop-up when typing times.
+ isShortCode = false;
if (pShortCodePos)
*pShortCodePos = (isShortCode) ? shortCodePos - 1 : -1;
return isShortCode;
@@ -97,6 +99,7 @@ void LLEmojiHelper::showHelper(LLUICtrl* hostctrl_p, S32 local_x, S32 local_y, c
LLFloater* pHelperFloater = LLFloaterReg::getInstance(DEFAULT_EMOJI_HELPER_FLOATER);
mHelperHandle = pHelperFloater->getHandle();
mHelperCommitConn = pHelperFloater->setCommitCallback(std::bind([&](const LLSD& sdValue) { onCommitEmoji(utf8str_to_wstring(sdValue.asStringRef())[0]); }, std::placeholders::_2));
+ mHelperCloseConn = pHelperFloater->setCloseCallback([this](LLUICtrl* ctrl, const LLSD& param) { onCloseHelper(ctrl, param); });
}
setHostCtrl(hostctrl_p);
mEmojiCommitCb = cb;
@@ -146,6 +149,16 @@ void LLEmojiHelper::onCommitEmoji(llwchar emoji)
}
}
+void LLEmojiHelper::onCloseHelper(LLUICtrl* ctrl, const LLSD& param)
+{
+ mCloseSignal(ctrl, param);
+}
+
+boost::signals2::connection LLEmojiHelper::setCloseCallback(const commit_signal_t::slot_type& cb)
+{
+ return mCloseSignal.connect(cb);
+}
+
void LLEmojiHelper::setHostCtrl(LLUICtrl* hostctrl_p)
{
const LLUICtrl* pCurHostCtrl = mHostHandle.get();
diff --git a/indra/llui/llemojihelper.h b/indra/llui/llemojihelper.h
index 2834b06061..26840eef94 100644
--- a/indra/llui/llemojihelper.h
+++ b/indra/llui/llemojihelper.h
@@ -51,16 +51,23 @@ public:
// Eventing
bool handleKey(const LLUICtrl* ctrl_p, KEY key, MASK mask);
void onCommitEmoji(llwchar emoji);
+ void onCloseHelper(LLUICtrl* ctrl, const LLSD& param);
+
+ typedef boost::signals2::signal<void(LLUICtrl* ctrl, const LLSD& param)> commit_signal_t;
+ boost::signals2::connection setCloseCallback(const commit_signal_t::slot_type& cb);
protected:
LLUICtrl* getHostCtrl() const { return mHostHandle.get(); }
void setHostCtrl(LLUICtrl* hostctrl_p);
private:
+ commit_signal_t mCloseSignal;
+
LLHandle<LLUICtrl> mHostHandle;
LLHandle<LLFloater> mHelperHandle;
boost::signals2::connection mHostCtrlFocusLostConn;
boost::signals2::connection mHelperCommitConn;
+ boost::signals2::connection mHelperCloseConn;
std::function<void(llwchar)> mEmojiCommitCb;
bool mIsHideDisabled;
};
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/llfiltereditor.h b/indra/llui/llfiltereditor.h
index 686827d94c..685219c9f6 100644
--- a/indra/llui/llfiltereditor.h
+++ b/indra/llui/llfiltereditor.h
@@ -49,7 +49,7 @@ protected:
LLFilterEditor(const Params&);
friend class LLUICtrlFactory;
- /*virtual*/ void handleKeystroke();
+ void handleKeystroke() override;
};
#endif // LL_FILTEREDITOR_H
diff --git a/indra/llui/llflashtimer.cpp b/indra/llui/llflashtimer.cpp
index c3db24c987..54f54653e2 100644
--- a/indra/llui/llflashtimer.cpp
+++ b/indra/llui/llflashtimer.cpp
@@ -85,12 +85,12 @@ void LLFlashTimer::stopFlashing()
mCurrentTickCount = 0;
}
-bool LLFlashTimer::isFlashingInProgress()
+bool LLFlashTimer::isFlashingInProgress() const
{
return mIsFlashingInProgress;
}
-bool LLFlashTimer::isCurrentlyHighlighted()
+bool LLFlashTimer::isCurrentlyHighlighted() const
{
return mIsCurrentlyHighlighted;
}
diff --git a/indra/llui/llflashtimer.h b/indra/llui/llflashtimer.h
index b55ce53fc0..4ef70faf2d 100644
--- a/indra/llui/llflashtimer.h
+++ b/indra/llui/llflashtimer.h
@@ -51,8 +51,8 @@ public:
void startFlashing();
void stopFlashing();
- bool isFlashingInProgress();
- bool isCurrentlyHighlighted();
+ bool isFlashingInProgress() const;
+ bool isCurrentlyHighlighted() const;
/*
* Use this instead of deleting this object.
* The next call to tick() will return true and that will destroy this object.
diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp
index 1799968afb..8178bada42 100644
--- a/indra/llui/llflatlistview.cpp
+++ b/indra/llui/llflatlistview.cpp
@@ -459,6 +459,7 @@ LLFlatListView::LLFlatListView(const LLFlatListView::Params& p)
, mNoItemsCommentTextbox(NULL)
, mIsConsecutiveSelection(false)
, mKeepSelectionVisibleOnReshape(p.keep_selection_visible_on_reshape)
+ , mFocusOnItemClicked(true)
{
mBorderThickness = getBorderWidth();
@@ -610,7 +611,10 @@ void LLFlatListView::onItemMouseClick(item_pair_t* item_pair, MASK mask)
return;
}
- setFocus(true);
+ if (mFocusOnItemClicked)
+ {
+ setFocus(true);
+ }
bool select_item = !isSelected(item_pair);
@@ -1250,17 +1254,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 +1270,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 +1286,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();
}
@@ -1351,7 +1341,7 @@ void LLFlatListViewEx::updateNoItemsMessage(const std::string& filter_string)
}
}
-bool LLFlatListViewEx::getForceShowingUnmatchedItems()
+bool LLFlatListViewEx::getForceShowingUnmatchedItems() const
{
return mForceShowingUnmatchedItems;
}
@@ -1412,11 +1402,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/llflatlistview.h b/indra/llui/llflatlistview.h
index 6d75e9f282..6271231183 100644
--- a/indra/llui/llflatlistview.h
+++ b/indra/llui/llflatlistview.h
@@ -113,7 +113,7 @@ public:
};
// disable traversal when finding widget to hand focus off to
- /*virtual*/ bool canFocusChildren() const { return false; }
+ /*virtual*/ bool canFocusChildren() const override { return false; }
/**
* Connects callback to signal called when Return key is pressed.
@@ -121,15 +121,15 @@ public:
boost::signals2::connection setReturnCallback( const commit_signal_t::slot_type& cb ) { return mOnReturnSignal.connect(cb); }
/** Overridden LLPanel's reshape, height is ignored, the list sets its height to accommodate all items */
- virtual void reshape(S32 width, S32 height, bool called_from_parent = true);
+ virtual void reshape(S32 width, S32 height, bool called_from_parent = true) override;
/** Returns full rect of child panel */
const LLRect& getItemsRect() const;
- LLRect getRequiredRect() { return getItemsRect(); }
+ LLRect getRequiredRect() override { return getItemsRect(); }
/** Returns distance between items */
- const S32 getItemsPad() { return mItemPad; }
+ const S32 getItemsPad() const { return mItemPad; }
/**
* Adds and item and LLSD value associated with it to the list at specified position
@@ -264,13 +264,13 @@ public:
void setCommitOnSelectionChange(bool b) { mCommitOnSelectionChange = b; }
/** Get number of selected items in the list */
- U32 numSelected() const {return static_cast<U32>(mSelectedItemPairs.size()); }
+ U32 numSelected() const { return static_cast<U32>(mSelectedItemPairs.size()); }
/** Get number of (visible) items in the list */
U32 size(const bool only_visible_items = true) const;
/** Removes all items from the list */
- virtual void clear();
+ virtual void clear() override;
/**
* Removes all items that can be detached from the list but doesn't destroy
@@ -294,10 +294,12 @@ public:
void scrollToShowFirstSelectedItem();
- void selectFirstItem ();
- void selectLastItem ();
+ void selectFirstItem();
+ void selectLastItem();
- virtual S32 notify(const LLSD& info) ;
+ virtual S32 notify(const LLSD& info) override;
+
+ void setFocusOnItemClicked(bool b) { mFocusOnItemClicked = b; }
virtual ~LLFlatListView();
@@ -346,8 +348,8 @@ protected:
virtual bool selectNextItemPair(bool is_up_direction, bool reset_selection);
- virtual bool canSelectAll() const;
- virtual void selectAll();
+ virtual bool canSelectAll() const override;
+ virtual void selectAll() override;
virtual bool isSelected(item_pair_t* item_pair) const;
@@ -364,15 +366,15 @@ protected:
*/
void notifyParentItemsRectChanged();
- virtual bool handleKeyHere(KEY key, MASK mask);
+ virtual bool handleKeyHere(KEY key, MASK mask) override;
- virtual bool postBuild();
+ virtual bool postBuild() override;
- virtual void onFocusReceived();
+ virtual void onFocusReceived() override;
- virtual void onFocusLost();
+ virtual void onFocusLost() override;
- virtual void draw();
+ virtual void draw() override;
LLRect getLastSelectedItemRect();
@@ -423,6 +425,8 @@ private:
bool mKeepSelectionVisibleOnReshape;
+ bool mFocusOnItemClicked;
+
/** All pairs of the list */
pairs_list_t mItemPairs;
@@ -478,7 +482,7 @@ public:
void setNoItemsMsg(const std::string& msg) { mNoItemsMsg = msg; }
void setNoFilteredItemsMsg(const std::string& msg) { mNoFilteredItemsMsg = msg; }
- bool getForceShowingUnmatchedItems();
+ bool getForceShowingUnmatchedItems() const;
void setForceShowingUnmatchedItems(bool show);
@@ -486,7 +490,7 @@ public:
* Sets up new filter string and filters the list.
*/
void setFilterSubString(const std::string& filter_str, bool notify_parent);
- std::string getFilterSubString() { return mFilterSubString; }
+ std::string getFilterSubString() const { return mFilterSubString; }
/**
* Filters the list, rearranges and notifies parent about shape changes.
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index f29f9286c9..fd07b2ec5d 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);
+ }
}
- if (dependent_rect.mBottom - getRect().mBottom >= old_rect.getHeight() ||
- dependent_rect.mTop == getRect().mBottom + old_rect.getHeight())
+ 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())
+ && 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);
@@ -1943,6 +1983,9 @@ void LLFloater::onClickCloseBtn(bool app_quitting)
// virtual
void LLFloater::draw()
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_UI;
+ LL_PROFILE_ZONE_TEXT(getTitle().c_str(), getTitle().length());
+
const F32 alpha = getCurrentTransparency();
// draw background
@@ -1999,21 +2042,6 @@ void LLFloater::draw()
LLPanel::updateDefaultBtn();
- if( getDefaultButton() )
- {
- if (hasFocus() && getDefaultButton()->getEnabled())
- {
- LLFocusableElement* focus_ctrl = gFocusMgr.getKeyboardFocus();
- // is this button a direct descendent and not a nested widget (e.g. checkbox)?
- bool focus_is_child_button = dynamic_cast<LLButton*>(focus_ctrl) != NULL && dynamic_cast<LLButton*>(focus_ctrl)->getParent() == this;
- // only enable default button when current focus is not a button
- getDefaultButton()->setBorderEnabled(!focus_is_child_button);
- }
- else
- {
- getDefaultButton()->setBorderEnabled(false);
- }
- }
if (isMinimized())
{
for (S32 i = 0; i < BUTTON_COUNT; i++)
@@ -2137,7 +2165,7 @@ void LLFloater::setCanDrag(bool can_drag)
}
}
-bool LLFloater::getCanDrag()
+bool LLFloater::getCanDrag() const
{
return mDragHandle->getEnabled();
}
@@ -2247,36 +2275,28 @@ void LLFloater::drawConeToOwner(F32 &context_cone_opacity,
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
LLGLEnable(GL_CULL_FACE);
- gGL.begin(LLRender::QUADS);
+ gGL.begin(LLRender::TRIANGLE_STRIP);
{
gGL.color4f(0.f, 0.f, 0.f, contex_cone_in_alpha * context_cone_opacity);
gGL.vertex2i(owner_rect.mLeft, owner_rect.mTop);
- gGL.vertex2i(owner_rect.mRight, owner_rect.mTop);
gGL.color4f(0.f, 0.f, 0.f, contex_cone_out_alpha * context_cone_opacity);
- gGL.vertex2i(local_rect.mRight, local_rect.mTop);
gGL.vertex2i(local_rect.mLeft, local_rect.mTop);
-
- gGL.color4f(0.f, 0.f, 0.f, contex_cone_out_alpha * context_cone_opacity);
- gGL.vertex2i(local_rect.mLeft, local_rect.mTop);
- gGL.vertex2i(local_rect.mLeft, local_rect.mBottom);
gGL.color4f(0.f, 0.f, 0.f, contex_cone_in_alpha * context_cone_opacity);
- gGL.vertex2i(owner_rect.mLeft, owner_rect.mBottom);
- gGL.vertex2i(owner_rect.mLeft, owner_rect.mTop);
-
+ gGL.vertex2i(owner_rect.mRight, owner_rect.mTop);
gGL.color4f(0.f, 0.f, 0.f, contex_cone_out_alpha * context_cone_opacity);
- gGL.vertex2i(local_rect.mRight, local_rect.mBottom);
gGL.vertex2i(local_rect.mRight, local_rect.mTop);
gGL.color4f(0.f, 0.f, 0.f, contex_cone_in_alpha * context_cone_opacity);
- gGL.vertex2i(owner_rect.mRight, owner_rect.mTop);
gGL.vertex2i(owner_rect.mRight, owner_rect.mBottom);
-
-
gGL.color4f(0.f, 0.f, 0.f, contex_cone_out_alpha * context_cone_opacity);
- gGL.vertex2i(local_rect.mLeft, local_rect.mBottom);
gGL.vertex2i(local_rect.mRight, local_rect.mBottom);
gGL.color4f(0.f, 0.f, 0.f, contex_cone_in_alpha * context_cone_opacity);
- gGL.vertex2i(owner_rect.mRight, owner_rect.mBottom);
gGL.vertex2i(owner_rect.mLeft, owner_rect.mBottom);
+ gGL.color4f(0.f, 0.f, 0.f, contex_cone_out_alpha * context_cone_opacity);
+ gGL.vertex2i(local_rect.mLeft, local_rect.mBottom);
+ gGL.color4f(0.f, 0.f, 0.f, contex_cone_in_alpha * context_cone_opacity);
+ gGL.vertex2i(owner_rect.mLeft, owner_rect.mTop);
+ gGL.color4f(0.f, 0.f, 0.f, contex_cone_out_alpha * context_cone_opacity);
+ gGL.vertex2i(local_rect.mLeft, local_rect.mTop);
}
gGL.end();
}
@@ -3626,7 +3646,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();
}
@@ -3669,28 +3689,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
@@ -3717,27 +3737,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/llfloater.h b/indra/llui/llfloater.h
index 9be2240f6f..9e1594bdd2 100644
--- a/indra/llui/llfloater.h
+++ b/indra/llui/llfloater.h
@@ -46,24 +46,24 @@ class LLMultiFloater;
class LLFloater;
-const bool RESIZE_YES = true;
-const bool RESIZE_NO = false;
+constexpr bool RESIZE_YES = true;
+constexpr bool RESIZE_NO = false;
-const bool DRAG_ON_TOP = false;
-const bool DRAG_ON_LEFT = true;
+constexpr bool DRAG_ON_TOP = false;
+constexpr bool DRAG_ON_LEFT = true;
-const bool MINIMIZE_YES = true;
-const bool MINIMIZE_NO = false;
+constexpr bool MINIMIZE_YES = true;
+constexpr bool MINIMIZE_NO = false;
-const bool CLOSE_YES = true;
-const bool CLOSE_NO = false;
+constexpr bool CLOSE_YES = true;
+constexpr bool CLOSE_NO = false;
-const bool ADJUST_VERTICAL_YES = true;
-const bool ADJUST_VERTICAL_NO = false;
+constexpr bool ADJUST_VERTICAL_YES = true;
+constexpr bool ADJUST_VERTICAL_NO = false;
-const F32 CONTEXT_CONE_IN_ALPHA = 0.f;
-const F32 CONTEXT_CONE_OUT_ALPHA = 1.f;
-const F32 CONTEXT_CONE_FADE_TIME = .08f;
+constexpr F32 CONTEXT_CONE_IN_ALPHA = 0.f;
+constexpr F32 CONTEXT_CONE_OUT_ALPHA = 1.f;
+constexpr F32 CONTEXT_CONE_FADE_TIME = .08f;
namespace LLFloaterEnums
{
@@ -228,7 +228,7 @@ public:
/*virtual*/ void setIsChrome(bool is_chrome);
/*virtual*/ void setRect(const LLRect &rect);
void setIsSingleInstance(bool is_single_instance);
- bool getIsSingleInstance() { return mSingleInstance; }
+ bool getIsSingleInstance() const { return mSingleInstance; }
void initFloater(const Params& p);
@@ -274,17 +274,17 @@ public:
static bool isShown(const LLFloater* floater);
static bool isVisible(const LLFloater* floater);
static bool isMinimized(const LLFloater* floater);
- bool isFirstLook() { return mFirstLook; } // EXT-2653: This function is necessary to prevent overlapping for secondary showed toasts
+ bool isFirstLook() const { return mFirstLook; } // EXT-2653: This function is necessary to prevent overlapping for secondary showed toasts
virtual bool isFrontmost();
- bool isDependent() { return !mDependeeHandle.isDead(); }
+ bool isDependent() const { return !mDependeeHandle.isDead(); }
void setCanMinimize(bool can_minimize);
void setCanClose(bool can_close);
void setCanTearOff(bool can_tear_off);
virtual void setCanResize(bool can_resize);
void setCanDrag(bool can_drag);
- bool getCanDrag();
+ bool getCanDrag() const;
void setHost(LLMultiFloater* host);
- bool isResizable() const { return mResizable; }
+ bool isResizable() const { return mResizable; }
void setResizeLimits( S32 min_width, S32 min_height );
void getResizeLimits( S32* min_width, S32* min_height ) { *min_width = mMinWidth; *min_height = mMinHeight; }
@@ -347,7 +347,7 @@ public:
virtual void setDocked(bool docked, bool pop_on_undock = true);
virtual void setTornOff(bool torn_off) { mTornOff = torn_off; }
- bool isTornOff() {return mTornOff;}
+ bool isTornOff() const { return mTornOff; }
void setOpenPositioning(LLFloaterEnums::EOpenPositioning pos) {mPositioning = pos;}
@@ -377,6 +377,10 @@ public:
void enableResizeCtrls(bool enable, bool width = true, bool height = true);
bool isPositioning(LLFloaterEnums::EOpenPositioning p) const { return (p == mPositioning); }
+
+ void setAutoFocus(bool focus) { mAutoFocus = focus; } // whether to automatically take focus when opened
+ bool getAutoFocus() const { return mAutoFocus; }
+
protected:
void applyControlsAndPosition(LLFloater* other);
@@ -401,8 +405,6 @@ protected:
void setExpandedRect(const LLRect& rect) { mExpandedRect = rect; } // size when not minimized
const LLRect& getExpandedRect() const { return mExpandedRect; }
- void setAutoFocus(bool focus) { mAutoFocus = focus; } // whether to automatically take focus when opened
- bool getAutoFocus() const { return mAutoFocus; }
LLDragHandle* getDragHandle() const { return mDragHandle; }
void destroy(); // Don't call this directly. You probably want to call closeFloater()
@@ -423,7 +425,6 @@ protected:
private:
void setForeground(bool b); // called only by floaterview
void cleanupHandles(); // remove handles to dead floaters
- void createMinimizeButton();
void buildButtons(const Params& p);
// Images and tooltips are named in the XML, but we want to look them
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/llfloaterreglistener.h b/indra/llui/llfloaterreglistener.h
index a36072892c..28f6e7c66b 100644
--- a/indra/llui/llfloaterreglistener.h
+++ b/indra/llui/llfloaterreglistener.h
@@ -30,7 +30,6 @@
#define LL_LLFLOATERREGLISTENER_H
#include "lleventapi.h"
-#include <string>
class LLSD;
diff --git a/indra/llui/llflyoutbutton.h b/indra/llui/llflyoutbutton.h
index 7a49501318..73190fc984 100644
--- a/indra/llui/llflyoutbutton.h
+++ b/indra/llui/llflyoutbutton.h
@@ -54,7 +54,7 @@ protected:
LLFlyoutButton(const Params&);
friend class LLUICtrlFactory;
public:
- virtual void draw();
+ void draw() override;
void setToggleState(bool state);
diff --git a/indra/llui/llfocusmgr.cpp b/indra/llui/llfocusmgr.cpp
index e0e789f730..0d7c98294f 100644
--- a/indra/llui/llfocusmgr.cpp
+++ b/indra/llui/llfocusmgr.cpp
@@ -59,12 +59,6 @@ bool LLFocusableElement::handleUnicodeChar(llwchar uni_char, bool called_from_pa
}
// virtual
-bool LLFocusableElement::handleUnicodeString(char *uni_str, bool editing, bool called_from_parent)
-{
- return FALSE;
-}
-
-// virtual
bool LLFocusableElement::wantsKeyUpKeyDown() const
{
return false;
@@ -79,10 +73,20 @@ bool LLFocusableElement::wantsReturnKey() const
// virtual
LLFocusableElement::~LLFocusableElement()
{
- delete mFocusLostCallback;
- delete mFocusReceivedCallback;
- delete mFocusChangedCallback;
- delete mTopLostCallback;
+ auto free_signal = [&](focus_signal_t*& signal)
+ {
+ if (signal)
+ {
+ signal->disconnect_all_slots();
+ delete signal;
+ signal = nullptr;
+ }
+ };
+
+ free_signal(mFocusLostCallback);
+ free_signal(mFocusReceivedCallback);
+ free_signal(mFocusChangedCallback);
+ free_signal(mTopLostCallback);
}
void LLFocusableElement::onFocusReceived()
@@ -189,7 +193,7 @@ void LLFocusMgr::releaseFocusIfNeeded( LLView* view )
}
}
- LLUI::getInstance()->removePopup(view);
+ if(LLUI::instanceExists()) LLUI::getInstance()->removePopup(view);
}
void LLFocusMgr::setKeyboardFocus(LLFocusableElement* new_focus, bool lock, bool keystrokes_only)
@@ -487,7 +491,7 @@ void LLFocusMgr::setAppHasFocus(bool focus)
// release focus from "top ctrl"s, which generally hides them
if (!focus)
{
- LLUI::getInstance()->clearPopups();
+ if(LLUI::instanceExists()) LLUI::getInstance()->clearPopups();
}
mAppHasFocus = focus;
}
diff --git a/indra/llui/llfocusmgr.h b/indra/llui/llfocusmgr.h
index 1ca6f50354..89fee5c9f1 100644
--- a/indra/llui/llfocusmgr.h
+++ b/indra/llui/llfocusmgr.h
@@ -59,7 +59,6 @@ public:
virtual bool handleKey(KEY key, MASK mask, bool called_from_parent);
virtual bool handleKeyUp(KEY key, MASK mask, bool called_from_parent);
virtual bool handleUnicodeChar(llwchar uni_char, bool called_from_parent);
- virtual bool handleUnicodeString(char *uni_str, bool editing, bool called_from_parent);
/**
* If true this LLFocusableElement wants to receive KEYUP and KEYDOWN messages
@@ -98,7 +97,7 @@ public:
LLFocusableElement* getLastKeyboardFocus() const { return mLastKeyboardFocus; }
bool childHasKeyboardFocus( const LLView* parent ) const;
void removeKeyboardFocusWithoutCallback( const LLFocusableElement* focus );
- bool getKeystrokesOnly() { return mKeystrokesOnly; }
+ bool getKeystrokesOnly() const { return mKeystrokesOnly; }
void setKeystrokesOnly(bool keystrokes_only) { mKeystrokesOnly = keystrokes_only; }
F32 getFocusFlashAmt() const;
diff --git a/indra/llui/llfolderview.cpp b/indra/llui/llfolderview.cpp
index 1d4ecbe9c9..b664065532 100644
--- a/indra/llui/llfolderview.cpp
+++ b/indra/llui/llfolderview.cpp
@@ -28,6 +28,7 @@
#include "llfolderview.h"
#include "llfolderviewmodel.h"
+#include "llcallbacklist.h"
#include "llclipboard.h" // *TODO: remove this once hack below gone.
#include "llkeyboard.h"
#include "lllineeditor.h"
@@ -211,7 +212,7 @@ LLFolderView::LLFolderView(const Params& p)
//clear label
// go ahead and render root folder as usual
// just make sure the label ("Inventory Folder") never shows up
- mLabel = LLStringUtil::null;
+ mLabel.clear();
// Escape is handled by reverting the rename, not commiting it (default behavior)
LLLineEditor::Params params;
@@ -274,7 +275,11 @@ LLFolderView::~LLFolderView( void )
mRenamer = NULL;
mStatusTextBox = NULL;
- if (mPopupMenuHandle.get()) mPopupMenuHandle.get()->die();
+ if (mPopupMenuHandle.get())
+ {
+ mPopupMenuHandle.get()->die();
+ gIdleCallbacks.deleteFunction(onIdleUpdateMenu, this);
+ }
mPopupMenuHandle.markDead();
mAutoOpenItems.removeAllNodes();
@@ -1095,7 +1100,10 @@ bool LLFolderView::handleKeyHere( KEY key, MASK mask )
LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get();
if (menu && menu->isOpen())
{
- LLMenuGL::sMenuContainer->hideMenus();
+ if (LLMenuGL::sMenuContainer->hideMenus())
+ {
+ gIdleCallbacks.deleteFunction(onIdleUpdateMenu, this);
+ }
}
switch( key )
@@ -1340,7 +1348,10 @@ bool LLFolderView::handleUnicodeCharHere(llwchar uni_char)
LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get();
if (menu && menu->isOpen())
{
- LLMenuGL::sMenuContainer->hideMenus();
+ if (LLMenuGL::sMenuContainer->hideMenus())
+ {
+ gIdleCallbacks.deleteFunction(onIdleUpdateMenu, this);
+ }
}
//do text search
@@ -1612,7 +1623,11 @@ void LLFolderView::deleteAllChildren()
{
LLUI::getInstance()->removePopup(mRenamer);
}
- if (mPopupMenuHandle.get()) mPopupMenuHandle.get()->die();
+ if (mPopupMenuHandle.get())
+ {
+ mPopupMenuHandle.get()->die();
+ gIdleCallbacks.deleteFunction(onIdleUpdateMenu, this);
+ }
mPopupMenuHandle.markDead();
mScrollContainer = NULL;
mRenameItem = NULL;
@@ -1649,7 +1664,7 @@ void LLFolderView::scrollToShowItem(LLFolderViewItem* item, const LLRect& constr
{
LLRect local_rect = item->getLocalRect();
S32 icon_height = mIcon.isNull() ? 0 : mIcon->getHeight();
- S32 label_height = getLabelFontForStyle(mLabelStyle)->getLineHeight();
+ S32 label_height = getLabelFont()->getLineHeight();
// when navigating with keyboard, only move top of opened folder on screen, otherwise show whole folder
S32 max_height_to_show = item->isOpen() && mScrollContainer->hasFocus() ? (llmax( icon_height, label_height ) + item->getIconPad()) : local_rect.getHeight();
@@ -1979,9 +1994,24 @@ void LLFolderView::updateMenu()
LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get();
if (menu && menu->getVisible())
{
- updateMenuOptions(menu);
+ // When fetching folders in bulk or in parts, each callback
+ // cause updateMenu individually, so make sure it gets called
+ // only once per frame, after callbacks are done.
+ // gIdleCallbacks has built in dupplicate protection.
+ gIdleCallbacks.addFunction(onIdleUpdateMenu, this);
+ }
+}
+
+void LLFolderView::onIdleUpdateMenu(void* user_data)
+{
+ LLFolderView* self = (LLFolderView*)user_data;
+ LLMenuGL* menu = (LLMenuGL*)self->mPopupMenuHandle.get();
+ if (menu)
+ {
+ self->updateMenuOptions(menu);
menu->needsArrange(); // update menu height if needed
}
+ gIdleCallbacks.deleteFunction(onIdleUpdateMenu, self);
}
bool LLFolderView::isFolderSelected()
diff --git a/indra/llui/llfolderview.h b/indra/llui/llfolderview.h
index 62ef2a0626..bdce9dec54 100644
--- a/indra/llui/llfolderview.h
+++ b/indra/llui/llfolderview.h
@@ -124,11 +124,11 @@ public:
void setSelectCallback(const signal_t::slot_type& cb) { mSelectSignal.connect(cb); }
void setReshapeCallback(const signal_t::slot_type& cb) { mReshapeSignal.connect(cb); }
- bool getAllowMultiSelect() { return mAllowMultiSelect; }
- bool getAllowDrag() { return mAllowDrag; }
+ bool getAllowMultiSelect() const { return mAllowMultiSelect; }
+ bool getAllowDrag() const { return mAllowDrag; }
void setSingleFolderMode(bool is_single_mode) { mSingleFolderMode = is_single_mode; }
- bool isSingleFolderMode() { return mSingleFolderMode; }
+ bool isSingleFolderMode() const { return mSingleFolderMode; }
// Close all folders in the view
void closeAllFolders();
@@ -142,7 +142,7 @@ public:
virtual S32 getItemHeight() const;
void arrangeAll() { mArrangeGeneration++; }
- S32 getArrangeGeneration() { return mArrangeGeneration; }
+ S32 getArrangeGeneration() const { return mArrangeGeneration; }
// applies filters to control visibility of items
virtual void filter( LLFolderViewFilter& filter);
@@ -227,27 +227,27 @@ public:
void setShowSelectionContext(bool show) { mShowSelectionContext = show; }
bool getShowSelectionContext();
void setShowSingleSelection(bool show);
- bool getShowSingleSelection() { return mShowSingleSelection; }
- F32 getSelectionFadeElapsedTime() { return mMultiSelectionFadeTimer.getElapsedTimeF32(); }
- bool getUseEllipses() { return mUseEllipses; }
- S32 getSelectedCount() { return (S32)mSelectedItems.size(); }
+ bool getShowSingleSelection() const { return mShowSingleSelection; }
+ F32 getSelectionFadeElapsedTime() const { return mMultiSelectionFadeTimer.getElapsedTimeF32(); }
+ bool getUseEllipses() const { return mUseEllipses; }
+ S32 getSelectedCount() const { return (S32)mSelectedItems.size(); }
- void update(); // needs to be called periodically (e.g. once per frame)
+ void update(); // needs to be called periodically (e.g. once per frame)
- bool needsAutoSelect() { return mNeedsAutoSelect && !mAutoSelectOverride; }
- bool needsAutoRename() { return mNeedsAutoRename; }
+ bool needsAutoSelect() const { return mNeedsAutoSelect && !mAutoSelectOverride; }
+ bool needsAutoRename() const { return mNeedsAutoRename; }
void setNeedsAutoRename(bool val) { mNeedsAutoRename = val; }
void setPinningSelectedItem(bool val) { mPinningSelectedItem = val; }
void setAutoSelectOverride(bool val) { mAutoSelectOverride = val; }
- bool showItemLinkOverlays() { return mShowItemLinkOverlays; }
+ bool showItemLinkOverlays() const { return mShowItemLinkOverlays; }
void setCallbackRegistrar(LLUICtrl::CommitCallbackRegistry::ScopedRegistrar* registrar) { mCallbackRegistrar = registrar; }
void setEnableRegistrar(LLUICtrl::EnableCallbackRegistry::ScopedRegistrar* registrar) { mEnableRegistrar = registrar; }
void setForceArrange(bool force) { mForceArrange = force; }
- LLPanel* getParentPanel() { return mParentPanel.get(); }
+ LLPanel* getParentPanel() const { return mParentPanel.get(); }
// DEBUG only
void dumpSelectionInformation();
@@ -255,7 +255,7 @@ public:
void setShowEmptyMessage(bool show_msg) { mShowEmptyMessage = show_msg; }
- bool useLabelSuffix() { return mUseLabelSuffix; }
+ bool useLabelSuffix() const { return mUseLabelSuffix; }
virtual void updateMenu();
void finishRenamingItem( void );
@@ -266,6 +266,7 @@ public:
private:
void updateMenuOptions(LLMenuGL* menu);
void updateRenamerPosition();
+ static void onIdleUpdateMenu(void* user_data);
protected:
LLScrollContainer* mScrollContainer; // NULL if this is not a child of a scroll container.
@@ -390,7 +391,7 @@ public:
virtual ~LLSelectFirstFilteredItem() {}
virtual void doFolder(LLFolderViewFolder* folder);
virtual void doItem(LLFolderViewItem* item);
- bool wasItemSelected() { return mItemSelected || mFolderSelected; }
+ bool wasItemSelected() const { return mItemSelected || mFolderSelected; }
protected:
bool mItemSelected;
bool mFolderSelected;
@@ -414,6 +415,7 @@ public:
virtual void doItem(LLFolderViewItem* item) {}
void setApply(bool apply);
void clearOpenFolders() { mOpenFolders.clear(); }
+ bool hasOpenFolders() { return !mOpenFolders.empty(); }
protected:
std::set<LLUUID> mOpenFolders;
bool mApply;
diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp
index 82cd2483e8..6d0cfcba95 100644
--- a/indra/llui/llfolderviewitem.cpp
+++ b/indra/llui/llfolderviewitem.cpp
@@ -23,7 +23,7 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
-#include "../newview/llviewerprecompiledheaders.h"
+#include "linden_common.h"
#include "llflashtimer.h"
@@ -48,7 +48,6 @@ static LLDefaultChildRegistry::Register<LLFolderViewItem> r("folder_view_item");
// statics
std::map<U8, LLFontGL*> LLFolderViewItem::sFonts; // map of styles to fonts
-bool LLFolderViewItem::sColorSetInitialized = false;
LLUIColor LLFolderViewItem::sFgColor;
LLUIColor LLFolderViewItem::sHighlightBgColor;
LLUIColor LLFolderViewItem::sFlashBgColor;
@@ -58,6 +57,10 @@ LLUIColor LLFolderViewItem::sFilterBGColor;
LLUIColor LLFolderViewItem::sFilterTextColor;
LLUIColor LLFolderViewItem::sSuffixColor;
LLUIColor LLFolderViewItem::sSearchStatusColor;
+S32 LLFolderViewItem::sTopPad = 0;
+LLUIImagePtr LLFolderViewItem::sFolderArrowImg;
+LLUIImagePtr LLFolderViewItem::sSelectionImg;
+LLFontGL* LLFolderViewItem::sSuffixFont = nullptr;
// only integers can be initialized in header
const F32 LLFolderViewItem::FOLDER_CLOSE_TIME_CONSTANT = 0.02f;
@@ -83,15 +86,42 @@ LLFontGL* LLFolderViewItem::getLabelFontForStyle(U8 style)
return rtn;
}
+
+const LLFontGL* LLFolderViewItem::getLabelFont()
+{
+ if (!pLabelFont)
+ {
+ pLabelFont = getLabelFontForStyle(mLabelStyle);
+ }
+ return pLabelFont;
+}
//static
void LLFolderViewItem::initClass()
{
+ const Params& default_params = LLUICtrlFactory::getDefaultParams<LLFolderViewItem>();
+ sTopPad = default_params.item_top_pad;
+ sFolderArrowImg = default_params.folder_arrow_image;
+ sSelectionImg = default_params.selection_image;
+ sSuffixFont = getLabelFontForStyle(LLFontGL::NORMAL);
+
+ sFgColor = LLUIColorTable::instance().getColor("MenuItemEnabledColor", DEFAULT_WHITE);
+ sHighlightBgColor = LLUIColorTable::instance().getColor("MenuItemHighlightBgColor", DEFAULT_WHITE);
+ sFlashBgColor = LLUIColorTable::instance().getColor("MenuItemFlashBgColor", DEFAULT_WHITE);
+ sFocusOutlineColor = LLUIColorTable::instance().getColor("InventoryFocusOutlineColor", DEFAULT_WHITE);
+ sMouseOverColor = LLUIColorTable::instance().getColor("InventoryMouseOverColor", DEFAULT_WHITE);
+ sFilterBGColor = LLUIColorTable::instance().getColor("FilterBackgroundColor", DEFAULT_WHITE);
+ sFilterTextColor = LLUIColorTable::instance().getColor("FilterTextColor", DEFAULT_WHITE);
+ sSuffixColor = LLUIColorTable::instance().getColor("InventoryItemLinkColor", DEFAULT_WHITE);
+ sSearchStatusColor = LLUIColorTable::instance().getColor("InventorySearchStatusColor", DEFAULT_WHITE);
}
//static
void LLFolderViewItem::cleanupClass()
{
sFonts.clear();
+ sFolderArrowImg = nullptr;
+ sSelectionImg = nullptr;
+ sSuffixFont = nullptr;
}
@@ -134,13 +164,14 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p)
mIsItemCut(false),
mCutGeneration(0),
mLabelStyle( LLFontGL::NORMAL ),
+ pLabelFont(nullptr),
mHasVisibleChildren(false),
mLocalIndentation(p.folder_indentation),
mIndentation(0),
mItemHeight(p.item_height),
mControlLabelRotation(0.f),
mDragAndDropTarget(false),
- mLabel(p.name),
+ mLabel(utf8str_to_wstring(p.name)),
mRoot(p.root),
mViewModelItem(p.listener),
mIsMouseOverTitle(false),
@@ -158,20 +189,6 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p)
mMaxFolderItemOverlap(p.max_folder_item_overlap),
mDoubleClickOverride(p.double_click_override)
{
- if (!sColorSetInitialized)
- {
- sFgColor = LLUIColorTable::instance().getColor("MenuItemEnabledColor", DEFAULT_WHITE);
- sHighlightBgColor = LLUIColorTable::instance().getColor("MenuItemHighlightBgColor", DEFAULT_WHITE);
- sFlashBgColor = LLUIColorTable::instance().getColor("MenuItemFlashBgColor", DEFAULT_WHITE);
- sFocusOutlineColor = LLUIColorTable::instance().getColor("InventoryFocusOutlineColor", DEFAULT_WHITE);
- sMouseOverColor = LLUIColorTable::instance().getColor("InventoryMouseOverColor", DEFAULT_WHITE);
- sFilterBGColor = LLUIColorTable::instance().getColor("FilterBackgroundColor", DEFAULT_WHITE);
- sFilterTextColor = LLUIColorTable::instance().getColor("FilterTextColor", DEFAULT_WHITE);
- sSuffixColor = LLUIColorTable::instance().getColor("InventoryItemLinkColor", DEFAULT_WHITE);
- sSearchStatusColor = LLUIColorTable::instance().getColor("InventorySearchStatusColor", DEFAULT_WHITE);
- sColorSetInitialized = true;
- }
-
if (mViewModelItem)
{
mViewModelItem->setFolderViewItem(this);
@@ -193,7 +210,7 @@ bool LLFolderViewItem::postBuild()
{
// getDisplayName() is expensive (due to internal getLabelSuffix() and name building)
// it also sets search strings so it requires a filter reset
- mLabel = vmi->getDisplayName();
+ mLabel = utf8str_to_wstring(vmi->getDisplayName());
setToolTip(vmi->getName());
// Dirty the filter flag of the model from the view (CHUI-849)
@@ -306,7 +323,8 @@ void LLFolderViewItem::refresh()
{
LLFolderViewModelItem& vmi = *getViewModelItem();
- mLabel = vmi.getDisplayName();
+ mLabel = utf8str_to_wstring(vmi.getDisplayName());
+ mLabelFontBuffer.reset();
setToolTip(vmi.getName());
// icons are slightly expensive to get, can be optimized
// see LLInventoryIcon::getIcon()
@@ -319,7 +337,9 @@ void LLFolderViewItem::refresh()
// Very Expensive!
// Can do a number of expensive checks, like checking active motions, wearables or friend list
mLabelStyle = vmi.getLabelStyle();
- mLabelSuffix = vmi.getLabelSuffix();
+ pLabelFont = nullptr; // refresh can be called from a coro, don't use getLabelFontForStyle, coro trips font list tread safety
+ mLabelSuffix = utf8str_to_wstring(vmi.getLabelSuffix());
+ mSuffixFontBuffer.reset();
}
// Dirty the filter flag of the model from the view (CHUI-849)
@@ -344,7 +364,8 @@ void LLFolderViewItem::refreshSuffix()
// Very Expensive!
// Can do a number of expensive checks, like checking active motions, wearables or friend list
mLabelStyle = vmi->getLabelStyle();
- mLabelSuffix = vmi->getLabelSuffix();
+ pLabelFont = nullptr;
+ mLabelSuffix = utf8str_to_wstring(vmi->getLabelSuffix());
}
mLabelWidthDirty = true;
@@ -405,7 +426,7 @@ S32 LLFolderViewItem::arrange( S32* width, S32* height )
// it is purely visual, so it is fine to do at our laisure
refreshSuffix();
}
- mLabelWidth = getLabelXPos() + getLabelFontForStyle(mLabelStyle)->getWidth(mLabel) + getLabelFontForStyle(LLFontGL::NORMAL)->getWidth(mLabelSuffix) + mLabelPaddingRight;
+ mLabelWidth = getLabelXPos() + getLabelFontForStyle(mLabelStyle)->getWidth(mLabel.c_str()) + getLabelFontForStyle(LLFontGL::NORMAL)->getWidth(mLabelSuffix.c_str()) + mLabelPaddingRight;
mLabelWidthDirty = false;
}
@@ -736,19 +757,17 @@ bool LLFolderViewItem::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop,
return handled;
}
-void LLFolderViewItem::drawOpenFolderArrow(const Params& default_params, const LLUIColor& fg_color)
+void LLFolderViewItem::drawOpenFolderArrow()
{
//--------------------------------------------------------------------------------//
// Draw open folder arrow
//
- const S32 TOP_PAD = default_params.item_top_pad;
if (hasVisibleChildren() || !isFolderComplete())
{
- LLUIImage* arrow_image = default_params.folder_arrow_image;
gl_draw_scaled_rotated_image(
- mIndentation, getRect().getHeight() - mArrowSize - mTextPad - TOP_PAD,
- mArrowSize, mArrowSize, mControlLabelRotation, arrow_image->getImage(), fg_color);
+ mIndentation, getRect().getHeight() - mArrowSize - mTextPad - sTopPad,
+ mArrowSize, mArrowSize, mControlLabelRotation, sFolderArrowImg->getImage(), sFgColor);
}
}
@@ -764,7 +783,7 @@ void LLFolderViewItem::drawOpenFolderArrow(const Params& default_params, const L
/*virtual*/ bool LLFolderViewItem::isFadeItem()
{
- LLClipboard& clipboard = LLClipboard::instance();
+ static const LLClipboard& clipboard = LLClipboard::instance(); // Make it a 'simpleton'?
if (mCutGeneration != clipboard.getGeneration())
{
mCutGeneration = clipboard.getGeneration();
@@ -775,8 +794,9 @@ void LLFolderViewItem::drawOpenFolderArrow(const Params& default_params, const L
return mIsItemCut;
}
-void LLFolderViewItem::drawHighlight(const bool showContent, const bool hasKeyboardFocus, const LLUIColor &selectColor, const LLUIColor &flashColor,
- const LLUIColor &focusOutlineColor, const LLUIColor &mouseOverColor)
+void LLFolderViewItem::drawHighlight(bool showContent, bool hasKeyboardFocus,
+ const LLUIColor& selectColor, const LLUIColor& flashColor,
+ const LLUIColor& focusOutlineColor, const LLUIColor& mouseOverColor)
{
const S32 focus_top = getRect().getHeight();
const S32 focus_bottom = getRect().getHeight() - mItemHeight;
@@ -784,7 +804,7 @@ void LLFolderViewItem::drawHighlight(const bool showContent, const bool hasKeybo
const S32 FOCUS_LEFT = 1;
// Determine which background color to use for highlighting
- LLUIColor bgColor = (isFlashing() ? flashColor : selectColor);
+ const LLUIColor& bgColor = isFlashing() ? flashColor : selectColor;
//--------------------------------------------------------------------------------//
// Draw highlight for selected items
@@ -792,7 +812,6 @@ void LLFolderViewItem::drawHighlight(const bool showContent, const bool hasKeybo
// items if mShowSingleSelection is false.
//
if (isHighlightAllowed())
-
{
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
@@ -801,7 +820,7 @@ void LLFolderViewItem::drawHighlight(const bool showContent, const bool hasKeybo
{
LLColor4 bg_color = bgColor;
// do time-based fade of extra objects
- F32 fade_time = (getRoot() ? getRoot()->getSelectionFadeElapsedTime() : 0.0f);
+ F32 fade_time = getRoot() ? getRoot()->getSelectionFadeElapsedTime() : 0.f;
if (getRoot() && getRoot()->getShowSingleSelection())
{
// fading out
@@ -890,7 +909,7 @@ void LLFolderViewItem::drawLabel(const LLFontGL * font, const F32 x, const F32 y
//--------------------------------------------------------------------------------//
// Draw the actual label text
//
- font->renderUTF8(mLabel, 0, x, y, color,
+ mLabelFontBuffer.render(font, mLabel, 0, x, y, color,
LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
S32_MAX, getRect().getWidth() - (S32) x - mLabelPaddingRight, &right_x, /*use_ellipses*/true);
}
@@ -900,16 +919,14 @@ void LLFolderViewItem::draw()
const bool show_context = (getRoot() ? getRoot()->getShowSelectionContext() : false);
const bool filled = show_context || (getRoot() ? getRoot()->getParentPanel()->hasFocus() : false); // If we have keyboard focus, draw selection filled
- const Params& default_params = LLUICtrlFactory::getDefaultParams<LLFolderViewItem>();
- const S32 TOP_PAD = default_params.item_top_pad;
-
- const LLFontGL* font = getLabelFontForStyle(mLabelStyle);
+ const LLFontGL* font = getLabelFont();
+ S32 line_height = font->getLineHeight();
getViewModelItem()->update();
- if(!mSingleFolderMode)
+ if (!mSingleFolderMode)
{
- drawOpenFolderArrow(default_params, sFgColor);
+ drawOpenFolderArrow();
}
drawHighlight(show_context, filled, sHighlightBgColor, sFlashBgColor, sFocusOutlineColor, sMouseOverColor);
@@ -918,18 +935,19 @@ void LLFolderViewItem::draw()
// Draw open icon
//
const S32 icon_x = mIndentation + mArrowSize + mTextPad;
+ const S32 rect_height = getRect().getHeight();
if (!mIconOpen.isNull() && (llabs(mControlLabelRotation) > 80)) // For open folders
{
- mIconOpen->draw(icon_x, getRect().getHeight() - mIconOpen->getHeight() - TOP_PAD + 1);
+ mIconOpen->draw(icon_x, rect_height - mIconOpen->getHeight() - sTopPad + 1);
}
else if (mIcon)
{
- mIcon->draw(icon_x, getRect().getHeight() - mIcon->getHeight() - TOP_PAD + 1);
+ mIcon->draw(icon_x, rect_height - mIcon->getHeight() - sTopPad + 1);
}
if (mIconOverlay && getRoot()->showItemLinkOverlays())
{
- mIconOverlay->draw(icon_x, getRect().getHeight() - mIcon->getHeight() - TOP_PAD + 1);
+ mIconOverlay->draw(icon_x, rect_height - mIcon->getHeight() - sTopPad + 1);
}
//--------------------------------------------------------------------------------//
@@ -940,47 +958,43 @@ void LLFolderViewItem::draw()
return;
}
- auto filter_string_length = mViewModelItem->hasFilterStringMatch() ? static_cast<S32>(mViewModelItem->getFilterStringSize()) : 0;
+ S32 filter_string_length = mViewModelItem->hasFilterStringMatch() ? (S32)mViewModelItem->getFilterStringSize() : 0;
F32 right_x = 0;
- F32 y = (F32)getRect().getHeight() - font->getLineHeight() - (F32)mTextPad - (F32)TOP_PAD;
+ F32 y = (F32)rect_height - line_height - (F32)mTextPad - (F32)sTopPad;
F32 text_left = (F32)getLabelXPos();
- std::string combined_string = mLabel + mLabelSuffix;
+ LLWString combined_string = mLabel + mLabelSuffix;
- const LLFontGL* suffix_font = getLabelFontForStyle(LLFontGL::NORMAL);
S32 filter_offset = static_cast<S32>(mViewModelItem->getFilterStringOffset());
if (filter_string_length > 0)
{
- S32 bottom = llfloor(getRect().getHeight() - font->getLineHeight() - 3 - TOP_PAD);
- S32 top = getRect().getHeight() - TOP_PAD;
- if(mLabelSuffix.empty() || (font == suffix_font))
+ S32 bottom = rect_height - line_height - 3 - sTopPad;
+ S32 top = rect_height - sTopPad;
+ if(mLabelSuffix.empty() || (font == sSuffixFont))
{
- S32 left = ll_round(text_left) + font->getWidth(combined_string, 0, static_cast<S32>(mViewModelItem->getFilterStringOffset())) - 2;
- S32 right = left + font->getWidth(combined_string, static_cast<S32>(mViewModelItem->getFilterStringOffset()), filter_string_length) + 2;
+ S32 left = ll_round(text_left) + font->getWidth(combined_string.c_str(), 0, filter_offset) - 2;
+ S32 right = left + font->getWidth(combined_string.c_str(), filter_offset, filter_string_length) + 2;
- LLUIImage* box_image = default_params.selection_image;
- LLRect box_rect(left, top, right, bottom);
- box_image->draw(box_rect, sFilterBGColor);
+ LLRect box_rect(left, top, right, bottom);
+ sSelectionImg->draw(box_rect, sFilterBGColor);
}
else
{
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;
- LLUIImage* box_image = default_params.selection_image;
+ S32 left = (S32)(ll_round(text_left) + font->getWidthF32(mLabel.c_str(), 0, llmin(filter_offset, (S32)mLabel.size()))) - 2;
+ S32 right = left + (S32)font->getWidthF32(mLabel.c_str(), filter_offset, label_filter_length) + 2;
LLRect box_rect(left, top, right, bottom);
- box_image->draw(box_rect, sFilterBGColor);
+ sSelectionImg->draw(box_rect, sFilterBGColor);
}
S32 suffix_filter_length = label_filter_length > 0 ? filter_string_length - label_filter_length : filter_string_length;
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;
- LLUIImage* box_image = default_params.selection_image;
+ S32 left = (S32)(ll_round(text_left) + font->getWidthF32(mLabel.c_str(), 0, static_cast<S32>(mLabel.size())) + sSuffixFont->getWidthF32(mLabelSuffix.c_str(), 0, suffix_offset)) - 2;
+ S32 right = left + (S32)sSuffixFont->getWidthF32(mLabelSuffix.c_str(), suffix_offset, suffix_filter_length) + 2;
LLRect box_rect(left, top, right, bottom);
- box_image->draw(box_rect, sFilterBGColor);
+ sSelectionImg->draw(box_rect, sFilterBGColor);
}
}
}
@@ -999,9 +1013,9 @@ void LLFolderViewItem::draw()
//
if (!mLabelSuffix.empty())
{
- suffix_font->renderUTF8( mLabelSuffix, 0, right_x, y, isFadeItem() ? color : (LLColor4)sSuffixColor,
- LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
- S32_MAX, S32_MAX, &right_x);
+ mSuffixFontBuffer.render(sSuffixFont, mLabelSuffix, 0, right_x, y, isFadeItem() ? color : sSuffixColor.get(),
+ LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
+ S32_MAX, S32_MAX, &right_x);
}
//--------------------------------------------------------------------------------//
@@ -1009,11 +1023,11 @@ void LLFolderViewItem::draw()
//
if (filter_string_length > 0)
{
- if(mLabelSuffix.empty() || (font == suffix_font))
+ if(mLabelSuffix.empty() || (font == sSuffixFont))
{
- F32 match_string_left = text_left + font->getWidthF32(combined_string, 0, filter_offset + filter_string_length) - font->getWidthF32(combined_string, filter_offset, filter_string_length);
- F32 yy = (F32)getRect().getHeight() - font->getLineHeight() - (F32)mTextPad - (F32)TOP_PAD;
- font->renderUTF8(combined_string, filter_offset, match_string_left, yy,
+ F32 match_string_left = text_left + font->getWidthF32(combined_string.c_str(), 0, filter_offset + filter_string_length) - font->getWidthF32(combined_string.c_str(), filter_offset, filter_string_length);
+ F32 yy = (F32)rect_height - line_height - (F32)mTextPad - (F32)sTopPad;
+ font->render(combined_string, filter_offset, match_string_left, yy,
sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
filter_string_length, S32_MAX, &right_x);
}
@@ -1022,9 +1036,9 @@ void LLFolderViewItem::draw()
S32 label_filter_length = llmin((S32)mLabel.size() - filter_offset, (S32)filter_string_length);
if(label_filter_length > 0)
{
- F32 match_string_left = text_left + font->getWidthF32(mLabel, 0, filter_offset + label_filter_length) - font->getWidthF32(mLabel, filter_offset, label_filter_length);
- F32 yy = (F32)getRect().getHeight() - font->getLineHeight() - (F32)mTextPad - (F32)TOP_PAD;
- font->renderUTF8(mLabel, filter_offset, match_string_left, yy,
+ F32 match_string_left = text_left + font->getWidthF32(mLabel.c_str(), 0, filter_offset + label_filter_length) - font->getWidthF32(mLabel.c_str(), filter_offset, label_filter_length);
+ F32 yy = (F32)rect_height - line_height - (F32)mTextPad - (F32)sTopPad;
+ font->render(mLabel, filter_offset, match_string_left, yy,
sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
label_filter_length, S32_MAX, &right_x);
}
@@ -1033,9 +1047,9 @@ void LLFolderViewItem::draw()
if(suffix_filter_length > 0)
{
S32 suffix_offset = llmax(0, filter_offset - (S32)mLabel.size());
- F32 match_string_left = text_left + font->getWidthF32(mLabel, 0, static_cast<S32>(mLabel.size())) + suffix_font->getWidthF32(mLabelSuffix, 0, suffix_offset + suffix_filter_length) - suffix_font->getWidthF32(mLabelSuffix, suffix_offset, suffix_filter_length);
- F32 yy = (F32)getRect().getHeight() - suffix_font->getLineHeight() - (F32)mTextPad - (F32)TOP_PAD;
- suffix_font->renderUTF8(mLabelSuffix, suffix_offset, match_string_left, yy, sFilterTextColor,
+ F32 match_string_left = text_left + font->getWidthF32(mLabel.c_str(), 0, static_cast<S32>(mLabel.size())) + sSuffixFont->getWidthF32(mLabelSuffix.c_str(), 0, suffix_offset + suffix_filter_length) - sSuffixFont->getWidthF32(mLabelSuffix.c_str(), suffix_offset, suffix_filter_length);
+ F32 yy = (F32)rect_height - sSuffixFont->getLineHeight() - (F32)mTextPad - (F32)sTopPad;
+ sSuffixFont->render(mLabelSuffix, suffix_offset, match_string_left, yy, sFilterTextColor,
LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
suffix_filter_length, S32_MAX, &right_x);
}
diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h
index f7ced81274..2ee018a90a 100644
--- a/indra/llui/llfolderviewitem.h
+++ b/indra/llui/llfolderviewitem.h
@@ -29,6 +29,7 @@
#include "llflashtimer.h"
#include "llview.h"
#include "lluiimage.h"
+#include "llfontvertexbuffer.h"
class LLFolderView;
class LLFolderViewModelItem;
@@ -89,14 +90,14 @@ protected:
LLFolderViewItem(const Params& p);
- std::string mLabel;
+ LLWString mLabel;
S32 mLabelWidth;
bool mLabelWidthDirty;
S32 mLabelPaddingRight;
LLFolderViewFolder* mParentFolder;
LLPointer<LLFolderViewModelItem> mViewModelItem;
LLFontGL::StyleFlags mLabelStyle;
- std::string mLabelSuffix;
+ LLWString mLabelSuffix;
bool mSuffixNeedsRefresh; //suffix and icons
LLUIImagePtr mIcon,
mIconOpen,
@@ -134,7 +135,6 @@ protected:
LLUIColor mFontHighlightColor;
// For now assuming all colors are the same in derived classes.
- static bool sColorSetInitialized;
static LLUIColor sFgColor;
static LLUIColor sFgDisabledColor;
static LLUIColor sHighlightBgColor;
@@ -154,9 +154,10 @@ protected:
virtual bool isHighlightActive();
virtual bool isFadeItem();
virtual bool isFlashing() { return false; }
- virtual void setFlashState(bool) { }
+ virtual void setFlashState(bool, bool) { }
static LLFontGL* getLabelFontForStyle(U8 style);
+ const LLFontGL* getLabelFont();
bool mIsSelected;
@@ -242,7 +243,7 @@ public:
// This method returns the label displayed on the view. This
// method was primarily added to allow sorting on the folder
// contents possible before the entire view has been constructed.
- const std::string& getLabel() const { return mLabel; }
+ const LLWString& getLabel() const { return mLabel; }
LLFolderViewFolder* getParentFolder( void ) { return mParentFolder; }
const LLFolderViewFolder* getParentFolder( void ) const { return mParentFolder; }
@@ -281,7 +282,7 @@ public:
// Does not need filter update
virtual void refreshSuffix();
- bool isSingleFolderMode() { return mSingleFolderMode; }
+ bool isSingleFolderMode() const { return mSingleFolderMode; }
// LLView functionality
virtual bool handleRightMouseDown( S32 x, S32 y, MASK mask );
@@ -296,9 +297,9 @@ public:
// virtual void handleDropped();
virtual void draw();
- void drawOpenFolderArrow(const Params& default_params, const LLUIColor& fg_color);
- void drawHighlight(const bool showContent, const bool hasKeyboardFocus, const LLUIColor &selectColor, const LLUIColor &flashColor, const LLUIColor &outlineColor, const LLUIColor &mouseOverColor);
- void drawLabel(const LLFontGL * font, const F32 x, const F32 y, const LLColor4& color, F32 &right_x);
+ void drawOpenFolderArrow();
+ void drawHighlight(bool showContent, bool hasKeyboardFocus, const LLUIColor& selectColor, const LLUIColor& flashColor, const LLUIColor& outlineColor, const LLUIColor& mouseOverColor);
+ void drawLabel(const LLFontGL* font, const F32 x, const F32 y, const LLColor4& color, F32 &right_x);
virtual bool handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop,
EDragAndDropType cargo_type,
void* cargo_data,
@@ -307,6 +308,14 @@ public:
private:
static std::map<U8, LLFontGL*> sFonts; // map of styles to fonts
+ static S32 sTopPad;
+ static LLUIImagePtr sFolderArrowImg;
+ static LLUIImagePtr sSelectionImg;
+ static LLFontGL* sSuffixFont;
+
+ LLFontVertexBuffer mLabelFontBuffer;
+ LLFontVertexBuffer mSuffixFontBuffer;
+ LLFontGL* pLabelFont{nullptr};
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -406,9 +415,6 @@ public:
// doesn't delete it.
virtual void extractItem( LLFolderViewItem* item, bool deparent_model = true);
- // This function is called by a child that needs to be resorted.
- void resort(LLFolderViewItem* item);
-
void setAutoOpenCountdown(F32 countdown) { mAutoOpenCountdown = countdown; }
// folders can be opened. This will usually be called by internal
diff --git a/indra/llui/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h
index b8d6d89971..9372818ca5 100644
--- a/indra/llui/llfolderviewmodel.h
+++ b/indra/llui/llfolderviewmodel.h
@@ -292,6 +292,7 @@ public:
dirtyFilter();
requestSort();
}
+
virtual void removeChild(LLFolderViewModelItem* child)
{
mChildren.remove(child);
diff --git a/indra/llui/lliconctrl.h b/indra/llui/lliconctrl.h
index aae1d1d572..29d3f0c3d4 100644
--- a/indra/llui/lliconctrl.h
+++ b/indra/llui/lliconctrl.h
@@ -79,7 +79,7 @@ public:
std::string getImageName() const;
- void setColor(const LLColor4& color) { mColor = color; }
+ void setColor(const LLUIColor& color) { mColor = color; }
void setImage(LLPointer<LLUIImage> image) { mImagep = image; }
const LLPointer<LLUIImage> getImage() { return mImagep; }
diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp
index 5e184b5ddb..2bea8fb4ed 100644
--- a/indra/llui/llkeywords.cpp
+++ b/indra/llui/llkeywords.cpp
@@ -85,7 +85,7 @@ LLKeywords::~LLKeywords()
// Add the token as described
void LLKeywords::addToken(LLKeywordToken::ETokenType type,
const std::string& key_in,
- const LLColor4& color,
+ const LLUIColor& color,
const std::string& tool_tip_in,
const std::string& delimiter_in)
{
@@ -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)
+LLUIColor LLKeywords::getColorGroup(std::string_view key_in) const
{
std::string color_group = "ScriptText";
if (key_in == "functions")
@@ -261,12 +261,12 @@ 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;
- LLColor4 color_deprecated = getColorGroup("deprecated");
- LLColor4 color_god_mode = getColorGroup("god-mode");
+ LLUIColor color;
+ LLUIColor color_group;
+ LLUIColor color_deprecated = getColorGroup("deprecated");
+ LLUIColor color_god_mode = getColorGroup("god-mode");
LLKeywordToken::ETokenType token_type = LLKeywordToken::TT_UNKNOWN;
// If a new token type is added here, it must also be added to the 'addToken' method
@@ -296,7 +296,7 @@ void LLKeywords::processTokensGroup(const LLSD& tokens, const std::string& group
}
color_group = getColorGroup(group);
- LL_DEBUGS("SyntaxLSL") << "Group: '" << group << "', using color: '" << color_group << "'" << LL_ENDL;
+ LL_DEBUGS("SyntaxLSL") << "Group: '" << group << "', using color: '" << color_group.get() << "'" << LL_ENDL;
if (tokens.isMap())
{
@@ -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
{
@@ -378,7 +378,7 @@ void LLKeywords::processTokensGroup(const LLSD& tokens, const std::string& group
}
else if (tokens.isArray()) // Currently nothing should need this, but it's here for completeness
{
- LL_INFOS("SyntaxLSL") << "Curious, shouldn't be an array here; adding all using color " << color << LL_ENDL;
+ LL_INFOS("SyntaxLSL") << "Curious, shouldn't be an array here; adding all using color " << color.get() << LL_ENDL;
for (S32 count = 0; count < tokens.size(); ++count)
{
addToken(token_type, tokens[count], color, "");
@@ -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;
@@ -725,7 +725,7 @@ void LLKeywords::insertSegments(const LLWString& wtext, std::vector<LLTextSegmen
insertSegment( seg_list, text_segment, text_len, style, editor);
}
-void LLKeywords::insertSegment(std::vector<LLTextSegmentPtr>& seg_list, LLTextSegmentPtr new_segment, S32 text_len, const LLColor4 &defaultColor, LLTextEditor& editor )
+void LLKeywords::insertSegment(std::vector<LLTextSegmentPtr>& seg_list, LLTextSegmentPtr new_segment, S32 text_len, const LLUIColor& defaultColor, LLTextEditor& editor )
{
LLTextSegmentPtr last = seg_list.back();
S32 new_seg_end = new_segment->getEnd();
diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h
index f498b3ddee..5892238593 100644
--- a/indra/llui/llkeywords.h
+++ b/indra/llui/llkeywords.h
@@ -72,7 +72,7 @@ public:
TT_TYPE // WORD
} ETokenType;
- LLKeywordToken( ETokenType type, const LLColor4& color, const LLWString& token, const LLWString& tool_tip, const LLWString& delimiter )
+ LLKeywordToken( ETokenType type, const LLUIColor& color, const LLWString& token, const LLWString& tool_tip, const LLWString& delimiter )
:
mType( type ),
mToken( token ),
@@ -87,7 +87,7 @@ public:
bool isHead(const llwchar* s) const;
bool isTail(const llwchar* s) const;
const LLWString& getToken() const { return mToken; }
- const LLColor4& getColor() const { return mColor; }
+ const LLUIColor& getColor() const { return mColor; }
ETokenType getType() const { return mType; }
const LLWString& getToolTip() const { return mToolTip; }
const LLWString& getDelimiter() const { return mDelimiter; }
@@ -99,7 +99,7 @@ public:
private:
ETokenType mType;
LLWString mToken;
- LLColor4 mColor;
+ LLUIColor mColor;
LLWString mToolTip;
LLWString mDelimiter;
};
@@ -111,8 +111,8 @@ public:
~LLKeywords();
void clearLoaded() { mLoaded = false; }
- LLColor4 getColorGroup(const std::string& key_in);
- bool isLoaded() const { return mLoaded; }
+ LLUIColor getColorGroup(std::string_view key_in) const;
+ bool isLoaded() const { return mLoaded; }
void findSegments(std::vector<LLTextSegmentPtr> *seg_list,
const LLWString& text,
@@ -124,7 +124,7 @@ public:
// Add the token as described
void addToken(LLKeywordToken::ETokenType type,
const std::string& key,
- const LLColor4& color,
+ const LLUIColor& color,
const std::string& tool_tip = LLStringUtil::null,
const std::string& delimiter = LLStringUtil::null);
@@ -153,7 +153,7 @@ public:
bool mOwner;
- LLColor4 mColor;
+ LLUIColor mColor;
};
typedef std::map<WStringMapIndex, LLKeywordToken*> word_token_map_t;
@@ -161,7 +161,7 @@ public:
keyword_iterator_t begin() const { return mWordTokenMap.begin(); }
keyword_iterator_t end() const { return mWordTokenMap.end(); }
- typedef std::map<WStringMapIndex, LLColor4> group_color_map_t;
+ typedef std::map<WStringMapIndex, LLUIColor> group_color_map_t;
typedef group_color_map_t::const_iterator color_iterator_t;
group_color_map_t mColorGroupMap;
@@ -170,11 +170,11 @@ 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,
- const LLColor4 &defaultColor,
+ const LLUIColor &defaultColor,
class LLTextEditor& editor);
void insertSegments(const LLWString& wtext,
std::vector<LLTextSegmentPtr>& seg_list,
@@ -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..fe0591ce4b 100644
--- a/indra/llui/lllayoutstack.cpp
+++ b/indra/llui/lllayoutstack.cpp
@@ -36,8 +36,8 @@
#include "lliconctrl.h"
#include "boost/foreach.hpp"
-static const F32 MIN_FRACTIONAL_SIZE = 0.00001f;
-static const F32 MAX_FRACTIONAL_SIZE = 1.f;
+static constexpr F32 MIN_FRACTIONAL_SIZE = 0.00001f;
+static constexpr F32 MAX_FRACTIONAL_SIZE = 1.f;
static LLDefaultChildRegistry::Register<LLLayoutStack> register_layout_stack("layout_stack");
static LLLayoutStack::LayoutStackRegistry::Register<LLLayoutPanel> register_layout_panel("layout_panel");
@@ -86,10 +86,6 @@ void LLLayoutPanel::initFromParams(const Params& p)
LLLayoutPanel::~LLLayoutPanel()
{
- // probably not necessary, but...
- delete mResizeBar;
- mResizeBar = NULL;
-
gFocusMgr.removeKeyboardFocusWithoutCallback(this);
}
@@ -131,7 +127,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 +205,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),
@@ -242,11 +238,9 @@ LLLayoutStack::LLLayoutStack(const LLLayoutStack::Params& p)
LLLayoutStack::~LLLayoutStack()
{
- e_panel_list_t panels = mPanels; // copy list of panel pointers
- mPanels.clear(); // clear so that removeChild() calls don't cause trouble
- std::for_each(panels.begin(), panels.end(), DeletePointer());
}
+// virtual
void LLLayoutStack::draw()
{
updateLayout();
@@ -284,8 +278,14 @@ void LLLayoutStack::draw()
}
}
+// virtual
void LLLayoutStack::deleteAllChildren()
{
+ for (LLLayoutPanel* p : mPanels)
+ {
+ p->mResizeBar = nullptr;
+ }
+
mPanels.clear();
LLView::deleteAllChildren();
@@ -295,29 +295,47 @@ void LLLayoutStack::deleteAllChildren()
mNeedsLayout = true;
}
+// virtual
void LLLayoutStack::removeChild(LLView* view)
{
- LLLayoutPanel* embedded_panelp = findEmbeddedPanel(dynamic_cast<LLPanel*>(view));
-
- if (embedded_panelp)
+ if (LLLayoutPanel* embedded_panelp = dynamic_cast<LLLayoutPanel*>(view))
{
- mPanels.erase(std::find(mPanels.begin(), mPanels.end(), embedded_panelp));
- LLView::removeChild(view);
- updateFractionalSizes();
- mNeedsLayout = true;
+ auto it = std::find(mPanels.begin(), mPanels.end(), embedded_panelp);
+ if (it != mPanels.end())
+ {
+ mPanels.erase(it);
+ }
+ if (embedded_panelp->mResizeBar)
+ {
+ LLView::removeChild(embedded_panelp->mResizeBar);
+ embedded_panelp->mResizeBar = nullptr;
+ }
}
- else
+ else if (LLResizeBar* resize_bar = dynamic_cast<LLResizeBar*>(view))
{
- LLView::removeChild(view);
+ for (LLLayoutPanel* p : mPanels)
+ {
+ if (p->mResizeBar == resize_bar)
+ {
+ p->mResizeBar = nullptr;
+ }
+ }
}
+
+ LLView::removeChild(view);
+
+ updateFractionalSizes();
+ mNeedsLayout = true;
}
+// virtual
bool LLLayoutStack::postBuild()
{
updateLayout();
return true;
}
+// virtual
bool LLLayoutStack::addChild(LLView* child, S32 tab_group)
{
LLLayoutPanel* panelp = dynamic_cast<LLLayoutPanel*>(child);
@@ -445,7 +463,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 +483,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 +566,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;
@@ -983,6 +1001,7 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect&
//normalizeFractionalSizes();
}
+// virtual
void LLLayoutStack::reshape(S32 width, S32 height, bool called_from_parent)
{
mNeedsLayout = true;
diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h
index 9e5f8048ba..9e3536aaff 100644
--- a/indra/llui/lllayoutstack.h
+++ b/indra/llui/lllayoutstack.h
@@ -75,9 +75,6 @@ public:
/*virtual*/ bool addChild(LLView* child, S32 tab_group = 0);
/*virtual*/ void reshape(S32 width, S32 height, bool called_from_parent = true);
-
- static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node = NULL);
-
typedef enum e_animate
{
NO_ANIMATE,
@@ -86,7 +83,7 @@ public:
void addPanel(LLLayoutPanel* panel, EAnimate animate = NO_ANIMATE);
void collapsePanel(LLPanel* panel, bool collapsed = true);
- S32 getNumPanels() { return static_cast<S32>(mPanels.size()); }
+ S32 getNumPanels() const { return static_cast<S32>(mPanels.size()); }
void updateLayout();
@@ -111,7 +108,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 );
@@ -190,7 +187,6 @@ public:
bool isCollapsed() const { return mCollapsed;}
void setOrientation(LLView::EOrientation orientation);
- void storeOriginalDim();
void setIgnoreReshape(bool ignore) { mIgnoreReshape = ignore; }
diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp
index fa71c7704d..45dab88e87 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
@@ -436,6 +436,9 @@ void LLLineEditor::setText(const LLStringExplicit &new_text, bool use_size_limit
{
mText.assign(utf8str_symbol_truncate(truncated_utf8, mMaxLengthChars));
}
+ mFontBufferPreSelection.reset();
+ mFontBufferSelection.reset();
+ mFontBufferPostSelection.reset();
if (all_selected)
{
@@ -617,6 +620,10 @@ void LLLineEditor::replaceWithSuggestion(U32 index)
mText.insert(it->first, suggestion);
setCursor(it->first + (S32)suggestion.length());
+ mFontBufferPreSelection.reset();
+ mFontBufferSelection.reset();
+ mFontBufferPostSelection.reset();
+
break;
}
}
@@ -969,6 +976,10 @@ void LLLineEditor::removeChar()
mText.erase(getCursor() - 1, 1);
setCursor(getCursor() - 1);
+
+ mFontBufferPreSelection.reset();
+ mFontBufferSelection.reset();
+ mFontBufferPostSelection.reset();
}
else
{
@@ -992,6 +1003,10 @@ void LLLineEditor::addChar(const llwchar uni_char)
return;
mText.erase(getCursor(), 1);
+
+ mFontBufferPreSelection.reset();
+ mFontBufferSelection.reset();
+ mFontBufferPostSelection.reset();
}
S32 cur_bytes = static_cast<S32>(mText.getString().size());
@@ -1022,6 +1037,10 @@ void LLLineEditor::addChar(const llwchar uni_char)
mText.insert(getCursor(), w_buf);
setCursor(getCursor() + 1);
+
+ mFontBufferPreSelection.reset();
+ mFontBufferSelection.reset();
+ mFontBufferPostSelection.reset();
}
else
{
@@ -1031,25 +1050,6 @@ void LLLineEditor::addChar(const llwchar uni_char)
getWindow()->hideCursorUntilMouseMove();
}
-void LLLineEditor::addString(char *s, bool editing)
-{
- if (hasSelection())
- deleteSelection();
- else if (LL_KIM_OVERWRITE == gKeyboard->getInsertMode()) {
- if (!prevalidateInput(mText.getWString()
- .substr(getCursor(), 1)))
- return;
- mText.erase(getCursor(), 1);
- } else if (editing) {
- mText.clear();
- setCursor(0);
- }
- mText.insert(getCursor(), utf8str_to_wstring(s));
- if (editing) setCursor(strlen(s));
- else setCursor(getCursor() + 1);
- getWindow()->hideCursorUntilMouseMove();
-}
-
// Extends the selection box to the new cursor position
void LLLineEditor::extendSelection( S32 new_cursor_pos )
{
@@ -1205,6 +1205,10 @@ void LLLineEditor::deleteSelection()
mText.erase(left_pos, selection_length);
deselect();
setCursor(left_pos);
+
+ mFontBufferPreSelection.reset();
+ mFontBufferSelection.reset();
+ mFontBufferPostSelection.reset();
}
}
@@ -1365,6 +1369,10 @@ void LLLineEditor::pasteHelper(bool is_primary)
setCursor( getCursor() + (S32)clean_string.length() );
deselect();
+ mFontBufferPreSelection.reset();
+ mFontBufferSelection.reset();
+ mFontBufferPostSelection.reset();
+
// Validate new string and rollback the if needed.
bool need_to_rollback = mPrevalidator && !mPrevalidator.validate(mText.getWString());
if (need_to_rollback)
@@ -1525,6 +1533,10 @@ bool LLLineEditor::handleSpecialKey(KEY key, MASK mask)
{
mText.assign(*(--mCurrentHistoryLine));
setCursorToEnd();
+
+ mFontBufferPreSelection.reset();
+ mFontBufferSelection.reset();
+ mFontBufferPostSelection.reset();
}
else
{
@@ -1542,6 +1554,10 @@ bool LLLineEditor::handleSpecialKey(KEY key, MASK mask)
{
mText.assign( *(++mCurrentHistoryLine) );
setCursorToEnd();
+
+ mFontBufferPreSelection.reset();
+ mFontBufferSelection.reset();
+ mFontBufferPostSelection.reset();
}
else
{
@@ -1704,36 +1720,6 @@ bool LLLineEditor::handleUnicodeCharHere(llwchar uni_char)
return handled;
}
-bool LLLineEditor::handleUnicodeStringHere(char *uni_str, bool editing)
-{
- auto handled = FALSE;
-
- if ((gFocusMgr.getKeyboardFocus() == this)
- && getVisible() && !mReadOnly) {
- handled = TRUE;
- LLLineEditorRollback rollback(this);
-
- addString(uni_str, editing);
-
- mKeystrokeTimer.reset();
- deselect();
- auto need_to_rollback = mPrevalidator
- && !mPrevalidator.validate(mText.getWString());
-
- if (need_to_rollback) {
- rollback.doRollback(this);
- LLUI::getInstance()->reportBadKeystroke();
- mPrevalidator.showLastErrorUsingTimeout();
- }
-
- if (!need_to_rollback && handled) {
- onKeystroke();
- mSpellCheckTimer.setTimerExpirySec(SPELLCHECK_DELAY);
- }
- }
-
- return handled;
-}
bool LLLineEditor::canDoDelete() const
{
@@ -1946,7 +1932,8 @@ void LLLineEditor::draw()
if( select_left > mScrollHPos )
{
// unselected, left side
- rendered_text = mGLFont->render(
+ rendered_text = mFontBufferPreSelection.render(
+ mGLFont,
mText, mScrollHPos,
rendered_pixels_right, text_bottom,
text_color,
@@ -1968,7 +1955,8 @@ void LLLineEditor::draw()
gl_rect_2d(ll_round(rendered_pixels_right), cursor_top, ll_round(rendered_pixels_right)+width, cursor_bottom, color);
LLColor4 tmp_color( 1.f - text_color.mV[0], 1.f - text_color.mV[1], 1.f - text_color.mV[2], alpha );
- rendered_text += mGLFont->render(
+ rendered_text += mFontBufferSelection.render(
+ mGLFont,
mText, mScrollHPos + rendered_text,
rendered_pixels_right, text_bottom,
tmp_color,
@@ -1983,7 +1971,8 @@ void LLLineEditor::draw()
if( (rendered_pixels_right < (F32)mTextRightEdge) && (rendered_text < text_len) )
{
// unselected, right side
- rendered_text += mGLFont->render(
+ rendered_text += mFontBufferPostSelection.render(
+ mGLFont,
mText, mScrollHPos + rendered_text,
rendered_pixels_right, text_bottom,
text_color,
@@ -1997,7 +1986,8 @@ void LLLineEditor::draw()
}
else
{
- rendered_text = mGLFont->render(
+ rendered_text = mFontBufferPreSelection.render(
+ mGLFont,
mText, mScrollHPos,
rendered_pixels_right, text_bottom,
text_color,
@@ -2157,8 +2147,9 @@ void LLLineEditor::draw()
//to give indication that it is not text you typed in
if (0 == mText.length() && (mReadOnly || mShowLabelFocused))
{
- mGLFont->render(mLabel.getWString(), 0,
- mTextLeftEdge, (F32)text_bottom,
+ mFontBufferLabel.render(mGLFont,
+ mLabel.getWString(), 0,
+ (F32)mTextLeftEdge, (F32)text_bottom,
label_color,
LLFontGL::LEFT,
LLFontGL::BOTTOM,
@@ -2182,8 +2173,9 @@ void LLLineEditor::draw()
// draw label if no text provided
if (0 == mText.length())
{
- mGLFont->render(mLabel.getWString(), 0,
- mTextLeftEdge, (F32)text_bottom,
+ mFontBufferLabel.render(mGLFont,
+ mLabel.getWString(), 0,
+ (F32)mTextLeftEdge, (F32)text_bottom,
label_color,
LLFontGL::LEFT,
LLFontGL::BOTTOM,
@@ -2453,12 +2445,16 @@ void LLLineEditor::setKeystrokeCallback(callback_t callback, void* user_data)
bool LLLineEditor::setTextArg( const std::string& key, const LLStringExplicit& text )
{
mText.setArg(key, text);
+ mFontBufferPreSelection.reset();
+ mFontBufferSelection.reset();
+ mFontBufferPostSelection.reset();
return true;
}
bool LLLineEditor::setLabelArg( const std::string& key, const LLStringExplicit& text )
{
mLabel.setArg(key, text);
+ mFontBufferLabel.reset();
return true;
}
@@ -2509,9 +2505,24 @@ void LLLineEditor::resetPreedit()
if (hasPreeditString())
{
const S32 preedit_pos = mPreeditPositions.front();
- mText.erase(preedit_pos, mPreeditPositions.back() - preedit_pos);
- mText.insert(preedit_pos, mPreeditOverwrittenWString);
- setCursor(preedit_pos);
+ const S32 end = mPreeditPositions.back();
+ const S32 len = end - preedit_pos;
+ const S32 size = mText.length();
+ if (preedit_pos < size
+ && end <= size
+ && preedit_pos >= 0
+ && len > 0)
+ {
+ mText.erase(preedit_pos, len);
+ mText.insert(preedit_pos, mPreeditOverwrittenWString);
+ setCursor(preedit_pos);
+ }
+ else
+ {
+ LL_WARNS() << "Index out of bounds. Start: " << preedit_pos
+ << ", end:" << end
+ << ", full string length: " << size << LL_ENDL;
+ }
mPreeditWString.clear();
mPreeditOverwrittenWString.clear();
@@ -2557,6 +2568,9 @@ void LLLineEditor::updatePreedit(const LLWString &preedit_string,
mPreeditOverwrittenWString.clear();
}
mText.insert(insert_preedit_at, mPreeditWString);
+ mFontBufferPreSelection.reset();
+ mFontBufferSelection.reset();
+ mFontBufferPostSelection.reset();
mPreeditStandouts = preedit_standouts;
diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h
index 2d9c3ac58a..7533f76f1d 100644
--- a/indra/llui/lllineeditor.h
+++ b/indra/llui/lllineeditor.h
@@ -40,6 +40,7 @@
#include "llframetimer.h"
#include "lleditmenuhandler.h"
+#include "llfontvertexbuffer.h"
#include "llspellcheckmenuhandler.h"
#include "lluictrl.h"
#include "lluiimage.h"
@@ -133,7 +134,6 @@ public:
/*virtual*/ bool handleRightMouseDown(S32 x, S32 y, MASK mask) override;
/*virtual*/ bool handleKeyHere(KEY key, MASK mask) override;
/*virtual*/ bool handleUnicodeCharHere(llwchar uni_char) override;
- /*virtual*/ bool handleUnicodeStringHere(char *uni_str, bool editing) override;
/*virtual*/ void onMouseCaptureLost() override;
// LLEditMenuHandler overrides
@@ -205,7 +205,7 @@ public:
void setText(const LLStringExplicit &new_text);
const std::string& getText() const override { return mText.getString(); }
- LLWString getWText() const { return mText.getWString(); }
+ const LLWString& getWText() const { return mText.getWString(); }
LLWString getConvertedText() const; // trimmed text with paragraphs converted to newlines
S32 getLength() const { return mText.length(); }
@@ -225,12 +225,12 @@ public:
void setRevertOnEsc( bool b ) { mRevertOnEsc = b; }
void setKeystrokeOnEsc(bool b) { mKeystrokeOnEsc = b; }
- void setCursorColor(const LLColor4& c) { mCursorColor = c; }
+ void setCursorColor(const LLUIColor& c) { mCursorColor = c; }
const LLColor4& getCursorColor() const { return mCursorColor.get(); }
- void setFgColor( const LLColor4& c ) { mFgColor = c; }
- void setReadOnlyFgColor( const LLColor4& c ) { mReadOnlyFgColor = c; }
- void setTentativeFgColor(const LLColor4& c) { mTentativeFgColor = c; }
+ void setFgColor( const LLUIColor& c ) { mFgColor = c; }
+ void setReadOnlyFgColor( const LLUIColor& c ) { mReadOnlyFgColor = c; }
+ void setTentativeFgColor(const LLUIColor& c) { mTentativeFgColor = c; }
const LLColor4& getFgColor() const { return mFgColor.get(); }
const LLColor4& getReadOnlyFgColor() const { return mReadOnlyFgColor.get(); }
@@ -301,14 +301,11 @@ public:
void removeChar();
void addChar(const llwchar c);
- void addString(char *s, bool editing);
void setCursorAtLocalPos(S32 local_mouse_x);
S32 findPixelNearestPos(S32 cursor_offset = 0) const;
S32 calcCursorPos(S32 mouse_x);
bool handleSpecialKey(KEY key, MASK mask);
bool handleSelectionKey(KEY key, MASK mask);
- bool handleControlKey(KEY key, MASK mask);
- S32 handleCommitKey(KEY key, MASK mask);
void updateTextPadding();
// Draw the background image depending on enabled/focused state.
@@ -346,6 +343,10 @@ protected:
LLViewBorder* mBorder;
const LLFontGL* mGLFont;
+ LLFontVertexBuffer mFontBufferPreSelection;
+ LLFontVertexBuffer mFontBufferSelection;
+ LLFontVertexBuffer mFontBufferPostSelection;
+ LLFontVertexBuffer mFontBufferLabel;
S32 mMaxLengthBytes; // Max length of the UTF8 string in bytes
S32 mMaxLengthChars; // Maximum number of characters in the string
S32 mCursorPos; // I-beam is just after the mCursorPos-th character.
@@ -441,7 +442,7 @@ private:
mText = ed->getText();
}
- void doRollback( LLLineEditor* ed )
+ void doRollback(LLLineEditor* ed) const
{
ed->mCursorPos = mCursorPos;
ed->mScrollHPos = mScrollHPos;
@@ -452,7 +453,7 @@ private:
ed->mPrevText = mText;
}
- std::string getText() { return mText; }
+ std::string getText() const { return mText; }
private:
std::string mText;
@@ -468,7 +469,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/llmenubutton.h b/indra/llui/llmenubutton.h
index a77ae7dae7..3f96b28246 100644
--- a/indra/llui/llmenubutton.h
+++ b/indra/llui/llmenubutton.h
@@ -65,8 +65,8 @@ public:
boost::signals2::connection setMouseDownCallback( const mouse_signal_t::slot_type& cb );
- /*virtual*/ bool handleMouseDown(S32 x, S32 y, MASK mask);
- /*virtual*/ bool handleKeyHere(KEY key, MASK mask );
+ bool handleMouseDown(S32 x, S32 y, MASK mask) override;
+ bool handleKeyHere(KEY key, MASK mask) override;
void hideMenu();
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index dffaf69a9f..c11b42a348 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -508,7 +508,7 @@ void LLMenuItemGL::draw( void )
// Highlight if needed
if( ll::ui::SearchableControl::getHighlighted() )
- color = ll::ui::SearchableControl::getHighlightColor();
+ color = ll::ui::SearchableControl::getHighlightFontColor();
// Draw the text on top.
if (mBriefItem)
@@ -545,8 +545,8 @@ void LLMenuItemGL::draw( void )
std::string::size_type offset = upper_case_label.find(mJumpKey);
if (offset != std::string::npos)
{
- S32 x_begin = LEFT_PLAIN_PIXELS + mFont->getWidth(mLabel, 0, static_cast<S32>(offset));
- S32 x_end = LEFT_PLAIN_PIXELS + mFont->getWidth(mLabel, 0, static_cast<S32>(offset) + 1);
+ S32 x_begin = LEFT_PLAIN_PIXELS + mFont->getWidth(mLabel.getWString().c_str(), 0, static_cast<S32>(offset));
+ S32 x_end = LEFT_PLAIN_PIXELS + mFont->getWidth(mLabel.getWString().c_str(), 0, static_cast<S32>(offset) + 1);
gl_line_2d(x_begin, (MENU_ITEM_PADDING / 2) + 1, x_end, (MENU_ITEM_PADDING / 2) + 1);
}
}
@@ -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)
@@ -1648,9 +1648,9 @@ void LLMenuItemBranchDownGL::draw( void )
std::string::size_type offset = upper_case_label.find(getJumpKey());
if (offset != std::string::npos)
{
- S32 x_offset = ll_round((F32)getRect().getWidth() / 2.f - getFont()->getWidthF32(mLabel.getString(), 0, S32_MAX) / 2.f);
- S32 x_begin = x_offset + getFont()->getWidth(mLabel, 0, static_cast<S32>(offset));
- S32 x_end = x_offset + getFont()->getWidth(mLabel, 0, static_cast<S32>(offset) + 1);
+ S32 x_offset = ll_round((F32)getRect().getWidth() / 2.f - getFont()->getWidthF32(mLabel.getWString().c_str(), 0, S32_MAX) / 2.f);
+ S32 x_begin = x_offset + getFont()->getWidth(mLabel.getWString().c_str(), 0, static_cast<S32>(offset));
+ S32 x_end = x_offset + getFont()->getWidth(mLabel.getWString().c_str(), 0, static_cast<S32>(offset) + 1);
gl_line_2d(x_begin, LABEL_BOTTOM_PAD_PIXELS, x_end, LABEL_BOTTOM_PAD_PIXELS);
}
}
@@ -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..ff9456acc6 100644
--- a/indra/llui/llmenugl.h
+++ b/indra/llui/llmenugl.h
@@ -439,8 +439,6 @@ protected:
public:
virtual ~LLMenuGL( void );
- void parseChildXML(LLXMLNodePtr child, LLView* parent);
-
// LLView Functionality
/*virtual*/ bool handleUnicodeCharHere( llwchar uni_char );
/*virtual*/ bool handleHover( S32 x, S32 y, MASK mask );
@@ -456,7 +454,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 +477,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 +685,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/llmultifloater.cpp b/indra/llui/llmultifloater.cpp
index a7f9b8b2d9..f53e22c349 100644
--- a/indra/llui/llmultifloater.cpp
+++ b/indra/llui/llmultifloater.cpp
@@ -390,7 +390,7 @@ LLFloater* LLMultiFloater::getActiveFloater()
return (LLFloater*)mTabContainer->getCurrentPanel();
}
-S32 LLMultiFloater::getFloaterCount()
+S32 LLMultiFloater::getFloaterCount() const
{
return mTabContainer->getTabCount();
}
diff --git a/indra/llui/llmultifloater.h b/indra/llui/llmultifloater.h
index eb0f917695..e0cd58aa3f 100644
--- a/indra/llui/llmultifloater.h
+++ b/indra/llui/llmultifloater.h
@@ -66,7 +66,7 @@ public:
virtual LLFloater* getActiveFloater();
virtual bool isFloaterFlashing(LLFloater* floaterp);
- virtual S32 getFloaterCount();
+ virtual S32 getFloaterCount() const;
virtual void setFloaterFlashing(LLFloater* floaterp, bool flashing);
virtual bool closeAllFloaters(); //Returns false if the floater could not be closed due to pending confirmation dialogs
diff --git a/indra/llui/llmultislider.h b/indra/llui/llmultislider.h
index b2bfc8bc84..af255bcc8f 100644
--- a/indra/llui/llmultislider.h
+++ b/indra/llui/llmultislider.h
@@ -117,10 +117,10 @@ public:
/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask) override;
/*virtual*/ void draw() override;
- S32 getMaxNumSliders() { return mMaxNumSliders; }
- S32 getCurNumSliders() { return static_cast<S32>(mValue.size()); }
- F32 getOverlapThreshold() { return mOverlapThreshold; }
- bool canAddSliders() { return mValue.size() < mMaxNumSliders; }
+ S32 getMaxNumSliders() const { return mMaxNumSliders; }
+ S32 getCurNumSliders() const { return static_cast<S32>(mValue.size()); }
+ F32 getOverlapThreshold() const { return mOverlapThreshold; }
+ bool canAddSliders() const { return mValue.size() < mMaxNumSliders; }
protected:
diff --git a/indra/llui/llmultisliderctrl.cpp b/indra/llui/llmultisliderctrl.cpp
index 01e2fc6ac9..3235110662 100644
--- a/indra/llui/llmultisliderctrl.cpp
+++ b/indra/llui/llmultisliderctrl.cpp
@@ -245,7 +245,7 @@ bool LLMultiSliderCtrl::setLabelArg( const std::string& key, const LLStringExpli
res = mLabelBox->setTextArg(key, text);
if (res && mLabelWidth == 0)
{
- S32 label_width = mFont->getWidth(mLabelBox->getText());
+ S32 label_width = mFont->getWidth(mLabelBox->getWText().c_str());
LLRect rect = mLabelBox->getRect();
S32 prev_right = rect.mRight;
rect.mRight = rect.mLeft + label_width;
@@ -440,7 +440,7 @@ void LLMultiSliderCtrl::setEnabled(bool b)
if( mLabelBox )
{
- mLabelBox->setColor( b ? mTextEnabledColor.get() : mTextDisabledColor.get() );
+ mLabelBox->setColor( b ? mTextEnabledColor : mTextDisabledColor );
}
mMultiSlider->setEnabled( b );
@@ -452,7 +452,7 @@ void LLMultiSliderCtrl::setEnabled(bool b)
if( mTextBox )
{
- mTextBox->setColor( b ? mTextEnabledColor.get() : mTextDisabledColor.get() );
+ mTextBox->setColor( b ? mTextEnabledColor : mTextDisabledColor );
}
}
diff --git a/indra/llui/llmultisliderctrl.h b/indra/llui/llmultisliderctrl.h
index fee05c92fd..2c2bc5e4d9 100644
--- a/indra/llui/llmultisliderctrl.h
+++ b/indra/llui/llmultisliderctrl.h
@@ -124,14 +124,14 @@ public:
F32 getMinValue() const { return mMultiSlider->getMinValue(); }
F32 getMaxValue() const { return mMultiSlider->getMaxValue(); }
- S32 getMaxNumSliders() { return mMultiSlider->getMaxNumSliders(); }
- S32 getCurNumSliders() { return mMultiSlider->getCurNumSliders(); }
- F32 getOverlapThreshold() { return mMultiSlider->getOverlapThreshold(); }
- bool canAddSliders() { return mMultiSlider->canAddSliders(); }
+ S32 getMaxNumSliders() const { return mMultiSlider->getMaxNumSliders(); }
+ S32 getCurNumSliders() const { return mMultiSlider->getCurNumSliders(); }
+ F32 getOverlapThreshold() const { return mMultiSlider->getOverlapThreshold(); }
+ bool canAddSliders() const { return mMultiSlider->canAddSliders(); }
void setLabel(const std::string& label) { if (mLabelBox) mLabelBox->setText(label); }
- void setLabelColor(const LLColor4& c) { mTextEnabledColor = c; }
- void setDisabledLabelColor(const LLColor4& c) { mTextDisabledColor = c; }
+ void setLabelColor(const LLUIColor& c) { mTextEnabledColor = c; }
+ void setDisabledLabelColor(const LLUIColor& c) { mTextDisabledColor = c; }
boost::signals2::connection setSliderMouseDownCallback( const commit_signal_t::slot_type& cb );
boost::signals2::connection setSliderMouseUpCallback( const commit_signal_t::slot_type& cb );
@@ -147,7 +147,6 @@ public:
static void onEditorCommit(LLUICtrl* ctrl, const LLSD& userdata);
static void onEditorGainFocus(LLFocusableElement* caller, void *userdata);
- static void onEditorChangeFocus(LLUICtrl* caller, S32 direction, void *userdata);
private:
void updateText();
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp
index bee7d5bb3f..a05feab1d9 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;
}
@@ -614,6 +614,13 @@ void LLNotification::cancel()
LLSD LLNotification::getResponseTemplate(EResponseTemplateType type)
{
LLSD response = LLSD::emptyMap();
+
+ if (!mForm)
+ {
+ LL_WARNS("Notifications") << "Null form when getting response template for notification " << getName() << LL_ENDL;
+ return response;
+ }
+
for (S32 element_idx = 0;
element_idx < mForm->getNumElements();
++element_idx)
@@ -769,7 +776,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 +868,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;
@@ -1249,9 +1256,26 @@ LLNotifications::LLNotifications()
LLInstanceTracker<LLNotificationChannel, std::string>::instanceCount();
}
+
+LLNotifications::~LLNotifications()
+{
+ // Clear explicitly, something in ~LLNotifications() crashes so narrowing down suspects
+ pHistoryChannel = nullptr;
+ pExpirationChannel = nullptr;
+ mGlobalStrings.clear();
+ mTemplates.clear();
+ mVisibilityRules.clear();
+ mUniqueNotifications.clear();
+ mListener = nullptr;
+}
+
void LLNotifications::clear()
{
- mDefaultChannels.clear();
+ mDefaultChannels.clear();
+ // At this point mTemplates still gets used by lingering notifications
+ // to do responses (ex: group notice will call forceResponse()), but
+ // since network should be down and everything save, it's questionable
+ // whether it should stay that way
}
// The expiration channel gets all notifications that are cancelled
@@ -1443,11 +1467,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 +1480,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);
}
@@ -1463,6 +1488,13 @@ bool LLNotifications::templateExists(const std::string& name)
void LLNotifications::forceResponse(const LLNotification::Params& params, S32 option)
{
LLNotificationPtr temp_notify(new LLNotification(params));
+
+ if (!temp_notify->getForm())
+ {
+ LL_WARNS("Notifications") << "Cannot force response for notification with null form: " << (std::string)params.name << LL_ENDL;
+ return;
+ }
+
LLSD response = temp_notify->getResponseTemplate();
LLSD selected_item = temp_notify->getForm()->getElement(option);
@@ -1554,7 +1586,7 @@ bool LLNotifications::loadTemplates()
gDirUtilp->findSkinnedFilenames(LLDir::XUI, "notifications.xml", LLDir::ALL_SKINS);
if (search_paths.empty())
{
- LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"));
+ LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"), LLError::LLUserWarningMsg::ERROR_MISSING_FILES);
LL_ERRS() << "Problem finding notifications.xml" << LL_ENDL;
}
@@ -1564,7 +1596,7 @@ bool LLNotifications::loadTemplates()
if (!success || root.isNull() || !root->hasName( "notifications" ))
{
- LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"));
+ LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"), LLError::LLUserWarningMsg::ERROR_MISSING_FILES);
LL_ERRS() << "Problem reading XML from UI Notifications file: " << base_filename << LL_ENDL;
return false;
}
@@ -1575,7 +1607,7 @@ bool LLNotifications::loadTemplates()
if(!params.validateBlock())
{
- LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"));
+ LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"), LLError::LLUserWarningMsg::ERROR_MISSING_FILES);
LL_ERRS() << "Problem reading XUI from UI Notifications file: " << base_filename << LL_ENDL;
return false;
}
@@ -1642,7 +1674,7 @@ bool LLNotifications::loadVisibilityRules()
if(!params.validateBlock())
{
- LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"));
+ LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"), LLError::LLUserWarningMsg::ERROR_MISSING_FILES);
LL_ERRS() << "Problem reading UI Notification Visibility Rules file: " << full_filename << LL_ENDL;
return false;
}
@@ -1740,7 +1772,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 +1847,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 +1858,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 +1871,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..3c8e1e85fa 100644
--- a/indra/llui/llnotifications.h
+++ b/indra/llui/llnotifications.h
@@ -87,6 +87,7 @@
#include <boost/type_traits.hpp>
#include <boost/signals2.hpp>
#include <boost/range.hpp>
+#include <boost/intrusive_ptr.hpp>
#include "llevents.h"
#include "llfunctorregistry.h"
@@ -246,16 +247,15 @@ public:
LLNotificationForm(const LLSD& sd);
LLNotificationForm(const std::string& name, const Params& p);
- void fromLLSD(const LLSD& sd);
LLSD asLLSD() const;
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
@@ -265,8 +265,8 @@ public:
bool getIgnored();
void setIgnored(bool ignored);
- EIgnoreType getIgnoreType() { return mIgnore; }
- std::string getIgnoreMessage() { return mIgnoreMsg; }
+ EIgnoreType getIgnoreType()const { return mIgnore; }
+ std::string getIgnoreMessage() const { return mIgnoreMsg; }
private:
LLSD mFormData;
@@ -641,7 +641,7 @@ public:
bool hasUniquenessConstraints() const;
- bool matchesTag(const std::string& tag);
+ bool matchesTag(std::string_view tag);
virtual ~LLNotification() {}
};
@@ -886,7 +886,7 @@ class LLNotifications :
{
LLSINGLETON(LLNotifications);
LOG_CLASS(LLNotifications);
- virtual ~LLNotifications() {}
+ virtual ~LLNotifications();
public:
@@ -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);
@@ -970,8 +970,6 @@ private:
/*virtual*/ void initSingleton() override;
/*virtual*/ void cleanupSingleton() override;
- void loadPersistentNotifications();
-
bool expirationFilter(LLNotificationPtr pNotification);
bool expirationHandler(const LLSD& payload);
bool uniqueFilter(LLNotificationPtr pNotification);
@@ -988,7 +986,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..db314cae0f 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"),
@@ -242,20 +242,6 @@ void LLPanel::draw()
void LLPanel::updateDefaultBtn()
{
- if( mDefaultBtn)
- {
- if (gFocusMgr.childHasKeyboardFocus( this ) && mDefaultBtn->getEnabled())
- {
- LLButton* buttonp = dynamic_cast<LLButton*>(gFocusMgr.getKeyboardFocus());
- bool focus_is_child_button = buttonp && buttonp->getCommitOnReturn();
- // only enable default button when current focus is not a return-capturing button
- mDefaultBtn->setBorderEnabled(!focus_is_child_button);
- }
- else
- {
- mDefaultBtn->setBorderEnabled(false);
- }
- }
}
void LLPanel::refresh()
@@ -266,18 +252,10 @@ void LLPanel::refresh()
void LLPanel::setDefaultBtn(LLButton* btn)
{
- if (mDefaultBtn && mDefaultBtn->getEnabled())
- {
- mDefaultBtn->setBorderEnabled(false);
- }
mDefaultBtn = btn;
- if (mDefaultBtn)
- {
- mDefaultBtn->setBorderEnabled(true);
- }
}
-void LLPanel::setDefaultBtn(const std::string& id)
+void LLPanel::setDefaultBtn(std::string_view id)
{
LLButton *button = getChild<LLButton>(id);
if (button)
@@ -490,8 +468,8 @@ void LLPanel::initFromParams(const LLPanel::Params& p)
setBackgroundVisible(p.background_visible);
setBackgroundOpaque(p.background_opaque);
- setBackgroundColor(p.bg_opaque_color().get());
- setTransparentColor(p.bg_alpha_color().get());
+ setBackgroundColor(p.bg_opaque_color);
+ setTransparentColor(p.bg_alpha_color);
mBgOpaqueImage = p.bg_opaque_image();
mBgAlphaImage = p.bg_alpha_image();
mBgOpaqueImageOverlay = p.bg_opaque_image_overlay;
@@ -593,12 +571,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 +586,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 +598,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 +618,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 +627,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 +636,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 +645,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 +662,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 +671,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 LLUIColor& color)
{
LLUICtrl* child = findChild<LLUICtrl>(id);
if (child)
@@ -702,7 +680,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 +690,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 +700,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 +710,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 +719,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 +730,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 +740,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 +750,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 +759,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..f085c123c1 100644
--- a/indra/llui/llpanel.h
+++ b/indra/llui/llpanel.h
@@ -134,22 +134,22 @@ public:
bool hasBorder() const { return mBorder != NULL; }
void setBorderVisible( bool b );
- void setBackgroundColor( const LLColor4& color ) { mBgOpaqueColor = color; }
+ void setBackgroundColor( const LLUIColor& color ) { mBgOpaqueColor = color; }
const LLColor4& getBackgroundColor() const { return mBgOpaqueColor; }
- void setTransparentColor(const LLColor4& color) { mBgAlphaColor = color; }
+ void setTransparentColor(const LLUIColor& color) { mBgAlphaColor = color; }
const LLColor4& getTransparentColor() const { return mBgAlphaColor; }
void setBackgroundImage(LLUIImage* image) { mBgOpaqueImage = image; }
void setTransparentImage(LLUIImage* image) { mBgAlphaImage = image; }
LLPointer<LLUIImage> getBackgroundImage() const { return mBgOpaqueImage; }
LLPointer<LLUIImage> getTransparentImage() const { return mBgAlphaImage; }
- LLColor4 getBackgroundImageOverlay() { return mBgOpaqueImageOverlay; }
- LLColor4 getTransparentImageOverlay() { return mBgAlphaImageOverlay; }
+ const LLColor4& getBackgroundImageOverlay() { return mBgOpaqueImageOverlay; }
+ const LLColor4& getTransparentImageOverlay() { return mBgAlphaImageOverlay; }
void setBackgroundVisible( bool b ) { mBgVisible = b; }
bool isBackgroundVisible() const { return mBgVisible; }
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 LLUIColor& 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/llprogressbar.h b/indra/llui/llprogressbar.h
index 0d5d32cf21..7245bbf1cf 100644
--- a/indra/llui/llprogressbar.h
+++ b/indra/llui/llprogressbar.h
@@ -48,9 +48,9 @@ public:
LLProgressBar(const Params&);
virtual ~LLProgressBar();
- void setValue(const LLSD& value);
+ void setValue(const LLSD& value) override;
- /*virtual*/ void draw();
+ void draw() override;
private:
F32 mPercentDone;
diff --git a/indra/llui/llresizebar.h b/indra/llui/llresizebar.h
index 4b0f435834..68bf0fd95e 100644
--- a/indra/llui/llresizebar.h
+++ b/indra/llui/llresizebar.h
@@ -61,7 +61,7 @@ public:
void setResizeLimits( S32 min_size, S32 max_size ) { mMinSize = min_size; mMaxSize = max_size; }
void setEnableSnapping(bool enable) { mSnappingEnabled = enable; }
void setAllowDoubleClickSnapping(bool allow) { mAllowDoubleClickSnapping = allow; }
- bool canResize() { return getEnabled() && mMaxSize > mMinSize; }
+ bool canResize() const { return getEnabled() && mMaxSize > mMinSize; }
void setResizeListener(boost::function<void(void*)> listener) {mResizeListener = listener;}
void setImagePanel(LLPanel * panelp);
LLPanel * getImagePanel() const;
diff --git a/indra/llui/llresizehandle.h b/indra/llui/llresizehandle.h
index 9cc4123544..caec33405c 100644
--- a/indra/llui/llresizehandle.h
+++ b/indra/llui/llresizehandle.h
@@ -50,10 +50,10 @@ protected:
LLResizeHandle(const LLResizeHandle::Params&);
friend class LLUICtrlFactory;
public:
- virtual void draw();
- virtual bool handleHover(S32 x, S32 y, MASK mask);
- virtual bool handleMouseDown(S32 x, S32 y, MASK mask);
- virtual bool handleMouseUp(S32 x, S32 y, MASK mask);
+ void draw() override;
+ bool handleHover(S32 x, S32 y, MASK mask) override;
+ bool handleMouseDown(S32 x, S32 y, MASK mask) override;
+ bool handleMouseUp(S32 x, S32 y, MASK mask) override;
void setResizeLimits( S32 min_width, S32 min_height ) { mMinWidth = min_width; mMinHeight = min_height; }
@@ -71,8 +71,8 @@ private:
const ECorner mCorner;
};
-const S32 RESIZE_HANDLE_HEIGHT = 11;
-const S32 RESIZE_HANDLE_WIDTH = 11;
+constexpr S32 RESIZE_HANDLE_HEIGHT = 11;
+constexpr S32 RESIZE_HANDLE_WIDTH = 11;
#endif // LL_RESIZEHANDLE_H
diff --git a/indra/llui/llrngwriter.h b/indra/llui/llrngwriter.h
index 33ec049a1a..2c39472607 100644
--- a/indra/llui/llrngwriter.h
+++ b/indra/llui/llrngwriter.h
@@ -37,7 +37,7 @@ public:
void writeRNG(const std::string& name, LLXMLNodePtr node, const LLInitParam::BaseBlock& block, const std::string& xml_namespace);
void addDefinition(const std::string& type_name, const LLInitParam::BaseBlock& block);
- /*virtual*/ std::string getCurrentElementName() { return LLStringUtil::null; }
+ std::string getCurrentElementName() override { return LLStringUtil::null; }
LLRNGWriter();
diff --git a/indra/llui/llscrollbar.cpp b/indra/llui/llscrollbar.cpp
index 9c73b1ba3f..d0eec387bd 100644
--- a/indra/llui/llscrollbar.cpp
+++ b/indra/llui/llscrollbar.cpp
@@ -113,7 +113,8 @@ LLScrollbar::LLScrollbar(const Params & p)
up_btn.tab_stop(false);
up_btn.follows.flags = (mOrientation == VERTICAL ? (FOLLOWS_RIGHT | FOLLOWS_TOP) : (FOLLOWS_LEFT | FOLLOWS_BOTTOM));
- addChild(LLUICtrlFactory::create<LLButton>(up_btn));
+ mLineUpBtn = LLUICtrlFactory::create<LLButton>(up_btn);
+ addChild(mLineUpBtn);
LLButton::Params down_btn(mOrientation == VERTICAL ? p.down_button : p.right_button);
down_btn.name(std::string("Line Down"));
@@ -123,7 +124,8 @@ LLScrollbar::LLScrollbar(const Params & p)
down_btn.mouse_held_callback.function(boost::bind(&LLScrollbar::onLineDownBtnPressed, this, _2));
down_btn.tab_stop(false);
- addChild(LLUICtrlFactory::create<LLButton>(down_btn));
+ mLineDownBtn = LLUICtrlFactory::create<LLButton>(down_btn);
+ addChild(mLineDownBtn);
}
@@ -468,22 +470,20 @@ void LLScrollbar::reshape(S32 width, S32 height, bool called_from_parent)
{
if (width == getRect().getWidth() && height == getRect().getHeight()) return;
LLView::reshape( width, height, called_from_parent );
- LLButton* up_button = getChild<LLButton>("Line Up");
- LLButton* down_button = getChild<LLButton>("Line Down");
if (mOrientation == VERTICAL)
{
- up_button->reshape(up_button->getRect().getWidth(), llmin(getRect().getHeight() / 2, mThickness));
- down_button->reshape(down_button->getRect().getWidth(), llmin(getRect().getHeight() / 2, mThickness));
- up_button->setOrigin(0, getRect().getHeight() - up_button->getRect().getHeight());
- down_button->setOrigin(0, 0);
+ mLineUpBtn->reshape(mLineUpBtn->getRect().getWidth(), llmin(getRect().getHeight() / 2, mThickness));
+ mLineDownBtn->reshape(mLineDownBtn->getRect().getWidth(), llmin(getRect().getHeight() / 2, mThickness));
+ mLineUpBtn->setOrigin(0, getRect().getHeight() - mLineUpBtn->getRect().getHeight());
+ mLineDownBtn->setOrigin(0, 0);
}
else
{
- up_button->reshape(llmin(getRect().getWidth() / 2, mThickness), up_button->getRect().getHeight());
- down_button->reshape(llmin(getRect().getWidth() / 2, mThickness), down_button->getRect().getHeight());
- up_button->setOrigin(0, 0);
- down_button->setOrigin(getRect().getWidth() - down_button->getRect().getWidth(), 0);
+ mLineUpBtn->reshape(llmin(getRect().getWidth() / 2, mThickness), mLineUpBtn->getRect().getHeight());
+ mLineDownBtn->reshape(llmin(getRect().getWidth() / 2, mThickness), mLineDownBtn->getRect().getHeight());
+ mLineUpBtn->setOrigin(0, 0);
+ mLineDownBtn->setOrigin(getRect().getWidth() - mLineDownBtn->getRect().getWidth(), 0);
}
updateThumbRect();
}
diff --git a/indra/llui/llscrollbar.h b/indra/llui/llscrollbar.h
index 7b935aa51b..9607355a9d 100644
--- a/indra/llui/llscrollbar.h
+++ b/indra/llui/llscrollbar.h
@@ -161,6 +161,9 @@ private:
LLUIImagePtr mTrackImageH;
S32 mThickness;
+
+ LLButton* mLineUpBtn = nullptr;
+ LLButton* mLineDownBtn = nullptr;
};
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..a3108d77e8 100644
--- a/indra/llui/llscrolllistcell.cpp
+++ b/indra/llui/llscrolllistcell.cpp
@@ -30,6 +30,7 @@
#include "llscrolllistcell.h"
#include "llcheckboxctrl.h"
+#include "llfontvertexbuffer.h"
#include "llui.h" // LLUIImage
#include "lluictrlfactory.h"
@@ -156,7 +157,7 @@ S32 LLScrollListIcon::getWidth() const
}
-void LLScrollListIcon::draw(const LLColor4& color, const LLColor4& highlight_color) const
+void LLScrollListIcon::draw(const LLColor4& color, const LLColor4& highlight_color)
{
if (mIcon)
{
@@ -209,7 +210,7 @@ void LLScrollListBar::setValue(const LLSD& value)
{
if (value.has("ratio"))
{
- mRatio = value["ratio"].asReal();
+ mRatio = (F32)value["ratio"].asReal();
}
if (value.has("bottom"))
{
@@ -236,10 +237,10 @@ S32 LLScrollListBar::getWidth() const
}
-void LLScrollListBar::draw(const LLColor4& color, const LLColor4& highlight_color) const
+void LLScrollListBar::draw(const LLColor4& color, const LLColor4& highlight_color)
{
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);
@@ -305,7 +306,20 @@ bool LLScrollListText::needsToolTip() const
return LLScrollListCell::needsToolTip();
// ...otherwise, show tooltips for truncated text
- return mFont->getWidth(mText.getString()) > getWidth();
+ return mFont->getWidth(mText.getWString().c_str()) > getWidth();
+}
+
+void LLScrollListText::setTextWidth(S32 value)
+{
+ mTextWidth = value;
+ mFontBuffer.reset();
+}
+
+void LLScrollListText::setWidth(S32 width)
+{
+ LLScrollListCell::setWidth(width);
+ mTextWidth = width;
+ mFontBuffer.reset();
}
//virtual
@@ -328,7 +342,7 @@ LLScrollListText::~LLScrollListText()
S32 LLScrollListText::getContentWidth() const
{
- return mFont->getWidth(mText.getString());
+ return mFont->getWidth(mText.getWString().c_str());
}
@@ -341,6 +355,7 @@ void LLScrollListText::setColor(const LLColor4& color)
void LLScrollListText::setText(const LLStringExplicit& text)
{
mText = text;
+ mFontBuffer.reset();
}
void LLScrollListText::setFontStyle(const U8 font_style)
@@ -348,6 +363,13 @@ void LLScrollListText::setFontStyle(const U8 font_style)
LLFontDescriptor new_desc(mFont->getFontDesc());
new_desc.setStyle(font_style);
mFont = LLFontGL::getFont(new_desc);
+ mFontBuffer.reset();
+}
+
+void LLScrollListText::setAlignment(LLFontGL::HAlign align)
+{
+ mFontAlignment = align;
+ mFontBuffer.reset();
}
//virtual
@@ -375,7 +397,7 @@ const LLSD LLScrollListText::getAltValue() const
}
-void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_color) const
+void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_color)
{
LLColor4 display_color;
if (mUseColor)
@@ -394,18 +416,18 @@ void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_col
switch(mFontAlignment)
{
case LLFontGL::LEFT:
- left = mFont->getWidth(mText.getString(), 1, mHighlightOffset);
+ left = mFont->getWidth(mText.getWString().c_str(), 1, mHighlightOffset);
break;
case LLFontGL::RIGHT:
- left = getWidth() - mFont->getWidth(mText.getString(), mHighlightOffset, S32_MAX);
+ left = getWidth() - mFont->getWidth(mText.getWString().c_str(), mHighlightOffset, S32_MAX);
break;
case LLFontGL::HCENTER:
- left = (getWidth() - mFont->getWidth(mText.getString())) / 2;
+ left = (getWidth() - mFont->getWidth(mText.getWString().c_str())) / 2;
break;
}
LLRect highlight_rect(left - 2,
mFont->getLineHeight() + 1,
- left + mFont->getWidth(mText.getString(), mHighlightOffset, mHighlightCount) + 1,
+ left + mFont->getWidth(mText.getWString().c_str(), mHighlightOffset, mHighlightCount) + 1,
1);
mRoundedRectImage->draw(highlight_rect, highlight_color);
}
@@ -426,17 +448,18 @@ void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_col
start_x = (F32)getWidth() * 0.5f;
break;
}
- mFont->render(mText.getWString(), 0,
- start_x, 0.f,
- display_color,
- mFontAlignment,
- LLFontGL::BOTTOM,
- 0,
- LLFontGL::NO_SHADOW,
- string_chars,
- getTextWidth(),
- &right_x,
- true);
+ mFontBuffer.render(mFont,
+ mText.getWString(), 0,
+ start_x, 0.f,
+ display_color,
+ mFontAlignment,
+ LLFontGL::BOTTOM,
+ 0,
+ LLFontGL::NO_SHADOW,
+ string_chars,
+ getTextWidth(),
+ &right_x,
+ true);
}
//
@@ -465,7 +488,7 @@ LLScrollListCheck::LLScrollListCheck(const LLScrollListCell::Params& p)
setWidth(rect.getWidth()); //check_box->getWidth();
}
- mCheckBox->setColor(p.color);
+ mCheckBox->setColor(p.color());
}
@@ -475,7 +498,7 @@ LLScrollListCheck::~LLScrollListCheck()
mCheckBox = NULL;
}
-void LLScrollListCheck::draw(const LLColor4& color, const LLColor4& highlight_color) const
+void LLScrollListCheck::draw(const LLColor4& color, const LLColor4& highlight_color)
{
mCheckBox->draw();
}
@@ -592,7 +615,7 @@ void LLScrollListIconText::setWidth(S32 width)
}
-void LLScrollListIconText::draw(const LLColor4& color, const LLColor4& highlight_color) const
+void LLScrollListIconText::draw(const LLColor4& color, const LLColor4& highlight_color)
{
LLColor4 display_color;
if (mUseColor)
@@ -613,18 +636,18 @@ void LLScrollListIconText::draw(const LLColor4& color, const LLColor4& highlight
switch (mFontAlignment)
{
case LLFontGL::LEFT:
- left = mFont->getWidth(mText.getString(), icon_space + 1, mHighlightOffset);
+ left = mFont->getWidth(mText.getWString().c_str(), icon_space + 1, mHighlightOffset);
break;
case LLFontGL::RIGHT:
- left = getWidth() - mFont->getWidth(mText.getString(), mHighlightOffset, S32_MAX) - icon_space;
+ left = getWidth() - mFont->getWidth(mText.getWString().c_str(), mHighlightOffset, S32_MAX) - icon_space;
break;
case LLFontGL::HCENTER:
- left = (getWidth() - mFont->getWidth(mText.getString()) - icon_space) / 2;
+ left = (getWidth() - mFont->getWidth(mText.getWString().c_str()) - icon_space) / 2;
break;
}
LLRect highlight_rect(left - 2,
mFont->getLineHeight() + 1,
- left + mFont->getWidth(mText.getString(), mHighlightOffset, mHighlightCount) + 1,
+ left + mFont->getWidth(mText.getWString().c_str(), mHighlightOffset, mHighlightCount) + 1,
1);
mRoundedRectImage->draw(highlight_rect, highlight_color);
}
@@ -637,20 +660,22 @@ 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:
start_text_x = (F32)getWidth();
- start_icon_x = getWidth() - mFont->getWidth(mText.getString()) - icon_space;
+ start_icon_x = getWidth() - mFont->getWidth(mText.getWString().c_str()) - icon_space;
break;
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.getWString().c_str())) * 0.5f));
break;
}
- mFont->render(mText.getWString(), 0,
+ mFontBuffer.render(
+ mFont,
+ mText.getWString(), 0,
start_text_x, 0.f,
display_color,
mFontAlignment,
diff --git a/indra/llui/llscrolllistcell.h b/indra/llui/llscrolllistcell.h
index c5d785ae52..7dded3c0b7 100644
--- a/indra/llui/llscrolllistcell.h
+++ b/indra/llui/llscrolllistcell.h
@@ -29,6 +29,7 @@
#define LLSCROLLLISTCELL_H
#include "llfontgl.h" // HAlign
+#include "llfontvertexbuffer.h" // HAlign
#include "llpointer.h" // LLPointer<>
#include "lluistring.h"
#include "v4color.h"
@@ -96,7 +97,7 @@ public:
LLScrollListCell(const LLScrollListCell::Params&);
virtual ~LLScrollListCell() {};
- virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const {}; // truncate to given width, if possible
+ virtual void draw(const LLColor4& color, const LLColor4& highlight_color) {}; // truncate to given width, if possible
virtual S32 getWidth() const {return mWidth;}
virtual S32 getContentWidth() const { return 0; }
virtual S32 getHeight() const { return 0; }
@@ -104,7 +105,7 @@ public:
virtual const LLSD getAltValue() const;
virtual void setValue(const LLSD& value) { }
virtual void setAltValue(const LLSD& value) { }
- virtual const std::string &getToolTip() const { return mToolTip; }
+ virtual const std::string& getToolTip() const { return mToolTip; }
virtual void setToolTip(const std::string &str) { mToolTip = str; }
virtual bool getVisible() const { return true; }
virtual void setWidth(S32 width) { mWidth = width; }
@@ -127,7 +128,7 @@ class LLScrollListSpacer : public LLScrollListCell
public:
LLScrollListSpacer(const LLScrollListCell::Params& p) : LLScrollListCell(p) {}
/*virtual*/ ~LLScrollListSpacer() {};
- /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const {}
+ /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) {}
};
/*
@@ -139,7 +140,7 @@ public:
LLScrollListText(const LLScrollListCell::Params&);
/*virtual*/ ~LLScrollListText();
- /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const;
+ /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color);
/*virtual*/ S32 getContentWidth() const;
/*virtual*/ S32 getHeight() const;
/*virtual*/ void setValue(const LLSD& value);
@@ -155,18 +156,20 @@ public:
/*virtual*/ bool needsToolTip() const;
S32 getTextWidth() const { return mTextWidth;}
- void setTextWidth(S32 value) { mTextWidth = value;}
- virtual void setWidth(S32 width) { LLScrollListCell::setWidth(width); mTextWidth = width; }
+ void setTextWidth(S32 value);
+ virtual void setWidth(S32 width);
void setText(const LLStringExplicit& text);
void setFontStyle(const U8 font_style);
- void setAlignment(LLFontGL::HAlign align) { mFontAlignment = align; }
+ void setAlignment(LLFontGL::HAlign align);
protected:
+
LLUIString mText;
LLUIString mAltText;
S32 mTextWidth;
const LLFontGL* mFont;
+ LLFontVertexBuffer mFontBuffer;
LLColor4 mColor;
LLColor4 mHighlightColor;
U8 mUseColor;
@@ -188,7 +191,7 @@ class LLScrollListIcon : public LLScrollListCell
public:
LLScrollListIcon(const LLScrollListCell::Params& p);
/*virtual*/ ~LLScrollListIcon();
- /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const;
+ /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color);
/*virtual*/ S32 getWidth() const;
/*virtual*/ S32 getHeight() const;
/*virtual*/ const LLSD getValue() const;
@@ -207,7 +210,7 @@ class LLScrollListBar : public LLScrollListCell
public:
LLScrollListBar(const LLScrollListCell::Params& p);
/*virtual*/ ~LLScrollListBar();
- /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const;
+ /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color);
/*virtual*/ S32 getWidth() const;
/*virtual*/ S32 getHeight() const;
/*virtual*/ const LLSD getValue() const;
@@ -229,7 +232,7 @@ class LLScrollListCheck : public LLScrollListCell
public:
LLScrollListCheck( const LLScrollListCell::Params&);
/*virtual*/ ~LLScrollListCheck();
- /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const;
+ /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color);
/*virtual*/ S32 getHeight() const { return 0; }
/*virtual*/ const LLSD getValue() const;
/*virtual*/ void setValue(const LLSD& value);
@@ -264,13 +267,11 @@ class LLScrollListIconText : public LLScrollListText
public:
LLScrollListIconText(const LLScrollListCell::Params& p);
/*virtual*/ ~LLScrollListIconText();
- /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const;
+ /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color);
/*virtual*/ const LLSD getValue() const;
/*virtual*/ void setValue(const LLSD& value);
-
- S32 getIconWidth() const;
- /*virtual*/ void setWidth(S32 width);/* { LLScrollListCell::setWidth(width); mTextWidth = width - ; }*/
+ /*virtual*/ void setWidth(S32 width);
private:
LLPointer<LLUIImage> mIcon;
diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp
index 1d9564d107..245339b107 100644
--- a/indra/llui/llscrolllistctrl.cpp
+++ b/indra/llui/llscrolllistctrl.cpp
@@ -196,7 +196,6 @@ LLScrollListCtrl::LLScrollListCtrl(const LLScrollListCtrl::Params& p)
mHighlightedItem(-1),
mBorder(NULL),
mSortCallback(NULL),
- mCommentTextView(NULL),
mNumDynamicWidthColumns(0),
mTotalStaticColumnWidth(0),
mTotalColumnPadding(0),
@@ -288,13 +287,6 @@ LLScrollListCtrl::LLScrollListCtrl(const LLScrollListCtrl::Params& p)
addColumn(*row_it);
}
- for (LLInitParam::ParamIterator<LLScrollListItem::Params>::const_iterator row_it = p.contents.rows.begin();
- row_it != p.contents.rows.end();
- ++row_it)
- {
- addRow(*row_it);
- }
-
LLTextBox::Params text_p;
text_p.name("comment_text");
text_p.border_visible(false);
@@ -302,7 +294,15 @@ LLScrollListCtrl::LLScrollListCtrl(const LLScrollListCtrl::Params& p)
text_p.follows.flags(FOLLOWS_ALL);
// word wrap was added accroding to the EXT-6841
text_p.wrap(true);
- addChild(LLUICtrlFactory::create<LLTextBox>(text_p));
+ mCommentText = LLUICtrlFactory::create<LLTextBox>(text_p);
+ addChild(mCommentText);
+
+ for (LLInitParam::ParamIterator<LLScrollListItem::Params>::const_iterator row_it = p.contents.rows.begin();
+ row_it != p.contents.rows.end();
+ ++row_it)
+ {
+ addRow(*row_it);
+ }
}
S32 LLScrollListCtrl::getSearchColumn()
@@ -410,10 +410,8 @@ void LLScrollListCtrl::clearRows()
LLScrollListItem* LLScrollListCtrl::getFirstSelected() const
{
- item_list::const_iterator iter;
- for (iter = mItemList.begin(); iter != mItemList.end(); iter++)
+ for (LLScrollListItem* item : mItemList)
{
- LLScrollListItem* item = *iter;
if (item->getSelected())
{
return item;
@@ -425,10 +423,8 @@ LLScrollListItem* LLScrollListCtrl::getFirstSelected() const
std::vector<LLScrollListItem*> LLScrollListCtrl::getAllSelected() const
{
std::vector<LLScrollListItem*> ret;
- item_list::const_iterator iter;
- for(iter = mItemList.begin(); iter != mItemList.end(); iter++)
+ for (LLScrollListItem* item : mItemList)
{
- LLScrollListItem* item = *iter;
if (item->getSelected())
{
ret.push_back(item);
@@ -441,9 +437,8 @@ S32 LLScrollListCtrl::getNumSelected() const
{
S32 numSelected = 0;
- for(item_list::const_iterator iter = mItemList.begin(); iter != mItemList.end(); ++iter)
+ for (LLScrollListItem* item : mItemList)
{
- LLScrollListItem* item = *iter;
if (item->getSelected())
{
++numSelected;
@@ -460,10 +455,8 @@ S32 LLScrollListCtrl::getFirstSelectedIndex() const
// make sure sort is up to date before returning an index
updateSort();
- item_list::const_iterator iter;
- for (iter = mItemList.begin(); iter != mItemList.end(); iter++)
+ for (LLScrollListItem* item : mItemList)
{
- LLScrollListItem* item = *iter;
if (item->getSelected())
{
return CurSelectedIndex;
@@ -476,29 +469,19 @@ S32 LLScrollListCtrl::getFirstSelectedIndex() const
LLScrollListItem* LLScrollListCtrl::getFirstData() const
{
- if (mItemList.size() == 0)
- {
- return NULL;
- }
- return mItemList[0];
+ return mItemList.empty() ? NULL : mItemList.front();
}
LLScrollListItem* LLScrollListCtrl::getLastData() const
{
- if (mItemList.size() == 0)
- {
- return NULL;
- }
- return mItemList[mItemList.size() - 1];
+ return mItemList.empty() ? NULL : mItemList.back();
}
std::vector<LLScrollListItem*> LLScrollListCtrl::getAllData() const
{
std::vector<LLScrollListItem*> ret;
- item_list::const_iterator iter;
- for(iter = mItemList.begin(); iter != mItemList.end(); iter++)
+ for (LLScrollListItem* item : mItemList)
{
- LLScrollListItem* item = *iter;
ret.push_back(item);
}
return ret;
@@ -509,20 +492,18 @@ LLScrollListItem* LLScrollListCtrl::getItem(const LLSD& sd) const
{
std::string string_val = sd.asString();
- item_list::const_iterator iter;
- for(iter = mItemList.begin(); iter != mItemList.end(); iter++)
+ for (LLScrollListItem* item : mItemList)
{
- LLScrollListItem* item = *iter;
// assumes string representation is good enough for comparison
if (item->getValue().asString() == string_val)
{
return item;
}
}
+
return NULL;
}
-
void LLScrollListCtrl::reshape( S32 width, S32 height, bool called_from_parent )
{
LLUICtrl::reshape( width, height, called_from_parent );
@@ -541,12 +522,7 @@ void LLScrollListCtrl::updateLayout()
getRect().getWidth() - 2 * mBorderThickness,
getRect().getHeight() - (2 * mBorderThickness ) - heading_size );
- if (mCommentTextView == NULL)
- {
- mCommentTextView = getChildView("comment_text");
- }
-
- mCommentTextView->setShape(mItemListRect);
+ mCommentText->setShape(mItemListRect);
// how many lines of content in a single "page"
S32 page_lines = getLinesPerPage();
@@ -572,15 +548,16 @@ void LLScrollListCtrl::updateLayout()
void LLScrollListCtrl::fitContents(S32 max_width, S32 max_height)
{
S32 height = llmin( getRequiredRect().getHeight(), max_height );
- if(mPageLines)
- height = llmin( mPageLines * mLineHeight + 2*mBorderThickness + (mDisplayColumnHeaders ? mHeadingHeight : 0), height );
+ if (mPageLines)
+ {
+ height = llmin(mPageLines * mLineHeight + 2 * mBorderThickness + (mDisplayColumnHeaders ? mHeadingHeight : 0), height);
+ }
S32 width = getRect().getWidth();
reshape( width, height );
}
-
LLRect LLScrollListCtrl::getRequiredRect()
{
S32 heading_size = (mDisplayColumnHeaders ? mHeadingHeight : 0);
@@ -632,7 +609,8 @@ bool LLScrollListCtrl::addItem( LLScrollListItem* item, EAddPosition pos, bool r
S32 i = 0;
for (LLScrollListCell* cell = item->getColumn(i); i < num_cols; cell = item->getColumn(++i))
{
- if (i >= (S32)mColumnsIndexed.size()) break;
+ if (i >= (S32)mColumnsIndexed.size())
+ break;
cell->setWidth(mColumnsIndexed[i]->getWidth());
}
@@ -655,23 +633,21 @@ S32 LLScrollListCtrl::calcMaxContentWidth()
S32 max_item_width = 0;
- ordered_columns_t::iterator column_itor;
- for (column_itor = mColumnsIndexed.begin(); column_itor != mColumnsIndexed.end(); ++column_itor)
+ for (LLScrollListColumn* column : mColumnsIndexed)
{
- LLScrollListColumn* column = *column_itor;
- if (!column) continue;
+ if (!column)
+ continue;
if (mColumnWidthsDirty)
{
// update max content width for this column, by looking at all items
- column->mMaxContentWidth = column->mHeader ? LLFontGL::getFontSansSerifSmall()->getWidth(column->mLabel) + mColumnPadding + HEADING_TEXT_PADDING : 0;
- item_list::iterator iter;
- for (iter = mItemList.begin(); iter != mItemList.end(); iter++)
+ column->mMaxContentWidth = column->mHeader ? LLFontGL::getFontSansSerifSmall()->getWidth(column->mLabel.getWString().c_str()) + mColumnPadding + HEADING_TEXT_PADDING : 0;
+ for (LLScrollListItem* item : mItemList)
{
- LLScrollListCell* cellp = (*iter)->getColumn(column->mIndex);
- if (!cellp) continue;
-
- column->mMaxContentWidth = llmax(LLFontGL::getFontSansSerifSmall()->getWidth(cellp->getValue().asString()) + mColumnPadding + COLUMN_TEXT_PADDING, column->mMaxContentWidth);
+ if (LLScrollListCell* cellp = item->getColumn(column->mIndex))
+ {
+ column->mMaxContentWidth = llmax(LLFontGL::getFontSansSerifSmall()->getWidth(cellp->getValue().asString()) + mColumnPadding + COLUMN_TEXT_PADDING, column->mMaxContentWidth);
+ }
}
}
max_item_width += column->mMaxContentWidth;
@@ -688,7 +664,8 @@ bool LLScrollListCtrl::updateColumnWidths()
for (column_itor = mColumnsIndexed.begin(); column_itor != mColumnsIndexed.end(); ++column_itor)
{
LLScrollListColumn* column = *column_itor;
- if (!column) continue;
+ if (!column)
+ continue;
// update column width
S32 new_width = 0;
@@ -742,7 +719,6 @@ void LLScrollListCtrl::updateLineHeightInsert(LLScrollListItem* itemp)
}
}
-
void LLScrollListCtrl::updateColumns(bool force_update)
{
if (!mColumnsDirty && !force_update)
@@ -815,7 +791,8 @@ void LLScrollListCtrl::updateColumns(bool force_update)
S32 i = 0;
for (LLScrollListCell* cell = itemp->getColumn(i); i < num_cols; cell = itemp->getColumn(++i))
{
- if (i >= (S32)mColumnsIndexed.size()) break;
+ if (i >= (S32)mColumnsIndexed.size())
+ break;
cell->setWidth(mColumnsIndexed[i]->getWidth());
}
@@ -842,8 +819,8 @@ void LLScrollListCtrl::setHeadingHeight(S32 heading_height)
mHeadingHeight = heading_height;
updateLayout();
-
}
+
void LLScrollListCtrl::setPageLines(S32 new_page_lines)
{
mPageLines = new_page_lines;
@@ -885,6 +862,7 @@ bool LLScrollListCtrl::selectFirstItem()
}
first_item = false;
}
+
if (mCommitOnSelectionChange)
{
commitIfChanged();
@@ -894,13 +872,13 @@ bool LLScrollListCtrl::selectFirstItem()
// Deselects all other items
// virtual
-bool LLScrollListCtrl::selectNthItem( S32 target_index )
+bool LLScrollListCtrl::selectNthItem(S32 target_index)
{
return selectItemRange(target_index, target_index);
}
// virtual
-bool LLScrollListCtrl::selectItemRange( S32 first_index, S32 last_index )
+bool LLScrollListCtrl::selectItemRange(S32 first_index, S32 last_index)
{
if (mItemList.empty())
{
@@ -910,28 +888,24 @@ bool LLScrollListCtrl::selectItemRange( S32 first_index, S32 last_index )
// make sure sort is up to date
updateSort();
- S32 listlen = (S32)mItemList.size();
- first_index = llclamp(first_index, 0, listlen-1);
-
- if (last_index < 0)
- last_index = listlen-1;
- else
- last_index = llclamp(last_index, first_index, listlen-1);
+ S32 bottom = (S32)mItemList.size() - 1;
+ first_index = llclamp(first_index, 0, bottom);
+ last_index = last_index < 0 ? bottom : llclamp(last_index, first_index, bottom);
bool success = false;
S32 index = 0;
for (item_list::iterator iter = mItemList.begin(); iter != mItemList.end(); )
{
LLScrollListItem *itemp = *iter;
- if(!itemp)
+ if (!itemp)
{
iter = mItemList.erase(iter);
- continue ;
+ continue;
}
- if( index >= first_index && index <= last_index )
+ if (index >= first_index && index <= last_index)
{
- if( itemp->getEnabled() )
+ if (itemp->getEnabled())
{
// TODO: support range selection for cells
selectItem(itemp, -1, false);
@@ -1178,7 +1152,6 @@ void LLScrollListCtrl::selectPrevItem( bool extend_selection)
mSearchString.clear();
}
-
void LLScrollListCtrl::selectNextItem( bool extend_selection)
{
LLScrollListItem* next_item = NULL;
@@ -1222,8 +1195,6 @@ void LLScrollListCtrl::selectNextItem( bool extend_selection)
mSearchString.clear();
}
-
-
void LLScrollListCtrl::deselectAllItems(bool no_commit_on_change)
{
item_list::iterator iter;
@@ -1244,7 +1215,7 @@ void LLScrollListCtrl::deselectAllItems(bool no_commit_on_change)
void LLScrollListCtrl::setCommentText(const std::string& comment_text)
{
- getChild<LLTextBox>("comment_text")->setValue(comment_text);
+ mCommentText->setValue(comment_text);
}
LLScrollListItem* LLScrollListCtrl::addSeparator(EAddPosition pos)
@@ -1295,16 +1266,14 @@ LLScrollListItem* LLScrollListCtrl::getItemByLabel(const std::string& label, boo
LLStringUtil::toLower(target_text);
}
- item_list::iterator iter;
- for (iter = mItemList.begin(); iter != mItemList.end(); iter++)
+ for (LLScrollListItem* item : mItemList)
{
- LLScrollListItem* item = *iter;
std::string item_text = item->getColumn(column)->getValue().asString(); // Only select enabled items with matching names
if (!case_sensitive)
{
LLStringUtil::toLower(item_text);
}
- if(item_text == target_text)
+ if (item_text == target_text)
{
return item;
}
@@ -1312,6 +1281,15 @@ LLScrollListItem* LLScrollListCtrl::getItemByLabel(const std::string& label, boo
return NULL;
}
+LLScrollListItem* LLScrollListCtrl::getItemByIndex(S32 index)
+{
+ if (index >= 0 && index < (S32)mItemList.size())
+ {
+ return mItemList[index];
+ }
+
+ return NULL;
+}
bool LLScrollListCtrl::selectItemByPrefix(const std::string& target, bool case_sensitive, S32 column)
{
@@ -1472,17 +1450,16 @@ U32 LLScrollListCtrl::searchItems(const LLWString& substring, bool case_sensitiv
return found;
}
-const std::string LLScrollListCtrl::getSelectedItemLabel(S32 column) const
+std::string LLScrollListCtrl::getSelectedItemLabel(S32 column) const
{
LLScrollListItem* item;
item = getFirstSelected();
if (item)
{
- auto col = item->getColumn(column);
- if(col)
+ if (LLScrollListCell* cell = item->getColumn(column))
{
- return col->getValue().asString();
+ return cell->getValue().asString();
}
}
@@ -1517,7 +1494,10 @@ bool LLScrollListCtrl::setSelectedByValue(const LLSD& value, bool selected)
{
bool found = false;
- if (selected && !mAllowMultipleSelection) deselectAllItems(true);
+ if (selected && !mAllowMultipleSelection)
+ {
+ deselectAllItems(true);
+ }
item_list::iterator iter;
for (iter = mItemList.begin(); iter != mItemList.end(); iter++)
@@ -1728,7 +1708,7 @@ void LLScrollListCtrl::draw()
updateColumns();
- getChildView("comment_text")->setVisible(mItemList.empty());
+ mCommentText->setVisible(mItemList.empty());
drawItems();
@@ -2644,9 +2624,7 @@ bool LLScrollListCtrl::isRepeatedChars(const LLWString& string) const
void LLScrollListCtrl::selectItem(LLScrollListItem* itemp, S32 cell, bool select_single_item)
{
- if (!itemp) return;
-
- if (!itemp->getSelected())
+ if (itemp && !itemp->getSelected())
{
if (mLastSelected)
{
@@ -2680,9 +2658,7 @@ void LLScrollListCtrl::selectItem(LLScrollListItem* itemp, S32 cell, bool select
void LLScrollListCtrl::deselectItem(LLScrollListItem* itemp)
{
- if (!itemp) return;
-
- if (itemp->getSelected())
+ if (itemp && itemp->getSelected())
{
if (mLastSelected == itemp)
{
@@ -2720,7 +2696,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;
@@ -2733,32 +2710,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();
}
@@ -2774,7 +2747,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);
}
}
@@ -2891,7 +2864,7 @@ void LLScrollListCtrl::updateStaticColumnWidth(LLScrollListColumn* col, S32 new_
// LLEditMenuHandler functions
// virtual
-void LLScrollListCtrl::copy()
+void LLScrollListCtrl::copy()
{
std::string buffer;
@@ -2905,26 +2878,26 @@ void LLScrollListCtrl::copy()
}
// virtual
-bool LLScrollListCtrl::canCopy() const
+bool LLScrollListCtrl::canCopy() const
{
return (getFirstSelected() != NULL);
}
// virtual
-void LLScrollListCtrl::cut()
+void LLScrollListCtrl::cut()
{
copy();
doDelete();
}
// virtual
-bool LLScrollListCtrl::canCut() const
+bool LLScrollListCtrl::canCut() const
{
return canCopy() && canDoDelete();
}
// virtual
-void LLScrollListCtrl::selectAll()
+void LLScrollListCtrl::selectAll()
{
// Deselects all other items
item_list::iterator iter;
@@ -2944,13 +2917,13 @@ void LLScrollListCtrl::selectAll()
}
// virtual
-bool LLScrollListCtrl::canSelectAll() const
+bool LLScrollListCtrl::canSelectAll() const
{
return getCanSelect() && mAllowMultipleSelection && !(mMaxSelectable > 0 && mItemList.size() > mMaxSelectable);
}
// virtual
-void LLScrollListCtrl::deselect()
+void LLScrollListCtrl::deselect()
{
deselectAllItems();
}
@@ -3093,8 +3066,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
@@ -3422,7 +3394,7 @@ bool LLScrollListCtrl::highlightMatchingItems(const std::string& filter_str)
bool res = false;
- setHighlightedColor(LLUIColorTable::instance().getColor("SearchableControlHighlightColor", LLColor4::red));
+ setHighlightedColor(LLUIColorTable::instance().getColor("SearchableControlHighlightBgColor", LLColor4::red4));
std::string filter_str_lc(filter_str);
LLStringUtil::toLower(filter_str_lc);
diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h
index f25ba61fd4..1f04100306 100644
--- a/indra/llui/llscrolllistctrl.h
+++ b/indra/llui/llscrolllistctrl.h
@@ -165,7 +165,6 @@ public:
void deleteAllItems() { clearRows(); }
// Sets an array of column descriptors
- void setColumnHeadings(const LLSD& headings);
void sortByColumnIndex(U32 column, bool ascending);
// LLCtrlListInterface functions
@@ -260,11 +259,12 @@ public:
// one of which can be selected at a time.
virtual LLScrollListItem* addSimpleElement(const std::string& value, EAddPosition pos = ADD_BOTTOM, const LLSD& id = LLSD());
- bool selectItemByLabel( const std::string& item, bool case_sensitive = true, S32 column = 0 ); // false if item not found
+ bool selectItemByLabel(const std::string& item, bool case_sensitive = true, S32 column = 0); // false if item not found
bool selectItemByPrefix(const std::string& target, bool case_sensitive = true, S32 column = -1);
bool selectItemByPrefix(const LLWString& target, bool case_sensitive = true, S32 column = -1);
- LLScrollListItem* getItemByLabel( const std::string& item, bool case_sensitive = true, S32 column = 0 );
- const std::string getSelectedItemLabel(S32 column = 0) const;
+ LLScrollListItem* getItemByLabel(const std::string& item, bool case_sensitive = true, S32 column = 0);
+ LLScrollListItem* getItemByIndex(S32 index);
+ std::string getSelectedItemLabel(S32 column = 0) const;
LLSD getSelectedValue();
// If multi select is on, select all element that include substring,
@@ -317,7 +317,7 @@ public:
void setAllowKeyboardMovement(bool b) { mAllowKeyboardMovement = b; }
void setMaxSelectable(U32 max_selected) { mMaxSelectable = max_selected; }
- S32 getMaxSelectable() { return mMaxSelectable; }
+ S32 getMaxSelectable() const { return mMaxSelectable; }
virtual S32 getScrollPos() const;
@@ -333,7 +333,7 @@ public:
// support right-click context menus for avatar/group lists
enum ContextMenuType { MENU_NONE, MENU_AVATAR, MENU_GROUP };
void setContextMenu(const ContextMenuType &menu) { mContextMenuType = menu; }
- ContextMenuType getContextMenuType() { return mContextMenuType; }
+ ContextMenuType getContextMenuType() const { return mContextMenuType; }
// Overridden from LLView
/*virtual*/ void draw();
@@ -361,7 +361,6 @@ public:
virtual void fitContents(S32 max_width, S32 max_height);
virtual LLRect getRequiredRect();
- static bool rowPreceeds(LLScrollListItem *new_row, LLScrollListItem *test_row);
LLRect getItemListRect() { return mItemListRect; }
@@ -383,7 +382,6 @@ public:
* then display all items.
*/
void setPageLines(S32 page_lines );
- void setCollapseEmptyColumns(bool collapse);
LLScrollListItem* hitItem(S32 x,S32 y);
virtual void scrollToShowSelected();
@@ -400,7 +398,7 @@ public:
void setNumDynamicColumns(S32 num) { mNumDynamicWidthColumns = num; }
void updateStaticColumnWidth(LLScrollListColumn* col, S32 new_width);
- S32 getTotalStaticColumnWidth() { return mTotalStaticColumnWidth; }
+ S32 getTotalStaticColumnWidth() const { return mTotalStaticColumnWidth; }
std::string getSortColumnName();
bool getSortAscending() { return mSortColumns.empty() ? true : mSortColumns.back().second; }
@@ -530,7 +528,7 @@ private:
class LLViewBorder* mBorder;
LLHandle<LLContextMenu> mPopupMenuHandle;
- LLView *mCommentTextView;
+ LLTextBox* mCommentText = nullptr;
LLWString mSearchString;
LLFrameTimer mSearchTimer;
@@ -559,6 +557,8 @@ private:
sort_signal_t* mSortCallback;
is_friend_signal_t* mIsFriendSignal;
+
+ friend class LLComboBox;
}; // end class LLScrollListCtrl
#endif // LL_SCROLLLISTCTRL_H
diff --git a/indra/llui/llsearchablecontrol.h b/indra/llui/llsearchablecontrol.h
index bccb4858e1..bae85fe9a5 100644
--- a/indra/llui/llsearchablecontrol.h
+++ b/indra/llui/llsearchablecontrol.h
@@ -43,9 +43,15 @@ namespace ll
virtual ~SearchableControl()
{ }
- LLColor4 getHighlightColor( ) const
+ const LLColor4& getHighlightBgColor( ) const
{
- static LLUIColor highlight_color = LLUIColorTable::instance().getColor("SearchableControlHighlightColor", LLColor4::red);
+ static LLUIColor highlight_color = LLUIColorTable::instance().getColor("SearchableControlHighlightBgColor", LLColor4::red4);
+ return highlight_color.get();
+ }
+
+ const LLColor4& getHighlightFontColor() const
+ {
+ static LLUIColor highlight_color = LLUIColorTable::instance().getColor("SearchableControlHighlightFontColor", LLColor4::red4);
return highlight_color.get();
}
diff --git a/indra/llui/llsliderctrl.cpp b/indra/llui/llsliderctrl.cpp
index 22579205d8..66e97f093f 100644
--- a/indra/llui/llsliderctrl.cpp
+++ b/indra/llui/llsliderctrl.cpp
@@ -225,7 +225,7 @@ bool LLSliderCtrl::setLabelArg( const std::string& key, const LLStringExplicit&
res = mLabelBox->setTextArg(key, text);
if (res && mLabelFont && mLabelWidth == 0)
{
- S32 label_width = mLabelFont->getWidth(mLabelBox->getText());
+ S32 label_width = mLabelFont->getWidth(mLabelBox->getWText().c_str());
LLRect rect = mLabelBox->getRect();
S32 prev_right = rect.mRight;
rect.mRight = rect.mLeft + label_width;
@@ -393,7 +393,7 @@ void LLSliderCtrl::setEnabled(bool b)
if( mLabelBox )
{
- mLabelBox->setColor( b ? mTextEnabledColor.get() : mTextDisabledColor.get() );
+ mLabelBox->setColor( b ? mTextEnabledColor : mTextDisabledColor );
}
mSlider->setEnabled( b );
@@ -405,7 +405,7 @@ void LLSliderCtrl::setEnabled(bool b)
if( mTextBox )
{
- mTextBox->setColor( b ? mTextEnabledColor.get() : mTextDisabledColor.get() );
+ mTextBox->setColor( b ? mTextEnabledColor : mTextDisabledColor );
}
}
diff --git a/indra/llui/llsliderctrl.h b/indra/llui/llsliderctrl.h
index a55e3bf6e9..23ce8fd955 100644
--- a/indra/llui/llsliderctrl.h
+++ b/indra/llui/llsliderctrl.h
@@ -107,8 +107,8 @@ public:
F32 getMaxValue() const { return mSlider->getMaxValue(); }
void setLabel(const LLStringExplicit& label) { if (mLabelBox) mLabelBox->setText(label); }
- void setLabelColor(const LLColor4& c) { mTextEnabledColor = c; }
- void setDisabledLabelColor(const LLColor4& c) { mTextDisabledColor = c; }
+ void setLabelColor(const LLUIColor& c) { mTextEnabledColor = c; }
+ void setDisabledLabelColor(const LLUIColor& c) { mTextDisabledColor = c; }
boost::signals2::connection setSliderMouseDownCallback( const commit_signal_t::slot_type& cb );
boost::signals2::connection setSliderMouseUpCallback( const commit_signal_t::slot_type& cb );
@@ -132,7 +132,6 @@ public:
static void onEditorCommit(LLUICtrl* ctrl, const LLSD& userdata);
static void onEditorGainFocus(LLFocusableElement* caller, void *userdata);
- static void onEditorChangeFocus(LLUICtrl* caller, S32 direction, void *userdata);
protected:
virtual std::string _getSearchText() const
diff --git a/indra/llui/llspellcheck.cpp b/indra/llui/llspellcheck.cpp
index 1615db5b52..e15616a16b 100644
--- a/indra/llui/llspellcheck.cpp
+++ b/indra/llui/llspellcheck.cpp
@@ -30,12 +30,7 @@
#include "llsdserialize.h"
#include "llspellcheck.h"
-#if LL_WINDOWS
- #include <hunspell/hunspelldll.h>
- #pragma comment(lib, "libhunspell.lib")
-#else
- #include <hunspell/hunspell.hxx>
-#endif
+#include <hunspell/hunspell.hxx>
static const std::string DICT_DIR = "dictionaries";
static const std::string DICT_FILE_CUSTOM = "user_custom.dic";
@@ -47,28 +42,22 @@ static const std::string DICT_FILE_USER = "user_dictionaries.xml";
LLSpellChecker::settings_change_signal_t LLSpellChecker::sSettingsChangeSignal;
LLSpellChecker::LLSpellChecker()
- : mHunspell(NULL)
{
+ // Load initial dictionary information
+ refreshDictionaryMap();
}
LLSpellChecker::~LLSpellChecker()
{
- delete mHunspell;
-}
-
-void LLSpellChecker::initSingleton()
-{
- // Load initial dictionary information
- refreshDictionaryMap();
}
bool LLSpellChecker::checkSpelling(const std::string& word) const
{
- if ( (!mHunspell) || (word.length() < 3) || (0 != mHunspell->spell(word.c_str())) )
+ if ( (!mHunspell) || (word.length() < 3) || (0 != mHunspell->spell(word)) )
{
return true;
}
- if (mIgnoreList.size() > 0)
+ if (!mIgnoreList.empty())
{
std::string word_lower(word);
LLStringUtil::toLower(word_lower);
@@ -85,15 +74,8 @@ S32 LLSpellChecker::getSuggestions(const std::string& word, std::vector<std::str
return 0;
}
- char** suggestion_list; int suggestion_cnt = 0;
- if ( (suggestion_cnt = mHunspell->suggest(&suggestion_list, word.c_str())) != 0 )
- {
- for (int suggestion_index = 0; suggestion_index < suggestion_cnt; suggestion_index++)
- {
- suggestions.push_back(suggestion_list[suggestion_index]);
- }
- mHunspell->free_list(&suggestion_list, suggestion_cnt);
- }
+ suggestions = mHunspell->suggest(word);
+
return static_cast<S32>(suggestions.size());
}
@@ -194,7 +176,7 @@ void LLSpellChecker::addToCustomDictionary(const std::string& word)
{
if (mHunspell)
{
- mHunspell->add(word.c_str());
+ mHunspell->add(word);
}
addToDictFile(getDictionaryUserPath() + DICT_FILE_CUSTOM, word);
sSettingsChangeSignal();
@@ -312,8 +294,7 @@ void LLSpellChecker::initHunspell(const std::string& dict_language)
{
if (mHunspell)
{
- delete mHunspell;
- mHunspell = NULL;
+ mHunspell.reset();
mDictLanguage.clear();
mDictFile.clear();
mIgnoreList.clear();
@@ -334,11 +315,11 @@ void LLSpellChecker::initHunspell(const std::string& dict_language)
const std::string filename_dic = dict_entry["name"].asString() + ".dic";
if ( (gDirUtilp->fileExists(user_path + filename_aff)) && (gDirUtilp->fileExists(user_path + filename_dic)) )
{
- mHunspell = new Hunspell((user_path + filename_aff).c_str(), (user_path + filename_dic).c_str());
+ mHunspell = std::make_unique<Hunspell>((user_path + filename_aff).c_str(), (user_path + filename_dic).c_str());
}
else if ( (gDirUtilp->fileExists(app_path + filename_aff)) && (gDirUtilp->fileExists(app_path + filename_dic)) )
{
- mHunspell = new Hunspell((app_path + filename_aff).c_str(), (app_path + filename_dic).c_str());
+ mHunspell = std::make_unique<Hunspell>((app_path + filename_aff).c_str(), (app_path + filename_dic).c_str());
}
if (!mHunspell)
{
@@ -422,7 +403,7 @@ bool LLSpellChecker::canRemoveDictionary(const std::string& dict_language)
const LLSD dict_info = getDictionaryData(dict_language);
return
(dict_info["user_installed"].asBoolean()) &&
- ( (!getUseSpellCheck()) || (!LLSpellChecker::instance().isActiveDictionary(dict_language)) );
+ ( (!getUseSpellCheck()) || (!isActiveDictionary(dict_language)) );
}
void LLSpellChecker::removeDictionary(const std::string& dict_language)
@@ -448,7 +429,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/llspellcheck.h b/indra/llui/llspellcheck.h
index e4d8a12ef1..9df2f94085 100644
--- a/indra/llui/llspellcheck.h
+++ b/indra/llui/llspellcheck.h
@@ -34,12 +34,12 @@
class Hunspell;
-class LLSpellChecker : public LLSingleton<LLSpellChecker>
+class LLSpellChecker : public LLSimpleton<LLSpellChecker>
{
- LLSINGLETON(LLSpellChecker);
+public:
+ LLSpellChecker();
~LLSpellChecker();
-public:
void addToCustomDictionary(const std::string& word);
void addToIgnoreList(const std::string& word);
bool checkSpelling(const std::string& word) const;
@@ -47,7 +47,6 @@ public:
protected:
void addToDictFile(const std::string& dict_path, const std::string& word);
void initHunspell(const std::string& dict_language);
- void initSingleton() override;
public:
typedef std::list<std::string> dict_list_t;
@@ -77,7 +76,7 @@ public:
static boost::signals2::connection setSettingsChangeCallback(const settings_change_signal_t::slot_type& cb);
protected:
- Hunspell* mHunspell;
+ std::unique_ptr<Hunspell> mHunspell;
std::string mDictLanguage;
std::string mDictFile;
dict_list_t mDictSecondary;
diff --git a/indra/llui/llspinctrl.cpp b/indra/llui/llspinctrl.cpp
index 7d41d80334..8cd3e6419a 100644
--- a/indra/llui/llspinctrl.cpp
+++ b/indra/llui/llspinctrl.cpp
@@ -310,7 +310,7 @@ void LLSpinCtrl::updateLabelColor()
{
if( mLabelBox )
{
- mLabelBox->setColor( getEnabled() ? mTextEnabledColor.get() : mTextDisabledColor.get() );
+ mLabelBox->setColor( getEnabled() ? mTextEnabledColor : mTextDisabledColor );
}
}
diff --git a/indra/llui/llspinctrl.h b/indra/llui/llspinctrl.h
index 75f1830d80..4ba8c97c63 100644
--- a/indra/llui/llspinctrl.h
+++ b/indra/llui/llspinctrl.h
@@ -77,8 +77,8 @@ public:
virtual void setPrecision(S32 precision);
void setLabel(const LLStringExplicit& label);
- void setLabelColor(const LLColor4& c) { mTextEnabledColor = c; updateLabelColor(); }
- void setDisabledLabelColor(const LLColor4& c) { mTextDisabledColor = c; updateLabelColor();}
+ void setLabelColor(const LLUIColor& c) { mTextEnabledColor = c; updateLabelColor(); }
+ void setDisabledLabelColor(const LLUIColor& c) { mTextDisabledColor = c; updateLabelColor();}
void setAllowEdit(bool allow_edit);
virtual void onTabInto();
@@ -94,7 +94,6 @@ public:
void onEditorCommit(const LLSD& data);
static void onEditorGainFocus(LLFocusableElement* caller, void *userdata);
static void onEditorLostFocus(LLFocusableElement* caller, void *userdata);
- static void onEditorChangeFocus(LLUICtrl* caller, S32 direction, void *userdata);
void onUpBtn(const LLSD& data);
void onDownBtn(const LLSD& data);
diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp
index adb1d51813..62c0401869 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)
{
@@ -460,7 +460,7 @@ void LLStatBar::draw()
max_value = 0.f;
gGL.color4f(1.f, 0.f, 0.f, 1.f);
- gGL.begin( LLRender::QUADS );
+ gGL.begin(LLRender::TRIANGLES);
const S32 max_frame = llmin(num_frames, num_values);
U32 num_samples = 0;
for (S32 i = 1; i <= max_frame; i++)
@@ -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:
@@ -498,6 +498,9 @@ void LLStatBar::draw()
gGL.vertex2f((F32)bar_rect.mRight - offset, max);
gGL.vertex2f((F32)bar_rect.mRight - offset, min);
gGL.vertex2f((F32)bar_rect.mRight - offset - 1, min);
+
+ gGL.vertex2f((F32)bar_rect.mRight - offset, max);
+ gGL.vertex2f((F32)bar_rect.mRight - offset - 1, min);
gGL.vertex2f((F32)bar_rect.mRight - offset - 1, max);
}
else
@@ -505,7 +508,10 @@ void LLStatBar::draw()
gGL.vertex2f(min, (F32)bar_rect.mBottom + offset + 1);
gGL.vertex2f(min, (F32)bar_rect.mBottom + offset);
gGL.vertex2f(max, (F32)bar_rect.mBottom + offset);
- gGL.vertex2f(max, (F32)bar_rect.mBottom + offset + 1 );
+
+ gGL.vertex2f(min, (F32)bar_rect.mBottom + offset + 1);
+ gGL.vertex2f(max, (F32)bar_rect.mBottom + offset);
+ gGL.vertex2f(max, (F32)bar_rect.mBottom + offset + 1);
}
}
gGL.end();
@@ -598,7 +604,7 @@ LLRect LLStatBar::getRequiredRect()
void LLStatBar::drawLabelAndValue( F32 value, std::string &label, LLRect &bar_rect, S32 decimal_digits )
{
- LLFontGL::getFontMonospace()->renderUTF8(mLabel, 0, 0, getRect().getHeight(), LLColor4(1.f, 1.f, 1.f, 1.f),
+ LLFontGL::getFontMonospace()->render(mLabel.getWString(), 0, 0.F, (F32)getRect().getHeight(), LLColor4(1.f, 1.f, 1.f, 1.f),
LLFontGL::LEFT, LLFontGL::TOP);
std::string value_str = !llisnan(value)
@@ -673,14 +679,14 @@ void LLStatBar::drawTicks( F32 min, F32 max, F32 value_scale, LLRect &bar_rect )
{
decimal_digits = 0;
}
- std::string tick_label = llformat("%.*f", decimal_digits, tick_value);
- S32 tick_label_width = LLFontGL::getFontMonospace()->getWidth(tick_label);
+ LLWString tick_label = utf8str_to_wstring(llformat("%.*f", decimal_digits, tick_value));
+ S32 tick_label_width = LLFontGL::getFontMonospace()->getWidth(tick_label.c_str());
if (mOrientation == HORIZONTAL)
{
if (tick_begin > last_label + MIN_LABEL_SPACING)
{
gl_rect_2d(bar_rect.mLeft, tick_end, bar_rect.mRight - TICK_LENGTH, tick_begin, LLColor4(1.f, 1.f, 1.f, 0.25f));
- LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, bar_rect.mRight, tick_begin,
+ LLFontGL::getFontMonospace()->render(tick_label, 0, (F32)bar_rect.mRight, (F32)tick_begin,
LLColor4(1.f, 1.f, 1.f, 0.5f),
LLFontGL::LEFT, LLFontGL::VCENTER);
last_label = tick_begin;
@@ -696,7 +702,7 @@ void LLStatBar::drawTicks( F32 min, F32 max, F32 value_scale, LLRect &bar_rect )
{
gl_rect_2d(tick_begin, bar_rect.mTop, tick_end, bar_rect.mBottom - TICK_LENGTH, LLColor4(1.f, 1.f, 1.f, 0.25f));
S32 label_pos = tick_begin - ll_round((F32)tick_label_width * ((F32)tick_begin / (F32)bar_rect.getWidth()));
- LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, label_pos, bar_rect.mBottom - TICK_LENGTH,
+ LLFontGL::getFontMonospace()->render(tick_label, 0, (F32)label_pos, (F32)(bar_rect.mBottom - TICK_LENGTH),
LLColor4(1.f, 1.f, 1.f, 0.5f),
LLFontGL::LEFT, LLFontGL::TOP);
last_label = label_pos;
diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h
index c36a138566..bbbf0b3a19 100644
--- a/indra/llui/llstatbar.h
+++ b/indra/llui/llstatbar.h
@@ -67,7 +67,7 @@ public:
void setStat(const std::string& stat_name);
void setRange(F32 bar_min, F32 bar_max);
- void getRange(F32& bar_min, F32& bar_max) { bar_min = mTargetMinBar; bar_max = mTargetMaxBar; }
+ void getRange(F32& bar_min, F32& bar_max) const { bar_min = mTargetMinBar; bar_max = mTargetMaxBar; }
/*virtual*/ LLRect getRequiredRect(); // Return the height of this object, given the set options.
diff --git a/indra/llui/llstatgraph.cpp b/indra/llui/llstatgraph.cpp
index d37f927073..0af717d447 100644
--- a/indra/llui/llstatgraph.cpp
+++ b/indra/llui/llstatgraph.cpp
@@ -36,7 +36,6 @@
#include "llglheaders.h"
#include "lltracerecording.h"
#include "lltracethreadrecorder.h"
-//#include "llviewercontrol.h"
///////////////////////////////////////////////////////////////////////////////////
@@ -70,11 +69,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);
}
}
@@ -93,8 +92,6 @@ void LLStatGraph::draw()
mUpdateTimer.reset();
}
- LLColor4 color;
-
threshold_vec_t::iterator it = std::lower_bound(mThresholds.begin(), mThresholds.end(), Threshold(mValue / mMax, LLUIColor()));
if (it != mThresholds.begin())
@@ -102,15 +99,14 @@ void LLStatGraph::draw()
it--;
}
- color = LLUIColorTable::instance().getColor( "MenuDefaultBgColor" );
- gGL.color4fv(color.mV);
+ static LLUIColor default_color = LLUIColorTable::instance().getColor( "MenuDefaultBgColor" );
+ gGL.color4fv(default_color.get().mV);
gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, true);
gGL.color4fv(LLColor4::black.mV);
gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, false);
- color = it->mColor;
- gGL.color4fv(color.mV);
+ gGL.color4fv(it->mColor().mV);
gl_rect_2d(1, ll_round(frac*getRect().getHeight()), getRect().getWidth() - 1, 0, true);
}
diff --git a/indra/llui/llstatgraph.h b/indra/llui/llstatgraph.h
index c254821870..6d9e3d1064 100644
--- a/indra/llui/llstatgraph.h
+++ b/indra/llui/llstatgraph.h
@@ -99,9 +99,7 @@ public:
void setMin(const F32 min);
void setMax(const F32 max);
- virtual void draw();
-
- /*virtual*/ void setValue(const LLSD& value);
+ void draw() override;
private:
LLTrace::StatType<LLTrace::CountAccumulator>* mNewStatFloatp;
@@ -133,9 +131,6 @@ private:
};
typedef std::vector<Threshold> threshold_vec_t;
threshold_vec_t mThresholds;
- //S32 mNumThresholds;
- //F32 mThresholds[4];
- //LLColor4 mThresholdColors[4];
};
#endif // LL_LLSTATGRAPH_H
diff --git a/indra/llui/llstatview.h b/indra/llui/llstatview.h
index b5187f886d..a396773057 100644
--- a/indra/llui/llstatview.h
+++ b/indra/llui/llstatview.h
@@ -29,7 +29,6 @@
#include "llstatbar.h"
#include "llcontainerview.h"
-#include <vector>
class LLStatBar;
diff --git a/indra/llui/llstyle.cpp b/indra/llui/llstyle.cpp
index abf6e1284b..7a0e620d61 100644
--- a/indra/llui/llstyle.cpp
+++ b/indra/llui/llstyle.cpp
@@ -33,15 +33,18 @@
#include "llui.h"
LLStyle::Params::Params()
-: visible("visible", true),
+ : visible("visible", true),
drop_shadow("drop_shadow", LLFontGL::NO_SHADOW),
color("color", LLColor4::black),
readonly_color("readonly_color", LLColor4::black),
selected_color("selected_color", LLColor4::black),
- font("font", LLFontGL::getFontMonospace()),
+ highlight_bg_color("highlight_bg_color", LLColor4::green),
+ alpha("alpha", 1.f),
+ font("font", LLStyle::getDefaultFont()),
image("image"),
link_href("href"),
- is_link("is_link")
+ is_link("is_link"),
+ draw_highlight_bg("draw_highlight_bg", false)
{}
@@ -50,11 +53,14 @@ LLStyle::LLStyle(const LLStyle::Params& p)
mColor(p.color),
mReadOnlyColor(p.readonly_color),
mSelectedColor(p.selected_color),
+ mHighlightBgColor(p.highlight_bg_color),
mFont(p.font()),
mLink(p.link_href),
mIsLink(p.is_link.isProvided() ? p.is_link : !p.link_href().empty()),
mDropShadow(p.drop_shadow),
- mImagep(p.image())
+ mImagep(p.image()),
+ mAlpha(p.alpha),
+ mDrawHighlightBg(p.draw_highlight_bg)
{}
void LLStyle::setFont(const LLFontGL* font)
@@ -68,6 +74,11 @@ const LLFontGL* LLStyle::getFont() const
return mFont;
}
+const LLFontGL* LLStyle::getDefaultFont()
+{
+ return LLFontGL::getFontMonospace();
+}
+
void LLStyle::setLinkHREF(const std::string& href)
{
mLink = href;
diff --git a/indra/llui/llstyle.h b/indra/llui/llstyle.h
index 7dbccfff87..71c3f88109 100644
--- a/indra/llui/llstyle.h
+++ b/indra/llui/llstyle.h
@@ -43,14 +43,25 @@ public:
Optional<LLFontGL::ShadowType> drop_shadow;
Optional<LLUIColor> color,
readonly_color,
- selected_color;
+ selected_color,
+ highlight_bg_color;
+ Optional<F32> alpha;
Optional<const LLFontGL*> font;
Optional<LLUIImage*> image;
Optional<std::string> link_href;
Optional<bool> is_link;
+ Optional<bool> draw_highlight_bg;
Params();
};
LLStyle(const Params& p = Params());
+
+ enum EUnderlineLink
+ {
+ UNDERLINE_ALWAYS = 0,
+ UNDERLINE_ON_HOVER,
+ UNDERLINE_NEVER
+ };
+
public:
const LLUIColor& getColor() const { return mColor; }
void setColor(const LLUIColor &color) { mColor = color; }
@@ -61,6 +72,9 @@ public:
const LLUIColor& getSelectedColor() const { return mSelectedColor; }
void setSelectedColor(const LLUIColor& color) { mSelectedColor = color; }
+ F32 getAlpha() const { return mAlpha; }
+ void setAlpha(F32 alpha) { mAlpha = alpha; }
+
bool isVisible() const;
void setVisible(bool is_visible);
@@ -68,6 +82,7 @@ public:
void setFont(const LLFontGL* font);
const LLFontGL* getFont() const;
+ static const LLFontGL* getDefaultFont();
const std::string& getLinkHREF() const { return mLink; }
void setLinkHREF(const std::string& href);
@@ -79,6 +94,9 @@ public:
bool isImage() const { return mImagep.notNull(); }
+ bool getDrawHighlightBg() const { return mDrawHighlightBg; }
+ const LLUIColor& getHighlightBgColor() const { return mHighlightBgColor; }
+
bool operator==(const LLStyle &rhs) const
{
return
@@ -86,10 +104,13 @@ public:
&& mColor == rhs.mColor
&& mReadOnlyColor == rhs.mReadOnlyColor
&& mSelectedColor == rhs.mSelectedColor
+ && mHighlightBgColor == rhs.mHighlightBgColor
&& mFont == rhs.mFont
&& mLink == rhs.mLink
&& mImagep == rhs.mImagep
- && mDropShadow == rhs.mDropShadow;
+ && mDropShadow == rhs.mDropShadow
+ && mAlpha == rhs.mAlpha
+ && mDrawHighlightBg == rhs.mDrawHighlightBg;
}
bool operator!=(const LLStyle& rhs) const { return !(*this == rhs); }
@@ -98,18 +119,21 @@ public:
LLFontGL::ShadowType mDropShadow;
protected:
- ~LLStyle() { }
+ ~LLStyle() = default;
private:
- bool mVisible;
+ std::string mFontName;
+ std::string mLink;
LLUIColor mColor;
LLUIColor mReadOnlyColor;
LLUIColor mSelectedColor;
- std::string mFontName;
+ LLUIColor mHighlightBgColor;
const LLFontGL* mFont;
- std::string mLink;
- bool mIsLink;
LLPointer<LLUIImage> mImagep;
+ F32 mAlpha;
+ bool mVisible;
+ bool mIsLink;
+ bool mDrawHighlightBg;
};
typedef LLPointer<LLStyle> LLStyleSP;
diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp
index 06f584d372..5e0985c79c 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)
@@ -1370,17 +1370,17 @@ LLPanel* LLTabContainer::getCurrentPanel()
return NULL;
}
-S32 LLTabContainer::getCurrentPanelIndex()
+S32 LLTabContainer::getCurrentPanelIndex() const
{
return mCurrentTabIdx;
}
-S32 LLTabContainer::getTabCount()
+S32 LLTabContainer::getTabCount() const
{
return static_cast<S32>(mTabList.size());
}
-LLPanel* LLTabContainer::getPanelByIndex(S32 index)
+LLPanel* LLTabContainer::getPanelByIndex(S32 index) const
{
if (index >= 0 && index < (S32)mTabList.size())
{
@@ -1389,7 +1389,7 @@ LLPanel* LLTabContainer::getPanelByIndex(S32 index)
return NULL;
}
-S32 LLTabContainer::getIndexForPanel(LLPanel* panel)
+S32 LLTabContainer::getIndexForPanel(LLPanel* panel) const
{
for (S32 index = 0; index < (S32)mTabList.size(); index++)
{
@@ -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) const
{
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..4ac7e73d25 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();
@@ -182,16 +182,16 @@ public:
void removeTabPanel( LLPanel* child );
void lockTabs(S32 num_tabs = 0);
void unlockTabs();
- S32 getNumLockedTabs() { return mLockedTabCount; }
+ S32 getNumLockedTabs() const { return mLockedTabCount; }
void enableTabButton(S32 which, bool enable);
void deleteAllTabs();
LLPanel* getCurrentPanel();
- S32 getCurrentPanelIndex();
- S32 getTabCount();
- LLPanel* getPanelByIndex(S32 index);
- S32 getIndexForPanel(LLPanel* panel);
- S32 getPanelIndexByTitle(const std::string& title);
- LLPanel* getPanelByName(const std::string& name);
+ S32 getCurrentPanelIndex() const;
+ S32 getTabCount() const;
+ LLPanel* getPanelByIndex(S32 index) const;
+ S32 getIndexForPanel(LLPanel* panel) const;
+ S32 getPanelIndexByTitle(std::string_view title) const;
+ 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..778b253c3c 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;
@@ -460,6 +460,62 @@ std::vector<LLRect> LLTextBase::getSelectionRects()
return selection_rects;
}
+std::vector<std::pair<LLRect, LLUIColor>> LLTextBase::getHighlightedBgRects()
+{
+ std::vector<std::pair<LLRect, LLUIColor>> highlight_rects;
+
+ LLRect content_display_rect = getVisibleDocumentRect();
+
+ // binary search for line that starts before top of visible buffer
+ line_list_t::const_iterator line_iter =
+ std::lower_bound(mLineInfoList.begin(), mLineInfoList.end(), content_display_rect.mTop, compare_bottom());
+ line_list_t::const_iterator end_iter =
+ std::upper_bound(mLineInfoList.begin(), mLineInfoList.end(), content_display_rect.mBottom, compare_top());
+
+ for (; line_iter != end_iter; ++line_iter)
+ {
+ segment_set_t::iterator segment_iter;
+ S32 segment_offset;
+ getSegmentAndOffset(line_iter->mDocIndexStart, &segment_iter, &segment_offset);
+
+ // Use F32 otherwise a string of multiple segments
+ // will accumulate a large error
+ 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)
+ {
+ LLTextSegmentPtr segmentp = *segment_iter;
+
+ S32 segment_line_start = segmentp->getStart() + segment_offset;
+ S32 segment_line_end = llmin(segmentp->getEnd(), line_iter->mDocIndexEnd);
+
+ if (segment_line_start > segment_line_end)
+ break;
+
+ F32 segment_width = 0;
+ S32 segment_height = 0;
+
+ S32 num_chars = segment_line_end - segment_line_start;
+ segmentp->getDimensionsF32(segment_offset, num_chars, segment_width, segment_height);
+ right_precise += segment_width;
+
+ if (segmentp->getStyle()->getDrawHighlightBg())
+ {
+ LLRect selection_rect;
+ 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;
+
+ highlight_rects.push_back(std::pair(selection_rect, segmentp->getStyle()->getHighlightBgColor()));
+ }
+ left_precise += segment_width;
+ }
+ }
+ return highlight_rects;
+}
+
// Draws the black box behind the selected text
void LLTextBase::drawSelectionBackground()
{
@@ -529,6 +585,71 @@ void LLTextBase::drawSelectionBackground()
}
}
+void LLTextBase::drawHighlightedBackground()
+{
+ if (!mLineInfoList.empty())
+ {
+ std::vector<std::pair<LLRect, LLUIColor>> highlight_rects = getHighlightedBgRects();
+
+ if (highlight_rects.empty())
+ return;
+
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+
+ LLRect content_display_rect = getVisibleDocumentRect();
+
+ for (std::vector<std::pair<LLRect, LLUIColor>>::iterator rect_it = highlight_rects.begin();
+ rect_it != highlight_rects.end(); ++rect_it)
+ {
+ LLRect selection_rect = rect_it->first;
+ const LLColor4& color = rect_it->second;
+ if (mScroller)
+ {
+ // If scroller is On content_display_rect has correct rect and safe to use as is
+ // Note: we might need to account for border
+ selection_rect.translate(mVisibleTextRect.mLeft - content_display_rect.mLeft, mVisibleTextRect.mBottom - content_display_rect.mBottom);
+ }
+ else
+ {
+ // If scroller is Off content_display_rect will have rect from document, adjusted to text width, heigh and position
+ // and we have to acount for offset depending on position
+ S32 v_delta = 0;
+ S32 h_delta = 0;
+ switch (mVAlign)
+ {
+ case LLFontGL::TOP:
+ v_delta = mVisibleTextRect.mTop - content_display_rect.mTop - mVPad;
+ break;
+ case LLFontGL::VCENTER:
+ v_delta = (llmax(mVisibleTextRect.getHeight() - content_display_rect.mTop, -content_display_rect.mBottom) + (mVisibleTextRect.mBottom - content_display_rect.mBottom)) / 2;
+ break;
+ case LLFontGL::BOTTOM:
+ v_delta = mVisibleTextRect.mBottom - content_display_rect.mBottom;
+ break;
+ default:
+ break;
+ }
+ switch (mHAlign)
+ {
+ case LLFontGL::LEFT:
+ h_delta = mVisibleTextRect.mLeft - content_display_rect.mLeft + mHPad;
+ break;
+ case LLFontGL::HCENTER:
+ h_delta = (llmax(mVisibleTextRect.getWidth() - content_display_rect.mLeft, -content_display_rect.mRight) + (mVisibleTextRect.mRight - content_display_rect.mRight)) / 2;
+ break;
+ case LLFontGL::RIGHT:
+ h_delta = mVisibleTextRect.mRight - content_display_rect.mRight;
+ break;
+ default:
+ break;
+ }
+ selection_rect.translate(h_delta, v_delta);
+ }
+ gl_rect_2d(selection_rect, color);
+ }
+ }
+}
+
void LLTextBase::drawCursor()
{
F32 alpha = getDrawContext().mAlpha;
@@ -584,9 +705,8 @@ void LLTextBase::drawCursor()
if (LL_KIM_OVERWRITE == gKeyboard->getInsertMode() && !hasSelection() && text[mCursorPos] != '\n')
{
- LLColor4 text_color;
const LLFontGL* fontp;
- text_color = segmentp->getColor();
+ const LLColor4& text_color = segmentp->getColor();
fontp = segmentp->getStyle()->getFont();
fontp->render(text, mCursorPos, cursor_rect,
LLColor4(1.f - text_color.mV[VRED], 1.f - text_color.mV[VGREEN], 1.f - text_color.mV[VBLUE], alpha),
@@ -598,7 +718,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 +875,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 +922,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)
@@ -949,7 +1069,6 @@ S32 LLTextBase::insertStringNoUndo(S32 pos, const LLWString &wstr, LLTextBase::s
S32 LLTextBase::removeStringNoUndo(S32 pos, S32 length)
{
-
beforeValueChange();
segment_set_t::iterator seg_iter = getSegIterContaining(pos);
while(seg_iter != mSegments.end())
@@ -1326,6 +1445,7 @@ void LLTextBase::reshape(S32 width, S32 height, bool called_from_parent)
//virtual
void LLTextBase::draw()
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_UI;
// reflow if needed, on demand
reflow();
@@ -1368,7 +1488,7 @@ void LLTextBase::draw()
{
bg_rect.intersectWith(text_rect);
}
- LLColor4 bg_color = mReadOnly
+ const LLColor4& bg_color = mReadOnly
? mReadOnlyBgColor.get()
: hasFocus()
? mFocusBgColor.get()
@@ -1379,7 +1499,7 @@ void LLTextBase::draw()
// Draw highlighted if needed
if( ll::ui::SearchableControl::getHighlighted() )
{
- LLColor4 bg_color = ll::ui::SearchableControl::getHighlightColor();
+ const LLColor4& bg_color = ll::ui::SearchableControl::getHighlightBgColor();
LLRect bg_rect = mVisibleTextRect;
if( mScroller )
bg_rect.intersectWith( text_rect );
@@ -1400,6 +1520,7 @@ void LLTextBase::draw()
drawChild(mDocumentView);
}
+ drawHighlightedBackground();
drawSelectionBackground();
drawText();
drawCursor();
@@ -1412,14 +1533,14 @@ void LLTextBase::draw()
//virtual
-void LLTextBase::setColor( const LLColor4& c )
+void LLTextBase::setColor( const LLUIColor& c )
{
mFgColor = c;
mStyleDirty = true;
}
//virtual
-void LLTextBase::setReadOnlyColor(const LLColor4 &c)
+void LLTextBase::setReadOnlyColor(const LLUIColor &c)
{
mReadOnlyFgColor = c;
mStyleDirty = true;
@@ -1439,7 +1560,8 @@ void LLTextBase::onVisibilityChange( bool new_visibility )
//virtual
void LLTextBase::setValue(const LLSD& value )
{
- setText(value.asString());
+ static const LLStyle::Params input_params = LLStyle::Params();
+ setText(value.asString(), input_params);
}
//virtual
@@ -1674,7 +1796,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 +2003,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 +2040,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 +2062,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()));
}
@@ -2200,20 +2322,20 @@ static LLUIImagePtr image_from_icon_name(const std::string& icon_name)
}
-void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Params& input_params)
+void LLTextBase::appendTextImpl(const std::string& new_text, const LLStyle::Params& input_params, bool force_slurl)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_UI;
- LLStyle::Params style_params(input_params);
- style_params.fillFrom(getStyleParams());
+ LLStyle::Params style_params(getStyleParams());
+ style_params.overwriteFrom(input_params);
S32 part = (S32)LLTextParser::WHOLE;
- if (mParseHTML && !style_params.is_link) // Don't search for URLs inside a link segment (STORM-358).
+ if ((mParseHTML || force_slurl) && !style_params.is_link) // Don't search for URLs inside a link segment (STORM-358).
{
S32 start=0,end=0;
LLUrlMatch match;
std::string text = new_text;
while (LLUrlRegistry::instance().findUrl(text, match,
- boost::bind(&LLTextBase::replaceUrl, this, _1, _2, _3), isContentTrusted() || mAlwaysShowIcons))
+ boost::bind(&LLTextBase::replaceUrl, this, _1, _2, _3), isContentTrusted() || mAlwaysShowIcons, force_slurl))
{
start = match.getStart();
end = match.getEnd()+1;
@@ -2245,7 +2367,7 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para
}
// output the styled Url
- appendAndHighlightTextImpl(match.getLabel(), part, link_params, match.underlineOnHoverOnly());
+ appendAndHighlightTextImpl(match.getLabel(), part, link_params, match.getUnderline());
bool tooltip_required = !match.getTooltip().empty();
// set the tooltip for the Url label
@@ -2260,7 +2382,7 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para
{
link_params.color = LLColor4::grey;
link_params.readonly_color = LLColor4::grey;
- appendAndHighlightTextImpl(label, part, link_params, match.underlineOnHoverOnly());
+ appendAndHighlightTextImpl(label, part, link_params, match.getUnderline());
// set the tooltip for the query part of url
if (tooltip_required)
@@ -2369,6 +2491,34 @@ S32 LLTextBase::removeFirstLine()
return 0;
}
+// virtual
+void LLTextBase::copyContents(const LLTextBase* source)
+{
+ llassert(source);
+ if (!source)
+ return;
+
+ beforeValueChange();
+ deselect();
+
+ mSegments.clear();
+ for (const LLTextSegmentPtr& segp : source->mSegments)
+ {
+ mSegments.emplace(segp->clone(*this));
+ }
+
+ mLineInfoList.clear();
+ for (const line_info& li : mLineInfoList)
+ {
+ mLineInfoList.push_back(line_info(li));
+ }
+
+ getViewModel()->setDisplay(source->getViewModel()->getDisplay());
+
+ onValueChange(0, getLength());
+ needsReflow();
+}
+
void LLTextBase::appendLineBreakSegment(const LLStyle::Params& style_params)
{
segment_vec_t segments;
@@ -2400,7 +2550,7 @@ void LLTextBase::appendWidget(const LLInlineViewSegment::Params& params, const s
insertStringNoUndo(getLength(), widget_wide_text, &segments);
}
-void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params, bool underline_on_hover_only)
+void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params, e_underline underline_link)
{
// Save old state
S32 selection_start = mSelectionStart;
@@ -2418,21 +2568,19 @@ void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 hig
{
LLStyle::Params highlight_params(style_params);
- LLSD pieces = LLTextParser::instance().parsePartialLineHighlights(new_text, highlight_params.color(), (LLTextParser::EHighlightPosition)highlight_part);
+ auto pieces = LLTextParser::instance().parsePartialLineHighlights(new_text, highlight_params.color, (LLTextParser::EHighlightPosition)highlight_part);
for (S32 i = 0; i < pieces.size(); i++)
{
- LLSD color_llsd = pieces[i]["color"];
- LLColor4 lcolor;
- lcolor.setValue(color_llsd);
- highlight_params.color = lcolor;
+ const auto& piece_pair = pieces[i];
+ highlight_params.color = piece_pair.second;
LLWString wide_text;
- wide_text = utf8str_to_wstring(pieces[i]["text"].asString());
+ wide_text = utf8str_to_wstring(piece_pair.first);
S32 cur_length = getLength();
LLStyleConstSP sp(new LLStyle(highlight_params));
LLTextSegmentPtr segmentp;
- if (underline_on_hover_only || mSkipLinkUnderline)
+ if ((underline_link == e_underline::UNDERLINE_ON_HOVER) || mSkipLinkUnderline)
{
highlight_params.font.style("NORMAL");
LLStyleConstSP normal_sp(new LLStyle(highlight_params));
@@ -2456,7 +2604,7 @@ void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 hig
S32 segment_start = old_length;
S32 segment_end = old_length + static_cast<S32>(wide_text.size());
LLStyleConstSP sp(new LLStyle(style_params));
- if (underline_on_hover_only || mSkipLinkUnderline)
+ if ((underline_link == e_underline::UNDERLINE_ON_HOVER) || mSkipLinkUnderline)
{
LLStyle::Params normal_style_params(style_params);
normal_style_params.font.style("NORMAL");
@@ -2490,7 +2638,7 @@ void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 hig
}
}
-void LLTextBase::appendAndHighlightText(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params, bool underline_on_hover_only)
+void LLTextBase::appendAndHighlightText(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params, e_underline underline_link)
{
if (new_text.empty())
{
@@ -2505,7 +2653,7 @@ void LLTextBase::appendAndHighlightText(const std::string &new_text, S32 highlig
if (pos != start)
{
std::string str = std::string(new_text,start,pos-start);
- appendAndHighlightTextImpl(str, highlight_part, style_params, underline_on_hover_only);
+ appendAndHighlightTextImpl(str, highlight_part, style_params, underline_link);
}
appendLineBreakSegment(style_params);
start = pos+1;
@@ -2513,7 +2661,7 @@ void LLTextBase::appendAndHighlightText(const std::string &new_text, S32 highlig
}
std::string str = std::string(new_text, start, new_text.length() - start);
- appendAndHighlightTextImpl(str, highlight_part, style_params, underline_on_hover_only);
+ appendAndHighlightTextImpl(str, highlight_part, style_params, underline_link);
}
@@ -2589,6 +2737,11 @@ const LLWString& LLTextBase::getWText() const
return getViewModel()->getDisplay();
}
+S32 LLTextBase::getTextGeneration() const
+{
+ return getViewModel()->getDisplayGeneration();
+}
+
// If round is true, if the position is on the right half of a character, the cursor
// will be put to its right. If round is false, the cursor will always be put to the
// character's left.
@@ -2608,7 +2761,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 +2779,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 +2809,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 +2856,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 +2887,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;
@@ -3231,6 +3384,24 @@ boost::signals2::connection LLTextBase::setIsObjectBlockedCallback(const is_bloc
LLTextSegment::~LLTextSegment()
{}
+// static
+LLStyleSP LLTextSegment::cloneStyle(LLTextBase& target, const LLStyle* source)
+{
+ // Take most params from target
+ LLStyle::Params params = target.getStyleParams();
+ LLStyle* style = new LLStyle(params);
+
+ // Take some params from source
+ style->setLinkHREF(source->getLinkHREF());
+ if (source->isImage())
+ {
+ style->setImage(source->getImage()->getName());
+ }
+
+ return style;
+}
+
+
bool LLTextSegment::getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const { width = 0; height = 0; return false; }
bool LLTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const
{
@@ -3247,8 +3418,8 @@ F32 LLTextSegment::draw(S32 start, S32 end, S32 selection_start, S32 selection_e
bool LLTextSegment::canEdit() const { return false; }
void LLTextSegment::unlinkFromDocument(LLTextBase*) {}
void LLTextSegment::linkToDocument(LLTextBase*) {}
-const LLColor4& LLTextSegment::getColor() const { return LLColor4::white; }
-//void LLTextSegment::setColor(const LLColor4 &color) {}
+const LLUIColor& LLTextSegment::getColor() const { static const LLUIColor white = LLUIColorTable::instance().getColor("White", LLColor4::white); return white; }
+//void LLTextSegment::setColor(const LLUIColor &color) {}
LLStyleConstSP LLTextSegment::getStyle() const {static LLStyleConstSP sp(new LLStyle()); return sp; }
void LLTextSegment::setStyle(LLStyleConstSP style) {}
void LLTextSegment::setToken( LLKeywordToken* token ) {}
@@ -3283,9 +3454,11 @@ LLNormalTextSegment::LLNormalTextSegment( LLStyleConstSP style, S32 start, S32 e
: LLTextSegment(start, end),
mStyle( style ),
mToken(NULL),
- mEditor(editor)
+ mEditor(editor),
+ mLastGeneration(-1)
{
mFontHeight = mStyle->getFont()->getLineHeight();
+ mCanEdit = !mStyle->getDrawHighlightBg();
LLUIImagePtr image = mStyle->getImage();
if (image.notNull())
@@ -3294,10 +3467,11 @@ LLNormalTextSegment::LLNormalTextSegment( LLStyleConstSP style, S32 start, S32 e
}
}
-LLNormalTextSegment::LLNormalTextSegment( const LLColor4& color, S32 start, S32 end, LLTextBase& editor, bool is_visible)
+LLNormalTextSegment::LLNormalTextSegment( const LLUIColor& color, S32 start, S32 end, LLTextBase& editor, bool is_visible)
: LLTextSegment(start, end),
mToken(NULL),
- mEditor(editor)
+ mEditor(editor),
+ mLastGeneration(-1)
{
mStyle = new LLStyle(LLStyle::Params().visible(is_visible).color(color));
@@ -3316,25 +3490,41 @@ F32 LLNormalTextSegment::draw(S32 start, S32 end, S32 selection_start, S32 selec
{
return drawClippedSegment( getStart() + start, getStart() + end, selection_start, selection_end, draw_rect);
}
+ else
+ {
+ mFontBufferPreSelection.reset();
+ mFontBufferSelection.reset();
+ mFontBufferPostSelection.reset();
+ }
return draw_rect.mLeft;
}
// Draws a single text segment, reversing the color for selection if needed.
F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 selection_start, S32 selection_end, LLRectf rect)
{
- F32 alpha = LLViewDrawContext::getCurrentContext().mAlpha;
-
- const LLWString &text = getWText();
-
F32 right_x = rect.mLeft;
if (!mStyle->isVisible())
{
return right_x;
}
- const LLFontGL* font = mStyle->getFont();
+ F32 alpha = LLViewDrawContext::getCurrentContext().mAlpha;
+
+ const LLWString& text = getWText();
+ S32 text_gen = mEditor.getTextGeneration();
- LLColor4 color = (mEditor.getReadOnly() ? mStyle->getReadOnlyColor() : mStyle->getColor()) % alpha;
+ if (text_gen != mLastGeneration)
+ {
+ mLastGeneration = text_gen;
+
+ mFontBufferPreSelection.reset();
+ mFontBufferSelection.reset();
+ mFontBufferPostSelection.reset();
+ }
+
+ const LLFontGL* font = mStyle->getFont();
+ LLColor4 color = (mEditor.getReadOnly() ? mStyle->getReadOnlyColor() : mStyle->getColor()) % (alpha * mStyle->getAlpha());
+ bool use_font_buffers = useFontBuffers();
if( selection_start > seg_start )
{
@@ -3342,16 +3532,40 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele
S32 start = seg_start;
S32 end = llmin( selection_start, seg_end );
S32 length = end - start;
- font->render(text, start,
- rect,
- color,
- LLFontGL::LEFT, mEditor.mTextVAlign,
- LLFontGL::NORMAL,
- mStyle->getShadowType(),
- length,
- &right_x,
- mEditor.getUseEllipses(),
- mEditor.getUseColor());
+ if (use_font_buffers)
+ {
+ mFontBufferPreSelection.render(
+ font,
+ text, start,
+ rect,
+ color,
+ LLFontGL::LEFT, mEditor.mTextVAlign,
+ LLFontGL::NORMAL,
+ mStyle->getShadowType(),
+ length,
+ &right_x,
+ mEditor.getUseEllipses(),
+ mEditor.getUseColor());
+ }
+ else
+ {
+ // Font buffer doesn't do well with changes and huge notecard with a bunch
+ // of segments will see a lot of buffer updates, so instead use derect
+ // rendering to cache.
+ // Todo: instead of mLastGeneration make buffer invalidation more fine grained
+ // like string hash of a given segment.
+ font->render(
+ text, start,
+ rect,
+ color,
+ LLFontGL::LEFT, mEditor.mTextVAlign,
+ LLFontGL::NORMAL,
+ mStyle->getShadowType(),
+ length,
+ &right_x,
+ mEditor.getUseEllipses(),
+ mEditor.getUseColor());
+ }
}
rect.mLeft = right_x;
@@ -3362,16 +3576,35 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele
S32 end = llmin( selection_end, seg_end );
S32 length = end - start;
- font->render(text, start,
- rect,
- mStyle->getSelectedColor().get(),
- LLFontGL::LEFT, mEditor.mTextVAlign,
- LLFontGL::NORMAL,
- LLFontGL::NO_SHADOW,
- length,
- &right_x,
- mEditor.getUseEllipses(),
- mEditor.getUseColor());
+ if (use_font_buffers)
+ {
+ mFontBufferSelection.render(
+ font,
+ text, start,
+ rect,
+ mStyle->getSelectedColor().get(),
+ LLFontGL::LEFT, mEditor.mTextVAlign,
+ LLFontGL::NORMAL,
+ LLFontGL::NO_SHADOW,
+ length,
+ &right_x,
+ mEditor.getUseEllipses(),
+ mEditor.getUseColor());
+ }
+ else
+ {
+ font->render(
+ text, start,
+ rect,
+ mStyle->getSelectedColor().get(),
+ LLFontGL::LEFT, mEditor.mTextVAlign,
+ LLFontGL::NORMAL,
+ LLFontGL::NO_SHADOW,
+ length,
+ &right_x,
+ mEditor.getUseEllipses(),
+ mEditor.getUseColor());
+ }
}
rect.mLeft = right_x;
if( selection_end < seg_end )
@@ -3380,16 +3613,36 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele
S32 start = llmax( selection_end, seg_start );
S32 end = seg_end;
S32 length = end - start;
- font->render(text, start,
- rect,
- color,
- LLFontGL::LEFT, mEditor.mTextVAlign,
- LLFontGL::NORMAL,
- mStyle->getShadowType(),
- length,
- &right_x,
- mEditor.getUseEllipses(),
- mEditor.getUseColor());
+ if (use_font_buffers)
+ {
+ mFontBufferPostSelection.render(
+ font,
+ text, start,
+ rect,
+ color,
+ LLFontGL::LEFT, mEditor.mTextVAlign,
+ LLFontGL::NORMAL,
+ mStyle->getShadowType(),
+ length,
+ &right_x,
+ mEditor.getUseEllipses(),
+ mEditor.getUseColor());
+ }
+ else
+ {
+ font->render(
+ text, start,
+ rect,
+ color,
+ LLFontGL::LEFT, mEditor.mTextVAlign,
+ LLFontGL::NORMAL,
+ mStyle->getShadowType(),
+ length,
+ &right_x,
+ mEditor.getUseEllipses(),
+ mEditor.getUseColor());
+
+ }
}
return right_x;
}
@@ -3491,6 +3744,13 @@ void LLNormalTextSegment::setToolTip(const std::string& tooltip)
mTooltip = tooltip;
}
+// virtual
+LLTextSegmentPtr LLNormalTextSegment::clone(LLTextBase& target) const
+{
+ LLStyleConstSP sp(cloneStyle(target, mStyle));
+ return new LLNormalTextSegment(sp, mStart, mEnd, target);
+}
+
bool LLNormalTextSegment::getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const
{
height = 0;
@@ -3576,6 +3836,15 @@ S32 LLNormalTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 lin
return num_chars;
}
+void LLNormalTextSegment::updateLayout(const class LLTextBase& editor)
+{
+ LLTextSegment::updateLayout(editor);
+
+ mFontBufferPreSelection.reset();
+ mFontBufferSelection.reset();
+ mFontBufferPostSelection.reset();
+}
+
void LLNormalTextSegment::dump() const
{
LL_INFOS() << "Segment [" <<
@@ -3604,11 +3873,18 @@ LLLabelTextSegment::LLLabelTextSegment( LLStyleConstSP style, S32 start, S32 end
{
}
-LLLabelTextSegment::LLLabelTextSegment( const LLColor4& color, S32 start, S32 end, LLTextBase& editor, bool is_visible)
+LLLabelTextSegment::LLLabelTextSegment( const LLUIColor& color, S32 start, S32 end, LLTextBase& editor, bool is_visible)
: LLNormalTextSegment(color, start, end, editor, is_visible)
{
}
+// virtual
+LLTextSegmentPtr LLLabelTextSegment::clone(LLTextBase& target) const
+{
+ LLStyleConstSP sp(cloneStyle(target, mStyle));
+ return new LLLabelTextSegment(sp, mStart, mEnd, target);
+}
+
/*virtual*/
const LLWString& LLLabelTextSegment::getWText() const
{
@@ -3628,11 +3904,18 @@ LLEmojiTextSegment::LLEmojiTextSegment(LLStyleConstSP style, S32 start, S32 end,
{
}
-LLEmojiTextSegment::LLEmojiTextSegment(const LLColor4& color, S32 start, S32 end, LLTextBase& editor, bool is_visible)
+LLEmojiTextSegment::LLEmojiTextSegment(const LLUIColor& color, S32 start, S32 end, LLTextBase& editor, bool is_visible)
: LLNormalTextSegment(color, start, end, editor, is_visible)
{
}
+// virtual
+LLTextSegmentPtr LLEmojiTextSegment::clone(LLTextBase& target) const
+{
+ LLStyleConstSP sp(cloneStyle(target, mStyle));
+ return new LLEmojiTextSegment(sp, mStart, mEnd, target);
+}
+
bool LLEmojiTextSegment::handleToolTip(S32 x, S32 y, MASK mask)
{
if (mTooltip.empty())
@@ -3656,6 +3939,14 @@ LLOnHoverChangeableTextSegment::LLOnHoverChangeableTextSegment( LLStyleConstSP s
mHoveredStyle(style),
mNormalStyle(normal_style){}
+// virtual
+LLTextSegmentPtr LLOnHoverChangeableTextSegment::clone(LLTextBase& target) const
+{
+ LLStyleConstSP hsp(cloneStyle(target, mHoveredStyle));
+ LLStyleConstSP nsp(cloneStyle(target, mNormalStyle));
+ return new LLOnHoverChangeableTextSegment(hsp, nsp, mStart, mEnd, target);
+}
+
/*virtual*/
F32 LLOnHoverChangeableTextSegment::draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRectf& draw_rect)
{
@@ -3695,6 +3986,13 @@ LLInlineViewSegment::~LLInlineViewSegment()
mView->die();
}
+// virtual
+LLTextSegmentPtr LLInlineViewSegment::clone(LLTextBase& target) const
+{
+ llassert_always_msg(false, "NOT SUPPORTED");
+ return nullptr;
+}
+
bool LLInlineViewSegment::getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const
{
if (first_char == 0 && num_chars == 0)
@@ -3706,8 +4004,7 @@ bool LLInlineViewSegment::getDimensionsF32(S32 first_char, S32 num_chars, F32& w
if (mForceNewLine)
{
// Chat, string can't be smaller then font height even if it is empty
- LLStyleSP s(new LLStyle(LLStyle::Params().visible(true)));
- height = s->getFont()->getLineHeight();
+ height = LLStyle::getDefaultFont()->getLineHeight();
return true; // new line
}
@@ -3720,7 +4017,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();
}
@@ -3771,9 +4068,7 @@ void LLInlineViewSegment::linkToDocument(LLTextBase* editor)
LLLineBreakTextSegment::LLLineBreakTextSegment(S32 pos):LLTextSegment(pos,pos+1)
{
- LLStyleSP s( new LLStyle(LLStyle::Params().visible(true)));
-
- mFontHeight = s->getFont()->getLineHeight();
+ mFontHeight = LLStyle::getDefaultFont()->getLineHeight();
}
LLLineBreakTextSegment::LLLineBreakTextSegment(LLStyleConstSP style,S32 pos):LLTextSegment(pos,pos+1)
{
@@ -3782,6 +4077,14 @@ LLLineBreakTextSegment::LLLineBreakTextSegment(LLStyleConstSP style,S32 pos):LLT
LLLineBreakTextSegment::~LLLineBreakTextSegment()
{
}
+
+// virtual
+LLTextSegmentPtr LLLineBreakTextSegment::clone(LLTextBase& target) const
+{
+ LLLineBreakTextSegment* copy = new LLLineBreakTextSegment(mStart);
+ copy->mFontHeight = mFontHeight;
+ return copy;
+}
bool LLLineBreakTextSegment::getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const
{
width = 0;
@@ -3809,8 +4112,16 @@ LLImageTextSegment::~LLImageTextSegment()
{
}
+// virtual
+LLTextSegmentPtr LLImageTextSegment::clone(LLTextBase& target) const
+{
+ LLStyleConstSP sp(cloneStyle(target, mStyle));
+ return new LLImageTextSegment(sp, mStart, target);
+}
+
static const S32 IMAGE_HPAD = 3;
+// virtual
bool LLImageTextSegment::getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const
{
width = 0;
@@ -3871,10 +4182,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/lltextbase.h b/indra/llui/lltextbase.h
index 4120d9ea32..8ca653acb9 100644
--- a/indra/llui/lltextbase.h
+++ b/indra/llui/lltextbase.h
@@ -30,10 +30,12 @@
#include "v4color.h"
#include "lleditmenuhandler.h"
+#include "llfontvertexbuffer.h"
#include "llspellcheckmenuhandler.h"
#include "llstyle.h"
#include "llkeywords.h"
#include "llpanel.h"
+#include "llurlmatch.h"
#include <string>
#include <vector>
@@ -44,6 +46,7 @@
class LLScrollContainer;
class LLContextMenu;
class LLUrlMatch;
+class LLTextBase;
///
/// A text segment is used to specify a subsection of a text string
@@ -61,6 +64,9 @@ public:
mEnd(end)
{}
virtual ~LLTextSegment();
+ virtual LLTextSegmentPtr clone(LLTextBase& terget) const { return new LLTextSegment(mStart, mEnd); }
+ static LLStyleSP cloneStyle(LLTextBase& target, const LLStyle* source);
+
bool getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const;
virtual bool getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const;
@@ -84,8 +90,8 @@ public:
virtual void unlinkFromDocument(class LLTextBase* editor);
virtual void linkToDocument(class LLTextBase* editor);
- virtual const LLColor4& getColor() const;
- //virtual void setColor(const LLColor4 &color);
+ virtual const LLUIColor& getColor() const;
+ //virtual void setColor(const LLUIColor &color);
virtual LLStyleConstSP getStyle() const;
virtual void setStyle(LLStyleConstSP style);
virtual void setToken( LLKeywordToken* token );
@@ -125,20 +131,21 @@ class LLNormalTextSegment : public LLTextSegment
{
public:
LLNormalTextSegment( LLStyleConstSP style, S32 start, S32 end, LLTextBase& editor );
- LLNormalTextSegment( const LLColor4& color, S32 start, S32 end, LLTextBase& editor, bool is_visible = true);
+ LLNormalTextSegment( const LLUIColor& color, S32 start, S32 end, LLTextBase& editor, bool is_visible = true);
virtual ~LLNormalTextSegment();
+ /*virtual*/ LLTextSegmentPtr clone(LLTextBase& target) const;
/*virtual*/ bool getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const;
/*virtual*/ S32 getOffset(S32 segment_local_x_coord, S32 start_offset, S32 num_chars, bool round) const;
/*virtual*/ S32 getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars, S32 line_ind) const;
+ /*virtual*/ void updateLayout(const class LLTextBase& editor);
/*virtual*/ F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRectf& draw_rect);
- /*virtual*/ bool canEdit() const { return true; }
- /*virtual*/ const LLColor4& getColor() const { return mStyle->getColor(); }
+ /*virtual*/ bool canEdit() const { return mCanEdit; }
+ /*virtual*/ const LLUIColor& getColor() const { return mStyle->getColor(); }
/*virtual*/ LLStyleConstSP getStyle() const { return mStyle; }
/*virtual*/ void setStyle(LLStyleConstSP style) { mStyle = style; }
/*virtual*/ void setToken( LLKeywordToken* token ) { mToken = token; }
/*virtual*/ LLKeywordToken* getToken() const { return mToken; }
- /*virtual*/ bool getToolTip( std::string& msg ) const;
/*virtual*/ void setToolTip(const std::string& tooltip);
/*virtual*/ void dump() const;
@@ -149,11 +156,14 @@ public:
/*virtual*/ bool handleToolTip(S32 x, S32 y, MASK mask);
protected:
+ virtual bool useFontBuffers() const { return true; }
F32 drawClippedSegment(S32 seg_start, S32 seg_end, S32 selection_start, S32 selection_end, LLRectf rect);
virtual const LLWString& getWText() const;
virtual const S32 getLength() const;
+ void setAllowEdit(bool can_edit) { mCanEdit = can_edit; }
+
protected:
class LLTextBase& mEditor;
LLStyleConstSP mStyle;
@@ -161,6 +171,14 @@ protected:
LLKeywordToken* mToken;
std::string mTooltip;
boost::signals2::connection mImageLoadedConnection;
+
+ bool mCanEdit { true };
+
+ // font rendering
+ LLFontVertexBuffer mFontBufferPreSelection;
+ LLFontVertexBuffer mFontBufferSelection;
+ LLFontVertexBuffer mFontBufferPostSelection;
+ S32 mLastGeneration = -1;
};
// This text segment is the same as LLNormalTextSegment, the only difference
@@ -170,7 +188,8 @@ class LLLabelTextSegment : public LLNormalTextSegment
{
public:
LLLabelTextSegment( LLStyleConstSP style, S32 start, S32 end, LLTextBase& editor );
- LLLabelTextSegment( const LLColor4& color, S32 start, S32 end, LLTextBase& editor, bool is_visible = true);
+ LLLabelTextSegment( const LLUIColor& color, S32 start, S32 end, LLTextBase& editor, bool is_visible = true);
+ /*virtual*/ LLTextSegmentPtr clone(LLTextBase& target) const;
protected:
@@ -184,7 +203,8 @@ class LLEmojiTextSegment : public LLNormalTextSegment
{
public:
LLEmojiTextSegment(LLStyleConstSP style, S32 start, S32 end, LLTextBase& editor);
- LLEmojiTextSegment(const LLColor4& color, S32 start, S32 end, LLTextBase& editor, bool is_visible = true);
+ LLEmojiTextSegment(const LLUIColor& color, S32 start, S32 end, LLTextBase& editor, bool is_visible = true);
+ /*virtual*/ LLTextSegmentPtr clone(LLTextBase& target) const override;
bool canEdit() const override { return false; }
bool handleToolTip(S32 x, S32 y, MASK mask) override;
@@ -195,6 +215,7 @@ class LLOnHoverChangeableTextSegment : public LLNormalTextSegment
{
public:
LLOnHoverChangeableTextSegment( LLStyleConstSP style, LLStyleConstSP normal_style, S32 start, S32 end, LLTextBase& editor );
+ /*virtual*/ LLTextSegmentPtr clone(LLTextBase& target) const;
/*virtual*/ F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRectf& draw_rect);
/*virtual*/ bool handleHover(S32 x, S32 y, MASK mask);
protected:
@@ -209,6 +230,7 @@ class LLIndexSegment : public LLTextSegment
{
public:
LLIndexSegment() : LLTextSegment(0, 0) {}
+ /*virtual*/ LLTextSegmentPtr clone(LLTextBase& target) const { return new LLIndexSegment(); }
};
class LLInlineViewSegment : public LLTextSegment
@@ -226,6 +248,8 @@ public:
LLInlineViewSegment(const Params& p, S32 start, S32 end);
~LLInlineViewSegment();
+ /*virtual*/ LLTextSegmentPtr clone(LLTextBase& target) const;
+
/*virtual*/ bool getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const;
/*virtual*/ S32 getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars, S32 line_ind) const;
/*virtual*/ void updateLayout(const class LLTextBase& editor);
@@ -250,6 +274,7 @@ public:
LLLineBreakTextSegment(LLStyleConstSP style,S32 pos);
LLLineBreakTextSegment(S32 pos);
~LLLineBreakTextSegment();
+ /*virtual*/ LLTextSegmentPtr clone(LLTextBase& target) const;
/*virtual*/ bool getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const;
S32 getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars, S32 line_ind) const;
F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRectf& draw_rect);
@@ -263,6 +288,8 @@ class LLImageTextSegment : public LLTextSegment
public:
LLImageTextSegment(LLStyleConstSP style,S32 pos,class LLTextBase& editor);
~LLImageTextSegment();
+ /*virtual*/ LLTextSegmentPtr clone(LLTextBase& target) const;
+
/*virtual*/ bool getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const;
S32 getNumChars(S32 num_pixels, S32 segment_offset, S32 char_offset, S32 max_chars, S32 line_ind) const;
F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRectf& draw_rect);
@@ -372,8 +399,8 @@ public:
// LLUICtrl interface
/*virtual*/ bool acceptsTextInput() const override { return !mReadOnly; }
- /*virtual*/ void setColor(const LLColor4& c) override;
- virtual void setReadOnlyColor(const LLColor4 &c);
+ /*virtual*/ void setColor(const LLUIColor& c) override;
+ virtual void setReadOnlyColor(const LLUIColor& c);
/*virtual*/ void onVisibilityChange(bool new_visibility) override;
/*virtual*/ void setValue(const LLSD& value) override;
@@ -427,11 +454,12 @@ public:
virtual void setText(const LLStringExplicit &utf8str , const LLStyle::Params& input_params = LLStyle::Params()); // uses default style
/*virtual*/ const std::string& getText() const override;
void setMaxTextLength(S32 length) { mMaxTextByteLength = length; }
- S32 getMaxTextLength() { return mMaxTextByteLength; }
+ S32 getMaxTextLength() const { return mMaxTextByteLength; }
// wide-char versions
void setWText(const LLWString& text);
const LLWString& getWText() const;
+ S32 getTextGeneration() const;
void appendText(const std::string &new_text, bool prepend_newline, const LLStyle::Params& input_params = LLStyle::Params());
@@ -465,20 +493,20 @@ public:
LLRect getTextBoundingRect();
LLRect getVisibleDocumentRect() const;
- S32 getVPad() { return mVPad; }
- S32 getHPad() { return mHPad; }
- F32 getLineSpacingMult() { return mLineSpacingMult; }
- S32 getLineSpacingPixels() { return mLineSpacingPixels; } // only for multiline
+ S32 getVPad() const { return mVPad; }
+ S32 getHPad() const { return mHPad; }
+ F32 getLineSpacingMult() const { return mLineSpacingMult; }
+ S32 getLineSpacingPixels() const { return mLineSpacingPixels; } // only for multiline
S32 getDocIndexFromLocalCoord( S32 local_x, S32 local_y, bool round, bool hit_past_end_of_line = true) const;
LLRect getLocalRectFromDocIndex(S32 pos) const;
LLRect getDocRectFromDocIndex(S32 pos) const;
void setReadOnly(bool read_only) { mReadOnly = read_only; }
- bool getReadOnly() { return mReadOnly; }
+ bool getReadOnly() const { return mReadOnly; }
void setSkipLinkUnderline(bool skip_link_underline) { mSkipLinkUnderline = skip_link_underline; }
- bool getSkipLinkUnderline() { return mSkipLinkUnderline; }
+ bool getSkipLinkUnderline() const { return mSkipLinkUnderline; }
void setParseURLs(bool parse_urls) { mParseHTML = parse_urls; }
@@ -492,14 +520,15 @@ public:
void endOfLine();
void startOfDoc();
void endOfDoc();
- void changePage( S32 delta );
- void changeLine( S32 delta );
+ void changePage(S32 delta);
+ void changeLine(S32 delta);
bool scrolledToStart();
bool scrolledToEnd();
const LLFontGL* getFont() const override { return mFont; }
+ virtual void copyContents(const LLTextBase* source);
virtual void appendLineBreakSegment(const LLStyle::Params& style_params);
virtual void appendImageSegment(const LLStyle::Params& style_params);
virtual void appendWidget(const LLInlineViewSegment::Params& params, const std::string& text, bool allow_undo);
@@ -582,6 +611,7 @@ protected:
bool operator()(const LLTextSegmentPtr& a, const LLTextSegmentPtr& b) const;
};
typedef std::multiset<LLTextSegmentPtr, compare_segment_end> segment_set_t;
+ typedef LLStyle::EUnderlineLink e_underline;
// member functions
LLTextBase(const Params &p);
@@ -595,12 +625,13 @@ protected:
virtual void drawSelectionBackground(); // draws the black box behind the selected text
void drawCursor();
void drawText();
+ void drawHighlightedBackground();
// modify contents
S32 insertStringNoUndo(S32 pos, const LLWString &wstr, segment_vec_t* segments = NULL); // returns num of chars actually inserted
S32 removeStringNoUndo(S32 pos, S32 length);
S32 overwriteCharNoUndo(S32 pos, llwchar wc);
- void appendAndHighlightText(const std::string &new_text, S32 highlight_part, const LLStyle::Params& stylep, bool underline_on_hover_only = false);
+ void appendAndHighlightText(const std::string &new_text, S32 highlight_part, const LLStyle::Params& stylep, e_underline underline_link = e_underline::UNDERLINE_ALWAYS);
// manage segments
@@ -648,8 +679,8 @@ protected:
// avatar names are looked up.
void replaceUrl(const std::string &url, const std::string &label, const std::string& icon);
- void appendTextImpl(const std::string &new_text, const LLStyle::Params& input_params = LLStyle::Params());
- void appendAndHighlightTextImpl(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params, bool underline_on_hover_only = false);
+ void appendTextImpl(const std::string &new_text, const LLStyle::Params& input_params = LLStyle::Params(), bool force_slurl = false);
+ void appendAndHighlightTextImpl(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params, e_underline underline_link = e_underline::UNDERLINE_ALWAYS);
S32 normalizeUri(std::string& uri);
protected:
@@ -660,6 +691,7 @@ protected:
}
std::vector<LLRect> getSelectionRects();
+ std::vector<std::pair<LLRect, LLUIColor>> getHighlightedBgRects();
protected:
// text segmentation and flow
diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp
index 92551b682c..9f945d3735 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),
@@ -159,7 +159,8 @@ LLSD LLTextBox::getValue() const
bool LLTextBox::setTextArg( const std::string& key, const LLStringExplicit& text )
{
mText.setArg(key, text);
- LLTextBase::setText(mText.getString());
+ static const LLStyle::Params input_params = LLStyle::Params();
+ LLTextBase::setText(mText.getString(), input_params);
return true;
}
diff --git a/indra/llui/lltextbox.h b/indra/llui/lltextbox.h
index c1f829c2b9..507d8f3ee6 100644
--- a/indra/llui/lltextbox.h
+++ b/indra/llui/lltextbox.h
@@ -46,42 +46,48 @@ protected:
friend class LLUICtrlFactory;
public:
- virtual ~LLTextBox();
+ ~LLTextBox() override;
- /*virtual*/ bool handleMouseDown(S32 x, S32 y, MASK mask);
- /*virtual*/ bool handleMouseUp(S32 x, S32 y, MASK mask);
- /*virtual*/ bool handleHover(S32 x, S32 y, MASK mask);
+ bool handleMouseDown(S32 x, S32 y, MASK mask) override;
+ bool handleMouseUp(S32 x, S32 y, MASK mask) override;
+ bool handleHover(S32 x, S32 y, MASK mask) override;
- /*virtual*/ void setEnabled(bool enabled);
+ void setEnabled(bool enabled) override;
- /*virtual*/ void setText( const LLStringExplicit& text, const LLStyle::Params& input_params = LLStyle::Params() );
+ void setText(const LLStringExplicit& text, const LLStyle::Params& input_params = LLStyle::Params()) override;
- void setRightAlign() { mHAlign = LLFontGL::RIGHT; }
- void setHAlign( LLFontGL::HAlign align ) { mHAlign = align; }
- void setClickedCallback( boost::function<void (void*)> cb, void* userdata = NULL );
+ void setRightAlign() { mHAlign = LLFontGL::RIGHT; }
+ void setHAlign(LLFontGL::HAlign align) { mHAlign = align; }
+ void setClickedCallback(boost::function<void(void*)> cb, void* userdata = NULL);
- void reshapeToFitText(bool called_from_parent = false);
+ void reshapeToFitText(bool called_from_parent = false);
- S32 getTextPixelWidth();
- S32 getTextPixelHeight();
+ S32 getTextPixelWidth();
+ S32 getTextPixelHeight();
- /*virtual*/ LLSD getValue() const;
- /*virtual*/ bool setTextArg( const std::string& key, const LLStringExplicit& text );
+ LLSD getValue() const override;
+ bool setTextArg(const std::string& key, const LLStringExplicit& text) override;
- void setShowCursorHand(bool show_cursor) { mShowCursorHand = show_cursor; }
+ void setShowCursorHand(bool show_cursor) { mShowCursorHand = show_cursor; }
protected:
- void onUrlLabelUpdated(const std::string &url, const std::string &label);
+ void onUrlLabelUpdated(const std::string& url, const std::string& label);
LLUIString mText;
callback_t mClickedCallback;
bool mShowCursorHand;
+
+protected:
+ virtual std::string _getSearchText() const override
+ {
+ return LLTextBase::_getSearchText() + mText.getString();
+ }
};
// 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 5d30c1299a..cfe729be06 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -60,6 +60,7 @@
#include "llurlregistry.h"
#include "lltooltip.h"
#include "llmenugl.h"
+#include "llchatmentionhelper.h"
#include <queue>
#include "llcombobox.h"
@@ -71,7 +72,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
@@ -167,50 +168,6 @@ private:
};
///////////////////////////////////////////////////////////////////
-class LLTextEditor::TextCmdAddString : public LLTextBase::TextCmd
-{
-public:
- TextCmdAddString(S32 pos, bool group_with_next, char *str,
- LLTextSegmentPtr segment) :
- TextCmd(pos, group_with_next, segment),
- mWString(utf8str_to_wstring(str)),
- mBlockExtensions(FALSE)
- {
- }
- virtual void blockExtensions()
- {
- mBlockExtensions = TRUE;
- }
- virtual bool canExtend(S32 pos) const
- {
- if (!mSegments.empty()) return FALSE;
-
- return !mBlockExtensions
- && (pos == getPosition() + (S32)mWString.length());
- }
- virtual bool execute(LLTextBase* editor, S32* delta)
- {
- *delta = insert(editor, getPosition(), mWString);
- LLWStringUtil::truncate(mWString, *delta);
- return (*delta != 0);
- }
- virtual S32 undo(LLTextBase* editor)
- {
- remove(editor, getPosition(), mWString.length());
- return getPosition();
- }
- virtual S32 redo(LLTextBase* editor)
- {
- insert(editor, getPosition(), mWString);
- return getPosition() + mWString.length();
- }
-
-private:
- LLWString mWString;
- bool mBlockExtensions;
-};
-
-///////////////////////////////////////////////////////////////////
class LLTextEditor::TextCmdOverwriteChar : public LLTextBase::TextCmd
{
@@ -253,8 +210,15 @@ public:
}
virtual bool execute( LLTextBase* editor, S32* delta )
{
- mWString = editor->getWText().substr(getPosition(), mLen);
- *delta = remove(editor, getPosition(), mLen );
+ try
+ {
+ mWString = editor->getWText().substr(getPosition(), mLen);
+ *delta = remove(editor, getPosition(), mLen);
+ }
+ catch (std::out_of_range&)
+ {
+ return false;
+ }
return (*delta != 0);
}
virtual S32 undo( LLTextBase* editor )
@@ -307,6 +271,7 @@ LLTextEditor::LLTextEditor(const LLTextEditor::Params& p) :
mPrevalidator(p.prevalidator()),
mShowContextMenu(p.show_context_menu),
mShowEmojiHelper(p.show_emoji_helper),
+ mShowChatMentionPicker(false),
mEnableTooltipPaste(p.enable_tooltip_paste),
mPassDelete(false),
mKeepSelectionOnReturn(false)
@@ -751,6 +716,30 @@ void LLTextEditor::handleEmojiCommit(llwchar emoji)
}
}
+void LLTextEditor::handleMentionCommit(std::string name_url)
+{
+ S32 mention_start_pos;
+ if (LLChatMentionHelper::instance().isCursorInNameMention(getWText(), mCursorPos, &mention_start_pos))
+ {
+ remove(mention_start_pos, mCursorPos - mention_start_pos, true);
+ insert(mention_start_pos, utf8str_to_wstring(name_url), false, LLTextSegmentPtr());
+
+ std::string new_text(wstring_to_utf8str(getConvertedText()));
+ clear();
+ appendTextImpl(new_text, LLStyle::Params(), true);
+
+ segment_set_t::const_iterator it = getSegIterContaining(mention_start_pos);
+ if (it != mSegments.end())
+ {
+ setCursorPos((*it)->getEnd() + 1);
+ }
+ else
+ {
+ setCursorPos(mention_start_pos);
+ }
+ }
+}
+
bool LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask)
{
bool handled = false;
@@ -1140,6 +1129,7 @@ void LLTextEditor::removeCharOrTab()
}
tryToShowEmojiHelper();
+ tryToShowMentionHelper();
}
else
{
@@ -1165,6 +1155,7 @@ void LLTextEditor::removeChar()
setCursorPos(mCursorPos - 1);
removeChar(mCursorPos);
tryToShowEmojiHelper();
+ tryToShowMentionHelper();
}
else
{
@@ -1208,18 +1199,6 @@ S32 LLTextEditor::addChar(S32 pos, llwchar wc)
return execute(new TextCmdAddChar(pos, false, wc, LLTextSegmentPtr()));
}
-S32 LLTextEditor::addString(S32 pos, char *str)
-{
- if ((wstring_utf8_length(getWText()) + strlen(str))
- > mMaxTextByteLength) {
- make_ui_sound("UISndBadKeystroke");
- return 0;
- }
-
- return execute(new TextCmdAddString(pos, FALSE, str,
- LLTextSegmentPtr()));
-}
-
void LLTextEditor::addChar(llwchar wc)
{
if (!getEnabled())
@@ -1238,6 +1217,7 @@ void LLTextEditor::addChar(llwchar wc)
setCursorPos(mCursorPos + addChar( mCursorPos, wc ));
tryToShowEmojiHelper();
+ tryToShowMentionHelper();
if (!mReadOnly && mAutoreplaceCallback != NULL)
{
@@ -1257,38 +1237,6 @@ void LLTextEditor::addChar(llwchar wc)
}
}
-void LLTextEditor::addString(char *str, bool editing)
-{
- if (!getEnabled())
- return;
- if (hasSelection())
- deleteSelection(TRUE);
- else if (LL_KIM_OVERWRITE == gKeyboard->getInsertMode())
- removeChar(mCursorPos);
- else if (editing) {
- clear();
- setCursorPos(0);
- }
-
- setCursorPos(mCursorPos + addString(mCursorPos, str));
-
- if (!mReadOnly && mAutoreplaceCallback != NULL) {
- S32 replacement_start;
- S32 replacement_length;
- LLWString replacement_string;
- S32 new_cursor_pos = mCursorPos;
- mAutoreplaceCallback(replacement_start, replacement_length,
- replacement_string, new_cursor_pos, getWText());
-
- if (replacement_length > 0 || !replacement_string.empty()) {
- remove(replacement_start, replacement_length, true);
- insert(replacement_start, replacement_string, false,
- LLTextSegmentPtr());
- setCursorPos(new_cursor_pos);
- }
- }
-}
-
void LLTextEditor::showEmojiHelper()
{
if (mReadOnly || !mShowEmojiHelper)
@@ -1299,6 +1247,14 @@ void LLTextEditor::showEmojiHelper()
LLEmojiHelper::instance().showHelper(this, cursorRect.mLeft, cursorRect.mTop, LLStringUtil::null, cb);
}
+void LLTextEditor::hideEmojiHelper()
+{
+ if (mShowEmojiHelper)
+ {
+ LLEmojiHelper::instance().hideHelper(this);
+ }
+}
+
void LLTextEditor::tryToShowEmojiHelper()
{
if (mReadOnly || !mShowEmojiHelper)
@@ -1320,6 +1276,31 @@ void LLTextEditor::tryToShowEmojiHelper()
}
}
+void LLTextEditor::tryToShowMentionHelper()
+{
+ if (mReadOnly || !mShowChatMentionPicker)
+ return;
+
+ S32 mention_start_pos;
+ LLWString text(getWText());
+ if (LLChatMentionHelper::instance().isCursorInNameMention(text, mCursorPos, &mention_start_pos))
+ {
+ const LLRect cursor_rect(getLocalRectFromDocIndex(mention_start_pos));
+ std::string name_part(wstring_to_utf8str(text.substr(mention_start_pos, mCursorPos - mention_start_pos)));
+ name_part.erase(0, 1);
+ auto cb = [this](std::string name_url)
+ {
+ handleMentionCommit(name_url);
+ };
+ LLChatMentionHelper::instance().showHelper(this, cursor_rect.mLeft, cursor_rect.mTop, name_part, cb);
+ }
+ else
+ {
+ LLChatMentionHelper::instance().hideHelper();
+ }
+}
+
+
void LLTextEditor::addLineBreakChar(bool group_together)
{
if( !getEnabled() )
@@ -1946,7 +1927,7 @@ bool LLTextEditor::handleKeyHere(KEY key, MASK mask )
// not handled and let the parent take care of field movement.
if (KEY_TAB == key && mTabsToNextField)
{
- return false;
+ return mShowChatMentionPicker && LLChatMentionHelper::instance().handleKey(this, key, mask);
}
if (mReadOnly && mScroller)
@@ -1957,9 +1938,13 @@ bool LLTextEditor::handleKeyHere(KEY key, MASK mask )
}
else
{
- if (!mReadOnly && mShowEmojiHelper && LLEmojiHelper::instance().handleKey(this, key, mask))
+ if (!mReadOnly)
{
- return true;
+ if ((mShowEmojiHelper && LLEmojiHelper::instance().handleKey(this, key, mask)) ||
+ (mShowChatMentionPicker && LLChatMentionHelper::instance().handleKey(this, key, mask)))
+ {
+ return true;
+ }
}
if (mEnableTooltipPaste &&
@@ -2060,24 +2045,6 @@ bool LLTextEditor::handleUnicodeCharHere(llwchar uni_char)
return handled;
}
-bool LLTextEditor::handleUnicodeStringHere(char *uni_str, bool editing)
-{
- auto handled = FALSE;
-
- if (!mReadOnly) {
- addString(uni_str, editing);
- getWindow()->hideCursorUntilMouseMove();
- handled = TRUE;
- }
-
- if (handled) {
- resetCursorBlink();
- deselect();
- onKeyStroke();
- }
-
- return handled;
-}
// virtual
bool LLTextEditor::canDoDelete() const
@@ -2421,17 +2388,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));
}
}
@@ -3174,3 +3141,21 @@ S32 LLTextEditor::spacesPerTab()
{
return SPACES_PER_TAB;
}
+
+LLWString LLTextEditor::getConvertedText() const
+{
+ LLWString text = getWText();
+ S32 diff = 0;
+ for (auto segment : mSegments)
+ {
+ if (segment && segment->getStyle() && segment->getStyle()->getDrawHighlightBg())
+ {
+ S32 seg_length = segment->getEnd() - segment->getStart();
+ std::string slurl = segment->getStyle()->getLinkHREF();
+
+ text.replace(segment->getStart() + diff, seg_length, utf8str_to_wstring(slurl));
+ diff += (S32)slurl.size() - seg_length;
+ }
+ }
+ return text;
+}
diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h
index 6ce08f48b5..882bb145df 100644
--- a/indra/llui/lltexteditor.h
+++ b/indra/llui/lltexteditor.h
@@ -95,6 +95,8 @@ public:
void insertEmoji(llwchar emoji);
void handleEmojiCommit(llwchar emoji);
+ void handleMentionCommit(std::string name_url);
+
// mousehandler overrides
virtual bool handleMouseDown(S32 x, S32 y, MASK mask);
virtual bool handleMouseUp(S32 x, S32 y, MASK mask);
@@ -105,7 +107,6 @@ public:
virtual bool handleKeyHere(KEY key, MASK mask );
virtual bool handleUnicodeCharHere(llwchar uni_char);
- virtual bool handleUnicodeStringHere(char *uni_str, bool editing);
virtual void onMouseCaptureLost();
@@ -201,24 +202,24 @@ public:
const LLUUID& getSourceID() const { return mSourceID; }
const LLTextSegmentPtr getPreviousSegment() const;
- const LLTextSegmentPtr getLastSegment() const;
void getSelectedSegments(segment_vec_t& segments) const;
void setShowContextMenu(bool show) { mShowContextMenu = show; }
bool getShowContextMenu() const { return mShowContextMenu; }
void showEmojiHelper();
+ void hideEmojiHelper();
void setShowEmojiHelper(bool show);
bool getShowEmojiHelper() const { return mShowEmojiHelper; }
void setPassDelete(bool b) { mPassDelete = b; }
+ LLWString getConvertedText() const;
+
protected:
void showContextMenu(S32 x, S32 y);
void drawPreeditMarker();
- void assignEmbedded(const std::string &s);
-
void removeCharOrTab();
void indentSelectedLines( S32 spaces );
@@ -238,7 +239,6 @@ protected:
void autoIndent();
- void findEmbeddedItemSegments(S32 start, S32 end);
void getSegmentsInRange(segment_vec_t& segments, S32 start, S32 end, bool include_partial) const;
virtual llwchar pasteEmbeddedItem(llwchar ext_char) { return ext_char; }
@@ -250,8 +250,6 @@ protected:
// Undoable operations
void addChar(llwchar c); // at mCursorPos
S32 addChar(S32 pos, llwchar wc);
- void addString(char *s, bool editing);
- S32 addString(S32 pos, char *str);
void addLineBreakChar(bool group_together = false);
S32 overwriteChar(S32 pos, llwchar wc);
void removeChar();
@@ -260,6 +258,7 @@ protected:
S32 remove(S32 pos, S32 length, bool group_with_next_op);
void tryToShowEmojiHelper();
+ void tryToShowMentionHelper();
void focusLostHelper();
void updateAllowingLanguageInput();
bool hasPreeditString() const;
@@ -274,6 +273,8 @@ protected:
virtual bool getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect *bounds, LLRect *control) const;
virtual S32 getPreeditFontSize() const;
virtual LLWString getPreeditString() const { return getWText(); }
+
+ virtual bool useFontBuffers() const { return getReadOnly(); }
//
// Protected data
//
@@ -295,6 +296,7 @@ protected:
bool mAutoIndent;
bool mParseOnTheFly;
+ bool mShowChatMentionPicker;
void updateLinkSegments();
void keepSelectionOnReturn(bool keep) { mKeepSelectionOnReturn = keep; }
@@ -305,7 +307,7 @@ private:
// Methods
//
void pasteHelper(bool is_primary);
- void cleanStringForPaste(LLWString & clean_string);
+ void cleanStringForPaste(LLWString& clean_string);
void pasteTextWithLinebreaks(LLWString & clean_string);
void onKeyStroke();
@@ -313,7 +315,6 @@ private:
// Concrete TextCmd sub-classes used by the LLTextEditor base class
class TextCmdInsert;
class TextCmdAddChar;
- class TextCmdAddString;
class TextCmdOverwriteChar;
class TextCmdRemove;
@@ -349,7 +350,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/lltextparser.cpp b/indra/llui/lltextparser.cpp
index 097b168106..d4ef77664e 100644
--- a/indra/llui/lltextparser.cpp
+++ b/indra/llui/lltextparser.cpp
@@ -36,6 +36,7 @@
#include "llmath.h"
#include "v4color.h"
#include "lldir.h"
+#include "lluicolor.h"
//
// Member Functions
@@ -80,14 +81,14 @@ S32 LLTextParser::findPattern(const std::string &text, LLSD highlight)
return static_cast<S32>(found);
}
-LLSD LLTextParser::parsePartialLineHighlights(const std::string &text, const LLColor4 &color, EHighlightPosition part, S32 index)
+LLTextParser::parser_out_vec_t LLTextParser::parsePartialLineHighlights(const std::string &text, const LLUIColor& color, EHighlightPosition part, S32 index)
{
loadKeywords();
//evil recursive string atomizer.
- LLSD ret_llsd, start_llsd, middle_llsd, end_llsd;
+ parser_out_vec_t ret_vec, start_vec, middle_vec, end_vec;
- for (S32 i=index;i<mHighlights.size();i++)
+ for (S32 i=index, size = (S32)mHighlights.size();i< size;i++)
{
S32 condition = mHighlights[i]["condition"];
if ((S32)mHighlights[i]["highlight"]==PART && condition!=MATCHES)
@@ -104,72 +105,69 @@ LLSD LLTextParser::parsePartialLineHighlights(const std::string &text, const LLC
EHighlightPosition newpart;
if (start==0)
{
- start_llsd[0]["text"] =text.substr(0,end);
- start_llsd[0]["color"]=mHighlights[i]["color"];
+ if (start_vec.empty())
+ {
+ start_vec.push_back(std::make_pair(text.substr(0, end), LLColor4(mHighlights[i]["color"])));
+ }
+ else
+ {
+ start_vec[0] = std::make_pair(text.substr(0, end), LLColor4(mHighlights[i]["color"]));
+ }
if (end < len)
{
if (part==END || part==WHOLE) newpart=END; else newpart=MIDDLE;
- end_llsd=parsePartialLineHighlights(text.substr( end ),color,newpart,i);
+ end_vec = parsePartialLineHighlights(text.substr( end ),color,newpart,i);
}
}
else
{
if (part==START || part==WHOLE) newpart=START; else newpart=MIDDLE;
- start_llsd=parsePartialLineHighlights(text.substr(0,start),color,newpart,i+1);
+ start_vec = parsePartialLineHighlights(text.substr(0,start),color,newpart,i+1);
if (end < len)
{
- middle_llsd[0]["text"] =text.substr(start,end);
- middle_llsd[0]["color"]=mHighlights[i]["color"];
+ if (middle_vec.empty())
+ {
+ middle_vec.push_back(std::make_pair(text.substr(start, end), LLColor4(mHighlights[i]["color"])));
+ }
+ else
+ {
+ middle_vec[0] = std::make_pair(text.substr(start, end), LLColor4(mHighlights[i]["color"]));
+ }
if (part==END || part==WHOLE) newpart=END; else newpart=MIDDLE;
- end_llsd=parsePartialLineHighlights(text.substr( (start+end) ),color,newpart,i);
+ end_vec = parsePartialLineHighlights(text.substr( (start+end) ),color,newpart,i);
}
else
{
- end_llsd[0]["text"] =text.substr(start,end);
- end_llsd[0]["color"]=mHighlights[i]["color"];
+ if (end_vec.empty())
+ {
+ end_vec.push_back(std::make_pair(text.substr(start, end), LLColor4(mHighlights[i]["color"])));
+ }
+ else
+ {
+ end_vec[0] = std::make_pair(text.substr(start, end), LLColor4(mHighlights[i]["color"]));
+ }
}
}
- S32 retcount=0;
-
- //FIXME These loops should be wrapped into a subroutine.
- for (LLSD::array_iterator iter = start_llsd.beginArray();
- iter != start_llsd.endArray();++iter)
- {
- LLSD highlight = *iter;
- ret_llsd[retcount++]=highlight;
- }
-
- for (LLSD::array_iterator iter = middle_llsd.beginArray();
- iter != middle_llsd.endArray();++iter)
- {
- LLSD highlight = *iter;
- ret_llsd[retcount++]=highlight;
- }
-
- for (LLSD::array_iterator iter = end_llsd.beginArray();
- iter != end_llsd.endArray();++iter)
- {
- LLSD highlight = *iter;
- ret_llsd[retcount++]=highlight;
- }
+ ret_vec.reserve(start_vec.size() + middle_vec.size() + end_vec.size());
+ ret_vec.insert(ret_vec.end(), start_vec.begin(), start_vec.end());
+ ret_vec.insert(ret_vec.end(), middle_vec.begin(), middle_vec.end());
+ ret_vec.insert(ret_vec.end(), end_vec.begin(), end_vec.end());
- return ret_llsd;
+ return ret_vec;
}
}
}
}
//No patterns found. Just send back what was passed in.
- ret_llsd[0]["text"] =text;
- LLSD color_sd = color.getValue();
- ret_llsd[0]["color"]=color_sd;
- return ret_llsd;
+ ret_vec.push_back(std::make_pair(text, color));
+ return ret_vec;
}
bool LLTextParser::parseFullLineHighlights(const std::string &text, LLColor4 *color)
diff --git a/indra/llui/lltextparser.h b/indra/llui/lltextparser.h
index 20fcc07e4c..c5756f9b4c 100644
--- a/indra/llui/lltextparser.h
+++ b/indra/llui/lltextparser.h
@@ -30,6 +30,7 @@
#include "llsd.h"
#include "llsingleton.h"
+#include "lluicolor.h"
class LLUUID;
class LLVector3d;
@@ -45,7 +46,9 @@ public:
typedef enum e_highlight_position { WHOLE, START, MIDDLE, END } EHighlightPosition;
typedef enum e_dialog_action { ACTION_NONE, ACTION_CLOSE, ACTION_ADD, ACTION_COPY, ACTION_UPDATE } EDialogAction;
- LLSD parsePartialLineHighlights(const std::string &text,const LLColor4 &color, EHighlightPosition part=WHOLE, S32 index=0);
+ using parser_out_vec_t = std::vector<std::pair<std::string, LLUIColor>>;
+
+ parser_out_vec_t parsePartialLineHighlights(const std::string &text,const LLUIColor &color, EHighlightPosition part=WHOLE, S32 index=0);
bool parseFullLineHighlights(const std::string &text, LLColor4 *color);
private:
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index aa48ae048f..5955a28fa3 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -1073,7 +1073,7 @@ bool LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop,
int orig_rank = getRankFromPosition(dragged_command);
mDragRank = getRankFromPosition(x, y);
// Don't DaD if we're dragging a command on itself
- mDragAndDropTarget = ((orig_rank != RANK_NONE) && ((mDragRank == orig_rank) || ((mDragRank - 1) == orig_rank)));
+ mDragAndDropTarget = (orig_rank == RANK_NONE) || ((mDragRank != orig_rank) && ((mDragRank - 1) != orig_rank));
//LL_INFOS() << "Merov debug : DaD, rank = " << mDragRank << ", dragged uui = " << inv_item->getUUID() << LL_ENDL;
/* Do the following if you want to animate the button itself
LLCommandId dragged_command(inv_item->getUUID());
diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h
index c57c979525..5556406fbd 100644
--- a/indra/llui/lltoolbar.h
+++ b/indra/llui/lltoolbar.h
@@ -68,7 +68,7 @@ public:
void reshape(S32 width, S32 height, bool called_from_parent = true);
void setEnabled(bool enabled);
void setCommandId(const LLCommandId& id) { mId = id; }
- LLCommandId getCommandId() { return mId; }
+ LLCommandId getCommandId() const { return mId; }
void setStartDragCallback(tool_startdrag_callback_t cb) { mStartDragItemCallback = cb; }
void setHandleDragCallback(tool_handledrag_callback_t cb) { mHandleDragItemCallback = cb; }
@@ -256,7 +256,7 @@ public:
// Methods used in loading and saving toolbar settings
void setButtonType(LLToolBarEnums::ButtonType button_type);
- LLToolBarEnums::ButtonType getButtonType() { return mButtonType; }
+ LLToolBarEnums::ButtonType getButtonType() const { return mButtonType; }
command_id_list_t& getCommandsList() { return mButtonCommands; }
void clearCommandsList();
diff --git a/indra/llui/lltooltip.cpp b/indra/llui/lltooltip.cpp
index 86525c2f7e..74f03618cf 100644
--- a/indra/llui/lltooltip.cpp
+++ b/indra/llui/lltooltip.cpp
@@ -390,22 +390,22 @@ void LLToolTip::draw()
}
}
-bool LLToolTip::isFading()
+bool LLToolTip::isFading() const
{
return mFadeTimer.getStarted();
}
-F32 LLToolTip::getVisibleTime()
+F32 LLToolTip::getVisibleTime() const
{
return mVisibleTimer.getStarted() ? mVisibleTimer.getElapsedTimeF32() : 0.f;
}
-bool LLToolTip::hasClickCallback()
+bool LLToolTip::hasClickCallback() const
{
return mHasClickCallback;
}
-void LLToolTip::getToolTipMessage(std::string & message)
+void LLToolTip::getToolTipMessage(std::string& message) const
{
if (mTextBox)
{
diff --git a/indra/llui/lltooltip.h b/indra/llui/lltooltip.h
index 8515504e3b..760acddd6f 100644
--- a/indra/llui/lltooltip.h
+++ b/indra/llui/lltooltip.h
@@ -44,15 +44,15 @@ public:
Params();
};
LLToolTipView(const LLToolTipView::Params&);
- /*virtual*/ bool handleHover(S32 x, S32 y, MASK mask);
- /*virtual*/ bool handleMouseDown(S32 x, S32 y, MASK mask);
- /*virtual*/ bool handleMiddleMouseDown(S32 x, S32 y, MASK mask);
- /*virtual*/ bool handleRightMouseDown(S32 x, S32 y, MASK mask);
- /*virtual*/ bool handleScrollWheel( S32 x, S32 y, S32 clicks );
+ bool handleHover(S32 x, S32 y, MASK mask) override;
+ bool handleMouseDown(S32 x, S32 y, MASK mask) override;
+ bool handleMiddleMouseDown(S32 x, S32 y, MASK mask) override;
+ bool handleRightMouseDown(S32 x, S32 y, MASK mask) override;
+ bool handleScrollWheel( S32 x, S32 y, S32 clicks ) override;
void drawStickyRect();
- /*virtual*/ void draw();
+ void draw() override;
};
class LLToolTip : public LLPanel
@@ -98,20 +98,20 @@ public:
Params();
};
- /*virtual*/ void draw();
- /*virtual*/ bool handleHover(S32 x, S32 y, MASK mask);
- /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
- /*virtual*/ void setVisible(bool visible);
+ void draw() override;
+ bool handleHover(S32 x, S32 y, MASK mask) override;
+ void onMouseLeave(S32 x, S32 y, MASK mask) override;
+ void setVisible(bool visible) override;
- bool isFading();
- F32 getVisibleTime();
- bool hasClickCallback();
+ bool isFading() const;
+ F32 getVisibleTime() const;
+ bool hasClickCallback() const;
LLToolTip(const Params& p);
virtual void initFromParams(const LLToolTip::Params& params);
- void getToolTipMessage(std::string & message);
- bool isTooltipPastable() { return mIsTooltipPastable; }
+ void getToolTipMessage(std::string & message) const;
+ bool isTooltipPastable() const { return mIsTooltipPastable; }
protected:
void updateTextBox();
diff --git a/indra/llui/lltrans.cpp b/indra/llui/lltrans.cpp
index 6c7e472a87..0c6c5b64e4 100644
--- a/indra/llui/lltrans.cpp
+++ b/indra/llui/lltrans.cpp
@@ -28,12 +28,8 @@
#include "lltrans.h"
-#include "llfasttimer.h" // for call count statistics
#include "llxuiparser.h"
#include "llsd.h"
-#include "llxmlnode.h"
-
-#include <map>
LLTrans::template_map_t LLTrans::sStringTemplates;
LLTrans::template_map_t LLTrans::sDefaultStringTemplates;
@@ -59,13 +55,13 @@ struct StringTable : public LLInitParam::Block<StringTable>
};
//static
-bool LLTrans::parseStrings(LLXMLNodePtr &root, const std::set<std::string>& default_args)
+bool LLTrans::parseStrings(LLXMLNodePtr& root, const std::set<std::string>& default_args)
{
std::string xml_filename = "(strings file)";
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;
@@ -107,13 +103,13 @@ bool LLTrans::parseStrings(LLXMLNodePtr &root, const std::set<std::string>& defa
//static
-bool LLTrans::parseLanguageStrings(LLXMLNodePtr &root)
+bool LLTrans::parseLanguageStrings(LLXMLNodePtr& root)
{
std::string xml_filename = "(language strings file)";
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;
@@ -138,12 +134,8 @@ bool LLTrans::parseLanguageStrings(LLXMLNodePtr &root)
return true;
}
-
-
-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 +159,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 +179,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 +205,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 +222,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 +249,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;
@@ -277,7 +269,7 @@ bool LLTrans::findString(std::string &result, const std::string &xml_desc, const
}
//static
-std::string LLTrans::getCountString(const std::string& language, const std::string& xml_desc, S32 count)
+std::string LLTrans::getCountString(std::string_view language, std::string_view xml_desc, S32 count)
{
// Compute which string identifier to use
const char* form = "";
@@ -337,7 +329,7 @@ std::string LLTrans::getCountString(const std::string& language, const std::stri
args["[COUNT]"] = llformat("%d", count);
// Look up "AgeYearsB" or "AgeWeeksC" including the "form"
- std::string key = llformat("%s%s", xml_desc.c_str(), form);
+ std::string key = llformat("%s%s", xml_desc.data(), form);
return getString(key, args);
}
diff --git a/indra/llui/lltrans.h b/indra/llui/lltrans.h
index 4f38ef9067..c5d01e6f8d 100644
--- a/indra/llui/lltrans.h
+++ b/indra/llui/lltrans.h
@@ -30,10 +30,8 @@
#include <map>
#include <set>
-#include "llpointer.h"
#include "llstring.h"
-
-class LLXMLNode;
+#include "llxmlnode.h"
class LLSD;
@@ -58,17 +56,17 @@ public:
class LLTrans
{
public:
- LLTrans();
+ LLTrans() = default;
/**
* @brief Parses the xml root that holds the strings. Used once on startup
-// *FIXME * @param xml_filename Filename to parse
+ * @param root xml root node to parse
* @param default_args Set of strings (expected to be in the file) to use as default replacement args, e.g. "SECOND_LIFE"
* @returns true if the file was parsed successfully, true if something went wrong
*/
- static bool parseStrings(LLPointer<LLXMLNode> & root, const std::set<std::string>& default_args);
+ static bool parseStrings(LLXMLNodePtr& root, const std::set<std::string>& default_args);
- static bool parseLanguageStrings(LLPointer<LLXMLNode> & root);
+ static bool parseLanguageStrings(LLXMLNodePtr& root);
/**
* @brief Returns a translated string
@@ -76,41 +74,40 @@ 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
// may have different plurals for 0, 1, 2 and > 2.
// See "AgeWeeksA", "AgeWeeksB", etc. in strings.xml for examples.
- static std::string getCountString(const std::string& language, const std::string& xml_desc, S32 count);
+ static std::string getCountString(std::string_view language, std::string_view xml_desc, S32 count);
/**
* @brief Returns a translated string
* @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 +125,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/lltransutil.cpp b/indra/llui/lltransutil.cpp
index 4af5376a8b..e82af0b96f 100644
--- a/indra/llui/lltransutil.cpp
+++ b/indra/llui/lltransutil.cpp
@@ -48,7 +48,7 @@ bool LLTransUtil::parseStrings(const std::string& xml_filename, const std::set<s
"Second Life viewer couldn't access some of the files it needs and will be closed."
"\n\nPlease reinstall viewer from https://secondlife.com/support/downloads/ and "
"contact https://support.secondlife.com if issue persists after reinstall.";
- LLError::LLUserWarningMsg::show(error_string);
+ LLError::LLUserWarningMsg::show(error_string, LLError::LLUserWarningMsg::ERROR_MISSING_FILES);
gDirUtilp->dumpCurrentDirectories(LLError::LEVEL_WARN);
LL_ERRS() << "Couldn't load string table " << xml_filename << " " << errno << LL_ENDL;
return false;
diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp
index ba8fe84377..e7dea79eaa 100644
--- a/indra/llui/llui.cpp
+++ b/indra/llui/llui.cpp
@@ -54,6 +54,7 @@
#include "llmenubutton.h"
#include "llloadingindicator.h"
#include "llwindow.h"
+#include "llspellcheck.h"
// for registration
#include "llfiltereditor.h"
@@ -156,7 +157,8 @@ mWindow(NULL), // set later in startup
mRootView(NULL),
mHelpImpl(NULL)
{
- LLRender2D::initParamSingleton(image_provider);
+ LLRender2D::createInstance(image_provider);
+ LLSpellChecker::createInstance();
if ((get_ptr_in_map(mSettingGroups, std::string("config")) == NULL) ||
(get_ptr_in_map(mSettingGroups, std::string("floater")) == NULL) ||
@@ -170,11 +172,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,13 +191,19 @@ 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();
}
+LLUI::~LLUI()
+{
+ LLSpellChecker::deleteSingleton();
+ LLRender2D::deleteSingleton();
+}
+
void LLUI::setPopupFuncs(const add_popup_t& add_popup, const remove_popup_t& remove_popup, const clear_popups_t& clear_popups)
{
mAddPopupFunc = add_popup;
@@ -372,7 +380,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)
@@ -534,7 +542,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..b2dcb6dc88 100644
--- a/indra/llui/llui.h
+++ b/indra/llui/llui.h
@@ -31,8 +31,6 @@
#include "llrect.h"
#include "llcoord.h"
#include "llcontrol.h"
-#include "llcoord.h"
-#include "llcontrol.h"
#include "llinitparam.h"
#include "llregistry.h"
#include "llrender2dutils.h"
@@ -112,18 +110,18 @@ class LLImageProviderInterface;
typedef void (*LLUIAudioCallback)(const LLUUID& uuid);
-class LLUI : public LLParamSingleton<LLUI>
+class LLUI : public LLSimpleton<LLUI>
{
+ LOG_CLASS(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,
+ LLUI(const settings_map_t &settings,
LLImageProviderInterface* image_provider,
LLUIAudioCallback audio_callback,
LLUIAudioCallback deferred_audio_callback);
- LOG_CLASS(LLUI);
-public:
+ ~LLUI();
+
//
// Classes
//
@@ -156,7 +154,7 @@ public:
sanitizeRange();
}
- S32 clamp(S32 input)
+ S32 clamp(S32 input) const
{
if (input < mMin) return mMin;
if (input > mMax) return mMax;
@@ -170,8 +168,8 @@ public:
sanitizeRange();
}
- S32 getMin() { return mMin; }
- S32 getMax() { return mMax; }
+ S32 getMin() const { return mMin; }
+ S32 getMax() const { return mMax; }
bool operator==(const RangeS32& other) const
{
@@ -225,7 +223,7 @@ public:
mValue = clamp(value);
}
- S32 get()
+ S32 get() const
{
return mValue;
}
@@ -255,7 +253,7 @@ public:
static std::string getLanguage(); // static for lldateutil_test compatibility
//helper functions (should probably move free standing rendering helper functions here)
- LLView* getRootView() { return mRootView; }
+ LLView* getRootView() const { return mRootView; }
void setRootView(LLView* view) { mRootView = view; }
/**
* Walk the LLView tree to resolve a path
@@ -295,10 +293,10 @@ 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; }
+ LLWindow* getWindow() const { return mWindow; }
void addPopup(LLView*);
void removePopup(LLView*);
diff --git a/indra/llui/lluicolortable.cpp b/indra/llui/lluicolortable.cpp
index 54f8727fa5..a792cb8103 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,9 +196,63 @@ 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);
+ auto it = mUserSetColors.lower_bound(name);
+ if(it != mUserSetColors.end() && !(mUserSetColors.key_comp()(name, it->first)))
+ {
+ it->second = color;
+ }
+ else
+ {
+ string_color_map_t::iterator base_iter = mLoadedColors.find(name);
+ if (base_iter != mLoadedColors.end())
+ {
+ LLColor4 original_color = base_iter->second.get();
+ auto color_handle = mLoadedColors.extract(base_iter);
+ auto new_color_pair = mUserSetColors.insert(std::move(color_handle));
+ new_color_pair.position->second = color;
+ mLoadedColors.emplace(name, LLUIColor(original_color));
+ }
+ else
+ {
+ mUserSetColors.insert(it, std::make_pair(name, color));
+ }
+ }
+}
+
+bool LLUIColorTable::isDefault(std::string_view name) const
+{
+ string_color_map_t::const_iterator base_iter = mLoadedColors.find(name);
+ string_color_map_t::const_iterator user_iter = mUserSetColors.find(name);
+ if (base_iter != mLoadedColors.end())
+ {
+ if(user_iter != mUserSetColors.end())
+ return user_iter->second == base_iter->second;
+
+ return true;
+ }
+ else if (user_iter != mUserSetColors.end()) // user only color ???
+ {
+ return true;
+ }
+
+ return false;
+}
+
+void LLUIColorTable::resetToDefault(std::string_view name)
+{
+ string_color_map_t::iterator iter = mUserSetColors.find(name);
+
+ if (iter != mUserSetColors.end())
+ {
+ auto default_iter = mLoadedColors.find(name);
+
+ if (default_iter != mLoadedColors.end())
+ {
+ iter->second = default_iter->second.get();
+ }
+ }
}
bool LLUIColorTable::loadFromSettings()
@@ -223,18 +277,16 @@ void LLUIColorTable::saveUserSettings() const
{
Params params;
- for(string_color_map_t::const_iterator it = mUserSetColors.begin();
- it != mUserSetColors.end();
- ++it)
+ for (const auto& color_pair : mUserSetColors)
{
// Compare user color value with the default value, skip if equal
- string_color_map_t::const_iterator itd = mLoadedColors.find(it->first);
- if(itd != mLoadedColors.end() && itd->second == it->second)
+ string_color_map_t::const_iterator itd = mLoadedColors.find(color_pair.first);
+ if(itd != mLoadedColors.end() && itd->second == color_pair.second)
continue;
ColorEntryParams color_entry;
- color_entry.name = it->first;
- color_entry.color.value = it->second;
+ color_entry.name = color_pair.first;
+ color_entry.color.value = color_pair.second;
params.color_entries.add(color_entry);
}
@@ -258,7 +310,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 +328,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..0c6286e5eb 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,17 @@ 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;
+
+ bool isDefault(std::string_view color_name) const;
+
+ void resetToDefault(std::string_view color_name);
// loads colors from settings files
bool loadFromSettings();
@@ -89,13 +93,16 @@ public:
// saves colors specified by the user to the users skin directory
void saveUserSettings() const;
+ const auto& getLoadedColors() { return mLoadedColors; }
+ const auto& getUserColors() { return mUserSetColors; }
+
private:
bool loadFromFilename(const std::string& filename, string_color_map_t& table);
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/lluiconstants.h b/indra/llui/lluiconstants.h
index 5fdfd37c6e..a317c66008 100644
--- a/indra/llui/lluiconstants.h
+++ b/indra/llui/lluiconstants.h
@@ -28,23 +28,23 @@
#define LL_LLUICONSTANTS_H
// spacing for small font lines of text, like LLTextBoxes
-const S32 LINE = 16;
+constexpr S32 LINE = 16;
// spacing for larger lines of text
-const S32 LINE_BIG = 24;
+constexpr S32 LINE_BIG = 24;
// default vertical padding
-const S32 VPAD = 4;
+constexpr S32 VPAD = 4;
// default horizontal padding
-const S32 HPAD = 4;
+constexpr S32 HPAD = 4;
// Account History, how far to look into past
-const S32 SUMMARY_INTERVAL = 7; // one week
-const S32 SUMMARY_MAX = 8; //
-const S32 DETAILS_INTERVAL = 1; // one day
-const S32 DETAILS_MAX = 30; // one month
-const S32 TRANSACTIONS_INTERVAL = 1;// one day
-const S32 TRANSACTIONS_MAX = 30; // one month
+constexpr S32 SUMMARY_INTERVAL = 7; // one week
+constexpr S32 SUMMARY_MAX = 8; //
+constexpr S32 DETAILS_INTERVAL = 1; // one day
+constexpr S32 DETAILS_MAX = 30; // one month
+constexpr S32 TRANSACTIONS_INTERVAL = 1;// one day
+constexpr S32 TRANSACTIONS_MAX = 30; // one month
#endif
diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp
index 52c5f72a45..cbabb5a933 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);
@@ -1023,7 +1023,7 @@ bool LLUICtrl::getTentative() const
}
// virtual
-void LLUICtrl::setColor(const LLColor4& color)
+void LLUICtrl::setColor(const LLUIColor& color)
{ }
F32 LLUICtrl::getCurrentTransparency()
diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h
index c56c3c43a4..bcaf479b0f 100644
--- a/indra/llui/lluictrl.h
+++ b/indra/llui/lluictrl.h
@@ -39,9 +39,9 @@
#include "llviewmodel.h" // *TODO move dependency to .cpp file
#include "llsearchablecontrol.h"
-const bool TAKE_FOCUS_YES = true;
-const bool TAKE_FOCUS_NO = false;
-const S32 DROP_SHADOW_FLOATER = 5;
+constexpr bool TAKE_FOCUS_YES = true;
+constexpr bool TAKE_FOCUS_NO = false;
+constexpr S32 DROP_SHADOW_FLOATER = 5;
class LLUICtrl
: public LLView, public boost::signals2::trackable
@@ -216,7 +216,7 @@ public:
// selected radio button, etc.). Defaults to no-op.
virtual void clear();
- virtual void setColor(const LLColor4& color);
+ virtual void setColor(const LLUIColor& color);
// Ansariel: Changed to virtual. We might want to change the transparency ourself!
virtual F32 getCurrentTransparency();
@@ -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..91221dc7f3 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;
+ typename T::Params widget_params{};
+ widget_params.name = std::string(name);
return create<T>(widget_params);
}
diff --git a/indra/llui/lluistring.cpp b/indra/llui/lluistring.cpp
index bfadeb8428..ab6de16639 100644
--- a/indra/llui/lluistring.cpp
+++ b/indra/llui/lluistring.cpp
@@ -47,6 +47,12 @@ void LLUIString::assign(const std::string& s)
dirty();
}
+void LLUIString::assign(const LLWString& instring)
+{
+ mOrig = wstring_to_utf8str(instring);
+ dirty();
+}
+
void LLUIString::setArgList(const LLStringUtil::format_map_t& args)
{
diff --git a/indra/llui/lluistring.h b/indra/llui/lluistring.h
index b9d4ff0ebb..950d4e72c6 100644
--- a/indra/llui/lluistring.h
+++ b/indra/llui/lluistring.h
@@ -61,10 +61,11 @@ public:
LLUIString() : mArgs(NULL), mNeedsResult(false), mNeedsWResult(false) {}
LLUIString(const std::string& instring, const LLStringUtil::format_map_t& args);
LLUIString(const std::string& instring) : mArgs(NULL) { assign(instring); }
- LLUIString(const LLWString& instring) : mArgs(NULL) { insert(0, instring); }
+ LLUIString(const LLWString& instring) : mArgs(NULL) { assign(instring); }
~LLUIString() { delete mArgs; }
void assign(const std::string& instring);
+ void assign(const LLWString& instring);
LLUIString& operator=(const std::string& s) { assign(s); return *this; }
void setArgList(const LLStringUtil::format_map_t& args);
@@ -109,8 +110,8 @@ private:
LLStringUtil::format_map_t* mArgs;
// controls lazy evaluation
- mutable bool mNeedsResult;
- mutable bool mNeedsWResult;
+ mutable bool mNeedsResult { true };
+ mutable bool mNeedsWResult { true };
};
#endif // LL_LLUISTRING_H
diff --git a/indra/llui/llundo.h b/indra/llui/llundo.h
index dc40702be0..990745e530 100644
--- a/indra/llui/llundo.h
+++ b/indra/llui/llundo.h
@@ -42,7 +42,7 @@ public:
LLUndoAction(): mClusterID(0) {};
virtual ~LLUndoAction(){};
private:
- S32 mClusterID;
+ S32 mClusterID;
};
LLUndoBuffer( LLUndoAction (*create_func()), S32 initial_count );
@@ -51,8 +51,8 @@ public:
LLUndoAction *getNextAction(bool setClusterBegin = true);
bool undoAction();
bool redoAction();
- bool canUndo() { return (mNextAction != mFirstAction); }
- bool canRedo() { return (mNextAction != mLastAction); }
+ bool canUndo() const { return (mNextAction != mFirstAction); }
+ bool canRedo() const { return (mNextAction != mLastAction); }
void flushActions();
diff --git a/indra/llui/llurlaction.h b/indra/llui/llurlaction.h
index 0f54b66299..ac9741a7ad 100644
--- a/indra/llui/llurlaction.h
+++ b/indra/llui/llurlaction.h
@@ -45,8 +45,6 @@
class LLUrlAction
{
public:
- LLUrlAction();
-
/// load a Url in the user's preferred web browser
static void openURL(std::string url);
diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp
index 198441804b..bcd13b7f0b 100644
--- a/indra/llui/llurlentry.cpp
+++ b/indra/llui/llurlentry.cpp
@@ -29,7 +29,6 @@
#include "llurlentry.h"
#include "lluictrl.h"
#include "lluri.h"
-#include "llurlmatch.h"
#include "llurlregistry.h"
#include "lluriparser.h"
@@ -48,7 +47,7 @@
// Utility functions
std::string localize_slapp_label(const std::string& url, const std::string& full_name);
-
+LLUUID LLUrlEntryBase::sAgentID(LLUUID::null);
LLUrlEntryBase::LLUrlEntryBase()
{
}
@@ -68,7 +67,7 @@ std::string LLUrlEntryBase::getIcon(const std::string &url)
return mIcon;
}
-LLStyle::Params LLUrlEntryBase::getStyle() const
+LLStyle::Params LLUrlEntryBase::getStyle(const std::string &url) const
{
LLStyle::Params style_params;
style_params.color = LLUIColorTable::instance().getColor("HTMLLinkColor");
@@ -221,6 +220,16 @@ bool LLUrlEntryBase::isWikiLinkCorrect(const std::string &labeled_url) const
},
L'\u002F'); // Solidus
+ std::replace_if(wlabel.begin(),
+ wlabel.end(),
+ [](const llwchar& chr)
+ {
+ return // Not a decomposition, but suficiently similar
+ (chr == L'\u04BA') // "Cyrillic Capital Letter Shha"
+ || (chr == L'\u04BB'); // "Cyrillic Small Letter Shha"
+ },
+ L'\u0068'); // "Latin Small Letter H"
+
std::string label = wstring_to_utf8str(wlabel);
if ((label.find(".com") != std::string::npos
|| label.find("www.") != std::string::npos)
@@ -239,7 +248,7 @@ std::string LLUrlEntryBase::urlToLabelWithGreyQuery(const std::string &url) cons
return url;
}
LLUriParser up(escapeUrl(url));
- if (up.normalize() == 0)
+ if (up.normalize())
{
std::string label;
up.extractParts();
@@ -600,15 +609,15 @@ void LLUrlEntryAgent::callObservers(const std::string &id,
void LLUrlEntryAgent::onAvatarNameCache(const LLUUID& id,
const LLAvatarName& av_name)
{
- avatar_name_cache_connection_map_t::iterator it = mAvatarNameCacheConnections.find(id);
- if (it != mAvatarNameCacheConnections.end())
+ auto range = mAvatarNameCacheConnections.equal_range(id);
+ for (avatar_name_cache_connection_map_t::iterator it = range.first; it != range.second; ++it)
{
if (it->second.connected())
{
it->second.disconnect();
}
- mAvatarNameCacheConnections.erase(it);
}
+ mAvatarNameCacheConnections.erase(range.first, range.second);
std::string label = av_name.getCompleteName();
@@ -621,6 +630,11 @@ LLUUID LLUrlEntryAgent::getID(const std::string &string) const
return LLUUID(getIDStringFromUrl(string));
}
+bool LLUrlEntryAgent::isAgentID(const std::string& url) const
+{
+ return sAgentID == getID(url);
+}
+
std::string LLUrlEntryAgent::getTooltip(const std::string &string) const
{
// return a tooltip corresponding to the URL type instead of the generic one
@@ -657,10 +671,14 @@ std::string LLUrlEntryAgent::getTooltip(const std::string &string) const
return LLTrans::getString("TooltipAgentUrl");
}
-bool LLUrlEntryAgent::underlineOnHoverOnly(const std::string &string) const
+LLStyle::EUnderlineLink LLUrlEntryAgent::getUnderline(const std::string& string) const
{
std::string url = getUrl(string);
- return LLStringUtil::endsWith(url, "/about") || LLStringUtil::endsWith(url, "/inspect");
+ if (LLStringUtil::endsWith(url, "/about") || LLStringUtil::endsWith(url, "/inspect"))
+ {
+ return LLStyle::EUnderlineLink::UNDERLINE_ON_HOVER;
+ }
+ return LLStyle::EUnderlineLink::UNDERLINE_ALWAYS;
}
std::string LLUrlEntryAgent::getLabel(const std::string &url, const LLUrlLabelCallback &cb)
@@ -695,27 +713,19 @@ std::string LLUrlEntryAgent::getLabel(const std::string &url, const LLUrlLabelCa
}
else
{
- avatar_name_cache_connection_map_t::iterator it = mAvatarNameCacheConnections.find(agent_id);
- if (it != mAvatarNameCacheConnections.end())
- {
- if (it->second.connected())
- {
- it->second.disconnect();
- }
- mAvatarNameCacheConnections.erase(it);
- }
- mAvatarNameCacheConnections[agent_id] = LLAvatarNameCache::get(agent_id, boost::bind(&LLUrlEntryAgent::onAvatarNameCache, this, _1, _2));
+ mAvatarNameCacheConnections.emplace(agent_id, LLAvatarNameCache::get(agent_id, boost::bind(&LLUrlEntryAgent::onAvatarNameCache, this, _1, _2)));
addObserver(agent_id_string, url, cb);
return LLTrans::getString("LoadingData");
}
}
-LLStyle::Params LLUrlEntryAgent::getStyle() const
+LLStyle::Params LLUrlEntryAgent::getStyle(const std::string &url) const
{
- LLStyle::Params style_params = LLUrlEntryBase::getStyle();
+ LLStyle::Params style_params = LLUrlEntryBase::getStyle(url);
style_params.color = LLUIColorTable::instance().getColor("HTMLLinkColor");
style_params.readonly_color = LLUIColorTable::instance().getColor("HTMLLinkColor");
+
return style_params;
}
@@ -750,6 +760,10 @@ std::string localize_slapp_label(const std::string& url, const std::string& full
{
return LLTrans::getString("SLappAgentRemoveFriend") + " " + full_name;
}
+ if (LLStringUtil::endsWith(url, "/mention"))
+ {
+ return "@" + full_name;
+ }
return full_name;
}
@@ -761,6 +775,36 @@ std::string LLUrlEntryAgent::getIcon(const std::string &url)
return mIcon;
}
+///
+/// LLUrlEntryAgentMention Describes a chat mention Url, e.g.,
+/// secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/mention
+///
+LLUrlEntryAgentMention::LLUrlEntryAgentMention()
+{
+ mPattern = boost::regex(APP_HEADER_REGEX "/agent/[\\da-f-]+/mention", boost::regex::perl | boost::regex::icase);
+ mMenuName = "menu_url_agent.xml";
+ mIcon = std::string();
+}
+
+LLStyle::EUnderlineLink LLUrlEntryAgentMention::getUnderline(const std::string& string) const
+{
+ return LLStyle::EUnderlineLink::UNDERLINE_NEVER;
+}
+
+LLStyle::Params LLUrlEntryAgentMention::getStyle(const std::string& url) const
+{
+ LLStyle::Params style_params = LLUrlEntryAgent::getStyle(url);
+ style_params.color = LLUIColorTable::instance().getColor("ChatMentionFont");
+ style_params.readonly_color = LLUIColorTable::instance().getColor("ChatMentionFont");
+ style_params.font.style = "NORMAL";
+ style_params.draw_highlight_bg = true;
+
+ LLUUID agent_id(getIDStringFromUrl(url));
+ style_params.highlight_bg_color = LLUIColorTable::instance().getColor((agent_id == sAgentID) ? "ChatSelfMentionHighlight" : "ChatMentionHighlight");
+
+ return style_params;
+}
+
//
// LLUrlEntryAgentName describes a Second Life agent name Url, e.g.,
// secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/(completename|displayname|username)
@@ -770,17 +814,17 @@ LLUrlEntryAgentName::LLUrlEntryAgentName()
{}
void LLUrlEntryAgentName::onAvatarNameCache(const LLUUID& id,
- const LLAvatarName& av_name)
+ const LLAvatarName& av_name)
{
- avatar_name_cache_connection_map_t::iterator it = mAvatarNameCacheConnections.find(id);
- if (it != mAvatarNameCacheConnections.end())
+ auto range = mAvatarNameCacheConnections.equal_range(id);
+ for (avatar_name_cache_connection_map_t::iterator it = range.first; it != range.second; ++it)
{
if (it->second.connected())
{
it->second.disconnect();
}
- mAvatarNameCacheConnections.erase(it);
}
+ mAvatarNameCacheConnections.erase(range.first, range.second);
std::string label = getName(av_name);
// received the agent name from the server - tell our observers
@@ -815,23 +859,14 @@ std::string LLUrlEntryAgentName::getLabel(const std::string &url, const LLUrlLab
}
else
{
- avatar_name_cache_connection_map_t::iterator it = mAvatarNameCacheConnections.find(agent_id);
- if (it != mAvatarNameCacheConnections.end())
- {
- if (it->second.connected())
- {
- it->second.disconnect();
- }
- mAvatarNameCacheConnections.erase(it);
- }
- mAvatarNameCacheConnections[agent_id] = LLAvatarNameCache::get(agent_id, boost::bind(&LLUrlEntryAgentName::onAvatarNameCache, this, _1, _2));
+ mAvatarNameCacheConnections.emplace(agent_id, LLAvatarNameCache::get(agent_id, boost::bind(&LLUrlEntryAgentName::onAvatarNameCache, this, _1, _2)));
addObserver(agent_id_string, url, cb);
return LLTrans::getString("LoadingData");
}
}
-LLStyle::Params LLUrlEntryAgentName::getStyle() const
+LLStyle::Params LLUrlEntryAgentName::getStyle(const std::string &url) const
{
// don't override default colors
return LLStyle::Params().is_link(false);
@@ -967,9 +1002,9 @@ std::string LLUrlEntryGroup::getLabel(const std::string &url, const LLUrlLabelCa
}
}
-LLStyle::Params LLUrlEntryGroup::getStyle() const
+LLStyle::Params LLUrlEntryGroup::getStyle(const std::string &url) const
{
- LLStyle::Params style_params = LLUrlEntryBase::getStyle();
+ LLStyle::Params style_params = LLUrlEntryBase::getStyle(url);
style_params.color = LLUIColorTable::instance().getColor("HTMLLinkColor");
style_params.readonly_color = LLUIColorTable::instance().getColor("HTMLLinkColor");
return style_params;
@@ -1045,7 +1080,6 @@ std::string LLUrlEntryChat::getLabel(const std::string &url, const LLUrlLabelCal
}
// LLUrlEntryParcel statics.
-LLUUID LLUrlEntryParcel::sAgentID(LLUUID::null);
LLUUID LLUrlEntryParcel::sSessionID(LLUUID::null);
LLHost LLUrlEntryParcel::sRegionHost;
bool LLUrlEntryParcel::sDisconnected(false);
@@ -1379,17 +1413,17 @@ std::string LLUrlEntrySLLabel::getTooltip(const std::string &string) const
return LLUrlEntryBase::getTooltip(string);
}
-bool LLUrlEntrySLLabel::underlineOnHoverOnly(const std::string &string) const
+LLStyle::EUnderlineLink LLUrlEntrySLLabel::getUnderline(const std::string& string) const
{
std::string url = getUrl(string);
- LLUrlMatch match;
+ LLUrlMatch match;
if (LLUrlRegistry::instance().findUrl(url, match))
{
- return match.underlineOnHoverOnly();
+ return match.getUnderline();
}
// unrecognized URL? should not happen
- return LLUrlEntryBase::underlineOnHoverOnly(string);
+ return LLUrlEntryBase::getUnderline(string);
}
//
@@ -1453,7 +1487,7 @@ std::string LLUrlEntryNoLink::getLabel(const std::string &url, const LLUrlLabelC
return getUrl(url);
}
-LLStyle::Params LLUrlEntryNoLink::getStyle() const
+LLStyle::Params LLUrlEntryNoLink::getStyle(const std::string &url) const
{
// Don't render as URL (i.e. no context menu or hand cursor).
return LLStyle::Params().is_link(false);
diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h
index 84ff278942..6e7d2fc80f 100644
--- a/indra/llui/llurlentry.h
+++ b/indra/llui/llurlentry.h
@@ -85,7 +85,7 @@ public:
virtual std::string getIcon(const std::string &url);
/// Return the style to render the displayed text
- virtual LLStyle::Params getStyle() const;
+ virtual LLStyle::Params getStyle(const std::string &url) const;
/// Given a matched Url, return a tooltip string for the hyperlink
virtual std::string getTooltip(const std::string &string) const { return mTooltip; }
@@ -96,12 +96,14 @@ public:
/// Return the name of a SL location described by this Url, if any
virtual std::string getLocation(const std::string &url) const { return ""; }
- /// Should this link text be underlined only when mouse is hovered over it?
- virtual bool underlineOnHoverOnly(const std::string &string) const { return false; }
+ virtual LLStyle::EUnderlineLink getUnderline(const std::string& string) const { return LLStyle::EUnderlineLink::UNDERLINE_ALWAYS; }
virtual bool isTrusted() const { return false; }
+ virtual bool getSkipProfileIcon(const std::string& string) const { return false; }
+
virtual LLUUID getID(const std::string &string) const { return LLUUID::null; }
+ virtual bool isAgentID(const std::string& url) const { return false; }
bool isLinkDisabled() const;
@@ -109,6 +111,8 @@ public:
virtual bool isSLURLvalid(const std::string &url) const { return true; };
+ static void setAgentID(const LLUUID& id) { sAgentID = id; }
+
protected:
std::string getIDStringFromUrl(const std::string &url) const;
std::string escapeUrl(const std::string &url) const;
@@ -130,6 +134,8 @@ protected:
std::string mMenuName;
std::string mTooltip;
std::multimap<std::string, LLUrlEntryObserver> mObservers;
+
+ static LLUUID sAgentID;
};
///
@@ -224,19 +230,36 @@ public:
/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
/*virtual*/ std::string getIcon(const std::string &url);
/*virtual*/ std::string getTooltip(const std::string &string) const;
- /*virtual*/ LLStyle::Params getStyle() const;
+ /*virtual*/ LLStyle::Params getStyle(const std::string &url) const;
/*virtual*/ LLUUID getID(const std::string &string) const;
- /*virtual*/ bool underlineOnHoverOnly(const std::string &string) const;
+
+ bool isAgentID(const std::string& url) const;
+
+ LLStyle::EUnderlineLink getUnderline(const std::string& string) const;
+
protected:
/*virtual*/ void callObservers(const std::string &id, const std::string &label, const std::string& icon);
private:
void onAvatarNameCache(const LLUUID& id, const LLAvatarName& av_name);
- typedef std::map<LLUUID, boost::signals2::connection> avatar_name_cache_connection_map_t;
+ typedef std::multimap<LLUUID, boost::signals2::connection> avatar_name_cache_connection_map_t;
avatar_name_cache_connection_map_t mAvatarNameCacheConnections;
};
///
+/// LLUrlEntryAgentMention Describes a chat mention Url, e.g.,
+/// secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/mention
+class LLUrlEntryAgentMention : public LLUrlEntryAgent
+{
+public:
+ LLUrlEntryAgentMention();
+
+ LLStyle::Params getStyle(const std::string& url) const;
+ LLStyle::EUnderlineLink getUnderline(const std::string& string) const;
+ bool getSkipProfileIcon(const std::string& string) const { return true; };
+};
+
+///
/// LLUrlEntryAgentName Describes a Second Life agent name Url, e.g.,
/// secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/(completename|displayname|username)
/// that displays various forms of user name
@@ -257,14 +280,14 @@ public:
mAvatarNameCacheConnections.clear();
}
/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
- /*virtual*/ LLStyle::Params getStyle() const;
+ /*virtual*/ LLStyle::Params getStyle(const std::string &url) const;
protected:
// override this to pull out relevant name fields
virtual std::string getName(const LLAvatarName& avatar_name) = 0;
private:
void onAvatarNameCache(const LLUUID& id, const LLAvatarName& av_name);
- typedef std::map<LLUUID, boost::signals2::connection> avatar_name_cache_connection_map_t;
+ typedef std::multimap<LLUUID, boost::signals2::connection> avatar_name_cache_connection_map_t;
avatar_name_cache_connection_map_t mAvatarNameCacheConnections;
};
@@ -339,7 +362,7 @@ class LLUrlEntryGroup : public LLUrlEntryBase
public:
LLUrlEntryGroup();
/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
- /*virtual*/ LLStyle::Params getStyle() const;
+ /*virtual*/ LLStyle::Params getStyle(const std::string &url) const;
/*virtual*/ LLUUID getID(const std::string &string) const;
private:
void onGroupNameReceived(const LLUUID& id, const std::string& name, bool is_group);
@@ -411,17 +434,15 @@ public:
// Processes parcel label and triggers notifying observers.
static void processParcelInfo(const LLParcelData& parcel_data);
- // Next 4 setters are used to update agent and viewer connection information
+ // Next setters are used to update agent and viewer connection information
// upon events like user login, viewer disconnect and user changing region host.
// These setters are made public to be accessible from newview and should not be
// used in other cases.
- static void setAgentID(const LLUUID& id) { sAgentID = id; }
static void setSessionID(const LLUUID& id) { sSessionID = id; }
static void setRegionHost(const LLHost& host) { sRegionHost = host; }
static void setDisconnected(bool disconnected) { sDisconnected = disconnected; }
private:
- static LLUUID sAgentID;
static LLUUID sSessionID;
static LLHost sRegionHost;
static bool sDisconnected;
@@ -486,7 +507,7 @@ public:
/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
/*virtual*/ std::string getUrl(const std::string &string) const;
/*virtual*/ std::string getTooltip(const std::string &string) const;
- /*virtual*/ bool underlineOnHoverOnly(const std::string &string) const;
+ LLStyle::EUnderlineLink getUnderline(const std::string& string) const;
};
///
@@ -510,7 +531,7 @@ public:
LLUrlEntryNoLink();
/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
/*virtual*/ std::string getUrl(const std::string &string) const;
- /*virtual*/ LLStyle::Params getStyle() const;
+ /*virtual*/ LLStyle::Params getStyle(const std::string &url) const;
};
///
diff --git a/indra/llui/llurlmatch.cpp b/indra/llui/llurlmatch.cpp
index bfa3b167b1..f093934ca9 100644
--- a/indra/llui/llurlmatch.cpp
+++ b/indra/llui/llurlmatch.cpp
@@ -37,8 +37,9 @@ LLUrlMatch::LLUrlMatch() :
mIcon(""),
mMenuName(""),
mLocation(""),
- mUnderlineOnHoverOnly(false),
- mTrusted(false)
+ mUnderline(e_underline::UNDERLINE_ALWAYS),
+ mTrusted(false),
+ mSkipProfileIcon(false)
{
}
@@ -46,7 +47,7 @@ void LLUrlMatch::setValues(U32 start, U32 end, const std::string &url, const std
const std::string& query, const std::string &tooltip,
const std::string &icon, const LLStyle::Params& style,
const std::string &menu, const std::string &location,
- const LLUUID& id, bool underline_on_hover_only, bool trusted)
+ const LLUUID& id, e_underline underline, bool trusted, bool skip_icon)
{
mStart = start;
mEnd = end;
@@ -60,6 +61,7 @@ void LLUrlMatch::setValues(U32 start, U32 end, const std::string &url, const std
mMenuName = menu;
mLocation = location;
mID = id;
- mUnderlineOnHoverOnly = underline_on_hover_only;
+ mUnderline = underline;
mTrusted = trusted;
+ mSkipProfileIcon = skip_icon;
}
diff --git a/indra/llui/llurlmatch.h b/indra/llui/llurlmatch.h
index ba822fbda6..418a21f963 100644
--- a/indra/llui/llurlmatch.h
+++ b/indra/llui/llurlmatch.h
@@ -31,7 +31,6 @@
//#include "linden_common.h"
#include <string>
-#include <vector>
#include "llstyle.h"
///
@@ -80,18 +79,20 @@ public:
/// return the SL location that this Url describes, or "" if none.
std::string getLocation() const { return mLocation; }
- /// Should this link text be underlined only when mouse is hovered over it?
- bool underlineOnHoverOnly() const { return mUnderlineOnHoverOnly; }
+ typedef LLStyle::EUnderlineLink e_underline;
+ e_underline getUnderline() const { return mUnderline; }
/// Return true if Url is trusted.
bool isTrusted() const { return mTrusted; }
+ bool getSkipProfileIcon() const { return mSkipProfileIcon; }
+
/// Change the contents of this match object (used by LLUrlRegistry)
void setValues(U32 start, U32 end, const std::string &url, const std::string &label,
const std::string& query, const std::string &tooltip, const std::string &icon,
const LLStyle::Params& style, const std::string &menu,
const std::string &location, const LLUUID& id,
- bool underline_on_hover_only = false, bool trusted = false);
+ e_underline underline = e_underline::UNDERLINE_ALWAYS, bool trusted = false, bool skip_icon = false);
const LLUUID& getID() const { return mID; }
private:
@@ -106,8 +107,9 @@ private:
std::string mLocation;
LLUUID mID;
LLStyle::Params mStyle;
- bool mUnderlineOnHoverOnly;
+ e_underline mUnderline;
bool mTrusted;
+ bool mSkipProfileIcon;
};
#endif
diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp
index 3a4ce6a72f..cb101d325d 100644
--- a/indra/llui/llurlregistry.cpp
+++ b/indra/llui/llurlregistry.cpp
@@ -62,6 +62,8 @@ LLUrlRegistry::LLUrlRegistry()
registerUrl(new LLUrlEntryAgentUserName());
// LLUrlEntryAgent*Name must appear before LLUrlEntryAgent since
// LLUrlEntryAgent is a less specific (catchall for agent urls)
+ mUrlEntryAgentMention = new LLUrlEntryAgentMention();
+ registerUrl(mUrlEntryAgentMention);
registerUrl(new LLUrlEntryAgent());
registerUrl(new LLUrlEntryChat());
registerUrl(new LLUrlEntryGroup());
@@ -155,7 +157,7 @@ static bool stringHasUrl(const std::string &text)
text.find("@") != std::string::npos);
}
-bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LLUrlLabelCallback &cb, bool is_content_trusted)
+bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LLUrlLabelCallback &cb, bool is_content_trusted, bool skip_non_mentions)
{
// avoid costly regexes if there is clearly no URL in the text
if (! stringHasUrl(text))
@@ -176,6 +178,11 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL
continue;
}
+ if (skip_non_mentions && (mUrlEntryAgentMention != *it))
+ {
+ continue;
+ }
+
LLUrlEntryBase *url_entry = *it;
U32 start = 0, end = 0;
@@ -221,7 +228,7 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL
if (match_entry == mUrlEntryTrusted)
{
LLUriParser up(url);
- if (up.normalize() == 0)
+ if (up.normalize())
{
url = up.normalizedUri();
}
@@ -233,12 +240,13 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL
match_entry->getQuery(url),
match_entry->getTooltip(url),
match_entry->getIcon(url),
- match_entry->getStyle(),
+ match_entry->getStyle(url),
match_entry->getMenuName(),
match_entry->getLocation(url),
match_entry->getID(url),
- match_entry->underlineOnHoverOnly(url),
- match_entry->isTrusted());
+ match_entry->getUnderline(url),
+ match_entry->isTrusted(),
+ match_entry->getSkipProfileIcon(url));
return true;
}
@@ -274,7 +282,9 @@ bool LLUrlRegistry::findUrl(const LLWString &text, LLUrlMatch &match, const LLUr
match.getMenuName(),
match.getLocation(),
match.getID(),
- match.underlineOnHoverOnly());
+ match.getUnderline(),
+ false,
+ match.getSkipProfileIcon());
return true;
}
return false;
@@ -317,3 +327,30 @@ void LLUrlRegistry::setKeybindingHandler(LLKeyBindingToStringHandler* handler)
LLUrlEntryKeybinding *entry = (LLUrlEntryKeybinding*)mUrlEntryKeybinding;
entry->setHandler(handler);
}
+
+bool LLUrlRegistry::containsAgentMention(const std::string& text)
+{
+ // avoid costly regexes if there is clearly no URL in the text
+ if (!stringHasUrl(text))
+ {
+ return false;
+ }
+
+ try
+ {
+ boost::sregex_iterator it(text.begin(), text.end(), mUrlEntryAgentMention->getPattern());
+ boost::sregex_iterator end;
+ for (; it != end; ++it)
+ {
+ if (mUrlEntryAgentMention->isAgentID(it->str()))
+ {
+ return true;
+ }
+ }
+ }
+ catch (boost::regex_error&)
+ {
+ LL_INFOS() << "Regex error for: " << text << LL_ENDL;
+ }
+ return false;
+}
diff --git a/indra/llui/llurlregistry.h b/indra/llui/llurlregistry.h
index 64cfec3960..592e422487 100644
--- a/indra/llui/llurlregistry.h
+++ b/indra/llui/llurlregistry.h
@@ -34,7 +34,6 @@
#include "llstring.h"
#include <string>
-#include <vector>
class LLKeyBindingToStringHandler;
@@ -76,7 +75,7 @@ public:
/// your callback is invoked if the matched Url's label changes in the future
bool findUrl(const std::string &text, LLUrlMatch &match,
const LLUrlLabelCallback &cb = &LLUrlRegistryNullCallback,
- bool is_content_trusted = false);
+ bool is_content_trusted = false, bool skip_non_mentions = false);
/// a slightly less efficient version of findUrl for wide strings
bool findUrl(const LLWString &text, LLUrlMatch &match,
@@ -93,6 +92,8 @@ public:
// Set handler for url registry to be capable of parsing and populating keybindings
void setKeybindingHandler(LLKeyBindingToStringHandler* handler);
+ bool containsAgentMention(const std::string& text);
+
private:
std::vector<LLUrlEntryBase *> mUrlEntry;
LLUrlEntryBase* mUrlEntryTrusted;
@@ -102,6 +103,7 @@ private:
LLUrlEntryBase* mUrlEntrySLLabel;
LLUrlEntryBase* mUrlEntryNoLink;
LLUrlEntryBase* mUrlEntryKeybinding;
+ LLUrlEntryBase* mUrlEntryAgentMention;
};
#endif
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index 1e72228fee..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() )
@@ -1080,31 +1080,12 @@ bool LLView::handleUnicodeChar(llwchar uni_char, bool called_from_parent)
return handled;
}
-bool LLView::handleUnicodeString(char *uni_str, bool editing, bool called_from_parent)
-{
- auto handled = FALSE;
-
- if (getVisible() && getEnabled() && !handled) {
- handled = handleUnicodeStringHere(uni_str, editing);
- if (handled && LLView::sDebugKeys)
- LL_INFOS() << "Unicode key handled by " << getName() << LL_ENDL;
- }
-
- if (!handled && !called_from_parent && mParentView)
- handled = mParentView->handleUnicodeString(uni_str, editing, FALSE);
-
- return handled;
-}
bool LLView::handleUnicodeCharHere(llwchar uni_char )
{
return false;
}
-bool LLView::handleUnicodeStringHere(char *uni_str, bool editing)
-{
- return FALSE;
-}
bool LLView::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop,
EDragAndDropType cargo_type, void* cargo_data,
@@ -1632,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());
@@ -1651,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;
}
@@ -1659,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;
@@ -2331,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;
@@ -2350,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 ad3b71505d..97212a9d2d 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -54,17 +54,17 @@
class LLSD;
-const U32 FOLLOWS_NONE = 0x00;
-const U32 FOLLOWS_LEFT = 0x01;
-const U32 FOLLOWS_RIGHT = 0x02;
-const U32 FOLLOWS_TOP = 0x10;
-const U32 FOLLOWS_BOTTOM = 0x20;
-const U32 FOLLOWS_ALL = 0x33;
+constexpr U32 FOLLOWS_NONE = 0x00;
+constexpr U32 FOLLOWS_LEFT = 0x01;
+constexpr U32 FOLLOWS_RIGHT = 0x02;
+constexpr U32 FOLLOWS_TOP = 0x10;
+constexpr U32 FOLLOWS_BOTTOM = 0x20;
+constexpr U32 FOLLOWS_ALL = 0x33;
-const bool MOUSE_OPAQUE = true;
-const bool NOT_MOUSE_OPAQUE = false;
+constexpr bool MOUSE_OPAQUE = true;
+constexpr bool NOT_MOUSE_OPAQUE = false;
-const U32 GL_NAME_UI_RESERVED = 2;
+constexpr U32 GL_NAME_UI_RESERVED = 2;
// maintains render state during traversal of UI tree
@@ -241,7 +241,7 @@ public:
void setUseBoundingRect( bool use_bounding_rect );
bool getUseBoundingRect() const;
- ECursorType getHoverCursor() { return mHoverCursor; }
+ ECursorType getHoverCursor() const { return mHoverCursor; }
static F32 getTooltipTimeout();
virtual const std::string getToolTip() const;
@@ -265,7 +265,7 @@ public:
void setDefaultTabGroup(S32 d) { mDefaultTabGroup = d; }
S32 getDefaultTabGroup() const { return mDefaultTabGroup; }
- S32 getLastTabGroup() { return mLastTabGroup; }
+ S32 getLastTabGroup() const { return mLastTabGroup; }
bool isInVisibleChain() const;
bool isInEnabledChain() const;
@@ -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;
@@ -385,7 +385,6 @@ public:
/* virtual */ bool handleKey(KEY key, MASK mask, bool called_from_parent);
/* virtual */ bool handleKeyUp(KEY key, MASK mask, bool called_from_parent);
/* virtual */ bool handleUnicodeChar(llwchar uni_char, bool called_from_parent);
- /* virtual */ bool handleUnicodeString(char *uni_str, bool editing, bool called_from_parent);
virtual bool handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop,
EDragAndDropType cargo_type,
@@ -417,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(); }
@@ -453,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);
@@ -519,7 +518,6 @@ public:
virtual bool handleKeyHere(KEY key, MASK mask);
virtual bool handleKeyUpHere(KEY key, MASK mask);
virtual bool handleUnicodeCharHere(llwchar uni_char);
- virtual bool handleUnicodeStringHere(char *uni_str, bool editing);
virtual void handleReshape(const LLRect& rect, bool by_user);
virtual void dirtyRect();
@@ -578,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()
@@ -698,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);
@@ -733,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/llviewborder.cpp b/indra/llui/llviewborder.cpp
index c1777c972c..d53fd6eb91 100644
--- a/indra/llui/llviewborder.cpp
+++ b/indra/llui/llviewborder.cpp
@@ -73,14 +73,14 @@ LLViewBorder::LLViewBorder(const LLViewBorder::Params& p)
mStyle(p.render_style)
{}
-void LLViewBorder::setColors( const LLColor4& shadow_dark, const LLColor4& highlight_light )
+void LLViewBorder::setColors( const LLUIColor& shadow_dark, const LLUIColor& highlight_light )
{
mShadowDark = shadow_dark;
mHighlightLight = highlight_light;
}
-void LLViewBorder::setColorsExtended( const LLColor4& shadow_light, const LLColor4& shadow_dark,
- const LLColor4& highlight_light, const LLColor4& highlight_dark )
+void LLViewBorder::setColorsExtended( const LLUIColor& shadow_light, const LLUIColor& shadow_dark,
+ const LLUIColor& highlight_light, const LLUIColor& highlight_dark )
{
mShadowDark = shadow_dark;
mShadowLight = shadow_light;
diff --git a/indra/llui/llviewborder.h b/indra/llui/llviewborder.h
index be499bb534..a4bb748b77 100644
--- a/indra/llui/llviewborder.h
+++ b/indra/llui/llviewborder.h
@@ -77,9 +77,9 @@ public:
S32 getBorderWidth() const { return mBorderWidth; }
void setBevel(EBevel bevel) { mBevel = bevel; }
EBevel getBevel() const { return mBevel; }
- void setColors( const LLColor4& shadow_dark, const LLColor4& highlight_light );
- void setColorsExtended( const LLColor4& shadow_light, const LLColor4& shadow_dark,
- const LLColor4& highlight_light, const LLColor4& highlight_dark );
+ void setColors( const LLUIColor& shadow_dark, const LLUIColor& highlight_light );
+ void setColorsExtended( const LLUIColor& shadow_light, const LLUIColor& shadow_dark,
+ const LLUIColor& highlight_light, const LLUIColor& highlight_dark );
void setTexture( const class LLUUID &image_id );
LLColor4 getHighlightLight() {return mHighlightLight.get();}
@@ -92,7 +92,6 @@ public:
private:
void drawOnePixelLines();
void drawTwoPixelLines();
- void drawTextures();
EBevel mBevel;
EStyle mStyle;
diff --git a/indra/llui/llviewereventrecorder.cpp b/indra/llui/llviewereventrecorder.cpp
index 1bf3e3c43b..6d907d7e45 100644
--- a/indra/llui/llviewereventrecorder.cpp
+++ b/indra/llui/llviewereventrecorder.cpp
@@ -98,6 +98,7 @@ void LLViewerEventRecorder::setMouseGlobalCoords(S32 x, S32 y) {
}
void LLViewerEventRecorder::updateMouseEventInfo(S32 local_x, S32 local_y, S32 global_x, S32 global_y, std::string mName) {
+ if (!logEvents) return;
LLView * target_view = LLUI::getInstance()->resolvePath(LLUI::getInstance()->getRootView(), xui);
if (! target_view) {
@@ -126,6 +127,8 @@ void LLViewerEventRecorder::updateMouseEventInfo(S32 local_x, S32 local_y, S32 g
void LLViewerEventRecorder::logVisibilityChange(std::string xui, std::string name, bool visibility, std::string event_subtype) {
+ if (!logEvents) return;
+
LLSD event=LLSD::emptyMap();
event.insert("event",LLSD(std::string("visibility")));
@@ -167,6 +170,7 @@ void LLViewerEventRecorder::update_xui(std::string xui) {
void LLViewerEventRecorder::logKeyEvent(KEY key, MASK mask) {
+ if (!logEvents) return;
// NOTE: Event recording only logs keydown events - the viewer itself hides keyup events at a fairly low level in the code and does not appear to care about them anywhere
LLSD event = LLSD::emptyMap();
@@ -257,7 +261,7 @@ void LLViewerEventRecorder::logKeyUnicodeEvent(llwchar uni_char) {
event.insert("event",LLSD("keyDown"));
- LL_DEBUGS() << "[VITA] unicode key: " << uni_char << LL_ENDL;
+ LL_DEBUGS() << "[VITA] unicode key: " << (int)uni_char << LL_ENDL;
LL_DEBUGS() << "[VITA] dumpxml " << LLSDXMLStreamer(event) << "\n" << LL_ENDL;
diff --git a/indra/llui/llviewereventrecorder.h b/indra/llui/llviewereventrecorder.h
index 9e752e8090..5636c068d8 100644
--- a/indra/llui/llviewereventrecorder.h
+++ b/indra/llui/llviewereventrecorder.h
@@ -61,7 +61,7 @@ public:
std::string get_xui();
void update_xui(std::string xui);
- bool getLoggingStatus(){return logEvents;};
+ bool getLoggingStatus() const { return logEvents; }
void setEventLoggingOn();
void setEventLoggingOff();
diff --git a/indra/llui/llviewmodel.cpp b/indra/llui/llviewmodel.cpp
index 93106b344f..35963c2b99 100644
--- a/indra/llui/llviewmodel.cpp
+++ b/indra/llui/llviewmodel.cpp
@@ -82,11 +82,20 @@ void LLTextViewModel::setValue(const LLSD& value)
// approximate LLSD storage usage
LLViewModel::setValue(value);
mDisplay = utf8str_to_wstring(mStringValue = value.asString());
+ mDisplayGeneration++;
// mDisplay and mValue agree
mUpdateFromDisplay = false;
}
+LLWString& LLTextViewModel::getEditableDisplay()
+{
+ mDirty = true;
+ mDisplayGeneration++;
+ mUpdateFromDisplay = true;
+ return mDisplay;
+}
+
void LLTextViewModel::setDisplay(const LLWString& value)
{
// This is the strange way to alter the value. Normally we'd setValue()
@@ -94,6 +103,7 @@ void LLTextViewModel::setDisplay(const LLWString& value)
// value. But a text editor might want to edit the display string
// directly, then convert back to UTF8 on commit.
mDisplay = value;
+ mDisplayGeneration++;
mDirty = true;
// Don't immediately convert to UTF8 -- do it lazily -- we expect many
// more setDisplay() calls than getValue() calls. Just flag that it needs
diff --git a/indra/llui/llviewmodel.h b/indra/llui/llviewmodel.h
index 6cf2200a81..16b0800ce2 100644
--- a/indra/llui/llviewmodel.h
+++ b/indra/llui/llviewmodel.h
@@ -105,7 +105,8 @@ public:
// New functions
/// Get the stored value in string form
const LLWString& getDisplay() const { return mDisplay; }
- LLWString& getEditableDisplay() { mDirty = true; mUpdateFromDisplay = true; return mDisplay; }
+ S32 getDisplayGeneration() const { return mDisplayGeneration; }
+ LLWString& getEditableDisplay();
/**
* Set the display string directly (see LLTextEditor). What the user is
@@ -120,6 +121,7 @@ private:
/// To avoid converting every widget's stored value from LLSD to LLWString
/// every frame, cache the converted value
LLWString mDisplay;
+ S32 mDisplayGeneration = -1;
/// As the user edits individual characters (setDisplay()), defer
/// LLWString-to-UTF8 conversions until s/he's done.
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/llvirtualtrackball.h b/indra/llui/llvirtualtrackball.h
index 61a78b2398..fbfda04585 100644
--- a/indra/llui/llvirtualtrackball.h
+++ b/indra/llui/llvirtualtrackball.h
@@ -78,20 +78,20 @@ public:
};
- virtual ~LLVirtualTrackball();
- /*virtual*/ bool postBuild();
+ ~LLVirtualTrackball() override;
+ bool postBuild() override;
- virtual bool handleHover(S32 x, S32 y, MASK mask);
- virtual bool handleMouseUp(S32 x, S32 y, MASK mask);
- virtual bool handleMouseDown(S32 x, S32 y, MASK mask);
- virtual bool handleRightMouseDown(S32 x, S32 y, MASK mask);
- virtual bool handleKeyHere(KEY key, MASK mask);
+ bool handleHover(S32 x, S32 y, MASK mask) override;
+ bool handleMouseUp(S32 x, S32 y, MASK mask) override;
+ bool handleMouseDown(S32 x, S32 y, MASK mask) override;
+ bool handleRightMouseDown(S32 x, S32 y, MASK mask) override;
+ bool handleKeyHere(KEY key, MASK mask) override;
- virtual void draw();
+ void draw() override;
- virtual void setValue(const LLSD& value);
- void setValue(F32 x, F32 y, F32 z, F32 w);
- virtual LLSD getValue() const;
+ void setValue(const LLSD& value) override;
+ void setValue(F32 x, F32 y, F32 z, F32 w);
+ LLSD getValue() const override;
void setRotation(const LLQuaternion &value);
LLQuaternion getRotation() const;
@@ -102,7 +102,6 @@ public:
protected:
friend class LLUICtrlFactory;
LLVirtualTrackball(const Params&);
- void onEditChange();
protected:
LLTextBox* mNLabel;
diff --git a/indra/llui/llwindowshade.cpp b/indra/llui/llwindowshade.cpp
index e48bc94b0a..8131a56288 100644
--- a/indra/llui/llwindowshade.cpp
+++ b/indra/llui/llwindowshade.cpp
@@ -81,8 +81,8 @@ void LLWindowShade::initFromParams(const LLWindowShade::Params& params)
panel_p.background_visible = true;
panel_p.bg_alpha_image = params.bg_image;
panel_p.auto_resize = false;
- LLLayoutPanel* notification_panel = LLUICtrlFactory::create<LLLayoutPanel>(panel_p);
- stackp->addChild(notification_panel);
+ mNotificationsArea = LLUICtrlFactory::create<LLLayoutPanel>(panel_p);
+ stackp->addChild(mNotificationsArea);
panel_p = LLUICtrlFactory::getDefaultParams<LLLayoutPanel>();
panel_p.auto_resize = true;
@@ -92,15 +92,15 @@ void LLWindowShade::initFromParams(const LLWindowShade::Params& params)
panel_p.mouse_opaque = false;
panel_p.background_visible = false;
panel_p.bg_alpha_color = params.shade_color;
- LLLayoutPanel* dummy_panel = LLUICtrlFactory::create<LLLayoutPanel>(panel_p);
- stackp->addChild(dummy_panel);
+ mBackgroundArea = LLUICtrlFactory::create<LLLayoutPanel>(panel_p);
+ stackp->addChild(mBackgroundArea);
layout_p = LLUICtrlFactory::getDefaultParams<LLLayoutStack>();
layout_p.rect = LLRect(0, 30, 800, 0);
layout_p.follows.flags = FOLLOWS_ALL;
layout_p.orientation = LLLayoutStack::HORIZONTAL;
stackp = LLUICtrlFactory::create<LLLayoutStack>(layout_p);
- notification_panel->addChild(stackp);
+ mNotificationsArea->addChild(stackp);
panel_p = LLUICtrlFactory::getDefaultParams<LLLayoutPanel>();
panel_p.rect.height = 30;
@@ -121,7 +121,8 @@ void LLWindowShade::initFromParams(const LLWindowShade::Params& params)
text_p.name = "notification_text";
text_p.use_ellipses = true;
text_p.wrap = true;
- panel->addChild(LLUICtrlFactory::create<LLTextBox>(text_p));
+ mNotificationsText = LLUICtrlFactory::create<LLTextBox>(text_p);
+ panel->addChild(mNotificationsText);
panel_p = LLUICtrlFactory::getDefaultParams<LLLayoutPanel>();
panel_p.auto_resize = false;
@@ -154,11 +155,9 @@ void LLWindowShade::initFromParams(const LLWindowShade::Params& params)
void LLWindowShade::draw()
{
- LLRect message_rect = getChild<LLTextBox>("notification_text")->getTextBoundingRect();
+ LLRect message_rect = mNotificationsText->getTextBoundingRect();
- LLLayoutPanel* notification_area = getChild<LLLayoutPanel>("notification_area");
-
- notification_area->reshape(notification_area->getRect().getWidth(),
+ mNotificationsArea->reshape(mNotificationsArea->getRect().getWidth(),
llclamp(message_rect.getHeight() + 15,
llmax(mFormHeight, MIN_NOTIFICATION_AREA_HEIGHT),
MAX_NOTIFICATION_AREA_HEIGHT));
@@ -176,21 +175,21 @@ void LLWindowShade::draw()
{
hide();
}
- else if (notification_area->getVisibleAmount() < 0.01f)
+ else if (mNotificationsArea->getVisibleAmount() < 0.01f)
{
displayLatestNotification();
}
- if (!notification_area->getVisible() && (notification_area->getVisibleAmount() < 0.001f))
+ if (!mNotificationsArea->getVisible() && (mNotificationsArea->getVisibleAmount() < 0.001f))
{
- getChildRef<LLLayoutPanel>("background_area").setBackgroundVisible(false);
+ mBackgroundArea->setBackgroundVisible(false);
setMouseOpaque(false);
}
}
void LLWindowShade::hide()
{
- getChildRef<LLLayoutPanel>("notification_area").setVisible(false);
+ mNotificationsArea->setVisible(false);
}
void LLWindowShade::onCloseNotification()
@@ -244,13 +243,12 @@ void LLWindowShade::displayLatestNotification()
LLSD payload = notification->getPayload();
LLNotificationFormPtr formp = notification->getForm();
- LLLayoutPanel& notification_area = getChildRef<LLLayoutPanel>("notification_area");
- notification_area.getChild<LLUICtrl>("notification_icon")->setValue(notification->getIcon());
- notification_area.getChild<LLUICtrl>("notification_text")->setValue(notification->getMessage());
- notification_area.getChild<LLUICtrl>("notification_text")->setToolTip(notification->getMessage());
+ mNotificationsArea->getChild<LLUICtrl>("notification_icon")->setValue(notification->getIcon());
+ mNotificationsText->setValue(notification->getMessage());
+ mNotificationsText->setToolTip(notification->getMessage());
LLNotificationForm::EIgnoreType ignore_type = formp->getIgnoreType();
- LLLayoutPanel& form_elements = notification_area.getChildRef<LLLayoutPanel>("form_elements");
+ LLLayoutPanel& form_elements = mNotificationsArea->getChildRef<LLLayoutPanel>("form_elements");
form_elements.deleteAllChildren();
form_elements.reshape(form_elements.getRect().getWidth(), MIN_NOTIFICATION_AREA_HEIGHT);
@@ -355,25 +353,25 @@ void LLWindowShade::displayLatestNotification()
(*it)->translate(0, delta_y);
}
- getChildRef<LLLayoutPanel>("notification_area").setVisible(true);
- getChildRef<LLLayoutPanel>("background_area").setBackgroundVisible(mModal);
+ mNotificationsArea->setVisible(true);
+ mBackgroundArea->setBackgroundVisible(mModal);
setMouseOpaque(mModal);
}
void LLWindowShade::setBackgroundImage(LLUIImage* image)
{
- getChild<LLLayoutPanel>("notification_area")->setTransparentImage(image);
+ mNotificationsArea->setTransparentImage(image);
}
void LLWindowShade::setTextColor(LLColor4 color)
{
- getChild<LLTextBox>("notification_text")->setColor(color);
+ mNotificationsText->setColor(color);
}
bool LLWindowShade::isShown() const
{
- return getChildRef<LLLayoutPanel>("notification_area").getVisible();
+ return mNotificationsArea->getVisible();
}
void LLWindowShade::setCanClose(bool can_close)
diff --git a/indra/llui/llwindowshade.h b/indra/llui/llwindowshade.h
index a401394d78..ee230cd2f6 100644
--- a/indra/llui/llwindowshade.h
+++ b/indra/llui/llwindowshade.h
@@ -31,6 +31,9 @@
#include "llnotifications.h"
#include "lluiimage.h"
+class LLLayoutPanel;
+class LLTextBox;
+
class LLWindowShade : public LLUICtrl
{
public:
@@ -46,7 +49,7 @@ public:
};
void show(LLNotificationPtr);
- /*virtual*/ void draw();
+ void draw() override;
void hide();
bool isShown() const;
@@ -68,6 +71,10 @@ private:
void onEnterNotificationText(LLUICtrl* ctrl, const std::string& name);
void onClickIgnore(LLUICtrl* ctrl);
+ LLLayoutPanel* mBackgroundArea = nullptr;
+ LLLayoutPanel* mNotificationsArea = nullptr;
+ LLTextBox* mNotificationsText = nullptr;
+
std::vector<LLNotificationPtr> mNotifications;
LLSD mNotificationResponse;
bool mModal;
diff --git a/indra/llui/llxuiparser.cpp b/indra/llui/llxuiparser.cpp
index 8fd85a89a1..8cd11b86b3 100644
--- a/indra/llui/llxuiparser.cpp
+++ b/indra/llui/llxuiparser.cpp
@@ -30,7 +30,7 @@
#include "llxmlnode.h"
#include "llfasttimer.h"
-#ifdef LL_USESYSTEMLIBS
+#if 1
#include <expat.h>
#else
#include "expat/expat.h"
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());
}
}
diff --git a/indra/llui/llxyvector.h b/indra/llui/llxyvector.h
index bc41213c13..646771f387 100644
--- a/indra/llui/llxyvector.h
+++ b/indra/llui/llxyvector.h
@@ -65,18 +65,18 @@ public:
};
- virtual ~LLXYVector();
- /*virtual*/ bool postBuild();
+ ~LLXYVector() override;
+ bool postBuild() override;
- virtual bool handleHover(S32 x, S32 y, MASK mask);
- virtual bool handleMouseUp(S32 x, S32 y, MASK mask);
- virtual bool handleMouseDown(S32 x, S32 y, MASK mask);
+ bool handleHover(S32 x, S32 y, MASK mask) override;
+ bool handleMouseUp(S32 x, S32 y, MASK mask) override;
+ bool handleMouseDown(S32 x, S32 y, MASK mask) override;
- virtual void draw();
+ void draw() override;
- virtual void setValue(const LLSD& value);
- void setValue(F32 x, F32 y);
- virtual LLSD getValue() const;
+ void setValue(const LLSD& value) override;
+ void setValue(F32 x, F32 y);
+ LLSD getValue() const override;
protected:
friend class LLUICtrlFactory;