summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/CMakeLists.txt4
-rw-r--r--indra/llui/llaccordionctrl.cpp330
-rw-r--r--indra/llui/llaccordionctrl.h2
-rw-r--r--indra/llui/llaccordionctrltab.cpp371
-rw-r--r--indra/llui/llaccordionctrltab.h12
-rw-r--r--indra/llui/llbutton.cpp26
-rw-r--r--indra/llui/llbutton.h5
-rw-r--r--indra/llui/llcommandmanager.cpp4
-rw-r--r--indra/llui/llemojidictionary.cpp469
-rw-r--r--indra/llui/llemojidictionary.h126
-rw-r--r--indra/llui/llemojihelper.cpp169
-rw-r--r--indra/llui/llemojihelper.h66
-rw-r--r--indra/llui/llfiltereditor.h1
-rw-r--r--indra/llui/llflatlistview.cpp95
-rw-r--r--indra/llui/llflatlistview.h11
-rw-r--r--indra/llui/llfloater.cpp193
-rw-r--r--indra/llui/llfloater.h23
-rw-r--r--indra/llui/llfolderview.cpp101
-rw-r--r--indra/llui/llfolderview.h20
-rw-r--r--indra/llui/llfolderviewitem.cpp164
-rw-r--r--indra/llui/llfolderviewitem.h15
-rw-r--r--indra/llui/llfolderviewmodel.cpp4
-rw-r--r--indra/llui/llfolderviewmodel.h8
-rw-r--r--indra/llui/lliconctrl.h4
-rw-r--r--indra/llui/lllayoutstack.cpp58
-rw-r--r--indra/llui/lllayoutstack.h4
-rw-r--r--indra/llui/lllineeditor.cpp25
-rw-r--r--indra/llui/lllineeditor.h121
-rw-r--r--indra/llui/llloadingindicator.cpp3
-rw-r--r--indra/llui/llmenugl.cpp17
-rw-r--r--indra/llui/llmenugl.h11
-rw-r--r--indra/llui/llnotifications.cpp61
-rw-r--r--indra/llui/llnotifications.h44
-rw-r--r--indra/llui/llnotificationslistener.cpp11
-rw-r--r--indra/llui/llscrollbar.cpp17
-rw-r--r--indra/llui/llscrollbar.h4
-rw-r--r--indra/llui/llscrollcontainer.cpp34
-rw-r--r--indra/llui/llscrollcontainer.h10
-rw-r--r--indra/llui/llscrollingpanellist.cpp184
-rw-r--r--indra/llui/llscrollingpanellist.h39
-rw-r--r--indra/llui/llscrolllistctrl.cpp6
-rw-r--r--indra/llui/llscrolllistctrl.h30
-rw-r--r--indra/llui/llsearcheditor.cpp12
-rw-r--r--indra/llui/llsearcheditor.h2
-rw-r--r--indra/llui/llspellcheck.h2
-rw-r--r--indra/llui/lltabcontainer.cpp49
-rw-r--r--indra/llui/lltabcontainer.h1
-rw-r--r--indra/llui/lltextbase.cpp152
-rw-r--r--indra/llui/lltextbase.h88
-rw-r--r--indra/llui/lltexteditor.cpp113
-rw-r--r--indra/llui/lltexteditor.h10
-rw-r--r--indra/llui/lltoolbar.cpp13
-rw-r--r--indra/llui/lltooltip.cpp48
-rw-r--r--indra/llui/lltooltip.h12
-rw-r--r--indra/llui/lltransutil.cpp8
-rw-r--r--indra/llui/llui.h3
-rw-r--r--indra/llui/lluicolortable.cpp3
-rw-r--r--indra/llui/lluictrl.cpp34
-rw-r--r--indra/llui/lluictrl.h3
-rw-r--r--indra/llui/lluistring.h1
-rw-r--r--indra/llui/llurlentry.cpp139
-rw-r--r--indra/llui/llurlentry.h33
-rw-r--r--indra/llui/llurlregistry.cpp14
-rw-r--r--indra/llui/llurlregistry.h6
-rw-r--r--indra/llui/llview.cpp110
-rw-r--r--indra/llui/llview.h32
-rw-r--r--indra/llui/llviewquery.h12
67 files changed, 2801 insertions, 1001 deletions
diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt
index 9108c6143c..a0314cb5f2 100644
--- a/indra/llui/CMakeLists.txt
+++ b/indra/llui/CMakeLists.txt
@@ -29,6 +29,8 @@ set(llui_SOURCE_FILES
lldockcontrol.cpp
lldraghandle.cpp
lleditmenuhandler.cpp
+ llemojidictionary.cpp
+ llemojihelper.cpp
llf32uictrl.cpp
llfiltereditor.cpp
llflashtimer.cpp
@@ -139,6 +141,8 @@ set(llui_HEADER_FILES
lldockablefloater.h
lldockcontrol.h
lleditmenuhandler.h
+ llemojidictionary.h
+ llemojihelper.h
llf32uictrl.h
llfiltereditor.h
llflashtimer.h
diff --git a/indra/llui/llaccordionctrl.cpp b/indra/llui/llaccordionctrl.cpp
index 809d72208f..0a82bed896 100644
--- a/indra/llui/llaccordionctrl.cpp
+++ b/indra/llui/llaccordionctrl.cpp
@@ -60,7 +60,7 @@ LLAccordionCtrl::LLAccordionCtrl(const Params& params):LLPanel(params)
initNoTabsWidget(params.no_matched_tabs_text);
mSingleExpansion = params.single_expansion;
- if(mFitParent && !mSingleExpansion)
+ if (mFitParent && !mSingleExpansion)
{
LL_INFOS() << "fit_parent works best when combined with single_expansion" << LL_ENDL;
}
@@ -102,14 +102,13 @@ void LLAccordionCtrl::draw()
LLPanel::draw();
}
-
//---------------------------------------------------------------------------------
BOOL LLAccordionCtrl::postBuild()
{
- static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0);
+ static LLUICachedControl<S32> scrollbar_size("UIScrollbarSize", 0);
LLRect scroll_rect;
- scroll_rect.setOriginAndSize(
+ scroll_rect.setOriginAndSize(
getRect().getWidth() - scrollbar_size,
1,
scrollbar_size,
@@ -126,39 +125,42 @@ BOOL LLAccordionCtrl::postBuild()
sbparams.follows.flags(FOLLOWS_RIGHT | FOLLOWS_TOP | FOLLOWS_BOTTOM);
sbparams.change_callback(boost::bind(&LLAccordionCtrl::onScrollPosChangeCallback, this, _1, _2));
- mScrollbar = LLUICtrlFactory::create<LLScrollbar> (sbparams);
- LLView::addChild( mScrollbar );
- mScrollbar->setVisible( false );
+ mScrollbar = LLUICtrlFactory::create<LLScrollbar>(sbparams);
+ LLView::addChild(mScrollbar);
+ mScrollbar->setVisible(FALSE);
mScrollbar->setFollowsRight();
mScrollbar->setFollowsTop();
mScrollbar->setFollowsBottom();
//if it was created from xml...
std::vector<LLUICtrl*> accordion_tabs;
- for(child_list_const_iter_t it = getChildList()->begin();
+ for (child_list_const_iter_t it = getChildList()->begin();
getChildList()->end() != it; ++it)
{
LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(*it);
- if(accordion_tab == NULL)
+ if (accordion_tab == NULL)
continue;
- if(std::find(mAccordionTabs.begin(),mAccordionTabs.end(),accordion_tab) == mAccordionTabs.end())
+ if (std::find(mAccordionTabs.begin(), mAccordionTabs.end(), accordion_tab) == mAccordionTabs.end())
{
accordion_tabs.push_back(accordion_tab);
}
}
- for(std::vector<LLUICtrl*>::reverse_iterator it = accordion_tabs.rbegin();it!=accordion_tabs.rend();++it)
+ for (std::vector<LLUICtrl*>::reverse_iterator it = accordion_tabs.rbegin();
+ it < accordion_tabs.rend(); ++it)
+ {
addCollapsibleCtrl(*it);
+ }
- arrange ();
+ arrange();
- if(mSingleExpansion)
+ if (mSingleExpansion)
{
- if(!mAccordionTabs[0]->getDisplayChildren())
+ if (!mAccordionTabs[0]->getDisplayChildren())
mAccordionTabs[0]->setDisplayChildren(true);
- for(size_t i=1;i<mAccordionTabs.size();++i)
+ for (size_t i = 1; i < mAccordionTabs.size(); ++i)
{
- if(mAccordionTabs[i]->getDisplayChildren())
+ if (mAccordionTabs[i]->getDisplayChildren())
mAccordionTabs[i]->setDisplayChildren(false);
}
}
@@ -205,23 +207,22 @@ BOOL LLAccordionCtrl::handleRightMouseDown(S32 x, S32 y, MASK mask)
//---------------------------------------------------------------------------------
void LLAccordionCtrl::shiftAccordionTabs(S16 panel_num, S32 delta)
{
- for(size_t i = panel_num; i < mAccordionTabs.size(); i++ )
+ for (size_t i = panel_num; i < mAccordionTabs.size(); ++i)
{
ctrlShiftVertical(mAccordionTabs[i],delta);
}
}
-
//---------------------------------------------------------------------------------
void LLAccordionCtrl::onCollapseCtrlCloseOpen(S16 panel_num)
{
- if(mSingleExpansion)
+ if (mSingleExpansion)
{
- for(size_t i=0;i<mAccordionTabs.size();++i)
+ for (size_t i = 0; i < mAccordionTabs.size(); ++i)
{
- if(i==panel_num)
+ if (i == panel_num)
continue;
- if(mAccordionTabs[i]->getDisplayChildren())
+ if (mAccordionTabs[i]->getDisplayChildren())
mAccordionTabs[i]->setDisplayChildren(false);
}
@@ -232,64 +233,63 @@ void LLAccordionCtrl::onCollapseCtrlCloseOpen(S16 panel_num)
void LLAccordionCtrl::show_hide_scrollbar(S32 width, S32 height)
{
calcRecuiredHeight();
- if(getRecuiredHeight() > height )
- showScrollbar(width,height);
+ if (getRecuiredHeight() > height)
+ showScrollbar(width, height);
else
- hideScrollbar(width,height);
+ hideScrollbar(width, height);
}
-void LLAccordionCtrl::showScrollbar(S32 width, S32 height)
+void LLAccordionCtrl::showScrollbar(S32 width, S32 height)
{
bool was_visible = mScrollbar->getVisible();
- mScrollbar->setVisible(true);
+ mScrollbar->setVisible(TRUE);
static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0);
ctrlSetLeftTopAndSize(mScrollbar
- ,width-scrollbar_size - PARENT_BORDER_MARGIN/2
- ,height-PARENT_BORDER_MARGIN
- ,scrollbar_size
- ,height-2*PARENT_BORDER_MARGIN);
+ , width - scrollbar_size - PARENT_BORDER_MARGIN / 2
+ , height - PARENT_BORDER_MARGIN
+ , scrollbar_size
+ , height - PARENT_BORDER_MARGIN * 2);
mScrollbar->setPageSize(height);
- mScrollbar->setDocParams(mInnerRect.getHeight(),mScrollbar->getDocPos());
+ mScrollbar->setDocParams(mInnerRect.getHeight(), mScrollbar->getDocPos());
- if(was_visible)
+ if (was_visible)
{
S32 scroll_pos = llmin(mScrollbar->getDocPos(), getRecuiredHeight() - height - 1);
mScrollbar->setDocPos(scroll_pos);
}
}
-void LLAccordionCtrl::hideScrollbar( S32 width, S32 height )
+void LLAccordionCtrl::hideScrollbar(S32 width, S32 height)
{
- if(mScrollbar->getVisible() == false)
+ if (mScrollbar->getVisible() == FALSE)
return;
- mScrollbar->setVisible(false);
+ mScrollbar->setVisible(FALSE);
static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0);
S32 panel_width = width - 2*BORDER_MARGIN;
- //reshape all accordeons and shift all draggers
- for(size_t i=0;i<mAccordionTabs.size();++i)
+ // Reshape all accordions and shift all draggers
+ for (size_t i = 0; i < mAccordionTabs.size(); ++i)
{
LLRect panel_rect = mAccordionTabs[i]->getRect();
- ctrlSetLeftTopAndSize(mAccordionTabs[i],panel_rect.mLeft,panel_rect.mTop,panel_width,panel_rect.getHeight());
+ ctrlSetLeftTopAndSize(mAccordionTabs[i], panel_rect.mLeft, panel_rect.mTop, panel_width, panel_rect.getHeight());
}
mScrollbar->setDocPos(0);
- if(mAccordionTabs.size()>0)
+ if (!mAccordionTabs.empty())
{
- S32 panel_top = height - BORDER_MARGIN; // Top coordinate of the first panel
+ S32 panel_top = height - BORDER_MARGIN; // Top coordinate of the first panel
S32 diff = panel_top - mAccordionTabs[0]->getRect().mTop;
- shiftAccordionTabs(0,diff);
+ shiftAccordionTabs(0, diff);
}
}
-
//---------------------------------------------------------------------------------
S32 LLAccordionCtrl::calcRecuiredHeight()
{
@@ -305,7 +305,7 @@ S32 LLAccordionCtrl::calcRecuiredHeight()
}
}
- mInnerRect.setLeftTopAndSize(0,rec_height + BORDER_MARGIN*2,getRect().getWidth(),rec_height + BORDER_MARGIN);
+ mInnerRect.setLeftTopAndSize(0, rec_height + BORDER_MARGIN * 2, getRect().getWidth(), rec_height + BORDER_MARGIN);
return mInnerRect.getHeight();
}
@@ -313,7 +313,7 @@ S32 LLAccordionCtrl::calcRecuiredHeight()
//---------------------------------------------------------------------------------
void LLAccordionCtrl::ctrlSetLeftTopAndSize(LLView* panel, S32 left, S32 top, S32 width, S32 height)
{
- if(!panel)
+ if (!panel)
return;
LLRect panel_rect = panel->getRect();
panel_rect.setLeftTopAndSize( left, top, width, height);
@@ -321,9 +321,9 @@ void LLAccordionCtrl::ctrlSetLeftTopAndSize(LLView* panel, S32 left, S32 top, S3
panel->setRect(panel_rect);
}
-void LLAccordionCtrl::ctrlShiftVertical(LLView* panel,S32 delta)
+void LLAccordionCtrl::ctrlShiftVertical(LLView* panel, S32 delta)
{
- if(!panel)
+ if (!panel)
return;
panel->translate(0,delta);
}
@@ -333,9 +333,9 @@ void LLAccordionCtrl::ctrlShiftVertical(LLView* panel,S32 delta)
void LLAccordionCtrl::addCollapsibleCtrl(LLView* view)
{
LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(view);
- if(!accordion_tab)
+ if (!accordion_tab)
return;
- if(std::find(beginChild(), endChild(), accordion_tab) == endChild())
+ if (std::find(beginChild(), endChild(), accordion_tab) == endChild())
addChild(accordion_tab);
mAccordionTabs.push_back(accordion_tab);
@@ -369,7 +369,7 @@ void LLAccordionCtrl::removeCollapsibleCtrl(LLView* view)
}
}
-void LLAccordionCtrl::initNoTabsWidget(const LLTextBox::Params& tb_params)
+void LLAccordionCtrl::initNoTabsWidget(const LLTextBox::Params& tb_params)
{
LLTextBox::Params tp = tb_params;
tp.rect(getLocalRect());
@@ -377,39 +377,39 @@ void LLAccordionCtrl::initNoTabsWidget(const LLTextBox::Params& tb_params)
mNoVisibleTabsHelpText = LLUICtrlFactory::create<LLTextBox>(tp, this);
}
-void LLAccordionCtrl::updateNoTabsHelpTextVisibility()
+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();
- for (; it != it_end; ++it)
+ while (it < it_end)
{
- if ((*it)->getVisible())
+ if ((*(it++))->getVisible())
{
visible_exists = true;
break;
}
}
- mNoVisibleTabsHelpText->setVisible(!visible_exists);
+ mNoVisibleTabsHelpText->setVisible(visible_exists ? FALSE : TRUE);
}
-void LLAccordionCtrl::arrangeSinge()
+void LLAccordionCtrl::arrangeSingle()
{
- S32 panel_left = BORDER_MARGIN; // Margin from left side of Splitter
- S32 panel_top = getRect().getHeight() - BORDER_MARGIN; // Top coordinate of the first panel
- S32 panel_width = getRect().getWidth() - 4; // Top coordinate of the first panel
+ S32 panel_left = BORDER_MARGIN; // Margin from left side of Splitter
+ S32 panel_top = getRect().getHeight() - BORDER_MARGIN; // Top coordinate of the first panel
+ S32 panel_width = getRect().getWidth() - 4;
S32 panel_height;
S32 collapsed_height = 0;
- for(size_t i=0;i<mAccordionTabs.size();++i)
+ for (size_t i = 0; i < mAccordionTabs.size(); ++i)
{
LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
- if(accordion_tab->getVisible() == false) //skip hidden accordion tabs
+ if (accordion_tab->getVisible() == FALSE) // Skip hidden accordion tabs
continue;
- if(!accordion_tab->isExpanded() )
+ if (!accordion_tab->isExpanded() )
{
collapsed_height+=mAccordionTabs[i]->getRect().getHeight();
}
@@ -417,28 +417,28 @@ void LLAccordionCtrl::arrangeSinge()
S32 expanded_height = getRect().getHeight() - BORDER_MARGIN - collapsed_height;
- for(size_t i=0;i<mAccordionTabs.size();++i)
+ for (size_t i = 0; i < mAccordionTabs.size(); ++i)
{
LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
- if(accordion_tab->getVisible() == false) //skip hidden accordion tabs
+ if (accordion_tab->getVisible() == FALSE) // Skip hidden accordion tabs
continue;
- if(!accordion_tab->isExpanded() )
+ if (!accordion_tab->isExpanded() )
{
panel_height = accordion_tab->getRect().getHeight();
}
else
{
- if(mFitParent)
+ if (mFitParent)
{
panel_height = expanded_height;
}
else
{
- if(accordion_tab->getAccordionView())
+ if (accordion_tab->getAccordionView())
{
panel_height = accordion_tab->getAccordionView()->getRect().getHeight() +
- accordion_tab->getHeaderHeight() + 2*BORDER_MARGIN;
+ accordion_tab->getHeaderHeight() + BORDER_MARGIN * 2;
}
else
{
@@ -451,67 +451,67 @@ void LLAccordionCtrl::arrangeSinge()
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();
+ panel_top -= mAccordionTabs[i]->getRect().getHeight();
}
show_hide_scrollbar(getRect().getWidth(), getRect().getHeight());
updateLayout(getRect().getWidth(), getRect().getHeight());
}
-void LLAccordionCtrl::arrangeMultiple()
+void LLAccordionCtrl::arrangeMultiple()
{
- S32 panel_left = BORDER_MARGIN; // Margin from left side of Splitter
- S32 panel_top = getRect().getHeight() - BORDER_MARGIN; // Top coordinate of the first panel
- S32 panel_width = getRect().getWidth() - 4; // Top coordinate of the first panel
+ S32 panel_left = BORDER_MARGIN; // Margin from left side of Splitter
+ S32 panel_top = getRect().getHeight() - BORDER_MARGIN; // Top coordinate of the first panel
+ S32 panel_width = getRect().getWidth() - 4;
//Calculate params
- for(size_t i = 0; i < mAccordionTabs.size(); i++ )
+ for (size_t i = 0; i < mAccordionTabs.size(); i++ )
{
LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
- if(accordion_tab->getVisible() == false) //skip hidden accordion tabs
+ if (accordion_tab->getVisible() == FALSE) // Skip hidden accordion tabs
continue;
- if(!accordion_tab->isExpanded() )
+ if (!accordion_tab->isExpanded() )
{
ctrlSetLeftTopAndSize(mAccordionTabs[i], panel_left, panel_top, panel_width, accordion_tab->getRect().getHeight());
- panel_top-=mAccordionTabs[i]->getRect().getHeight();
+ panel_top -= mAccordionTabs[i]->getRect().getHeight();
}
else
{
S32 panel_height = accordion_tab->getRect().getHeight();
- if(mFitParent)
+ if (mFitParent)
{
- // all expanded tabs will have equal height
+ // All expanded tabs will have equal height
panel_height = calcExpandedTabHeight(i, panel_top);
ctrlSetLeftTopAndSize(accordion_tab, panel_left, panel_top, panel_width, panel_height);
- // try to make accordion tab fit accordion view height.
+ // Try to make accordion tab fit accordion view height.
// Accordion View should implement getRequiredRect() and provide valid height
S32 optimal_height = accordion_tab->getAccordionView()->getRequiredRect().getHeight();
optimal_height += accordion_tab->getHeaderHeight() + 2 * BORDER_MARGIN;
- if(optimal_height < panel_height)
+ if (optimal_height < panel_height)
{
panel_height = optimal_height;
}
// minimum tab height is equal to header height
- if(mAccordionTabs[i]->getHeaderHeight() > panel_height)
+ if (mAccordionTabs[i]->getHeaderHeight() > panel_height)
{
panel_height = mAccordionTabs[i]->getHeaderHeight();
}
}
ctrlSetLeftTopAndSize(mAccordionTabs[i], panel_left, panel_top, panel_width, panel_height);
- panel_top-=panel_height;
+ panel_top -= panel_height;
}
}
- show_hide_scrollbar(getRect().getWidth(),getRect().getHeight());
+ show_hide_scrollbar(getRect().getWidth(), getRect().getHeight());
- updateLayout(getRect().getWidth(),getRect().getHeight());
+ updateLayout(getRect().getWidth(), getRect().getHeight());
}
@@ -519,70 +519,67 @@ void LLAccordionCtrl::arrange()
{
updateNoTabsHelpTextVisibility();
- if( mAccordionTabs.size() == 0)
+ if (mAccordionTabs.empty())
{
- //We do not arrange if we do not have what should be arranged
+ // Nothing to arrange
return;
}
-
- if(mAccordionTabs.size() == 1)
+ if (mAccordionTabs.size() == 1)
{
- S32 panel_top = getRect().getHeight() - BORDER_MARGIN; // Top coordinate of the first panel
- S32 panel_width = getRect().getWidth() - 4; // Top coordinate of the first panel
+ 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]);
LLRect panel_rect = accordion_tab->getRect();
- S32 panel_height = getRect().getHeight() - 2*BORDER_MARGIN;
-
+ S32 panel_height = getRect().getHeight() - BORDER_MARGIN * 2;
if (accordion_tab->getFitParent())
panel_height = accordion_tab->getRect().getHeight();
- ctrlSetLeftTopAndSize(accordion_tab,panel_rect.mLeft,panel_top,panel_width,panel_height);
+
+ ctrlSetLeftTopAndSize(accordion_tab, panel_rect.mLeft, panel_top, panel_width, panel_height);
- show_hide_scrollbar(getRect().getWidth(),getRect().getHeight());
+ show_hide_scrollbar(getRect().getWidth(), getRect().getHeight());
return;
-
}
- if(mSingleExpansion)
- arrangeSinge ();
+ if (mSingleExpansion)
+ arrangeSingle();
else
- arrangeMultiple ();
+ arrangeMultiple();
}
//---------------------------------------------------------------------------------
-BOOL LLAccordionCtrl::handleScrollWheel ( S32 x, S32 y, S32 clicks )
+BOOL LLAccordionCtrl::handleScrollWheel(S32 x, S32 y, S32 clicks)
{
- if(LLPanel::handleScrollWheel(x,y,clicks))
+ if (LLPanel::handleScrollWheel(x, y, clicks))
return TRUE;
- if( mScrollbar->getVisible() && mScrollbar->handleScrollWheel( 0, 0, clicks ) )
+ if (mScrollbar->getVisible() && mScrollbar->handleScrollWheel(0, 0, clicks))
return TRUE;
- return false;
-
+ return FALSE;
}
-BOOL LLAccordionCtrl::handleKeyHere (KEY key, MASK mask)
+BOOL LLAccordionCtrl::handleKeyHere(KEY key, MASK mask)
{
- if( mScrollbar->getVisible() && mScrollbar->handleKeyHere( key,mask ) )
+ if (mScrollbar->getVisible() && mScrollbar->handleKeyHere(key, mask))
return TRUE;
- return LLPanel::handleKeyHere(key,mask);
+ return LLPanel::handleKeyHere(key, mask);
}
-BOOL LLAccordionCtrl::handleDragAndDrop (S32 x, S32 y, MASK mask,
- BOOL drop,
- EDragAndDropType cargo_type,
- void* cargo_data,
- EAcceptance* accept,
- std::string& tooltip_msg)
+BOOL LLAccordionCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask,
+ BOOL drop,
+ EDragAndDropType cargo_type,
+ void* cargo_data,
+ EAcceptance* accept,
+ std::string& tooltip_msg)
{
// Scroll folder view if needed. Never accepts a drag or drop.
*accept = ACCEPT_NO;
BOOL handled = autoScroll(x, y);
- if( !handled )
+ if (!handled)
{
handled = childrenHandleDragAndDrop(x, y, mask, drop, cargo_type,
cargo_data, accept, tooltip_msg) != NULL;
@@ -590,14 +587,14 @@ BOOL LLAccordionCtrl::handleDragAndDrop (S32 x, S32 y, MASK mask,
return TRUE;
}
-BOOL LLAccordionCtrl::autoScroll (S32 x, S32 y)
+BOOL LLAccordionCtrl::autoScroll(S32 x, S32 y)
{
static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0);
bool scrolling = false;
- if( mScrollbar->getVisible() )
+ if (mScrollbar->getVisible())
{
- LLRect rect_local( 0, getRect().getHeight(), getRect().getWidth() - scrollbar_size, 0 );
+ LLRect rect_local(0, getRect().getHeight(), getRect().getWidth() - scrollbar_size, 0);
LLRect screen_local_extents;
// clip rect against root view
@@ -610,51 +607,52 @@ BOOL LLAccordionCtrl::autoScroll (S32 x, S32 y)
LLRect bottom_scroll_rect = screen_local_extents;
bottom_scroll_rect.mTop = rect_local.mBottom + auto_scroll_region_height;
- if( bottom_scroll_rect.pointInRect( x, y ) && (mScrollbar->getDocPos() < mScrollbar->getDocPosMax()) )
+ if (bottom_scroll_rect.pointInRect( x, y ) && (mScrollbar->getDocPos() < mScrollbar->getDocPosMax()))
{
- mScrollbar->setDocPos( mScrollbar->getDocPos() + auto_scroll_speed );
+ mScrollbar->setDocPos(mScrollbar->getDocPos() + auto_scroll_speed);
mAutoScrolling = true;
scrolling = true;
}
LLRect top_scroll_rect = screen_local_extents;
top_scroll_rect.mBottom = rect_local.mTop - auto_scroll_region_height;
- if( top_scroll_rect.pointInRect( x, y ) && (mScrollbar->getDocPos() > 0) )
+ if (top_scroll_rect.pointInRect(x, y) && (mScrollbar->getDocPos() > 0))
{
- mScrollbar->setDocPos( mScrollbar->getDocPos() - auto_scroll_speed );
+ mScrollbar->setDocPos(mScrollbar->getDocPos() - auto_scroll_speed);
mAutoScrolling = true;
scrolling = true;
}
}
- return scrolling;
+
+ return scrolling ? TRUE : FALSE;
}
-void LLAccordionCtrl::updateLayout (S32 width, S32 height)
+void LLAccordionCtrl::updateLayout(S32 width, S32 height)
{
S32 panel_top = height - BORDER_MARGIN ;
- if(mScrollbar->getVisible())
- panel_top+=mScrollbar->getDocPos();
+ if (mScrollbar->getVisible())
+ panel_top += mScrollbar->getDocPos();
- S32 panel_width = width - 2*BORDER_MARGIN;
+ S32 panel_width = width - BORDER_MARGIN * 2;
static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0);
- if(mScrollbar->getVisible())
- panel_width-=scrollbar_size;
+ if (mScrollbar->getVisible())
+ panel_width -= scrollbar_size;
- //set sizes for first panels and dragbars
- for(size_t i=0;i<mAccordionTabs.size();++i)
+ // set sizes for first panels and dragbars
+ for (size_t i = 0; i < mAccordionTabs.size(); ++i)
{
- if(!mAccordionTabs[i]->getVisible())
+ if (!mAccordionTabs[i]->getVisible())
continue;
LLRect panel_rect = mAccordionTabs[i]->getRect();
- ctrlSetLeftTopAndSize(mAccordionTabs[i],panel_rect.mLeft,panel_top,panel_width,panel_rect.getHeight());
- panel_top-=panel_rect.getHeight();
+ ctrlSetLeftTopAndSize(mAccordionTabs[i], panel_rect.mLeft, panel_top, panel_width, panel_rect.getHeight());
+ panel_top -= panel_rect.getHeight();
}
}
-void LLAccordionCtrl::onScrollPosChangeCallback(S32, LLScrollbar*)
+void LLAccordionCtrl::onScrollPosChangeCallback(S32, LLScrollbar*)
{
- updateLayout(getRect().getWidth(),getRect().getHeight());
+ updateLayout(getRect().getWidth(), getRect().getHeight());
}
// virtual
@@ -687,42 +685,43 @@ void LLAccordionCtrl::onUpdateScrollToChild(const LLUICtrl *cntrl)
LLUICtrl::onUpdateScrollToChild(cntrl);
}
-void LLAccordionCtrl::onOpen (const LLSD& key)
+void LLAccordionCtrl::onOpen(const LLSD& key)
{
- for(size_t i=0;i<mAccordionTabs.size();++i)
+ for (size_t i = 0; i < mAccordionTabs.size(); ++i)
{
LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
LLPanel* panel = dynamic_cast<LLPanel*>(accordion_tab->getAccordionView());
- if(panel!=NULL)
+ if (panel != NULL)
{
panel->onOpen(key);
}
}
}
+
S32 LLAccordionCtrl::notifyParent(const LLSD& info)
{
- if(info.has("action"))
+ if (info.has("action"))
{
std::string str_action = info["action"];
- if(str_action == "size_changes")
+ if (str_action == "size_changes")
{
//
arrange();
return 1;
}
- else if(str_action == "select_next")
+ if (str_action == "select_next")
{
- for(size_t i=0;i<mAccordionTabs.size();++i)
+ for (size_t i = 0; i < mAccordionTabs.size(); ++i)
{
LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
- if(accordion_tab->hasFocus())
+ if (accordion_tab->hasFocus())
{
- while(++i<mAccordionTabs.size())
+ while (++i < mAccordionTabs.size())
{
- if(mAccordionTabs[i]->getVisible())
+ if (mAccordionTabs[i]->getVisible())
break;
}
- if(i<mAccordionTabs.size())
+ if (i < mAccordionTabs.size())
{
accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
accordion_tab->notify(LLSD().with("action","select_first"));
@@ -733,17 +732,17 @@ S32 LLAccordionCtrl::notifyParent(const LLSD& info)
}
return 0;
}
- else if(str_action == "select_prev")
+ if (str_action == "select_prev")
{
- for(size_t i=0;i<mAccordionTabs.size();++i)
+ for (size_t i = 0; i < mAccordionTabs.size(); ++i)
{
LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
- if(accordion_tab->hasFocus() && i>0)
+ if (accordion_tab->hasFocus() && i > 0)
{
bool prev_visible_tab_found = false;
- while(i>0)
+ while (i > 0)
{
- if(mAccordionTabs[--i]->getVisible())
+ if (mAccordionTabs[--i]->getVisible())
{
prev_visible_tab_found = true;
break;
@@ -761,12 +760,12 @@ S32 LLAccordionCtrl::notifyParent(const LLSD& info)
}
return 0;
}
- else if(str_action == "select_current")
+ if (str_action == "select_current")
{
- for(size_t i=0;i<mAccordionTabs.size();++i)
+ for (size_t i = 0; i < mAccordionTabs.size(); ++i)
{
// Set selection to the currently focused tab.
- if(mAccordionTabs[i]->hasFocus())
+ if (mAccordionTabs[i]->hasFocus())
{
if (mAccordionTabs[i] != mSelectedTab)
{
@@ -783,7 +782,7 @@ S32 LLAccordionCtrl::notifyParent(const LLSD& info)
}
return 0;
}
- else if(str_action == "deselect_current")
+ if (str_action == "deselect_current")
{
// Reset selection to the currently selected tab.
if (mSelectedTab)
@@ -802,9 +801,9 @@ S32 LLAccordionCtrl::notifyParent(const LLSD& info)
screenRectToLocal(screen_rc, &local_rc);
// Translate to parent coordinatess to check if we are in visible rectangle
- local_rc.translate( getRect().mLeft, getRect().mBottom );
+ local_rc.translate(getRect().mLeft, getRect().mBottom);
- if ( !getRect().contains (local_rc) )
+ if (!getRect().contains (local_rc))
{
// Back to local coords and calculate position for scroller
S32 bottom = mScrollbar->getDocPos() - local_rc.mBottom + getRect().mBottom;
@@ -814,7 +813,7 @@ S32 LLAccordionCtrl::notifyParent(const LLSD& info)
bottom, // min vertical scroll
top); // max vertical scroll
- mScrollbar->setDocPos( scroll_pos );
+ mScrollbar->setDocPos(scroll_pos);
}
return 1;
}
@@ -834,15 +833,16 @@ S32 LLAccordionCtrl::notifyParent(const LLSD& info)
}
return LLPanel::notifyParent(info);
}
-void LLAccordionCtrl::reset ()
+
+void LLAccordionCtrl::reset()
{
- if(mScrollbar)
+ if (mScrollbar)
mScrollbar->setDocPos(0);
}
void LLAccordionCtrl::expandDefaultTab()
{
- if (mAccordionTabs.size() > 0)
+ if (!mAccordionTabs.empty())
{
LLAccordionCtrlTab* tab = mAccordionTabs.front();
@@ -877,7 +877,7 @@ void LLAccordionCtrl::sort()
arrange();
}
-void LLAccordionCtrl::setFilterSubString(const std::string& filter_string)
+void LLAccordionCtrl::setFilterSubString(const std::string& filter_string)
{
LLStringUtil::format_map_t args;
args["[SEARCH_TERM]"] = LLURI::escape(filter_string);
@@ -907,7 +907,7 @@ const LLAccordionCtrlTab* LLAccordionCtrl::getExpandedTab() const
S32 LLAccordionCtrl::calcExpandedTabHeight(S32 tab_index /* = 0 */, S32 available_height /* = 0 */)
{
- if(tab_index < 0)
+ if (tab_index < 0)
{
return available_height;
}
@@ -915,9 +915,9 @@ 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 (size_t n = tab_index; n < mAccordionTabs.size(); ++n)
{
- if(!mAccordionTabs[n]->isExpanded())
+ if (!mAccordionTabs[n]->isExpanded())
{
collapsed_tabs_height += mAccordionTabs[n]->getHeaderHeight();
}
@@ -927,7 +927,7 @@ S32 LLAccordionCtrl::calcExpandedTabHeight(S32 tab_index /* = 0 */, S32 availabl
}
}
- if(0 == num_expanded)
+ if (0 == num_expanded)
{
return available_height;
}
diff --git a/indra/llui/llaccordionctrl.h b/indra/llui/llaccordionctrl.h
index 2828254472..6a1989afba 100644
--- a/indra/llui/llaccordionctrl.h
+++ b/indra/llui/llaccordionctrl.h
@@ -144,7 +144,7 @@ private:
void initNoTabsWidget(const LLTextBox::Params& tb_params);
void updateNoTabsHelpTextVisibility();
- void arrangeSinge();
+ void arrangeSingle();
void arrangeMultiple();
// Calc Splitter's height that is necessary to display all child content
diff --git a/indra/llui/llaccordionctrltab.cpp b/indra/llui/llaccordionctrltab.cpp
index 04485c6262..20da568746 100644
--- a/indra/llui/llaccordionctrltab.cpp
+++ b/indra/llui/llaccordionctrltab.cpp
@@ -69,13 +69,13 @@ public:
virtual BOOL postBuild();
std::string getTitle();
- void setTitle(const std::string& title, const std::string& hl);
+ void setTitle(const std::string& title, const std::string& hl);
- void setTitleFontStyle(std::string style);
+ void setTitleFontStyle(std::string style);
- void setTitleColor(LLUIColor);
+ void setTitleColor(LLUIColor);
- void setSelected(bool is_selected) { mIsSelected = is_selected; }
+ void setSelected(bool is_selected) { mIsSelected = is_selected; }
virtual void onMouseEnter(S32 x, S32 y, MASK mask);
virtual void onMouseLeave(S32 x, S32 y, MASK mask);
@@ -85,8 +85,8 @@ public:
void* cargo_data,
EAcceptance* accept,
std::string& tooltip_msg);
-private:
+private:
LLTextBox* mHeaderTextbox;
// Overlay images (arrows)
@@ -102,7 +102,7 @@ private:
LLPointer<LLUIImage> mImageHeaderFocused;
// style saved when applying it in setTitleFontStyle
- LLStyle::Params mStyleParams;
+ LLStyle::Params mStyleParams;
LLUIColor mHeaderBGColor;
@@ -157,19 +157,17 @@ BOOL LLAccordionCtrlTab::LLAccordionCtrlTabHeader::postBuild()
std::string LLAccordionCtrlTab::LLAccordionCtrlTabHeader::getTitle()
{
- if(mHeaderTextbox)
+ if (mHeaderTextbox)
{
return mHeaderTextbox->getText();
}
- else
- {
- return LLStringUtil::null;
- }
+
+ return LLStringUtil::null;
}
void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::setTitle(const std::string& title, const std::string& hl)
{
- if(mHeaderTextbox)
+ if (mHeaderTextbox)
{
LLTextUtil::textboxSetHighlightedVal(
mHeaderTextbox,
@@ -192,7 +190,7 @@ void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::setTitleFontStyle(std::string
void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::setTitleColor(LLUIColor color)
{
- if(mHeaderTextbox)
+ if (mHeaderTextbox)
{
mHeaderTextbox->setColor(color);
}
@@ -204,11 +202,11 @@ void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::draw()
S32 height = getRect().getHeight();
F32 alpha = getCurrentTransparency();
- gl_rect_2d(0,0,width - 1 ,height - 1,mHeaderBGColor.get() % alpha,true);
+ gl_rect_2d(0, 0, width - 1, height - 1, mHeaderBGColor.get() % alpha, TRUE);
LLAccordionCtrlTab* parent = dynamic_cast<LLAccordionCtrlTab*>(getParent());
- bool collapsible = (parent && parent->getCollapsible());
- bool expanded = (parent && parent->getDisplayChildren());
+ bool collapsible = parent && parent->getCollapsible();
+ bool expanded = parent && parent->getDisplayChildren();
// Handle overlay images, if needed
// Only show green "focus" background image if the accordion is open,
@@ -218,23 +216,22 @@ void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::draw()
/*&& !(collapsible && !expanded)*/ // WHY??
)
{
- mImageHeaderFocused->draw(0,0,width,height);
+ mImageHeaderFocused->draw(0, 0, width, height);
}
else
{
- mImageHeader->draw(0,0,width,height);
+ mImageHeader->draw(0, 0, width, height);
}
- if(mNeedsHighlight)
+ if (mNeedsHighlight)
{
- mImageHeaderOver->draw(0,0,width,height);
+ mImageHeaderOver->draw(0, 0, width, height);
}
-
- if(collapsible)
+ if (collapsible)
{
LLPointer<LLUIImage> overlay_image;
- if(expanded)
+ if (expanded)
{
overlay_image = mImageExpanded;
}
@@ -242,8 +239,7 @@ void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::draw()
{
overlay_image = mImageCollapsed;
}
- overlay_image->draw(HEADER_IMAGE_LEFT_OFFSET,
- (height - overlay_image->getHeight()) / 2);
+ overlay_image->draw(HEADER_IMAGE_LEFT_OFFSET, (height - overlay_image->getHeight()) / 2);
}
LLUICtrl::draw();
@@ -253,7 +249,7 @@ void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::reshape(S32 width, S32 height
{
S32 header_height = mHeaderTextbox->getTextPixelHeight();
- LLRect textboxRect(HEADER_TEXT_LEFT_OFFSET,(height+header_height)/2 ,width,(height-header_height)/2);
+ LLRect textboxRect(HEADER_TEXT_LEFT_OFFSET, (height + header_height) / 2, width, (height - header_height) / 2);
mHeaderTextbox->reshape(textboxRect.getWidth(), textboxRect.getHeight());
mHeaderTextbox->setRect(textboxRect);
@@ -272,20 +268,24 @@ void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::onMouseEnter(S32 x, S32 y, MA
LLUICtrl::onMouseEnter(x, y, mask);
mNeedsHighlight = true;
}
+
void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::onMouseLeave(S32 x, S32 y, MASK mask)
{
LLUICtrl::onMouseLeave(x, y, mask);
mNeedsHighlight = false;
mAutoOpenTimer.stop();
}
+
BOOL LLAccordionCtrlTab::LLAccordionCtrlTabHeader::handleKey(KEY key, MASK mask, BOOL called_from_parent)
{
- if ( ( key == KEY_LEFT || key == KEY_RIGHT) && mask == MASK_NONE)
+ if ((key == KEY_LEFT || key == KEY_RIGHT) && mask == MASK_NONE)
{
return getParent()->handleKey(key, mask, called_from_parent);
}
+
return LLUICtrl::handleKey(key, mask, called_from_parent);
}
+
BOOL LLAccordionCtrlTab::LLAccordionCtrlTabHeader::handleDragAndDrop(S32 x, S32 y, MASK mask,
BOOL drop,
EDragAndDropType cargo_type,
@@ -295,7 +295,7 @@ BOOL LLAccordionCtrlTab::LLAccordionCtrlTabHeader::handleDragAndDrop(S32 x, S32
{
LLAccordionCtrlTab* parent = dynamic_cast<LLAccordionCtrlTab*>(getParent());
- if ( parent && !parent->getDisplayChildren() && parent->getCollapsible() && parent->canOpenClose() )
+ if (parent && !parent->getDisplayChildren() && parent->getCollapsible() && parent->canOpenClose())
{
if (mAutoOpenTimer.getStarted())
{
@@ -307,12 +307,15 @@ BOOL LLAccordionCtrlTab::LLAccordionCtrlTabHeader::handleDragAndDrop(S32 x, S32
}
}
else
+ {
mAutoOpenTimer.start();
+ }
}
return LLUICtrl::handleDragAndDrop(x, y, mask, drop, cargo_type,
cargo_data, accept, tooltip_msg);
}
+
LLAccordionCtrlTab::Params::Params()
: title("title")
,display_children("expanded", true)
@@ -384,41 +387,39 @@ LLAccordionCtrlTab::~LLAccordionCtrlTab()
{
}
-
void LLAccordionCtrlTab::setDisplayChildren(bool display)
{
mDisplayChildren = display;
LLRect rect = getRect();
- rect.mBottom = rect.mTop - (getDisplayChildren() ?
- mExpandedHeight : HEADER_HEIGHT);
+ rect.mBottom = rect.mTop - (getDisplayChildren() ? mExpandedHeight : HEADER_HEIGHT);
setRect(rect);
- if(mContainerPanel)
+ if (mContainerPanel)
+ {
mContainerPanel->setVisible(getDisplayChildren());
+ }
- if(mDisplayChildren)
+ if (mDisplayChildren)
{
adjustContainerPanel();
}
else
{
- if(mScrollbar)
- mScrollbar->setVisible(false);
+ if (mScrollbar)
+ mScrollbar->setVisible(FALSE);
}
-
}
void LLAccordionCtrlTab::reshape(S32 width, S32 height, BOOL called_from_parent /* = TRUE */)
{
LLRect headerRect;
- headerRect.setLeftTopAndSize(
- 0,height,width,HEADER_HEIGHT);
+ headerRect.setLeftTopAndSize(0, height, width, HEADER_HEIGHT);
mHeader->setRect(headerRect);
mHeader->reshape(headerRect.getWidth(), headerRect.getHeight());
- if(!mDisplayChildren)
+ if (!mDisplayChildren)
return;
LLRect childRect;
@@ -426,7 +427,7 @@ void LLAccordionCtrlTab::reshape(S32 width, S32 height, BOOL called_from_parent
childRect.setLeftTopAndSize(
getPaddingLeft(),
height - getHeaderHeight() - getPaddingTop(),
- width - getPaddingLeft() - getPaddingRight(),
+ width - getPaddingLeft() - getPaddingRight(),
height - getHeaderHeight() - getPaddingTop() - getPaddingBottom() );
adjustContainerPanel(childRect);
@@ -434,7 +435,7 @@ void LLAccordionCtrlTab::reshape(S32 width, S32 height, BOOL called_from_parent
void LLAccordionCtrlTab::changeOpenClose(bool is_open)
{
- if(is_open)
+ if (is_open)
mExpandedHeight = getRect().getHeight();
setDisplayChildren(!is_open);
@@ -483,14 +484,14 @@ void LLAccordionCtrlTab::onUpdateScrollToChild(const LLUICtrl *cntrl)
BOOL LLAccordionCtrlTab::handleMouseDown(S32 x, S32 y, MASK mask)
{
- if(mCollapsible && mHeaderVisible && mCanOpenClose)
+ if (mCollapsible && mHeaderVisible && mCanOpenClose)
{
- if(y >= (getRect().getHeight() - HEADER_HEIGHT) )
+ if (y >= (getRect().getHeight() - HEADER_HEIGHT))
{
mHeader->setFocus(true);
changeOpenClose(getDisplayChildren());
- //reset stored state
+ // Reset stored state
mWasStateStored = false;
return TRUE;
}
@@ -510,7 +511,7 @@ boost::signals2::connection LLAccordionCtrlTab::setDropDownStateChangedCallback(
bool LLAccordionCtrlTab::addChild(LLView* child, S32 tab_group)
{
- if(DD_HEADER_NAME != child->getName())
+ if (DD_HEADER_NAME != child->getName())
{
reshape(child->getRect().getWidth() , child->getRect().getHeight() + HEADER_HEIGHT );
mExpandedHeight = getRect().getHeight();
@@ -518,12 +519,12 @@ bool LLAccordionCtrlTab::addChild(LLView* child, S32 tab_group)
bool res = LLUICtrl::addChild(child, tab_group);
- if(DD_HEADER_NAME != child->getName())
+ if (DD_HEADER_NAME != child->getName())
{
- if(!mCollapsible)
+ if (!mCollapsible)
setDisplayChildren(true);
else
- setDisplayChildren(getDisplayChildren());
+ setDisplayChildren(getDisplayChildren());
}
if (!mContainerPanel)
@@ -534,7 +535,7 @@ bool LLAccordionCtrlTab::addChild(LLView* child, S32 tab_group)
void LLAccordionCtrlTab::setAccordionView(LLView* panel)
{
- addChild(panel,0);
+ addChild(panel, 0);
}
std::string LLAccordionCtrlTab::getTitle() const
@@ -543,10 +544,8 @@ std::string LLAccordionCtrlTab::getTitle() const
{
return mHeader->getTitle();
}
- else
- {
- return LLStringUtil::null;
- }
+
+ return LLStringUtil::null;
}
void LLAccordionCtrlTab::setTitle(const std::string& title, const std::string& hl)
@@ -579,6 +578,7 @@ boost::signals2::connection LLAccordionCtrlTab::setFocusReceivedCallback(const f
{
return mHeader->setFocusReceivedCallback(cb);
}
+
return boost::signals2::connection();
}
@@ -588,6 +588,7 @@ boost::signals2::connection LLAccordionCtrlTab::setFocusLostCallback(const focus
{
return mHeader->setFocusLostCallback(cb);
}
+
return boost::signals2::connection();
}
@@ -601,59 +602,65 @@ void LLAccordionCtrlTab::setSelected(bool is_selected)
LLView* LLAccordionCtrlTab::findContainerView()
{
- for(child_list_const_iter_t it = getChildList()->begin();
- getChildList()->end() != it; ++it)
+ child_list_const_iter_t it = getChildList()->begin(), it_end = getChildList()->end();
+ while (it != it_end)
{
- LLView* child = *it;
- if(DD_HEADER_NAME == child->getName())
- continue;
- if(!child->getVisible())
- continue;
- return child;
+ LLView* child = *(it++);
+ if (DD_HEADER_NAME != child->getName() && child->getVisible())
+ return child;
}
+
return NULL;
}
void LLAccordionCtrlTab::selectOnFocusReceived()
{
if (getParent()) // A parent may not be set if tabs are added dynamically.
+ {
getParent()->notifyParent(LLSD().with("action", "select_current"));
+ }
}
void LLAccordionCtrlTab::deselectOnFocusLost()
{
- if(getParent()) // A parent may not be set if tabs are added dynamically.
+ if (getParent()) // A parent may not be set if tabs are added dynamically.
{
getParent()->notifyParent(LLSD().with("action", "deselect_current"));
}
-
}
S32 LLAccordionCtrlTab::getHeaderHeight()
{
- return mHeaderVisible?HEADER_HEIGHT:0;
+ return mHeaderVisible ? HEADER_HEIGHT : 0;
}
-void LLAccordionCtrlTab::setHeaderVisible(bool value)
+void LLAccordionCtrlTab::setHeaderVisible(bool value)
{
- if(mHeaderVisible == value)
+ if (mHeaderVisible == value)
return;
+
mHeaderVisible = value;
- if(mHeader)
- mHeader->setVisible(value);
+
+ if (mHeader)
+ {
+ mHeader->setVisible(value ? TRUE : FALSE);
+ }
+
reshape(getRect().getWidth(), getRect().getHeight(), FALSE);
};
//virtual
BOOL LLAccordionCtrlTab::postBuild()
{
- if(mHeader)
+ if (mHeader)
+ {
mHeader->setVisible(mHeaderVisible);
-
- static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0);
+ }
+
+ static LLUICachedControl<S32> scrollbar_size("UIScrollbarSize", 0);
LLRect scroll_rect;
- scroll_rect.setOriginAndSize(
+ scroll_rect.setOriginAndSize(
getRect().getWidth() - scrollbar_size,
1,
scrollbar_size,
@@ -661,7 +668,7 @@ BOOL LLAccordionCtrlTab::postBuild()
mContainerPanel = findContainerView();
- if(!mFitPanel)
+ if (!mFitPanel)
{
LLScrollbar::Params sbparams;
sbparams.name("scrollable vertical");
@@ -674,9 +681,8 @@ BOOL LLAccordionCtrlTab::postBuild()
sbparams.follows.flags(FOLLOWS_RIGHT | FOLLOWS_TOP | FOLLOWS_BOTTOM);
sbparams.change_callback(boost::bind(&LLAccordionCtrlTab::onScrollPosChangeCallback, this, _1, _2));
-
- mScrollbar = LLUICtrlFactory::create<LLScrollbar> (sbparams);
- LLView::addChild( mScrollbar );
+ mScrollbar = LLUICtrlFactory::create<LLScrollbar>(sbparams);
+ LLView::addChild(mScrollbar);
mScrollbar->setFollowsRight();
mScrollbar->setFollowsTop();
mScrollbar->setFollowsBottom();
@@ -684,44 +690,48 @@ BOOL LLAccordionCtrlTab::postBuild()
mScrollbar->setVisible(false);
}
- if(mContainerPanel)
+ if (mContainerPanel)
+ {
mContainerPanel->setVisible(mDisplayChildren);
+ }
return LLUICtrl::postBuild();
}
-bool LLAccordionCtrlTab::notifyChildren (const LLSD& info)
+
+bool LLAccordionCtrlTab::notifyChildren (const LLSD& info)
{
- if(info.has("action"))
+ if (info.has("action"))
{
std::string str_action = info["action"];
- if(str_action == "store_state")
+ if (str_action == "store_state")
{
storeOpenCloseState();
return true;
}
- if(str_action == "restore_state")
+
+ if (str_action == "restore_state")
{
restoreOpenCloseState();
return true;
}
}
+
return LLUICtrl::notifyChildren(info);
}
S32 LLAccordionCtrlTab::notifyParent(const LLSD& info)
{
- if(info.has("action"))
+ if (info.has("action"))
{
std::string str_action = info["action"];
- if(str_action == "size_changes")
+ if (str_action == "size_changes")
{
- //
S32 height = info["height"];
- height = llmax(height,10) + HEADER_HEIGHT + getPaddingTop() + getPaddingBottom();
+ height = llmax(height, 10) + HEADER_HEIGHT + getPaddingTop() + getPaddingBottom();
mExpandedHeight = height;
- if(isExpanded() && !mSkipChangesOnNotifyParent)
+ if (isExpanded() && !mSkipChangesOnNotifyParent)
{
LLRect panel_rect = getRect();
panel_rect.setLeftTopAndSize( panel_rect.mLeft, panel_rect.mTop, panel_rect.getWidth(), height);
@@ -729,12 +739,13 @@ S32 LLAccordionCtrlTab::notifyParent(const LLSD& info)
setRect(panel_rect);
}
- //LLAccordionCtrl should rearrange accordion tab if one of accordion change its size
+ // LLAccordionCtrl should rearrange accordion tab if one of accordions changed its size
if (getParent()) // A parent may not be set if tabs are added dynamically.
getParent()->notifyParent(info);
return 1;
}
- else if(str_action == "select_prev")
+
+ if (str_action == "select_prev")
{
showAndFocusHeader();
return 1;
@@ -772,78 +783,85 @@ S32 LLAccordionCtrlTab::notifyParent(const LLSD& info)
S32 LLAccordionCtrlTab::notify(const LLSD& info)
{
- if(info.has("action"))
+ if (info.has("action"))
{
std::string str_action = info["action"];
- if(str_action == "select_first")
+ if (str_action == "select_first")
{
showAndFocusHeader();
return 1;
}
- else if( str_action == "select_last" )
+
+ if (str_action == "select_last")
{
- if(getDisplayChildren() == false)
+ if (!getDisplayChildren())
{
showAndFocusHeader();
}
else
{
LLView* view = getAccordionView();
- if(view)
- view->notify(LLSD().with("action","select_last"));
+ if (view)
+ {
+ view->notify(LLSD().with("action", "select_last"));
+ }
}
}
}
+
return 0;
}
BOOL LLAccordionCtrlTab::handleKey(KEY key, MASK mask, BOOL called_from_parent)
{
- if( !mHeader->hasFocus() )
+ if (!mHeader->hasFocus())
return LLUICtrl::handleKey(key, mask, called_from_parent);
- if ( (key == KEY_RETURN )&& mask == MASK_NONE)
+ if ((key == KEY_RETURN) && mask == MASK_NONE)
{
changeOpenClose(getDisplayChildren());
return TRUE;
}
- if ( (key == KEY_ADD || key == KEY_RIGHT)&& mask == MASK_NONE)
+ if ((key == KEY_ADD || key == KEY_RIGHT) && mask == MASK_NONE)
{
- if(getDisplayChildren() == false)
+ if (!getDisplayChildren())
{
changeOpenClose(getDisplayChildren());
return TRUE;
}
}
- if ( (key == KEY_SUBTRACT || key == KEY_LEFT)&& mask == MASK_NONE)
+
+ if ((key == KEY_SUBTRACT || key == KEY_LEFT) && mask == MASK_NONE)
{
- if(getDisplayChildren() == true)
+ if (getDisplayChildren())
{
changeOpenClose(getDisplayChildren());
return TRUE;
}
}
- if ( key == KEY_DOWN && mask == MASK_NONE)
+ if (key == KEY_DOWN && mask == MASK_NONE)
{
- //if collapsed go to the next accordion
- if(getDisplayChildren() == false)
- //we processing notifyParent so let call parent directly
- getParent()->notifyParent(LLSD().with("action","select_next"));
+ // if collapsed go to the next accordion
+ if (!getDisplayChildren())
+ {
+ // we're processing notifyParent so let call parent directly
+ getParent()->notifyParent(LLSD().with("action", "select_next"));
+ }
else
{
- getAccordionView()->notify(LLSD().with("action","select_first"));
+ getAccordionView()->notify(LLSD().with("action", "select_first"));
}
return TRUE;
}
- if ( key == KEY_UP && mask == MASK_NONE)
+ if (key == KEY_UP && mask == MASK_NONE)
{
- //go to the previous accordion
+ // go to the previous accordion
- //we processing notifyParent so let call parent directly
- getParent()->notifyParent(LLSD().with("action","select_prev"));
+ // we're processing notifyParent so let call parent directly
+ getParent()->notifyParent(LLSD().with("action", "select_prev"));
return TRUE;
}
@@ -869,28 +887,29 @@ void LLAccordionCtrlTab::showAndFocusHeader()
// accordion tab (assuming that the parent is an LLAccordionCtrl) the calls chain
// is shortened and messages from inside the collapsed tabs are avoided.
// See STORM-536.
- getParent()->notifyParent(LLSD().with("scrollToShowRect",screen_rc.getValue()));
+ getParent()->notifyParent(LLSD().with("scrollToShowRect", screen_rc.getValue()));
}
-void LLAccordionCtrlTab::storeOpenCloseState()
+
+void LLAccordionCtrlTab::storeOpenCloseState()
{
- if(mWasStateStored)
+ if (mWasStateStored)
return;
mStoredOpenCloseState = getDisplayChildren();
mWasStateStored = true;
}
-void LLAccordionCtrlTab::restoreOpenCloseState()
+void LLAccordionCtrlTab::restoreOpenCloseState()
{
- if(!mWasStateStored)
+ if (!mWasStateStored)
return;
- if(getDisplayChildren() != mStoredOpenCloseState)
+ if (getDisplayChildren() != mStoredOpenCloseState)
{
changeOpenClose(getDisplayChildren());
}
mWasStateStored = false;
}
-void LLAccordionCtrlTab::adjustContainerPanel ()
+void LLAccordionCtrlTab::adjustContainerPanel()
{
S32 width = getRect().getWidth();
S32 height = getRect().getHeight();
@@ -907,83 +926,83 @@ void LLAccordionCtrlTab::adjustContainerPanel ()
void LLAccordionCtrlTab::adjustContainerPanel(const LLRect& child_rect)
{
- if(!mContainerPanel)
+ if (!mContainerPanel)
return;
- if(!mFitPanel)
+ if (!mFitPanel)
{
show_hide_scrollbar(child_rect);
updateLayout(child_rect);
}
else
{
- mContainerPanel->reshape(child_rect.getWidth(),child_rect.getHeight());
+ mContainerPanel->reshape(child_rect.getWidth(), child_rect.getHeight());
mContainerPanel->setRect(child_rect);
}
}
S32 LLAccordionCtrlTab::getChildViewHeight()
{
- if(!mContainerPanel)
+ if (!mContainerPanel)
return 0;
return mContainerPanel->getRect().getHeight();
}
void LLAccordionCtrlTab::show_hide_scrollbar(const LLRect& child_rect)
{
- if(getChildViewHeight() > child_rect.getHeight() )
+ if (getChildViewHeight() > child_rect.getHeight())
showScrollbar(child_rect);
else
hideScrollbar(child_rect);
}
+
void LLAccordionCtrlTab::showScrollbar(const LLRect& child_rect)
{
- if(!mContainerPanel || !mScrollbar)
+ if (!mContainerPanel || !mScrollbar)
return;
bool was_visible = mScrollbar->getVisible();
mScrollbar->setVisible(true);
static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0);
- {
- ctrlSetLeftTopAndSize(mScrollbar,child_rect.getWidth()-scrollbar_size,
- child_rect.getHeight()-PARENT_BORDER_MARGIN,
- scrollbar_size,
- child_rect.getHeight()-2*PARENT_BORDER_MARGIN);
- }
+ ctrlSetLeftTopAndSize(mScrollbar,
+ child_rect.getWidth() - scrollbar_size,
+ child_rect.getHeight() - PARENT_BORDER_MARGIN,
+ scrollbar_size,
+ child_rect.getHeight() - PARENT_BORDER_MARGIN * 2);
LLRect orig_rect = mContainerPanel->getRect();
mScrollbar->setPageSize(child_rect.getHeight());
- mScrollbar->setDocParams(orig_rect.getHeight(),mScrollbar->getDocPos());
+ mScrollbar->setDocParams(orig_rect.getHeight(), mScrollbar->getDocPos());
- if(was_visible)
+ if (was_visible)
{
S32 scroll_pos = llmin(mScrollbar->getDocPos(), orig_rect.getHeight() - child_rect.getHeight() - 1);
mScrollbar->setDocPos(scroll_pos);
}
- else//shrink child panel
+ else // Shrink child panel
{
updateLayout(child_rect);
}
-
}
-void LLAccordionCtrlTab::hideScrollbar( const LLRect& child_rect )
+void LLAccordionCtrlTab::hideScrollbar(const LLRect& child_rect)
{
- if(!mContainerPanel || !mScrollbar)
+ if (!mContainerPanel || !mScrollbar)
return;
- if(mScrollbar->getVisible() == false)
+ if (mScrollbar->getVisible() == FALSE)
return;
- mScrollbar->setVisible(false);
+
+ mScrollbar->setVisible(FALSE);
mScrollbar->setDocPos(0);
//shrink child panel
updateLayout(child_rect);
}
-void LLAccordionCtrlTab::onScrollPosChangeCallback(S32, LLScrollbar*)
+void LLAccordionCtrlTab::onScrollPosChangeCallback(S32, LLScrollbar*)
{
LLRect child_rect;
@@ -999,21 +1018,20 @@ void LLAccordionCtrlTab::onScrollPosChangeCallback(S32, LLScrollbar*)
updateLayout(child_rect);
}
-void LLAccordionCtrlTab::drawChild(const LLRect& root_rect,LLView* child)
+void LLAccordionCtrlTab::drawChild(const LLRect& root_rect, LLView* child)
{
if (child && child->getVisible() && child->getRect().isValid())
{
LLRect screen_rect;
- localRectToScreen(child->getRect(),&screen_rect);
-
- if ( root_rect.overlaps(screen_rect) && sDirtyRect.overlaps(screen_rect))
+ localRectToScreen(child->getRect(), &screen_rect);
+
+ if (root_rect.overlaps(screen_rect) && sDirtyRect.overlaps(screen_rect))
{
gGL.matrixMode(LLRender::MM_MODELVIEW);
LLUI::pushMatrix();
{
LLUI::translate((F32)child->getRect().mLeft, (F32)child->getRect().mBottom);
child->draw();
-
}
LLUI::popMatrix();
}
@@ -1022,64 +1040,67 @@ void LLAccordionCtrlTab::drawChild(const LLRect& root_rect,LLView* child)
void LLAccordionCtrlTab::draw()
{
- if(mFitPanel)
+ if (mFitPanel)
+ {
LLUICtrl::draw();
+ }
else
{
- LLRect root_rect = getRootView()->getRect();
- drawChild(root_rect,mHeader);
- drawChild(root_rect,mScrollbar );
- {
- LLRect child_rect;
+ LLRect root_rect(getRootView()->getRect());
+ drawChild(root_rect, mHeader);
+ drawChild(root_rect, mScrollbar);
- S32 width = getRect().getWidth();
- S32 height = getRect().getHeight();
+ LLRect child_rect;
- child_rect.setLeftTopAndSize(
- getPaddingLeft(),
- height - getHeaderHeight() - getPaddingTop(),
- width - getPaddingLeft() - getPaddingRight(),
- height - getHeaderHeight() - getPaddingTop() - getPaddingBottom() );
+ S32 width = getRect().getWidth();
+ S32 height = getRect().getHeight();
- LLLocalClipRect clip(child_rect);
- drawChild(root_rect,mContainerPanel);
- }
+ child_rect.setLeftTopAndSize(
+ getPaddingLeft(),
+ height - getHeaderHeight() - getPaddingTop(),
+ width - getPaddingLeft() - getPaddingRight(),
+ height - getHeaderHeight() - getPaddingTop() - getPaddingBottom());
+
+ LLLocalClipRect clip(child_rect);
+ drawChild(root_rect,mContainerPanel);
}
}
-void LLAccordionCtrlTab::updateLayout ( const LLRect& child_rect )
+void LLAccordionCtrlTab::updateLayout(const LLRect& child_rect)
{
LLView* child = getAccordionView();
- if(!mContainerPanel)
+ if (!mContainerPanel)
return;
S32 panel_top = child_rect.getHeight();
S32 panel_width = child_rect.getWidth();
- static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0);
- if(mScrollbar && mScrollbar->getVisible() != false)
+ static LLUICachedControl<S32> scrollbar_size("UIScrollbarSize", 0);
+ if (mScrollbar && mScrollbar->getVisible())
{
- panel_top+=mScrollbar->getDocPos();
- panel_width-=scrollbar_size;
+ panel_top += mScrollbar->getDocPos();
+ panel_width -= scrollbar_size;
}
- //set sizes for first panels and dragbars
+ // Set sizes for first panels and dragbars
LLRect panel_rect = child->getRect();
- ctrlSetLeftTopAndSize(mContainerPanel,child_rect.mLeft,panel_top,panel_width,panel_rect.getHeight());
+ ctrlSetLeftTopAndSize(mContainerPanel, child_rect.mLeft, panel_top, panel_width, panel_rect.getHeight());
}
+
void LLAccordionCtrlTab::ctrlSetLeftTopAndSize(LLView* panel, S32 left, S32 top, S32 width, S32 height)
{
- if(!panel)
+ if (!panel)
return;
LLRect panel_rect = panel->getRect();
- panel_rect.setLeftTopAndSize( left, top, width, height);
+ panel_rect.setLeftTopAndSize(left, top, width, height);
panel->reshape( width, height, 1);
panel->setRect(panel_rect);
}
+
BOOL LLAccordionCtrlTab::handleToolTip(S32 x, S32 y, MASK mask)
{
//header may be not the first child but we need to process it first
- if(y >= (getRect().getHeight() - HEADER_HEIGHT - HEADER_HEIGHT/2) )
+ if (y >= (getRect().getHeight() - HEADER_HEIGHT - HEADER_HEIGHT / 2))
{
//inside tab header
//fix for EXT-6619
@@ -1088,16 +1109,18 @@ BOOL LLAccordionCtrlTab::handleToolTip(S32 x, S32 y, MASK mask)
}
return LLUICtrl::handleToolTip(x, y, mask);
}
-BOOL LLAccordionCtrlTab::handleScrollWheel ( S32 x, S32 y, S32 clicks )
+
+BOOL LLAccordionCtrlTab::handleScrollWheel(S32 x, S32 y, S32 clicks)
{
- if( LLUICtrl::handleScrollWheel(x,y,clicks))
+ if (LLUICtrl::handleScrollWheel(x, y, clicks))
{
return TRUE;
}
- if( mScrollbar && mScrollbar->getVisible() && mScrollbar->handleScrollWheel( 0, 0, clicks ) )
+
+ if (mScrollbar && mScrollbar->getVisible() && mScrollbar->handleScrollWheel(0, 0, clicks))
{
return TRUE;
}
+
return FALSE;
}
-
diff --git a/indra/llui/llaccordionctrltab.h b/indra/llui/llaccordionctrltab.h
index 2c72e8c036..496c34c38b 100644
--- a/indra/llui/llaccordionctrltab.h
+++ b/indra/llui/llaccordionctrltab.h
@@ -104,7 +104,7 @@ public:
virtual void setDisplayChildren(bool display);
// Returns expand/collapse state
- virtual bool getDisplayChildren() const {return mDisplayChildren;};
+ virtual bool getDisplayChildren() const { return mDisplayChildren; };
//set LLAccordionCtrlTab panel
void setAccordionView(LLView* panel);
@@ -126,12 +126,12 @@ public:
void setSelected(bool is_selected);
- bool getCollapsible() {return mCollapsible;};
+ bool getCollapsible() { return mCollapsible; };
- void setCollapsible(bool collapsible) {mCollapsible = collapsible;};
+ void setCollapsible(bool collapsible) { mCollapsible = collapsible; };
void changeOpenClose(bool is_open);
- void canOpenClose(bool can_open_close) { mCanOpenClose = can_open_close;};
+ void canOpenClose(bool can_open_close) { mCanOpenClose = can_open_close; };
bool canOpenClose() const { return mCanOpenClose; };
virtual BOOL postBuild();
@@ -142,8 +142,8 @@ public:
void draw();
- void storeOpenCloseState ();
- void restoreOpenCloseState ();
+ void storeOpenCloseState();
+ void restoreOpenCloseState();
protected:
LLAccordionCtrlTab(const LLAccordionCtrlTab::Params&);
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp
index 3354cb2db3..9ef019840a 100644
--- a/indra/llui/llbutton.cpp
+++ b/indra/llui/llbutton.cpp
@@ -68,6 +68,7 @@ LLButton::Params::Params()
label_shadow("label_shadow", true),
auto_resize("auto_resize", false),
use_ellipses("use_ellipses", false),
+ use_font_color("use_font_color", true),
image_unselected("image_unselected"),
image_selected("image_selected"),
image_hover_selected("image_hover_selected"),
@@ -160,6 +161,7 @@ LLButton::LLButton(const LLButton::Params& p)
mDropShadowedText(p.label_shadow),
mAutoResize(p.auto_resize),
mUseEllipses( p.use_ellipses ),
+ mUseFontColor( p.use_font_color),
mHAlign(p.font_halign),
mLeftHPad(p.pad_left),
mRightHPad(p.pad_right),
@@ -203,7 +205,8 @@ LLButton::LLButton(const LLButton::Params& p)
}
// Hack to make sure there is space for at least one character
- if (getRect().getWidth() - (mRightHPad + mLeftHPad) < mGLFont->getWidth(std::string(" ")))
+ if (getRect().mRight >= 0 && getRect().getWidth() > 0 &&
+ getRect().getWidth() - (mRightHPad + mLeftHPad) < mGLFont->getWidth(std::string(" ")))
{
// Use old defaults
mLeftHPad = llbutton_orig_h_pad;
@@ -960,7 +963,7 @@ void LLButton::draw()
LLFontGL::NORMAL,
mDropShadowedText ? LLFontGL::DROP_SHADOW_SOFT : LLFontGL::NO_SHADOW,
S32_MAX, text_width,
- NULL, mUseEllipses);
+ NULL, mUseEllipses, mUseFontColor);
}
LLUICtrl::draw();
@@ -1020,6 +1023,16 @@ BOOL LLButton::toggleState()
return flipped;
}
+void LLButton::setLabel( const std::string& label )
+{
+ mUnselectedLabel = mSelectedLabel = label;
+}
+
+void LLButton::setLabel( const LLUIString& label )
+{
+ mUnselectedLabel = mSelectedLabel = label;
+}
+
void LLButton::setLabel( const LLStringExplicit& label )
{
setLabelUnselected(label);
@@ -1051,14 +1064,7 @@ bool LLButton::labelIsTruncated() const
const LLUIString& LLButton::getCurrentLabel() const
{
- if( getToggleState() )
- {
- return mSelectedLabel;
- }
- else
- {
- return mUnselectedLabel;
- }
+ return getToggleState() ? mSelectedLabel : mUnselectedLabel;
}
void LLButton::setImageUnselected(LLPointer<LLUIImage> image)
diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h
index ccd31e90c0..257159f64f 100644
--- a/indra/llui/llbutton.h
+++ b/indra/llui/llbutton.h
@@ -73,6 +73,7 @@ public:
Optional<bool> label_shadow;
Optional<bool> auto_resize;
Optional<bool> use_ellipses;
+ Optional<bool> use_font_color;
// images
Optional<LLUIImage*> image_unselected,
@@ -174,6 +175,7 @@ public:
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; }
boost::signals2::connection setClickedCallback(const CommitCallbackParam& cb);
@@ -238,6 +240,8 @@ public:
void autoResize(); // resize with label of current btn state
void resize(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 );
void setLabelUnselected(const LLStringExplicit& label);
@@ -353,6 +357,7 @@ protected:
bool mDropShadowedText;
bool mAutoResize;
bool mUseEllipses;
+ bool mUseFontColor;
bool mBorderEnabled;
bool mFlashing;
diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp
index 3e159365e5..8ef7bd837f 100644
--- a/indra/llui/llcommandmanager.cpp
+++ b/indra/llui/llcommandmanager.cpp
@@ -34,8 +34,6 @@
#include "llerror.h"
#include "llxuiparser.h"
-#include <boost/foreach.hpp>
-
//
// LLCommandId class
@@ -182,7 +180,7 @@ bool LLCommandManager::load()
return false;
}
- BOOST_FOREACH(LLCommand::Params& commandParams, commandsParams.commands)
+ for (const LLCommand::Params& commandParams : commandsParams.commands)
{
LLCommand * command = new LLCommand(commandParams);
diff --git a/indra/llui/llemojidictionary.cpp b/indra/llui/llemojidictionary.cpp
new file mode 100644
index 0000000000..f16c38a11a
--- /dev/null
+++ b/indra/llui/llemojidictionary.cpp
@@ -0,0 +1,469 @@
+/**
+* @file llemojidictionary.cpp
+* @brief Implementation of LLEmojiDictionary
+*
+* $LicenseInfo:firstyear=2014&license=viewerlgpl$
+* Second Life Viewer Source Code
+* Copyright (C) 2014, 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 "lldir.h"
+#include "llemojidictionary.h"
+#include "llsdserialize.h"
+
+#include <boost/algorithm/string.hpp>
+#include <boost/range/adaptor/filtered.hpp>
+#include <boost/range/algorithm/transform.hpp>
+
+// ============================================================================
+// Constants
+//
+
+static const std::string SKINNED_EMOJI_FILENAME("emoji_characters.xml");
+static const std::string SKINNED_CATEGORY_FILENAME("emoji_categories.xml");
+static const std::string COMMON_GROUP_FILENAME("emoji_groups.xml");
+static const std::string GROUP_NAME_SKIP("skip");
+// https://www.compart.com/en/unicode/U+1F302
+static const S32 GROUP_OTHERS_IMAGE_INDEX = 0x1F302;
+
+// ============================================================================
+// Helper functions
+//
+
+template<class T>
+std::list<T> llsd_array_to_list(const LLSD& sd, std::function<void(T&)> mutator = {});
+
+template<>
+std::list<std::string> llsd_array_to_list(const LLSD& sd, std::function<void(std::string&)> mutator)
+{
+ std::list<std::string> result;
+ for (LLSD::array_const_iterator it = sd.beginArray(), end = sd.endArray(); it != end; ++it)
+ {
+ const LLSD& entry = *it;
+ if (!entry.isString())
+ continue;
+
+ result.push_back(entry.asStringRef());
+ if (mutator)
+ {
+ mutator(result.back());
+ }
+ }
+ return result;
+}
+
+struct emoji_filter_base
+{
+ emoji_filter_base(const std::string& needle)
+ {
+ // Search without the colon (if present) so the user can type ':food' and see all emojis in the 'Food' category
+ mNeedle = (boost::starts_with(needle, ":")) ? needle.substr(1) : needle;
+ LLStringUtil::toLower(mNeedle);
+ }
+
+protected:
+ std::string mNeedle;
+};
+
+struct emoji_filter_shortcode_or_category_contains : public emoji_filter_base
+{
+ emoji_filter_shortcode_or_category_contains(const std::string& needle) : emoji_filter_base(needle) {}
+
+ bool operator()(const LLEmojiDescriptor& descr) const
+ {
+ for (const auto& short_code : descr.ShortCodes)
+ {
+ if (boost::icontains(short_code, mNeedle))
+ return true;
+ }
+
+ if (boost::icontains(descr.Category, mNeedle))
+ return true;
+
+ return false;
+ }
+};
+
+std::string LLEmojiDescriptor::getShortCodes() const
+{
+ std::string result;
+ for (const std::string& shortCode : ShortCodes)
+ {
+ if (!result.empty())
+ {
+ result += ", ";
+ }
+ result += shortCode;
+ }
+ return result;
+}
+
+// ============================================================================
+// LLEmojiDictionary class
+//
+
+LLEmojiDictionary::LLEmojiDictionary()
+{
+}
+
+// static
+void LLEmojiDictionary::initClass()
+{
+ LLEmojiDictionary* pThis = &LLEmojiDictionary::initParamSingleton();
+
+ pThis->loadTranslations();
+ pThis->loadGroups();
+ pThis->loadEmojis();
+}
+
+LLWString LLEmojiDictionary::findMatchingEmojis(const std::string& needle) const
+{
+ LLWString result;
+ boost::transform(mEmojis | boost::adaptors::filtered(emoji_filter_shortcode_or_category_contains(needle)),
+ std::back_inserter(result), [](const auto& descr) { return descr.Character; });
+ return result;
+}
+
+// static
+bool LLEmojiDictionary::searchInShortCode(std::size_t& begin, std::size_t& end, const std::string& shortCode, const std::string& needle)
+{
+ begin = 0;
+ end = 1;
+ std::size_t index = 1;
+ // Search for begin
+ char d = tolower(needle[index++]);
+ while (end < shortCode.size())
+ {
+ char s = tolower(shortCode[end++]);
+ if (s == d)
+ {
+ begin = end - 1;
+ break;
+ }
+ }
+ if (!begin)
+ return false;
+ // Search for end
+ d = tolower(needle[index++]);
+ if (!d)
+ return true;
+ while (end < shortCode.size() && index <= needle.size())
+ {
+ char s = tolower(shortCode[end++]);
+ if (s == d)
+ {
+ if (index == needle.size())
+ return true;
+ d = tolower(needle[index++]);
+ continue;
+ }
+ switch (s)
+ {
+ case L'-':
+ case L'_':
+ case L'+':
+ continue;
+ }
+ break;
+ }
+ return false;
+}
+
+void LLEmojiDictionary::findByShortCode(
+ std::vector<LLEmojiSearchResult>& result,
+ const std::string& needle
+) const
+{
+ result.clear();
+
+ if (needle.empty() || needle.front() != ':')
+ return;
+
+ std::map<llwchar, std::vector<LLEmojiSearchResult>> results;
+
+ for (const LLEmojiDescriptor& d : mEmojis)
+ {
+ if (!d.ShortCodes.empty())
+ {
+ const std::string& shortCode = d.ShortCodes.front();
+ if (shortCode.size() >= needle.size() && shortCode.front() == needle.front())
+ {
+ std::size_t begin, end;
+ if (searchInShortCode(begin, end, shortCode, needle))
+ {
+ results[begin].emplace_back(d.Character, shortCode, begin, end);
+ }
+ }
+ }
+ }
+
+ for (const auto& it : results)
+ {
+#ifdef __cpp_lib_containers_ranges
+ result.append_range(it.second);
+#else
+ result.insert(result.end(), it.second.cbegin(), it.second.cend());
+#endif
+ }
+}
+
+const LLEmojiDescriptor* LLEmojiDictionary::getDescriptorFromEmoji(llwchar emoji) const
+{
+ const auto it = mEmoji2Descr.find(emoji);
+ return (mEmoji2Descr.end() != it) ? it->second : nullptr;
+}
+
+const LLEmojiDescriptor* LLEmojiDictionary::getDescriptorFromShortCode(const std::string& short_code) const
+{
+ const auto it = mShortCode2Descr.find(short_code);
+ return (mShortCode2Descr.end() != it) ? it->second : nullptr;
+}
+
+std::string LLEmojiDictionary::getNameFromEmoji(llwchar ch) const
+{
+ const auto it = mEmoji2Descr.find(ch);
+ return (mEmoji2Descr.end() != it) ? it->second->ShortCodes.front() : LLStringUtil::null;
+}
+
+bool LLEmojiDictionary::isEmoji(llwchar ch) const
+{
+ // Currently used codes: A9,AE,203C,2049,2122,...,2B55,3030,303D,3297,3299,1F004,...,1FAF6
+ if (ch == 0xA9 || ch == 0xAE || (ch >= 0x2000 && ch < 0x3300) || (ch >= 0x1F000 && ch < 0x20000))
+ {
+ return mEmoji2Descr.find(ch) != mEmoji2Descr.end();
+ }
+
+ return false;
+}
+
+void LLEmojiDictionary::loadTranslations()
+{
+ std::vector<std::string> filenames = gDirUtilp->findSkinnedFilenames(LLDir::XUI, SKINNED_CATEGORY_FILENAME, LLDir::CURRENT_SKIN);
+ if (filenames.empty())
+ {
+ LL_WARNS() << "Emoji file categories not found" << LL_ENDL;
+ return;
+ }
+
+ const std::string filename = filenames.back();
+ llifstream file(filename.c_str());
+ if (!file.is_open())
+ {
+ LL_WARNS() << "Emoji file categories failed to open" << LL_ENDL;
+ return;
+ }
+
+ LL_DEBUGS() << "Loading emoji categories file at " << filename << LL_ENDL;
+
+ LLSD data;
+ LLSDSerialize::fromXML(data, file);
+ if (data.isUndefined())
+ {
+ LL_WARNS() << "Emoji file categories missing or ill-formed" << LL_ENDL;
+ return;
+ }
+
+ // Register translations for all categories
+ for (LLSD::array_const_iterator it = data.beginArray(), end = data.endArray(); it != end; ++it)
+ {
+ const LLSD& sd = *it;
+ const std::string& name = sd["Name"].asStringRef();
+ const std::string& category = sd["Category"].asStringRef();
+ if (!name.empty() && !category.empty())
+ {
+ mTranslations[name] = category;
+ }
+ else
+ {
+ LL_WARNS() << "Skipping invalid emoji category '" << name << "' => '" << category << "'" << LL_ENDL;
+ }
+ }
+}
+
+void LLEmojiDictionary::loadGroups()
+{
+ const std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, COMMON_GROUP_FILENAME);
+ llifstream file(filename.c_str());
+ if (!file.is_open())
+ {
+ LL_WARNS() << "Emoji file groups failed to open" << LL_ENDL;
+ return;
+ }
+
+ LL_DEBUGS() << "Loading emoji groups file at " << filename << LL_ENDL;
+
+ LLSD data;
+ LLSDSerialize::fromXML(data, file);
+ if (data.isUndefined())
+ {
+ LL_WARNS() << "Emoji file groups missing or ill-formed" << LL_ENDL;
+ return;
+ }
+
+ mGroups.clear();
+
+ // Register all groups
+ for (LLSD::array_const_iterator it = data.beginArray(), end = data.endArray(); it != end; ++it)
+ {
+ const LLSD& sd = *it;
+ const std::string& name = sd["Name"].asStringRef();
+ if (name == GROUP_NAME_SKIP)
+ {
+ mSkipCategories = loadCategories(sd);
+ translateCategories(mSkipCategories);
+ }
+ else
+ {
+ // Add new group
+ mGroups.emplace_back();
+ LLEmojiGroup& group = mGroups.back();
+ group.Character = loadIcon(sd);
+ group.Categories = loadCategories(sd);
+ translateCategories(group.Categories);
+
+ for (const std::string& category : group.Categories)
+ {
+ mCategory2Group.insert(std::make_pair(category, &group));
+ }
+ }
+ }
+
+ // Add group "others"
+ mGroups.emplace_back();
+ mGroups.back().Character = GROUP_OTHERS_IMAGE_INDEX;
+}
+
+void LLEmojiDictionary::loadEmojis()
+{
+ std::vector<std::string> filenames = gDirUtilp->findSkinnedFilenames(LLDir::XUI, SKINNED_EMOJI_FILENAME, LLDir::CURRENT_SKIN);
+ if (filenames.empty())
+ {
+ LL_WARNS() << "Emoji file characters not found" << LL_ENDL;
+ return;
+ }
+
+ const std::string filename = filenames.back();
+ llifstream file(filename.c_str());
+ if (!file.is_open())
+ {
+ LL_WARNS() << "Emoji file characters failed to open" << LL_ENDL;
+ return;
+ }
+
+ LL_DEBUGS() << "Loading emoji characters file at " << filename << LL_ENDL;
+
+ LLSD data;
+ LLSDSerialize::fromXML(data, file);
+ if (data.isUndefined())
+ {
+ LL_WARNS() << "Emoji file characters missing or ill-formed" << LL_ENDL;
+ return;
+ }
+
+ for (LLSD::array_const_iterator it = data.beginArray(), end = data.endArray(); it != end; ++it)
+ {
+ const LLSD& sd = *it;
+
+ llwchar icon = loadIcon(sd);
+ if (!icon)
+ {
+ LL_WARNS() << "Skipping invalid emoji descriptor (no icon)" << LL_ENDL;
+ continue;
+ }
+
+ std::list<std::string> categories = loadCategories(sd);
+ if (categories.empty())
+ {
+ LL_WARNS() << "Skipping invalid emoji descriptor (no categories)" << LL_ENDL;
+ continue;
+ }
+
+ std::string category = categories.front();
+
+ if (std::find(mSkipCategories.begin(), mSkipCategories.end(), category) != mSkipCategories.end())
+ {
+ // This category is listed for skip
+ continue;
+ }
+
+ std::list<std::string> shortCodes = loadShortCodes(sd);
+ if (shortCodes.empty())
+ {
+ LL_WARNS() << "Skipping invalid emoji descriptor (no shortCodes)" << LL_ENDL;
+ continue;
+ }
+
+ if (mCategory2Group.find(category) == mCategory2Group.end())
+ {
+ // Add unknown category to "others" group
+ mGroups.back().Categories.push_back(category);
+ mCategory2Group.insert(std::make_pair(category, &mGroups.back()));
+ }
+
+ mEmojis.emplace_back();
+ LLEmojiDescriptor& emoji = mEmojis.back();
+ emoji.Character = icon;
+ emoji.Category = category;
+ emoji.ShortCodes = std::move(shortCodes);
+
+ mEmoji2Descr.insert(std::make_pair(icon, &emoji));
+ mCategory2Descrs[category].push_back(&emoji);
+ for (const std::string& shortCode : emoji.ShortCodes)
+ {
+ mShortCode2Descr.insert(std::make_pair(shortCode, &emoji));
+ }
+ }
+}
+
+llwchar LLEmojiDictionary::loadIcon(const LLSD& sd)
+{
+ // We don't currently support character composition
+ const LLWString icon = utf8str_to_wstring(sd["Character"].asString());
+ return (1 == icon.size()) ? icon[0] : L'\0';
+}
+
+std::list<std::string> LLEmojiDictionary::loadCategories(const LLSD& sd)
+{
+ static const std::string key("Categories");
+ return llsd_array_to_list<std::string>(sd[key]);
+}
+
+std::list<std::string> LLEmojiDictionary::loadShortCodes(const LLSD& sd)
+{
+ static const std::string key("ShortCodes");
+ auto toLower = [](std::string& str) { LLStringUtil::toLower(str); };
+ return llsd_array_to_list<std::string>(sd[key], toLower);
+}
+
+void LLEmojiDictionary::translateCategories(std::list<std::string>& categories)
+{
+ for (std::string& category : categories)
+ {
+ auto it = mTranslations.find(category);
+ if (it != mTranslations.end())
+ {
+ category = it->second;
+ }
+ }
+}
+
+// ============================================================================
diff --git a/indra/llui/llemojidictionary.h b/indra/llui/llemojidictionary.h
new file mode 100644
index 0000000000..4af376df64
--- /dev/null
+++ b/indra/llui/llemojidictionary.h
@@ -0,0 +1,126 @@
+/**
+* @file llemojidictionary.h
+* @brief Header file for LLEmojiDictionary
+*
+* $LicenseInfo:firstyear=2014&license=viewerlgpl$
+* Second Life Viewer Source Code
+* Copyright (C) 2014, 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 "lldictionary.h"
+#include "llinitdestroyclass.h"
+#include "llsingleton.h"
+
+// ============================================================================
+// LLEmojiDescriptor class
+//
+
+struct LLEmojiDescriptor
+{
+ llwchar Character;
+ std::string Category;
+ std::list<std::string> ShortCodes;
+ std::string getShortCodes() const;
+};
+
+// ============================================================================
+// LLEmojiGroup class
+//
+
+struct LLEmojiGroup
+{
+ llwchar Character;
+ std::list<std::string> Categories;
+};
+
+// ============================================================================
+// LLEmojiSearchResult class
+//
+
+struct LLEmojiSearchResult
+{
+ llwchar Character;
+ std::string String;
+ std::size_t Begin, End;
+
+ LLEmojiSearchResult(llwchar character, const std::string& string, std::size_t begin, std::size_t end)
+ : Character(character)
+ , String(string)
+ , Begin(begin)
+ , End(end)
+ {
+ }
+};
+
+// ============================================================================
+// LLEmojiDictionary class
+//
+
+class LLEmojiDictionary : public LLParamSingleton<LLEmojiDictionary>, public LLInitClass<LLEmojiDictionary>
+{
+ LLSINGLETON(LLEmojiDictionary);
+ ~LLEmojiDictionary() override {};
+
+public:
+ typedef std::map<std::string, std::string> cat2cat_map_t;
+ typedef std::map<std::string, const LLEmojiGroup*> cat2group_map_t;
+ typedef std::map<llwchar, const LLEmojiDescriptor*> emoji2descr_map_t;
+ typedef std::map<std::string, const LLEmojiDescriptor*> code2descr_map_t;
+ typedef std::map<std::string, std::vector<const LLEmojiDescriptor*>> cat2descrs_map_t;
+
+ static void initClass();
+ LLWString findMatchingEmojis(const std::string& needle) const;
+ static bool searchInShortCode(std::size_t& begin, std::size_t& end, const std::string& shortCode, const std::string& needle);
+ void findByShortCode(std::vector<LLEmojiSearchResult>& result, const std::string& needle) const;
+ const LLEmojiDescriptor* getDescriptorFromEmoji(llwchar emoji) const;
+ const LLEmojiDescriptor* getDescriptorFromShortCode(const std::string& short_code) const;
+ std::string getNameFromEmoji(llwchar ch) const;
+ bool isEmoji(llwchar ch) const;
+
+ const std::vector<LLEmojiGroup>& getGroups() const { return mGroups; }
+ const emoji2descr_map_t& getEmoji2Descr() const { return mEmoji2Descr; }
+ const cat2descrs_map_t& getCategory2Descrs() const { return mCategory2Descrs; }
+ const code2descr_map_t& getShortCode2Descr() const { return mShortCode2Descr; }
+
+private:
+ void loadTranslations();
+ void loadGroups();
+ void loadEmojis();
+
+ static llwchar loadIcon(const LLSD& sd);
+ static std::list<std::string> loadCategories(const LLSD& sd);
+ static std::list<std::string> loadShortCodes(const LLSD& sd);
+ void translateCategories(std::list<std::string>& categories);
+
+private:
+ std::vector<LLEmojiGroup> mGroups;
+ std::list<LLEmojiDescriptor> mEmojis;
+ std::list<std::string> mSkipCategories;
+
+ cat2cat_map_t mTranslations;
+ cat2group_map_t mCategory2Group;
+ emoji2descr_map_t mEmoji2Descr;
+ cat2descrs_map_t mCategory2Descrs;
+ code2descr_map_t mShortCode2Descr;
+};
+
+// ============================================================================
diff --git a/indra/llui/llemojihelper.cpp b/indra/llui/llemojihelper.cpp
new file mode 100644
index 0000000000..89e6ddf987
--- /dev/null
+++ b/indra/llui/llemojihelper.cpp
@@ -0,0 +1,169 @@
+/**
+* @file llemojihelper.h
+* @brief Header file for LLEmojiHelper
+*
+* $LicenseInfo:firstyear=2014&license=viewerlgpl$
+* Second Life Viewer Source Code
+* Copyright (C) 2014, 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 "llemojidictionary.h"
+#include "llemojihelper.h"
+#include "llfloater.h"
+#include "llfloaterreg.h"
+#include "lluictrl.h"
+
+// ============================================================================
+// Constants
+//
+
+constexpr char DEFAULT_EMOJI_HELPER_FLOATER[] = "emoji_picker";
+constexpr S32 HELPER_FLOATER_OFFSET_X = 0;
+constexpr S32 HELPER_FLOATER_OFFSET_Y = 0;
+
+// ============================================================================
+// LLEmojiHelper
+//
+
+std::string LLEmojiHelper::getToolTip(llwchar ch) const
+{
+ return LLEmojiDictionary::instance().getNameFromEmoji(ch);
+}
+
+bool LLEmojiHelper::isActive(const LLUICtrl* ctrl_p) const
+{
+ return mHostHandle.get() == ctrl_p;
+}
+
+// static
+bool LLEmojiHelper::isCursorInEmojiCode(const LLWString& wtext, S32 cursorPos, S32* pShortCodePos)
+{
+ // If the cursor is currently on a colon start the check one character further back
+ S32 shortCodePos = (cursorPos == 0 || L':' != wtext[cursorPos - 1]) ? cursorPos : cursorPos - 1;
+
+ auto isPartOfShortcode = [](llwchar ch) {
+ switch (ch)
+ {
+ case L'-':
+ case L'_':
+ case L'+':
+ return true;
+ default:
+ return LLStringOps::isAlnum(ch);
+ }
+ };
+ while (shortCodePos > 1 && isPartOfShortcode(wtext[shortCodePos - 1]))
+ {
+ shortCodePos--;
+ }
+
+ bool isShortCode = (L':' == wtext[shortCodePos - 1]) && (cursorPos - shortCodePos >= 2);
+ if (pShortCodePos)
+ *pShortCodePos = (isShortCode) ? shortCodePos - 1 : -1;
+ return isShortCode;
+}
+
+void LLEmojiHelper::showHelper(LLUICtrl* hostctrl_p, S32 local_x, S32 local_y, const std::string& short_code, std::function<void(llwchar)> cb)
+{
+ // Commit immediately if the user already typed a full shortcode
+ if (const auto* emojiDescrp = LLEmojiDictionary::instance().getDescriptorFromShortCode(short_code))
+ {
+ cb(emojiDescrp->Character);
+ hideHelper();
+ return;
+ }
+
+ if (mHelperHandle.isDead())
+ {
+ 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));
+ }
+ setHostCtrl(hostctrl_p);
+ mEmojiCommitCb = cb;
+
+ S32 floater_x, floater_y;
+ if (!hostctrl_p->localPointToOtherView(local_x, local_y, &floater_x, &floater_y, gFloaterView))
+ {
+ LL_ERRS() << "Cannot show emoji helper for non-floater controls." << LL_ENDL;
+ return;
+ }
+
+ LLFloater* pHelperFloater = mHelperHandle.get();
+ LLRect rect = pHelperFloater->getRect();
+ S32 left = floater_x - HELPER_FLOATER_OFFSET_X;
+ S32 top = floater_y - HELPER_FLOATER_OFFSET_Y + rect.getHeight();
+ rect.setLeftTopAndSize(left, top, rect.getWidth(), rect.getHeight());
+ pHelperFloater->setRect(rect);
+ pHelperFloater->openFloater(LLSD().with("hint", short_code));
+}
+
+void LLEmojiHelper::hideHelper(const LLUICtrl* ctrl_p, bool strict)
+{
+ mIsHideDisabled &= !strict;
+ if (mIsHideDisabled || (ctrl_p && !isActive(ctrl_p)))
+ {
+ return;
+ }
+
+ setHostCtrl(nullptr);
+}
+
+bool LLEmojiHelper::handleKey(const LLUICtrl* ctrl_p, KEY key, MASK mask)
+{
+ if (mHelperHandle.isDead() || !isActive(ctrl_p))
+ {
+ return false;
+ }
+
+ return mHelperHandle.get()->handleKey(key, mask, true);
+}
+
+void LLEmojiHelper::onCommitEmoji(llwchar emoji)
+{
+ if (!mHostHandle.isDead() && mEmojiCommitCb)
+ {
+ mEmojiCommitCb(emoji);
+ }
+}
+
+void LLEmojiHelper::setHostCtrl(LLUICtrl* hostctrl_p)
+{
+ const LLUICtrl* pCurHostCtrl = mHostHandle.get();
+ if (pCurHostCtrl != hostctrl_p)
+ {
+ mHostCtrlFocusLostConn.disconnect();
+ mHostHandle.markDead();
+ mEmojiCommitCb = {};
+
+ if (!mHelperHandle.isDead())
+ {
+ mHelperHandle.get()->closeFloater();
+ }
+
+ if (hostctrl_p)
+ {
+ mHostHandle = hostctrl_p->getHandle();
+ mHostCtrlFocusLostConn = hostctrl_p->setFocusLostCallback(std::bind([&]() { hideHelper(getHostCtrl()); }));
+ }
+ }
+}
diff --git a/indra/llui/llemojihelper.h b/indra/llui/llemojihelper.h
new file mode 100644
index 0000000000..e826ff93e6
--- /dev/null
+++ b/indra/llui/llemojihelper.h
@@ -0,0 +1,66 @@
+/**
+* @file llemojihelper.h
+* @brief Header file for LLEmojiHelper
+*
+* $LicenseInfo:firstyear=2014&license=viewerlgpl$
+* Second Life Viewer Source Code
+* Copyright (C) 2014, 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 LLEmojiHelper : public LLSingleton<LLEmojiHelper>
+{
+ LLSINGLETON(LLEmojiHelper) {}
+ ~LLEmojiHelper() override {}
+
+public:
+ // General
+ std::string getToolTip(llwchar ch) const;
+ bool isActive(const LLUICtrl* ctrl_p) const;
+ static bool isCursorInEmojiCode(const LLWString& wtext, S32 cursor_pos, S32* short_code_pos_p = nullptr);
+ void showHelper(LLUICtrl* hostctrl_p, S32 local_x, S32 local_y, const std::string& short_code, std::function<void(llwchar)> commit_cb);
+ void hideHelper(const LLUICtrl* ctrl_p = nullptr, bool strict = false);
+ void setIsHideDisabled(bool disabled) { mIsHideDisabled = disabled; };
+
+ // Eventing
+ bool handleKey(const LLUICtrl* ctrl_p, KEY key, MASK mask);
+ void onCommitEmoji(llwchar emoji);
+
+protected:
+ LLUICtrl* getHostCtrl() const { return mHostHandle.get(); }
+ void setHostCtrl(LLUICtrl* hostctrl_p);
+
+private:
+ LLHandle<LLUICtrl> mHostHandle;
+ LLHandle<LLFloater> mHelperHandle;
+ boost::signals2::connection mHostCtrlFocusLostConn;
+ boost::signals2::connection mHelperCommitConn;
+ std::function<void(llwchar)> mEmojiCommitCb;
+ bool mIsHideDisabled;
+};
diff --git a/indra/llui/llfiltereditor.h b/indra/llui/llfiltereditor.h
index 3a05bc05a1..52cad3bff4 100644
--- a/indra/llui/llfiltereditor.h
+++ b/indra/llui/llfiltereditor.h
@@ -43,6 +43,7 @@ class LLFilterEditor : public LLSearchEditor
public:
struct Params : public LLInitParam::Block<Params, LLSearchEditor::Params>
{};
+ virtual ~LLFilterEditor() {}
protected:
LLFilterEditor(const Params&);
diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp
index b13e7389cc..fd4c33df30 100644
--- a/indra/llui/llflatlistview.cpp
+++ b/indra/llui/llflatlistview.cpp
@@ -1198,7 +1198,7 @@ void LLFlatListView::onFocusReceived()
{
if (size())
{
- mSelectedItemsBorder->setVisible(TRUE);
+ mSelectedItemsBorder->setVisible(TRUE);
}
gEditMenuHandler = this;
}
@@ -1207,7 +1207,7 @@ void LLFlatListView::onFocusLost()
{
mSelectedItemsBorder->setVisible(FALSE);
// Route menu back to the default
- if( gEditMenuHandler == this )
+ if (gEditMenuHandler == this)
{
gEditMenuHandler = NULL;
}
@@ -1216,16 +1216,16 @@ void LLFlatListView::onFocusLost()
//virtual
S32 LLFlatListView::notify(const LLSD& info)
{
- if(info.has("action"))
+ if (info.has("action"))
{
std::string str_action = info["action"];
- if(str_action == "select_first")
+ if (str_action == "select_first")
{
setFocus(true);
selectFirstItem();
return 1;
}
- else if(str_action == "select_last")
+ else if (str_action == "select_last")
{
setFocus(true);
selectLastItem();
@@ -1238,6 +1238,7 @@ S32 LLFlatListView::notify(const LLSD& info)
notifyParentItemsRectChanged();
return 1;
}
+
return 0;
}
@@ -1249,10 +1250,8 @@ 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.
- for (pairs_iterator_t
- iter = mItemPairs.begin(),
- iter_end = mItemPairs.end();
- iter != iter_end; ++iter)
+ pairs_iterator_t iter = mItemPairs.begin(), iter_end = mItemPairs.end();
+ while (iter != iter_end)
{
LLPanel* pItem = (*iter)->first;
if (1 == pItem->notify(action))
@@ -1261,6 +1260,7 @@ void LLFlatListView::detachItems(std::vector<LLPanel*>& detached_items)
mItemsPanel->removeChild(pItem);
detached_items.push_back(pItem);
}
+ iter++;
}
if (!detached_items.empty())
{
@@ -1268,13 +1268,12 @@ void LLFlatListView::detachItems(std::vector<LLPanel*>& detached_items)
if (detached_items.size() == mItemPairs.size())
{
// This way will be faster if all items were disconnected
- for (pairs_iterator_t
- iter = mItemPairs.begin(),
- iter_end = mItemPairs.end();
- iter != iter_end; ++iter)
+ pairs_iterator_t iter = mItemPairs.begin(), iter_end = mItemPairs.end();
+ while (iter != iter_end)
{
(*iter)->first = NULL;
delete *iter;
+ iter++;
}
mItemPairs.clear();
// Also set items panel height to zero.
@@ -1287,16 +1286,14 @@ void LLFlatListView::detachItems(std::vector<LLPanel*>& detached_items)
}
else
{
- for (std::vector<LLPanel*>::const_iterator
- detached_iter = detached_items.begin(),
- detached_iter_end = detached_items.end();
- detached_iter != detached_iter_end; ++detached_iter)
+ std::vector<LLPanel*>::const_iterator
+ detached_iter = detached_items.begin(),
+ detached_iter_end = detached_items.end();
+ while (detached_iter < detached_iter_end)
{
LLPanel* pDetachedItem = *detached_iter;
- for (pairs_iterator_t
- iter = mItemPairs.begin(),
- iter_end = mItemPairs.end();
- iter != iter_end; ++iter)
+ pairs_iterator_t iter = mItemPairs.begin(), iter_end = mItemPairs.end();
+ while (iter != iter_end)
{
item_pair_t* item_pair = *iter;
if (item_pair->first == pDetachedItem)
@@ -1306,7 +1303,9 @@ void LLFlatListView::detachItems(std::vector<LLPanel*>& detached_items)
delete item_pair;
break;
}
+ iter++;
}
+ detached_iter++;
}
rearrangeItems();
}
@@ -1322,7 +1321,6 @@ LLFlatListViewEx::Params::Params()
: no_items_msg("no_items_msg")
, no_filtered_items_msg("no_filtered_items_msg")
{
-
}
LLFlatListViewEx::LLFlatListViewEx(const Params& p)
@@ -1332,7 +1330,6 @@ LLFlatListViewEx::LLFlatListViewEx(const Params& p)
, mForceShowingUnmatchedItems(false)
, mHasMatchedItems(false)
{
-
}
void LLFlatListViewEx::updateNoItemsMessage(const std::string& filter_string)
@@ -1352,7 +1349,6 @@ void LLFlatListViewEx::updateNoItemsMessage(const std::string& filter_string)
// list does not contain any items at all
setNoItemsCommentText(mNoItemsMsg);
}
-
}
bool LLFlatListViewEx::getForceShowingUnmatchedItems()
@@ -1365,26 +1361,28 @@ void LLFlatListViewEx::setForceShowingUnmatchedItems(bool show)
mForceShowingUnmatchedItems = show;
}
-void LLFlatListViewEx::setFilterSubString(const std::string& filter_str)
+void LLFlatListViewEx::setFilterSubString(const std::string& filter_str, bool notify_parent)
{
if (0 != LLStringUtil::compareInsensitive(filter_str, mFilterSubString))
{
mFilterSubString = filter_str;
updateNoItemsMessage(mFilterSubString);
- filterItems();
+ filterItems(false, notify_parent);
}
}
-void LLFlatListViewEx::updateItemVisibility(LLPanel* item, const LLSD &action)
+bool LLFlatListViewEx::updateItemVisibility(LLPanel* item, const LLSD &action)
{
- if (!item) return;
+ if (!item)
+ return false;
+
+ BOOL visible = TRUE;
// 0 signifies that filter is matched,
// i.e. we don't hide items that don't support 'match_filter' action, separators etc.
if (0 == item->notify(action))
{
mHasMatchedItems = true;
- item->setVisible(true);
}
else
{
@@ -1392,36 +1390,45 @@ void LLFlatListViewEx::updateItemVisibility(LLPanel* item, const LLSD &action)
if (!mForceShowingUnmatchedItems)
{
selectItem(item, false);
+ visible = FALSE;
}
- item->setVisible(mForceShowingUnmatchedItems);
}
+
+ if (item->getVisible() != visible)
+ {
+ item->setVisible(visible);
+ return true;
+ }
+
+ return false;
}
-void LLFlatListViewEx::filterItems()
+void LLFlatListViewEx::filterItems(bool re_sort, bool notify_parent)
{
- typedef std::vector <LLPanel*> item_panel_list_t;
-
std::string cur_filter = mFilterSubString;
LLStringUtil::toUpper(cur_filter);
LLSD action;
action.with("match_filter", cur_filter);
- item_panel_list_t items;
- getItems(items);
-
mHasMatchedItems = false;
- for (item_panel_list_t::iterator
- iter = items.begin(),
- iter_end = items.end();
- iter != iter_end; ++iter)
+ bool visibility_changed = false;
+ pairs_const_iterator_t iter = getItemPairs().begin(), iter_end = getItemPairs().end();
+ while (iter != iter_end)
{
- LLPanel* pItem = (*iter);
- updateItemVisibility(pItem, action);
+ LLPanel* pItem = (*(iter++))->first;
+ visibility_changed |= updateItemVisibility(pItem, action);
}
- sort();
- notifyParentItemsRectChanged();
+ if (re_sort)
+ {
+ sort();
+ }
+
+ if (visibility_changed && notify_parent)
+ {
+ notifyParentItemsRectChanged();
+ }
}
bool LLFlatListViewEx::hasMatchedItems()
diff --git a/indra/llui/llflatlistview.h b/indra/llui/llflatlistview.h
index d47c1cf333..adb0e3e553 100644
--- a/indra/llui/llflatlistview.h
+++ b/indra/llui/llflatlistview.h
@@ -300,6 +300,7 @@ public:
virtual S32 notify(const LLSD& info) ;
virtual ~LLFlatListView();
+
protected:
/** Pairs LLpanel representing a single item LLPanel and LLSD associated with it */
@@ -375,7 +376,9 @@ protected:
LLRect getLastSelectedItemRect();
- void ensureSelectedVisible();
+ void ensureSelectedVisible();
+
+ const pairs_list_t& getItemPairs() { return mItemPairs; }
private:
@@ -482,14 +485,14 @@ public:
/**
* Sets up new filter string and filters the list.
*/
- void setFilterSubString(const std::string& filter_str);
+ void setFilterSubString(const std::string& filter_str, bool notify_parent);
std::string getFilterSubString() { return mFilterSubString; }
/**
* Filters the list, rearranges and notifies parent about shape changes.
* Derived classes may want to overload rearrangeItems() to exclude repeated separators after filtration.
*/
- void filterItems();
+ void filterItems(bool re_sort, bool notify_parent);
/**
* Returns true if last call of filterItems() found at least one matching item
@@ -513,7 +516,7 @@ protected:
* @param item - item we are changing
* @param item - action - parameters to determin visibility from
*/
- void updateItemVisibility(LLPanel* item, const LLSD &action);
+ bool updateItemVisibility(LLPanel* item, const LLSD &action);
private:
std::string mNoFilteredItemsMsg;
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 2303cd24b7..c7b04c905c 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -59,7 +59,6 @@
#include "llmultifloater.h"
#include "llsdutil.h"
#include "lluiusage.h"
-#include <boost/foreach.hpp>
// use this to control "jumping" behavior when Ctrl-Tabbing
@@ -182,6 +181,7 @@ LLFloater::Params::Params()
save_visibility("save_visibility", false),
can_dock("can_dock", false),
show_title("show_title", true),
+ auto_close("auto_close", false),
positioning("positioning", LLFloaterEnums::POSITIONING_RELATIVE),
header_height("header_height", 0),
legacy_header_height("legacy_header_height", 0),
@@ -254,6 +254,7 @@ LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p)
mCanClose(p.can_close),
mDragOnLeft(p.can_drag_on_left),
mResizable(p.can_resize),
+ mAutoClose(p.auto_close),
mPositioning(p.positioning),
mMinWidth(p.min_width),
mMinHeight(p.min_height),
@@ -681,7 +682,7 @@ void LLFloater::openFloater(const LLSD& key)
if (getHost() != NULL)
{
getHost()->setMinimized(FALSE);
- getHost()->setVisibleAndFrontmost(mAutoFocus);
+ getHost()->setVisibleAndFrontmost(mAutoFocus && !getIsChrome());
getHost()->showFloater(this);
}
else
@@ -693,7 +694,7 @@ void LLFloater::openFloater(const LLSD& key)
}
applyControlsAndPosition(floater_to_stack);
setMinimized(FALSE);
- setVisibleAndFrontmost(mAutoFocus);
+ setVisibleAndFrontmost(mAutoFocus && !getIsChrome());
}
mOpenSignal(this, key);
@@ -829,6 +830,24 @@ void LLFloater::reshape(S32 width, S32 height, BOOL called_from_parent)
LLPanel::reshape(width, height, called_from_parent);
}
+// virtual
+void LLFloater::translate(S32 x, S32 y)
+{
+ LLView::translate(x, y);
+
+ if (!mTranslateWithDependents || mDependents.empty())
+ return;
+
+ for (const LLHandle<LLFloater>& handle : mDependents)
+ {
+ LLFloater* floater = handle.get();
+ if (floater && floater->getSnapTarget() == getHandle())
+ {
+ floater->LLView::translate(x, y);
+ }
+ }
+}
+
void LLFloater::releaseFocus()
{
LLUI::getInstance()->removePopup(this);
@@ -1117,9 +1136,9 @@ BOOL LLFloater::canSnapTo(const LLView* other_view)
if (other_view != getParent())
{
- const LLFloater* other_floaterp = dynamic_cast<const LLFloater*>(other_view);
- if (other_floaterp
- && other_floaterp->getSnapTarget() == getHandle()
+ const LLFloater* other_floaterp = dynamic_cast<const LLFloater*>(other_view);
+ if (other_floaterp
+ && other_floaterp->getSnapTarget() == getHandle()
&& mDependents.find(other_floaterp->getHandle()) != mDependents.end())
{
// this is a dependent that is already snapped to us, so don't snap back to it
@@ -1509,30 +1528,40 @@ BOOL LLFloater::isFrontmost()
&& floater_view->getFrontmost() == this);
}
-void LLFloater::addDependentFloater(LLFloater* floaterp, BOOL reposition)
+void LLFloater::addDependentFloater(LLFloater* floaterp, BOOL reposition, BOOL resize)
{
mDependents.insert(floaterp->getHandle());
floaterp->mDependeeHandle = getHandle();
if (reposition)
{
- floaterp->setRect(gFloaterView->findNeighboringPosition(this, floaterp));
+ LLRect rect = gFloaterView->findNeighboringPosition(this, floaterp);
+ if (resize)
+ {
+ const LLRect& base = getRect();
+ if (rect.mTop == base.mTop)
+ rect.mBottom = base.mBottom;
+ else if (rect.mLeft == base.mLeft)
+ rect.mRight = base.mRight;
+ floaterp->reshape(rect.getWidth(), rect.getHeight(), FALSE);
+ }
+ floaterp->setRect(rect);
floaterp->setSnapTarget(getHandle());
}
gFloaterView->adjustToFitScreen(floaterp, FALSE, TRUE);
if (floaterp->isFrontmost())
{
// make sure to bring self and sibling floaters to front
- gFloaterView->bringToFront(floaterp);
+ gFloaterView->bringToFront(floaterp, floaterp->getAutoFocus() && !getIsChrome());
}
}
-void LLFloater::addDependentFloater(LLHandle<LLFloater> dependent, BOOL reposition)
+void LLFloater::addDependentFloater(LLHandle<LLFloater> dependent, BOOL reposition, BOOL resize)
{
LLFloater* dependent_floaterp = dependent.get();
if(dependent_floaterp)
{
- addDependentFloater(dependent_floaterp, reposition);
+ addDependentFloater(dependent_floaterp, reposition, resize);
}
}
@@ -1542,6 +1571,44 @@ void LLFloater::removeDependentFloater(LLFloater* floaterp)
floaterp->mDependeeHandle = LLHandle<LLFloater>();
}
+void LLFloater::fitWithDependentsOnScreen(const LLRect& left, const LLRect& bottom, const LLRect& right, const LLRect& constraint, S32 min_overlap_pixels)
+{
+ LLRect total_rect = getRect();
+
+ for (const LLHandle<LLFloater>& handle : mDependents)
+ {
+ LLFloater* floater = handle.get();
+ if (floater && floater->getSnapTarget() == getHandle())
+ {
+ total_rect.unionWith(floater->getRect());
+ }
+ }
+
+ S32 delta_left = left.notEmpty() ? left.mRight - total_rect.mRight : 0;
+ S32 delta_bottom = bottom.notEmpty() ? bottom.mTop - total_rect.mTop : 0;
+ S32 delta_right = right.notEmpty() ? right.mLeft - total_rect.mLeft : 0;
+
+ // move floater with dependings fully onscreen
+ mTranslateWithDependents = true;
+ if (translateRectIntoRect(total_rect, constraint, min_overlap_pixels))
+ {
+ clearSnapTarget();
+ }
+ else if (delta_left > 0 && total_rect.mTop < left.mTop && total_rect.mBottom > left.mBottom)
+ {
+ translate(delta_left, 0);
+ }
+ else if (delta_bottom > 0 && total_rect.mLeft > bottom.mLeft && total_rect.mRight < bottom.mRight)
+ {
+ translate(0, delta_bottom);
+ }
+ else if (delta_right < 0 && total_rect.mTop < right.mTop && total_rect.mBottom > right.mBottom)
+ {
+ translate(delta_right, 0);
+ }
+ mTranslateWithDependents = false;
+}
+
BOOL LLFloater::offerClickToButton(S32 x, S32 y, MASK mask, EFloaterButton index)
{
if( mButtonsEnabled[index] )
@@ -1630,6 +1697,7 @@ BOOL LLFloater::handleDoubleClick(S32 x, S32 y, MASK mask)
return was_minimized || LLPanel::handleDoubleClick(x, y, mask);
}
+// virtual
void LLFloater::bringToFront( S32 x, S32 y )
{
if (getVisible() && pointInView(x, y))
@@ -1644,12 +1712,20 @@ void LLFloater::bringToFront( S32 x, S32 y )
LLFloaterView* parent = dynamic_cast<LLFloaterView*>( getParent() );
if (parent)
{
- parent->bringToFront( this );
+ parent->bringToFront(this, !getIsChrome());
}
}
}
}
+// virtual
+void LLFloater::goneFromFront()
+{
+ if (mAutoClose)
+ {
+ closeFloater();
+ }
+}
// virtual
void LLFloater::setVisibleAndFrontmost(BOOL take_focus,const LLSD& key)
@@ -1772,6 +1848,8 @@ void LLFloater::onClickTearOff(LLFloater* self)
{
if (self->mSaveRect)
{
+ LLRect screen_rect = self->calcScreenRect();
+ self->mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert();
self->storeRectControl();
}
self->setMinimized(FALSE); // to reenable minimize button if it was minimized
@@ -2329,8 +2407,7 @@ LLFloaterView::LLFloaterView (const Params& p)
mFocusCycleMode(FALSE),
mMinimizePositionVOffset(0),
mSnapOffsetBottom(0),
- mSnapOffsetRight(0),
- mFrontChild(NULL)
+ mSnapOffsetRight(0)
{
mSnapView = getHandle();
}
@@ -2385,7 +2462,7 @@ void LLFloaterView::reshape(S32 width, S32 height, BOOL called_from_parent)
//{
// floaterp->translate(translate_x, translate_y);
//}
- BOOST_FOREACH(LLHandle<LLFloater> dependent_floater, floaterp->mDependents)
+ for (LLHandle<LLFloater> dependent_floater : floaterp->mDependents)
{
if (dependent_floater.get())
{
@@ -2400,10 +2477,9 @@ void LLFloaterView::reshape(S32 width, S32 height, BOOL called_from_parent)
void LLFloaterView::restoreAll()
{
// make sure all subwindows aren't minimized
- child_list_t child_list = *(getChildList());
- for (child_list_const_iter_t child_it = child_list.begin(); child_it != child_list.end(); ++child_it)
+ for (auto child : *getChildList())
{
- LLFloater* floaterp = dynamic_cast<LLFloater*>(*child_it);
+ LLFloater* floaterp = dynamic_cast<LLFloater*>(child);
if (floaterp)
{
floaterp->setMinimized(FALSE);
@@ -2486,16 +2562,22 @@ void LLFloaterView::bringToFront(LLFloater* child, BOOL give_focus, BOOL restore
if (!child)
return;
- if (mFrontChild == child)
+ LLFloater* front_child = mFrontChildHandle.get();
+ if (front_child == child)
{
- if (give_focus && !gFocusMgr.childHasKeyboardFocus(child))
+ if (give_focus && child->canFocusStealFrontmost() && !gFocusMgr.childHasKeyboardFocus(child))
{
child->setFocus(TRUE);
}
return;
}
- mFrontChild = child;
+ if (front_child && front_child->getVisible())
+ {
+ front_child->goneFromFront();
+ }
+
+ mFrontChildHandle = child->getHandle();
// *TODO: make this respect floater's mAutoFocus value, instead of
// using parameter
@@ -2852,10 +2934,17 @@ void LLFloaterView::adjustToFitScreen(LLFloater* floater, BOOL allow_partial_out
// floater is hosted elsewhere, so ignore
return;
}
+
+ if (floater->getDependee() &&
+ floater->getDependee() == floater->getSnapTarget().get())
+ {
+ // floater depends on other and snaps to it, so ignore
+ return;
+ }
+
LLRect::tCoordType screen_width = getSnapRect().getWidth();
LLRect::tCoordType screen_height = getSnapRect().getHeight();
-
// only automatically resize non-minimized, resizable floaters
if( floater->isResizable() && !floater->isMinimized() )
{
@@ -2897,29 +2986,10 @@ void LLFloaterView::adjustToFitScreen(LLFloater* floater, BOOL allow_partial_out
}
}
- const LLRect& floater_rect = floater->getRect();
-
- S32 delta_left = mToolbarLeftRect.notEmpty() ? mToolbarLeftRect.mRight - floater_rect.mRight : 0;
- S32 delta_bottom = mToolbarBottomRect.notEmpty() ? mToolbarBottomRect.mTop - floater_rect.mTop : 0;
- S32 delta_right = mToolbarRightRect.notEmpty() ? mToolbarRightRect.mLeft - floater_rect.mLeft : 0;
+ const LLRect& constraint = snap_in_toolbars ? getSnapRect() : gFloaterView->getRect();
+ S32 min_overlap_pixels = allow_partial_outside ? FLOATER_MIN_VISIBLE_PIXELS : S32_MAX;
- // move window fully onscreen
- if (floater->translateIntoRect( snap_in_toolbars ? getSnapRect() : gFloaterView->getRect(), allow_partial_outside ? FLOATER_MIN_VISIBLE_PIXELS : S32_MAX ))
- {
- floater->clearSnapTarget();
- }
- else if (delta_left > 0 && floater_rect.mTop < mToolbarLeftRect.mTop && floater_rect.mBottom > mToolbarLeftRect.mBottom)
- {
- floater->translate(delta_left, 0);
- }
- else if (delta_bottom > 0 && floater_rect.mLeft > mToolbarBottomRect.mLeft && floater_rect.mRight < mToolbarBottomRect.mRight)
- {
- floater->translate(0, delta_bottom);
- }
- else if (delta_right < 0 && floater_rect.mTop < mToolbarRightRect.mTop && floater_rect.mBottom > mToolbarRightRect.mBottom)
- {
- floater->translate(delta_right, 0);
- }
+ floater->fitWithDependentsOnScreen(mToolbarLeftRect, mToolbarBottomRect, mToolbarRightRect, constraint, min_overlap_pixels);
}
void LLFloaterView::draw()
@@ -3006,6 +3076,10 @@ LLFloater *LLFloaterView::getBackmost() const
void LLFloaterView::syncFloaterTabOrder()
{
+ LLFloater* front_child = mFrontChildHandle.get();
+ if (front_child && front_child->getIsChrome())
+ return;
+
// look for a visible modal dialog, starting from first
LLModalDialog* modal_dialog = NULL;
for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
@@ -3041,7 +3115,35 @@ void LLFloaterView::syncFloaterTabOrder()
LLFloater* floaterp = dynamic_cast<LLFloater*>(*child_it);
if (gFocusMgr.childHasKeyboardFocus(floaterp))
{
- bringToFront(floaterp, FALSE);
+ LLFloater* front_child = mFrontChildHandle.get();
+ if (front_child != floaterp)
+ {
+ // Grab a list of the top floaters that want to stay on top of the focused floater
+ std::list<LLFloater*> listTop;
+ if (front_child && !front_child->canFocusStealFrontmost())
+ {
+ for (LLView* childp : *getChildList())
+ {
+ LLFloater* child_floaterp = static_cast<LLFloater*>(childp);
+ if (child_floaterp->canFocusStealFrontmost())
+ break;
+ listTop.push_back(child_floaterp);
+ }
+ }
+
+ bringToFront(floaterp, FALSE);
+
+ // Restore top floaters
+ if (!listTop.empty())
+ {
+ for (LLView* childp : listTop)
+ {
+ sendChildToFront(childp);
+ }
+ mFrontChildHandle = listTop.back()->getHandle();
+ }
+ }
+
break;
}
}
@@ -3226,6 +3328,7 @@ void LLFloater::initFromParams(const LLFloater::Params& p)
mDefaultRelativeY = p.rel_y;
mPositioning = p.positioning;
+ mAutoClose = p.auto_close;
mSaveRect = p.save_rect;
if (p.save_visibility)
diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h
index 668cd208a9..39957386df 100644
--- a/indra/llui/llfloater.h
+++ b/indra/llui/llfloater.h
@@ -113,8 +113,6 @@ struct LLCoordFloater : LLCoord<LL_COORD_FLOATER>
bool operator!=(const LLCoordFloater& other) const { return !(*this == other); }
void setFloater(LLFloater& floater);
-
-
};
class LLFloater : public LLPanel, public LLInstanceTracker<LLFloater>
@@ -165,7 +163,8 @@ public:
save_visibility,
save_dock_state,
can_dock,
- show_title;
+ show_title,
+ auto_close;
Optional<LLFloaterEnums::EOpenPositioning> positioning;
@@ -225,6 +224,7 @@ public:
/*virtual*/ void setIsChrome(BOOL is_chrome);
/*virtual*/ void setRect(const LLRect &rect);
void setIsSingleInstance(BOOL is_single_instance);
+ BOOL getIsSingleInstance() { return mSingleInstance; }
void initFloater(const Params& p);
@@ -237,6 +237,7 @@ public:
virtual void closeHostedFloater();
/*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
+ /*virtual*/ void translate(S32 x, S32 y);
// Release keyboard and mouse focus
void releaseFocus();
@@ -255,10 +256,11 @@ public:
std::string getShortTitle() const;
virtual void setMinimized(BOOL b);
void moveResizeHandlesToFront();
- void addDependentFloater(LLFloater* dependent, BOOL reposition = TRUE);
- void addDependentFloater(LLHandle<LLFloater> dependent_handle, BOOL reposition = TRUE);
+ void addDependentFloater(LLFloater* dependent, BOOL reposition = TRUE, BOOL resize = FALSE);
+ void addDependentFloater(LLHandle<LLFloater> dependent_handle, BOOL reposition = TRUE, BOOL resize = FALSE);
LLFloater* getDependee() { return (LLFloater*)mDependeeHandle.get(); }
- void removeDependentFloater(LLFloater* dependent);
+ void removeDependentFloater(LLFloater* dependent);
+ void fitWithDependentsOnScreen(const LLRect& left, const LLRect& bottom, const LLRect& right, const LLRect& constraint, S32 min_overlap_pixels);
BOOL isMinimized() const { return mMinimized; }
/// isShown() differs from getVisible() in that isShown() also considers
/// isMinimized(). isShown() is true only if visible and not minimized.
@@ -313,6 +315,9 @@ public:
/*virtual*/ void setVisible(BOOL visible); // do not override
/*virtual*/ void onVisibilityChange ( BOOL new_visibility ); // do not override
+ bool canFocusStealFrontmost() const { return mFocusStealsFrontmost; }
+ void setFocusStealsFrontmost(bool wants_frontmost) { mFocusStealsFrontmost = wants_frontmost; }
+
void setFrontmost(BOOL take_focus = TRUE, BOOL restore = TRUE);
virtual void setVisibleAndFrontmost(BOOL take_focus=TRUE, const LLSD& key = LLSD());
@@ -386,6 +391,7 @@ protected:
void setInstanceName(const std::string& name);
virtual void bringToFront(S32 x, S32 y);
+ virtual void goneFromFront();
void setExpandedRect(const LLRect& rect) { mExpandedRect = rect; } // size when not minimized
const LLRect& getExpandedRect() const { return mExpandedRect; }
@@ -481,8 +487,10 @@ private:
BOOL mCanTearOff;
BOOL mCanMinimize;
BOOL mCanClose;
+ bool mFocusStealsFrontmost = true; // FALSE if we don't want the currently focused floater to cover this floater without user interaction
BOOL mDragOnLeft;
BOOL mResizable;
+ BOOL mAutoClose;
LLFloaterEnums::EOpenPositioning mPositioning;
LLCoordFloater mPosition;
@@ -502,6 +510,7 @@ private:
typedef std::set<LLHandle<LLFloater> > handle_set_t;
typedef std::set<LLHandle<LLFloater> >::iterator handle_set_iter_t;
handle_set_t mDependents;
+ bool mTranslateWithDependents { false };
bool mButtonsEnabled[BUTTON_COUNT];
F32 mButtonScale;
@@ -613,7 +622,7 @@ private:
S32 mMinimizePositionVOffset;
typedef std::vector<std::pair<LLHandle<LLFloater>, boost::signals2::connection> > hidden_floaters_t;
hidden_floaters_t mHiddenFloaters;
- LLFloater * mFrontChild;
+ LLHandle<LLFloater> mFrontChildHandle;
};
//
diff --git a/indra/llui/llfolderview.cpp b/indra/llui/llfolderview.cpp
index 62c311f522..650ae9ae75 100644
--- a/indra/llui/llfolderview.cpp
+++ b/indra/llui/llfolderview.cpp
@@ -189,7 +189,9 @@ LLFolderView::LLFolderView(const Params& p)
mStatusTextBox(NULL),
mShowItemLinkOverlays(p.show_item_link_overlays),
mViewModel(p.view_model),
- mGroupedItemModel(p.grouped_item_model)
+ mGroupedItemModel(p.grouped_item_model),
+ mForceArrange(false),
+ mSingleFolderMode(false)
{
LLPanel* panel = p.parent_panel;
mParentPanel = panel->getHandle();
@@ -609,6 +611,7 @@ void LLFolderView::clearSelection()
}
mSelectedItems.clear();
+ mNeedsScroll = false;
}
std::set<LLFolderViewItem*> LLFolderView::getSelectionList() const
@@ -665,7 +668,7 @@ void LLFolderView::draw()
}
else if (mShowEmptyMessage)
{
- mStatusTextBox->setValue(getFolderViewModel()->getStatusText());
+ mStatusTextBox->setValue(getFolderViewModel()->getStatusText(mItems.empty() && mFolders.empty()));
mStatusTextBox->setVisible( TRUE );
// firstly reshape message textbox with current size. This is necessary to
@@ -693,12 +696,16 @@ void LLFolderView::draw()
}
}
- if (mRenameItem && mRenamer && mRenamer->getVisible() && !getVisibleRect().overlaps(mRenamer->getRect()))
- {
- // renamer is not connected to the item we are renaming in any form so manage it manually
- // TODO: consider stopping on any scroll action instead of when out of visible area
- finishRenamingItem();
- }
+ if (mRenameItem
+ && mRenamer
+ && mRenamer->getVisible()
+ && !getVisibleRect().overlaps(mRenamer->getRect()))
+ {
+ // renamer is not connected to the item we are renaming in any form so manage it manually
+ // TODO: consider stopping on any scroll action instead of when out of visible area
+ LL_DEBUGS("Inventory") << "Renamer out of bounds, hiding" << LL_ENDL;
+ finishRenamingItem();
+ }
// skip over LLFolderViewFolder::draw since we don't want the folder icon, label,
// and arrow for the root folder
@@ -832,9 +839,12 @@ void LLFolderView::autoOpenItem( LLFolderViewFolder* item )
mAutoOpenItems.push(item);
item->setOpen(TRUE);
+ if(!item->isSingleFolderMode())
+ {
LLRect content_rect = (mScrollContainer ? mScrollContainer->getContentWindowRect() : LLRect());
LLRect constraint_rect(0,content_rect.getHeight(), content_rect.getWidth(), 0);
scrollToShowItem(item, constraint_rect);
+ }
}
void LLFolderView::closeAutoOpenedFolders()
@@ -1038,6 +1048,8 @@ void LLFolderView::paste()
// public rename functionality - can only start the process
void LLFolderView::startRenamingSelectedItem( void )
{
+ LL_DEBUGS("Inventory") << "Starting inventory renamer" << LL_ENDL;
+
// make sure selection is visible
scrollToShowSelection();
@@ -1273,6 +1285,11 @@ BOOL LLFolderView::handleKeyHere( KEY key, MASK mask )
if(mSelectedItems.size())
{
LLFolderViewItem* last_selected = getCurSelectedItem();
+ if(last_selected && last_selected->isSingleFolderMode())
+ {
+ handled = FALSE;
+ break;
+ }
LLFolderViewItem* parent_folder = last_selected->getParentFolder();
if (!last_selected->isOpen() && parent_folder && parent_folder->getParentFolder())
{
@@ -1458,9 +1475,19 @@ BOOL LLFolderView::handleRightMouseDown( S32 x, S32 y, MASK mask )
mCallbackRegistrar->popScope();
}
}
+
+ BOOL item_clicked = FALSE;
+ for (selected_items_t::iterator item_it = mSelectedItems.begin(); item_it != mSelectedItems.end(); ++item_it)
+ {
+ item_clicked |= (*item_it)->getRect().pointInRect(x, y);
+ }
+ if(!item_clicked && mSingleFolderMode)
+ {
+ clearSelection();
+ }
bool hide_folder_menu = mSuppressFolderMenu && isFolderSelected();
- if (menu && (handled
- && ( count > 0 && (hasVisibleChildren()) )) && // show menu only if selected items are visible
+ if (menu && (mSingleFolderMode || (handled
+ && ( count > 0 && (hasVisibleChildren()) ))) && // show menu only if selected items are visible
!hide_folder_menu)
{
if (mCallbackRegistrar)
@@ -1532,6 +1559,22 @@ BOOL LLFolderView::handleHover( S32 x, S32 y, MASK mask )
return LLView::handleHover( x, y, mask );
}
+LLFolderViewItem* LLFolderView::getHoveredItem() const
+{
+ return dynamic_cast<LLFolderViewItem*>(mHoveredItem.get());
+}
+
+void LLFolderView::setHoveredItem(LLFolderViewItem* itemp)
+{
+ if (mHoveredItem.get() != itemp)
+ {
+ if (itemp)
+ mHoveredItem = itemp->getHandle();
+ else
+ mHoveredItem.markDead();
+ }
+}
+
BOOL LLFolderView::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
EDragAndDropType cargo_type,
void* cargo_data,
@@ -1716,7 +1759,7 @@ void LLFolderView::update()
mNeedsAutoSelect = FALSE;
}
- BOOL is_visible = isInVisibleChain();
+ BOOL is_visible = isInVisibleChain() || mForceArrange;
//Puts folders/items in proper positions
// arrange() takes the model filter flag into account and call sort() if necessary (CHUI-849)
@@ -1817,13 +1860,28 @@ void LLFolderView::update()
}
}
- if (mSignalSelectCallback)
- {
- //RN: we use keyboard focus as a proxy for user-explicit actions
- BOOL take_keyboard_focus = (mSignalSelectCallback == SIGNAL_KEYBOARD_FOCUS);
- mSelectSignal(mSelectedItems, take_keyboard_focus);
- }
- mSignalSelectCallback = FALSE;
+ if (mSelectedItems.size())
+ {
+ LLFolderViewItem* item = mSelectedItems.back();
+ // If the goal is to show renamer, don't callback untill
+ // item is visible or is no longer being scrolled to.
+ // Otherwise renamer will be instantly closed
+ // Todo: consider moving renamer out of selection callback
+ if (!mNeedsAutoRename || !mNeedsScroll || item->getVisible())
+ {
+ if (mSignalSelectCallback)
+ {
+ //RN: we use keyboard focus as a proxy for user-explicit actions
+ BOOL take_keyboard_focus = (mSignalSelectCallback == SIGNAL_KEYBOARD_FOCUS);
+ mSelectSignal(mSelectedItems, take_keyboard_focus);
+ }
+ mSignalSelectCallback = FALSE;
+ }
+ }
+ else
+ {
+ mSignalSelectCallback = FALSE;
+ }
}
void LLFolderView::dumpSelectionInformation()
@@ -1886,6 +1944,11 @@ void LLFolderView::updateMenuOptions(LLMenuGL* menu)
flags = multi_select_flag;
}
+ if(mSingleFolderMode && (mSelectedItems.size() == 0))
+ {
+ buildContextMenu(*menu, flags);
+ }
+
// This adds a check for restrictions based on the entire
// selection set - for example, any one wearable may not push you
// over the limit, but all wearables together still might.
@@ -2042,7 +2105,7 @@ LLFolderViewItem* LLFolderView::getNextUnselectedItem()
return new_selection;
}
-S32 LLFolderView::getItemHeight()
+S32 LLFolderView::getItemHeight() const
{
if(!hasVisibleChildren())
{
diff --git a/indra/llui/llfolderview.h b/indra/llui/llfolderview.h
index 7dfa04828a..5f8a173889 100644
--- a/indra/llui/llfolderview.h
+++ b/indra/llui/llfolderview.h
@@ -127,6 +127,9 @@ public:
bool getAllowMultiSelect() { return mAllowMultiSelect; }
bool getAllowDrag() { return mAllowDrag; }
+ void setSingleFolderMode(bool is_single_mode) { mSingleFolderMode = is_single_mode; }
+ bool isSingleFolderMode() { return mSingleFolderMode; }
+
// Close all folders in the view
void closeAllFolders();
void openTopLevelFolders();
@@ -136,7 +139,7 @@ public:
// Find width and height of this object and its children. Also
// makes sure that this view and its children are the right size.
virtual S32 arrange( S32* width, S32* height );
- virtual S32 getItemHeight();
+ virtual S32 getItemHeight() const;
void arrangeAll() { mArrangeGeneration++; }
S32 getArrangeGeneration() { return mArrangeGeneration; }
@@ -144,6 +147,10 @@ public:
// applies filters to control visibility of items
virtual void filter( LLFolderViewFilter& filter);
+ void clearHoveredItem() { setHoveredItem(nullptr); }
+ LLFolderViewItem* getHoveredItem() const;
+ void setHoveredItem(LLFolderViewItem* itemp);
+
// Get the last selected item
virtual LLFolderViewItem* getCurSelectedItem( void );
selected_items_t& getSelectedItems( void );
@@ -210,6 +217,7 @@ public:
virtual void draw();
virtual void deleteAllChildren();
+ void stopAutoScollining() {mNeedsScroll = false;}
void scrollToShowSelection();
void scrollToShowItem(LLFolderViewItem* item, const LLRect& constraint_rect);
void setScrollContainer( LLScrollContainer* parent ) { mScrollContainer = parent; }
@@ -237,11 +245,15 @@ public:
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(); }
// DEBUG only
void dumpSelectionInformation();
virtual S32 notify(const LLSD& info) ;
+
+ void setShowEmptyMessage(bool show_msg) { mShowEmptyMessage = show_msg; }
bool useLabelSuffix() { return mUseLabelSuffix; }
virtual void updateMenu();
@@ -275,6 +287,7 @@ protected:
LLHandle<LLView> mPopupMenuHandle;
std::string mMenuFileName;
+ LLHandle<LLView> mHoveredItem;
selected_items_t mSelectedItems;
bool mKeyboardSelection,
mAllowMultiSelect,
@@ -291,7 +304,8 @@ protected:
mShowItemLinkOverlays,
mShowSelectionContext,
mShowSingleSelection,
- mSuppressFolderMenu;
+ mSuppressFolderMenu,
+ mSingleFolderMode;
// Renaming variables and methods
LLFolderViewItem* mRenameItem; // The item currently being renamed
@@ -330,6 +344,8 @@ protected:
LLUICtrl::CommitCallbackRegistry::ScopedRegistrar* mCallbackRegistrar;
LLUICtrl::EnableCallbackRegistry::ScopedRegistrar* mEnableRegistrar;
+
+ bool mForceArrange;
public:
static F32 sAutoOpenTime;
diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp
index 8883626d78..2bd14f6f6a 100644
--- a/indra/llui/llfolderviewitem.cpp
+++ b/indra/llui/llfolderviewitem.cpp
@@ -32,6 +32,7 @@
#include "llfolderview.h"
#include "llfolderviewmodel.h"
#include "llpanel.h"
+#include "llcallbacklist.h"
#include "llcriticaldamp.h"
#include "llclipboard.h"
#include "llfocusmgr.h" // gFocusMgr
@@ -113,6 +114,8 @@ LLFolderViewItem::Params::Params()
icon_width("icon_width", 0),
text_pad("text_pad", 0),
text_pad_right("text_pad_right", 0),
+ single_folder_mode("single_folder_mode", false),
+ double_click_override("double_click_override", false),
arrow_size("arrow_size", 0),
max_folder_item_overlap("max_folder_item_overlap", 0)
{ }
@@ -151,7 +154,9 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p)
mTextPad(p.text_pad),
mTextPadRight(p.text_pad_right),
mArrowSize(p.arrow_size),
- mMaxFolderItemOverlap(p.max_folder_item_overlap)
+ mSingleFolderMode(p.single_folder_mode),
+ mMaxFolderItemOverlap(p.max_folder_item_overlap),
+ mDoubleClickOverride(p.double_click_override)
{
if (!sColorSetInitialized)
{
@@ -162,7 +167,7 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p)
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("InventoryItemColor", DEFAULT_WHITE);
+ sSuffixColor = LLUIColorTable::instance().getColor("InventoryItemLinkColor", DEFAULT_WHITE);
sSearchStatusColor = LLUIColorTable::instance().getColor("InventorySearchStatusColor", DEFAULT_WHITE);
sColorSetInitialized = true;
}
@@ -400,7 +405,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(mLabelStyle)->getWidth(mLabelSuffix) + mLabelPaddingRight;
+ mLabelWidth = getLabelXPos() + getLabelFontForStyle(mLabelStyle)->getWidth(mLabel) + getLabelFontForStyle(LLFontGL::NORMAL)->getWidth(mLabelSuffix) + mLabelPaddingRight;
mLabelWidthDirty = false;
}
@@ -417,7 +422,7 @@ S32 LLFolderViewItem::arrange( S32* width, S32* height )
return *height;
}
-S32 LLFolderViewItem::getItemHeight()
+S32 LLFolderViewItem::getItemHeight() const
{
return mItemHeight;
}
@@ -629,11 +634,14 @@ BOOL LLFolderViewItem::handleHover( S32 x, S32 y, MASK mask )
getWindow()->setCursor(UI_CURSOR_NOLOCKED);
}
+ root->clearHoveredItem();
return TRUE;
}
else
{
- getRoot()->setShowSelectionContext(FALSE);
+ LLFolderView* pRoot = getRoot();
+ pRoot->setHoveredItem(this);
+ pRoot->setShowSelectionContext(FALSE);
getWindow()->setCursor(UI_CURSOR_ARROW);
// let parent handle this then...
return FALSE;
@@ -688,6 +696,13 @@ BOOL LLFolderViewItem::handleMouseUp( S32 x, S32 y, MASK mask )
void LLFolderViewItem::onMouseLeave(S32 x, S32 y, MASK mask)
{
mIsMouseOverTitle = false;
+
+ // NOTE: LLViewerWindow::updateUI() calls "enter" before "leave"; if the mouse moved to another item, we can't just outright clear it
+ LLFolderView* pRoot = getRoot();
+ if (this == pRoot->getHoveredItem())
+ {
+ pRoot->clearHoveredItem();
+ }
}
BOOL LLFolderViewItem::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
@@ -879,7 +894,7 @@ void LLFolderViewItem::drawLabel(const LLFontGL * font, const F32 x, const F32 y
//
font->renderUTF8(mLabel, 0, x, y, color,
LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
- S32_MAX, getRect().getWidth() - (S32) x - mLabelPaddingRight, &right_x, TRUE);
+ S32_MAX, getRect().getWidth() - (S32) x - mLabelPaddingRight, &right_x, /*use_ellipses*/TRUE);
}
void LLFolderViewItem::draw()
@@ -894,7 +909,10 @@ void LLFolderViewItem::draw()
getViewModelItem()->update();
- drawOpenFolderArrow(default_params, sFgColor);
+ if(!mSingleFolderMode)
+ {
+ drawOpenFolderArrow(default_params, sFgColor);
+ }
drawHighlight(show_context, filled, sHighlightBgColor, sFlashBgColor, sFocusOutlineColor, sMouseOverColor);
@@ -930,16 +948,43 @@ void LLFolderViewItem::draw()
F32 text_left = (F32)getLabelXPos();
std::string combined_string = mLabel + mLabelSuffix;
+ const LLFontGL* suffix_font = getLabelFontForStyle(LLFontGL::NORMAL);
+ S32 filter_offset = mViewModelItem->getFilterStringOffset();
if (filter_string_length > 0)
{
- S32 left = ll_round(text_left) + font->getWidth(combined_string, 0, mViewModelItem->getFilterStringOffset()) - 2;
+ S32 bottom = llfloor(getRect().getHeight() - font->getLineHeight() - 3 - TOP_PAD);
+ S32 top = getRect().getHeight() - TOP_PAD;
+ if(mLabelSuffix.empty() || (font == suffix_font))
+ {
+ S32 left = ll_round(text_left) + font->getWidth(combined_string, 0, mViewModelItem->getFilterStringOffset()) - 2;
S32 right = left + font->getWidth(combined_string, mViewModelItem->getFilterStringOffset(), filter_string_length) + 2;
- S32 bottom = llfloor(getRect().getHeight() - font->getLineHeight() - 3 - TOP_PAD);
- S32 top = getRect().getHeight() - TOP_PAD;
LLUIImage* box_image = default_params.selection_image;
LLRect box_rect(left, top, right, bottom);
box_image->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;
+ LLRect box_rect(left, top, right, bottom);
+ box_image->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, 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;
+ LLRect box_rect(left, top, right, bottom);
+ box_image->draw(box_rect, sFilterBGColor);
+ }
+ }
}
LLColor4 color = (mIsSelected && filled) ? mFontHighlightColor : mFontColor;
@@ -956,9 +1001,9 @@ void LLFolderViewItem::draw()
//
if (!mLabelSuffix.empty())
{
- font->renderUTF8( mLabelSuffix, 0, right_x, y, isFadeItem() ? color : (LLColor4)sSuffixColor,
+ 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, FALSE );
+ S32_MAX, S32_MAX, &right_x);
}
//--------------------------------------------------------------------------------//
@@ -966,12 +1011,38 @@ void LLFolderViewItem::draw()
//
if (filter_string_length > 0)
{
- S32 filter_offset = mViewModelItem->getFilterStringOffset();
- 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,
- sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
- filter_string_length, S32_MAX, &right_x, FALSE );
+ if(mLabelSuffix.empty() || (font == suffix_font))
+ {
+ 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,
+ sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
+ filter_string_length, S32_MAX, &right_x);
+ }
+ else
+ {
+ 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,
+ sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
+ label_filter_length, S32_MAX, &right_x);
+ }
+
+ 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());
+ F32 match_string_left = text_left + font->getWidthF32(mLabel, 0, 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,
+ LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
+ suffix_filter_length, S32_MAX, &right_x);
+ }
+ }
+
}
//Gilbert Linden 9-20-2012: Although this should be legal, removing it because it causes the mLabelSuffix rendering to
@@ -1282,7 +1353,7 @@ BOOL LLFolderViewFolder::setSelection(LLFolderViewItem* selection, BOOL openitem
child_selected = TRUE;
}
}
- if(openitem && child_selected)
+ if(openitem && child_selected && !mSingleFolderMode)
{
setOpenArrangeRecursively(TRUE);
}
@@ -1707,6 +1778,11 @@ BOOL LLFolderViewFolder::isRemovable()
return TRUE;
}
+void LLFolderViewFolder::destroyRoot()
+{
+ delete this;
+}
+
// this is an internal method used for adding items to folders.
void LLFolderViewFolder::addItem(LLFolderViewItem* item)
{
@@ -1775,7 +1851,19 @@ void LLFolderViewFolder::toggleOpen()
// Force a folder open or closed
void LLFolderViewFolder::setOpen(BOOL openitem)
{
- setOpenArrangeRecursively(openitem);
+ if(mSingleFolderMode)
+ {
+ // navigateToFolder can destroy this view
+ // delay it in case setOpen was called from click or key processing
+ doOnIdleOneTime([this]()
+ {
+ getViewModelItem()->navigateToFolder();
+ });
+ }
+ else
+ {
+ setOpenArrangeRecursively(openitem);
+ }
}
void LLFolderViewFolder::setOpenArrangeRecursively(BOOL openitem, ERecurseType recurse)
@@ -1978,7 +2066,8 @@ BOOL LLFolderViewFolder::handleMouseDown( S32 x, S32 y, MASK mask )
}
if( !handled )
{
- if(mIndentation < x && x < mIndentation + (isCollapsed() ? 0 : mArrowSize) + mTextPad)
+ if((mIndentation < x && x < mIndentation + (isCollapsed() ? 0 : mArrowSize) + mTextPad)
+ && !mSingleFolderMode)
{
toggleOpen();
handled = TRUE;
@@ -1996,12 +2085,45 @@ BOOL LLFolderViewFolder::handleMouseDown( S32 x, S32 y, MASK mask )
BOOL LLFolderViewFolder::handleDoubleClick( S32 x, S32 y, MASK mask )
{
BOOL handled = FALSE;
+ if(mSingleFolderMode)
+ {
+ static LLUICachedControl<bool> double_click_new_window("SingleModeDoubleClickOpenWindow", false);
+ if (double_click_new_window)
+ {
+ getViewModelItem()->navigateToFolder(true);
+ }
+ else
+ {
+ // navigating is going to destroy views and change children
+ // delay it untill handleDoubleClick processing is complete
+ doOnIdleOneTime([this]()
+ {
+ getViewModelItem()->navigateToFolder(false);
+ });
+ }
+ return TRUE;
+ }
+
if( isOpen() )
{
handled = childrenHandleDoubleClick( x, y, mask ) != NULL;
}
if( !handled )
{
+ if(mDoubleClickOverride)
+ {
+ static LLUICachedControl<U32> double_click_action("MultiModeDoubleClickFolder", false);
+ if (double_click_action == 1)
+ {
+ getViewModelItem()->navigateToFolder(true);
+ return TRUE;
+ }
+ if (double_click_action == 2)
+ {
+ getViewModelItem()->navigateToFolder(false, true);
+ return TRUE;
+ }
+ }
if(mIndentation < x && x < mIndentation + (isCollapsed() ? 0 : mArrowSize) + mTextPad)
{
// don't select when user double-clicks plus sign
diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h
index a5157266c5..5c2a1ecff0 100644
--- a/indra/llui/llfolderviewitem.h
+++ b/indra/llui/llfolderviewitem.h
@@ -72,6 +72,8 @@ public:
text_pad_right,
arrow_size,
max_folder_item_overlap;
+ Optional<bool> single_folder_mode,
+ double_click_override;
Params();
};
@@ -121,6 +123,8 @@ protected:
mIsMouseOverTitle,
mAllowWear,
mAllowDrop,
+ mSingleFolderMode,
+ mDoubleClickOverride,
mSelectPending,
mIsItemCut;
@@ -174,7 +178,7 @@ public:
// Finds width and height of this object and it's children. Also
// makes sure that this view and it's children are the right size.
virtual S32 arrange( S32* width, S32* height );
- virtual S32 getItemHeight();
+ virtual S32 getItemHeight() const;
virtual S32 getLabelXPos();
S32 getIconPad();
S32 getTextPad();
@@ -213,9 +217,9 @@ public:
void setIsCurSelection(BOOL select) { mIsCurSelection = select; }
- BOOL getIsCurSelection() { return mIsCurSelection; }
+ BOOL getIsCurSelection() const { return mIsCurSelection; }
- BOOL hasVisibleChildren() { return mHasVisibleChildren; }
+ BOOL hasVisibleChildren() const { return mHasVisibleChildren; }
// true if object can't have children
virtual bool isFolderComplete() { return true; }
@@ -264,7 +268,7 @@ public:
virtual LLFolderView* getRoot();
virtual const LLFolderView* getRoot() const;
BOOL isDescendantOf( const LLFolderViewFolder* potential_ancestor );
- S32 getIndentation() { return mIndentation; }
+ S32 getIndentation() const { return mIndentation; }
virtual BOOL passedFilter(S32 filter_generation = -1);
virtual BOOL isPotentiallyVisible(S32 filter_generation = -1);
@@ -277,6 +281,8 @@ public:
// Does not need filter update
virtual void refreshSuffix();
+ bool isSingleFolderMode() { return mSingleFolderMode; }
+
// LLView functionality
virtual BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
@@ -387,6 +393,7 @@ public:
// destroys this folder, and all children
virtual void destroyView();
+ void destroyRoot();
// whether known children are fully loaded (arrange sets to true)
virtual bool isFolderComplete() { return mIsFolderComplete; }
diff --git a/indra/llui/llfolderviewmodel.cpp b/indra/llui/llfolderviewmodel.cpp
index 93122503d1..f217b743a0 100644
--- a/indra/llui/llfolderviewmodel.cpp
+++ b/indra/llui/llfolderviewmodel.cpp
@@ -34,7 +34,7 @@ bool LLFolderViewModelCommon::needsSort(LLFolderViewModelItem* item)
return item->getSortVersion() < mTargetSortVersion;
}
-std::string LLFolderViewModelCommon::getStatusText()
+std::string LLFolderViewModelCommon::getStatusText(bool is_empty_folder)
{
if (!contentsReady() || mFolderView->getViewModelItem()->getLastFilterGeneration() < getFilter().getCurrentGeneration())
{
@@ -42,7 +42,7 @@ std::string LLFolderViewModelCommon::getStatusText()
}
else
{
- return getFilter().getEmptyLookupMessage();
+ return getFilter().getEmptyLookupMessage(is_empty_folder);
}
}
diff --git a/indra/llui/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h
index c5e027d314..551a60e097 100644
--- a/indra/llui/llfolderviewmodel.h
+++ b/indra/llui/llfolderviewmodel.h
@@ -69,7 +69,7 @@ public:
virtual bool checkFolder(const LLFolderViewModelItem* folder) const = 0;
virtual void setEmptyLookupMessage(const std::string& message) = 0;
- virtual std::string getEmptyLookupMessage() const = 0;
+ virtual std::string getEmptyLookupMessage(bool is_empty_folder = false) const = 0;
virtual bool showAllResults() const = 0;
@@ -125,7 +125,7 @@ public:
virtual void setFolderView(LLFolderView* folder_view) = 0;
virtual LLFolderViewFilter& getFilter() = 0;
virtual const LLFolderViewFilter& getFilter() const = 0;
- virtual std::string getStatusText() = 0;
+ virtual std::string getStatusText(bool is_empty_folder = false) = 0;
virtual bool startDrag(std::vector<LLFolderViewModelItem*>& items) = 0;
};
@@ -159,6 +159,8 @@ public:
virtual void openItem( void ) = 0;
virtual void closeItem( void ) = 0;
virtual void selectItem(void) = 0;
+
+ virtual void navigateToFolder(bool new_window = false, bool change_mode = false) = 0;
virtual BOOL isItemWearable() const { return FALSE; }
@@ -392,7 +394,7 @@ public:
// sort everything
mTargetSortVersion++;
}
- virtual std::string getStatusText();
+ virtual std::string getStatusText(bool is_empty_folder = false);
virtual void filter();
void setFolderView(LLFolderView* folder_view) { mFolderView = folder_view;}
diff --git a/indra/llui/lliconctrl.h b/indra/llui/lliconctrl.h
index 5d6c544571..e983d63a01 100644
--- a/indra/llui/lliconctrl.h
+++ b/indra/llui/lliconctrl.h
@@ -39,7 +39,9 @@ class LLUICtrlFactory;
// Classes
//
-//
+// Class for diplaying named UI textures
+// Do not use for displaying textures from network,
+// UI textures are stored permanently!
class LLIconCtrl
: public LLUICtrl
{
diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp
index 7b22f9dbdc..2769a96875 100644
--- a/indra/llui/lllayoutstack.cpp
+++ b/indra/llui/lllayoutstack.cpp
@@ -216,7 +216,8 @@ LLLayoutStack::Params::Params()
drag_handle_first_indent("drag_handle_first_indent", 0),
drag_handle_second_indent("drag_handle_second_indent", 0),
drag_handle_thickness("drag_handle_thickness", 5),
- drag_handle_shift("drag_handle_shift", 2)
+ drag_handle_shift("drag_handle_shift", 2),
+ drag_handle_color("drag_handle_color", LLUIColorTable::instance().getColor("ResizebarBody"))
{
addSynonym(border_size, "drag_handle_gap");
}
@@ -236,7 +237,8 @@ LLLayoutStack::LLLayoutStack(const LLLayoutStack::Params& p)
mDragHandleFirstIndent(p.drag_handle_first_indent),
mDragHandleSecondIndent(p.drag_handle_second_indent),
mDragHandleThickness(p.drag_handle_thickness),
- mDragHandleShift(p.drag_handle_shift)
+ mDragHandleShift(p.drag_handle_shift),
+ mDragHandleColor(p.drag_handle_color())
{
}
@@ -393,8 +395,7 @@ void LLLayoutStack::updateLayout()
: getRect().getHeight();
// first, assign minimum dimensions
- LLLayoutPanel* panelp = NULL;
- BOOST_FOREACH(panelp, mPanels)
+ for (LLLayoutPanel* panelp : mPanels)
{
if (panelp->mAutoResize)
{
@@ -407,12 +408,15 @@ void LLLayoutStack::updateLayout()
llassert(total_visible_fraction < 1.05f);
// don't need spacing after last panel
- space_to_distribute += panelp ? ll_round((F32)mPanelSpacing * panelp->getVisibleAmount()) : 0;
+ if (!mPanels.empty())
+ {
+ space_to_distribute += ll_round(F32(mPanelSpacing) * mPanels.back()->getVisibleAmount());
+ }
S32 remaining_space = space_to_distribute;
if (space_to_distribute > 0 && total_visible_fraction > 0.f)
{ // give space proportionally to visible auto resize panels
- BOOST_FOREACH(LLLayoutPanel* panelp, mPanels)
+ for (LLLayoutPanel* panelp : mPanels)
{
if (panelp->mAutoResize)
{
@@ -425,7 +429,7 @@ void LLLayoutStack::updateLayout()
}
// distribute any left over pixels to non-collapsed, visible panels
- BOOST_FOREACH(LLLayoutPanel* panelp, mPanels)
+ for (LLLayoutPanel* panelp : mPanels)
{
if (remaining_space == 0) break;
@@ -441,7 +445,7 @@ void LLLayoutStack::updateLayout()
F32 cur_pos = (mOrientation == HORIZONTAL) ? 0.f : (F32)getRect().getHeight();
- BOOST_FOREACH(LLLayoutPanel* panelp, mPanels)
+ for (LLLayoutPanel* panelp : mPanels)
{
F32 panel_dim = llmax(panelp->getExpandedMinDim(), panelp->mTargetDim);
@@ -523,11 +527,20 @@ void LLLayoutStack::updateLayout()
mNeedsLayout = continue_animating;
} // end LLLayoutStack::updateLayout
+void LLLayoutStack::setPanelSpacing(S32 val)
+{
+ if (mPanelSpacing != val)
+ {
+ mPanelSpacing = val;
+ mNeedsLayout = true;
+ }
+}
+
LLLayoutPanel* LLLayoutStack::findEmbeddedPanel(LLPanel* panelp) const
{
if (!panelp) return NULL;
- BOOST_FOREACH(LLLayoutPanel* p, mPanels)
+ for (LLLayoutPanel* p : mPanels)
{
if (p == panelp)
{
@@ -541,7 +554,7 @@ LLLayoutPanel* LLLayoutStack::findEmbeddedPanelByName(const std::string& name) c
{
LLLayoutPanel* result = NULL;
- BOOST_FOREACH(LLLayoutPanel* p, mPanels)
+ for (LLLayoutPanel* p : mPanels)
{
if (p->getName() == name)
{
@@ -555,7 +568,7 @@ LLLayoutPanel* LLLayoutStack::findEmbeddedPanelByName(const std::string& name) c
void LLLayoutStack::createResizeBar(LLLayoutPanel* panelp)
{
- BOOST_FOREACH(LLLayoutPanel* lp, mPanels)
+ for (LLLayoutPanel* lp : mPanels)
{
if (lp->mResizeBar == NULL)
{
@@ -576,7 +589,7 @@ void LLLayoutStack::createResizeBar(LLLayoutPanel* panelp)
resize_bar_bg_panel_p.follows.flags = FOLLOWS_ALL;
resize_bar_bg_panel_p.tab_stop = false;
resize_bar_bg_panel_p.background_visible = true;
- resize_bar_bg_panel_p.bg_alpha_color = LLUIColorTable::instance().getColor("ResizebarBody");
+ resize_bar_bg_panel_p.bg_alpha_color = mDragHandleColor;
resize_bar_bg_panel_p.has_border = true;
resize_bar_bg_panel_p.border.border_thickness = 1;
resize_bar_bg_panel_p.border.highlight_light_color = LLUIColorTable::instance().getColor("ResizebarBorderLight");
@@ -658,7 +671,7 @@ void LLLayoutStack::updateFractionalSizes()
{
F32 total_resizable_dim = 0.f;
- BOOST_FOREACH(LLLayoutPanel* panelp, mPanels)
+ for (LLLayoutPanel* panelp : mPanels)
{
if (panelp->mAutoResize)
{
@@ -666,7 +679,7 @@ void LLLayoutStack::updateFractionalSizes()
}
}
- BOOST_FOREACH(LLLayoutPanel* panelp, mPanels)
+ for (LLLayoutPanel* panelp : mPanels)
{
if (panelp->mAutoResize)
{
@@ -687,7 +700,7 @@ void LLLayoutStack::normalizeFractionalSizes()
S32 num_auto_resize_panels = 0;
F32 total_fractional_size = 0.f;
- BOOST_FOREACH(LLLayoutPanel* panelp, mPanels)
+ for (LLLayoutPanel* panelp : mPanels)
{
if (panelp->mAutoResize)
{
@@ -698,7 +711,7 @@ void LLLayoutStack::normalizeFractionalSizes()
if (total_fractional_size == 0.f)
{ // equal distribution
- BOOST_FOREACH(LLLayoutPanel* panelp, mPanels)
+ for (LLLayoutPanel* panelp : mPanels)
{
if (panelp->mAutoResize)
{
@@ -708,7 +721,7 @@ void LLLayoutStack::normalizeFractionalSizes()
}
else
{ // renormalize
- BOOST_FOREACH(LLLayoutPanel* panelp, mPanels)
+ for (LLLayoutPanel* panelp : mPanels)
{
if (panelp->mAutoResize)
{
@@ -725,7 +738,7 @@ bool LLLayoutStack::animatePanels()
//
// animate visibility
//
- BOOST_FOREACH(LLLayoutPanel* panelp, mPanels)
+ for (LLLayoutPanel* panelp : mPanels)
{
if (panelp->getVisible())
{
@@ -823,7 +836,7 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect&
LLLayoutPanel* other_resize_panel = NULL;
LLLayoutPanel* following_panel = NULL;
- BOOST_REVERSE_FOREACH(LLLayoutPanel* panelp, mPanels)
+ BOOST_REVERSE_FOREACH(LLLayoutPanel* panelp, mPanels) // Should replace this when C++20 reverse view adaptor becomes available...
{
if (panelp->mAutoResize)
{
@@ -872,7 +885,7 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect&
AFTER_RESIZED_PANEL
} which_panel = BEFORE_RESIZED_PANEL;
- BOOST_FOREACH(LLLayoutPanel* panelp, mPanels)
+ for (LLLayoutPanel* panelp : mPanels)
{
if (!panelp->getVisible() || panelp->mCollapsed)
{
@@ -963,6 +976,7 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect&
MIN_FRACTIONAL_SIZE,
MAX_FRACTIONAL_SIZE);
}
+ break;
default:
break;
}
@@ -979,8 +993,8 @@ void LLLayoutStack::reshape(S32 width, S32 height, BOOL called_from_parent)
void LLLayoutStack::updateResizeBarLimits()
{
- LLLayoutPanel* previous_visible_panelp = NULL;
- BOOST_REVERSE_FOREACH(LLLayoutPanel* visible_panelp, mPanels)
+ LLLayoutPanel* previous_visible_panelp{ nullptr };
+ BOOST_REVERSE_FOREACH(LLLayoutPanel* visible_panelp, mPanels) // Should replace this when C++20 reverse view adaptor becomes available...
{
if (!visible_panelp->getVisible() || visible_panelp->mCollapsed)
{
diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h
index 22f11eb20f..000b919ae7 100644
--- a/indra/llui/lllayoutstack.h
+++ b/indra/llui/lllayoutstack.h
@@ -59,6 +59,8 @@ public:
Optional<S32> drag_handle_thickness;
Optional<S32> drag_handle_shift;
+ Optional<LLUIColor> drag_handle_color;
+
Params();
};
@@ -89,6 +91,7 @@ public:
void updateLayout();
S32 getPanelSpacing() const { return mPanelSpacing; }
+ void setPanelSpacing(S32 val);
static void updateClass();
@@ -128,6 +131,7 @@ private:
S32 mDragHandleSecondIndent;
S32 mDragHandleThickness;
S32 mDragHandleShift;
+ LLUIColor mDragHandleColor;
}; // end class LLLayoutStack
diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp
index 940cf398c0..453fa29e7c 100644
--- a/indra/llui/lllineeditor.cpp
+++ b/indra/llui/lllineeditor.cpp
@@ -89,6 +89,7 @@ LLLineEditor::Params::Params()
background_image_disabled("background_image_disabled"),
background_image_focused("background_image_focused"),
bg_image_always_focused("bg_image_always_focused", false),
+ show_label_focused("show_label_focused", false),
select_on_focus("select_on_focus", false),
revert_on_esc("revert_on_esc", true),
spellcheck("spellcheck", false),
@@ -152,6 +153,7 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p)
mBgImageDisabled( p.background_image_disabled ),
mBgImageFocused( p.background_image_focused ),
mShowImageFocused( p.bg_image_always_focused ),
+ mShowLabelFocused( p.show_label_focused ),
mUseBgColor(p.use_bg_color),
mHaveHistory(FALSE),
mReplaceNewlinesWithSpaces( TRUE ),
@@ -164,7 +166,8 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p)
mHighlightColor(p.highlight_color()),
mPreeditBgColor(p.preedit_bg_color()),
mGLFont(p.font),
- mContextMenuHandle()
+ mContextMenuHandle(),
+ mShowContextMenu(true)
{
llassert( mMaxLengthBytes > 0 );
@@ -825,7 +828,7 @@ BOOL LLLineEditor::handleMiddleMouseDown(S32 x, S32 y, MASK mask)
BOOL LLLineEditor::handleRightMouseDown(S32 x, S32 y, MASK mask)
{
setFocus(TRUE);
- if (!LLUICtrl::handleRightMouseDown(x, y, mask))
+ if (!LLUICtrl::handleRightMouseDown(x, y, mask) && getShowContextMenu())
{
showContextMenu(x, y);
}
@@ -1736,6 +1739,20 @@ void LLLineEditor::drawBackground()
}
}
+//virtual
+const std::string LLLineEditor::getToolTip() const
+{
+ if (sDebugUnicode)
+ {
+ std::string text = getText();
+ std::string tooltip = utf8str_showBytesUTF8(text);
+ return tooltip;
+ }
+
+ return LLUICtrl::getToolTip();
+}
+
+//virtual
void LLLineEditor::draw()
{
F32 alpha = getDrawContext().mAlpha;
@@ -2068,7 +2085,7 @@ void LLLineEditor::draw()
//draw label if no text is provided
//but we should draw it in a different color
//to give indication that it is not text you typed in
- if (0 == mText.length() && mReadOnly)
+ if (0 == mText.length() && (mReadOnly || mShowLabelFocused))
{
mGLFont->render(mLabel.getWString(), 0,
mTextLeftEdge, (F32)text_bottom,
@@ -2104,7 +2121,7 @@ void LLLineEditor::draw()
LLFontGL::NO_SHADOW,
S32_MAX,
mTextRightEdge - ll_round(rendered_pixels_right),
- &rendered_pixels_right, FALSE);
+ &rendered_pixels_right);
}
// Draw children (border)
LLView::draw();
diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h
index ae4e05c065..5794b3c35a 100644
--- a/indra/llui/lllineeditor.h
+++ b/indra/llui/lllineeditor.h
@@ -91,6 +91,7 @@ public:
commit_on_focus_lost,
ignore_tab,
bg_image_always_focused,
+ show_label_focused,
is_password,
use_bg_color;
@@ -118,54 +119,55 @@ protected:
friend class LLUICtrlFactory;
friend class LLFloaterEditUI;
void showContextMenu(S32 x, S32 y);
+
public:
virtual ~LLLineEditor();
// mousehandler overrides
- /*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 handleDoubleClick(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 handleKeyHere(KEY key, MASK mask );
- /*virtual*/ BOOL handleUnicodeCharHere(llwchar uni_char);
- /*virtual*/ void onMouseCaptureLost();
+ /*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 handleDoubleClick(S32 x,S32 y,MASK mask) override;
+ /*virtual*/ BOOL handleMiddleMouseDown(S32 x,S32 y,MASK mask) override;
+ /*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*/ void onMouseCaptureLost() override;
// LLEditMenuHandler overrides
- virtual void cut();
- virtual BOOL canCut() const;
- virtual void copy();
- virtual BOOL canCopy() const;
- virtual void paste();
- virtual BOOL canPaste() const;
+ /*virtual*/ void cut() override;
+ /*virtual*/ BOOL canCut() const override;
+ /*virtual*/ void copy() override;
+ /*virtual*/ BOOL canCopy() const override;
+ /*virtual*/ void paste() override;
+ /*virtual*/ BOOL canPaste() const override;
virtual void updatePrimary();
virtual void copyPrimary();
virtual void pastePrimary();
virtual BOOL canPastePrimary() const;
- virtual void doDelete();
- virtual BOOL canDoDelete() const;
+ /*virtual*/ void doDelete() override;
+ /*virtual*/ BOOL canDoDelete() const override;
- virtual void selectAll();
- virtual BOOL canSelectAll() const;
+ /*virtual*/ void selectAll() override;
+ /*virtual*/ BOOL canSelectAll() const override;
- virtual void deselect();
- virtual BOOL canDeselect() const;
+ /*virtual*/ void deselect() override;
+ /*virtual*/ BOOL canDeselect() const override;
// LLSpellCheckMenuHandler overrides
- /*virtual*/ bool getSpellCheck() const;
+ /*virtual*/ bool getSpellCheck() const override;
- /*virtual*/ const std::string& getSuggestion(U32 index) const;
- /*virtual*/ U32 getSuggestionCount() const;
- /*virtual*/ void replaceWithSuggestion(U32 index);
+ /*virtual*/ const std::string& getSuggestion(U32 index) const override;
+ /*virtual*/ U32 getSuggestionCount() const override;
+ /*virtual*/ void replaceWithSuggestion(U32 index) override;
- /*virtual*/ void addToDictionary();
- /*virtual*/ bool canAddToDictionary() const;
+ /*virtual*/ void addToDictionary() override;
+ /*virtual*/ bool canAddToDictionary() const override;
- /*virtual*/ void addToIgnore();
- /*virtual*/ bool canAddToIgnore() const;
+ /*virtual*/ void addToIgnore() override;
+ /*virtual*/ bool canAddToIgnore() const override;
// Spell checking helper functions
std::string getMisspelledWord(U32 pos) const;
@@ -173,27 +175,28 @@ public:
void onSpellCheckSettingsChange();
// view overrides
- virtual void draw();
- virtual void reshape(S32 width,S32 height,BOOL called_from_parent=TRUE);
- virtual void onFocusReceived();
- virtual void onFocusLost();
- virtual void setEnabled(BOOL enabled);
+ /*virtual*/ const std::string getToolTip() const override;
+ /*virtual*/ void draw() override;
+ /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE) override;
+ /*virtual*/ void onFocusReceived() override;
+ /*virtual*/ void onFocusLost() override;
+ /*virtual*/ void setEnabled(BOOL enabled) override;
// UI control overrides
- virtual void clear();
- virtual void onTabInto();
- virtual void setFocus( BOOL b );
- virtual void setRect(const LLRect& rect);
- virtual BOOL acceptsTextInput() const;
- virtual void onCommit();
- virtual BOOL isDirty() const; // Returns TRUE if user changed value at all
- virtual void resetDirty(); // Clear dirty state
+ /*virtual*/ void clear() override;
+ /*virtual*/ void onTabInto() override;
+ /*virtual*/ void setFocus(BOOL b) override;
+ /*virtual*/ void setRect(const LLRect& rect) override;
+ /*virtual*/ BOOL acceptsTextInput() const override;
+ /*virtual*/ void onCommit() override;
+ /*virtual*/ BOOL isDirty() const override; // Returns TRUE if user changed value at all
+ /*virtual*/ void resetDirty() override; // Clear dirty state
// assumes UTF8 text
- virtual void setValue(const LLSD& value );
- virtual LLSD getValue() const;
- virtual BOOL setTextArg( const std::string& key, const LLStringExplicit& text );
- virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text );
+ /*virtual*/ void setValue(const LLSD& value) override;
+ /*virtual*/ LLSD getValue() const override;
+ /*virtual*/ BOOL setTextArg(const std::string& key, const LLStringExplicit& text) override;
+ /*virtual*/ BOOL setLabelArg(const std::string& key, const LLStringExplicit& text) override;
void setLabel(const LLStringExplicit &new_label) { mLabel = new_label; }
const std::string& getLabel() { return mLabel.getString(); }
@@ -215,7 +218,7 @@ public:
// Selects characters 'start' to 'end'.
void setSelection(S32 start, S32 end);
- virtual void getSelectionRange(S32 *position, S32 *length) const;
+ /*virtual*/ void getSelectionRange(S32 *position, S32 *length) const override;
void setCommitOnFocusLost( BOOL b ) { mCommitOnFocusLost = b; }
void setRevertOnEsc( BOOL b ) { mRevertOnEsc = b; }
@@ -286,7 +289,10 @@ public:
void setBgImage(LLPointer<LLUIImage> image) { mBgImage = image; }
void setBgImageFocused(LLPointer<LLUIImage> image) { mBgImageFocused = image; }
-private:
+ void setShowContextMenu(bool show) { mShowContextMenu = show; }
+ bool getShowContextMenu() const { return mShowContextMenu; }
+
+ private:
// private helper methods
void pasteHelper(bool is_primary);
@@ -311,14 +317,14 @@ private:
void updateAllowingLanguageInput();
BOOL hasPreeditString() const;
// Implementation (overrides) of LLPreeditor
- virtual void resetPreedit();
- virtual void updatePreedit(const LLWString &preedit_string,
- const segment_lengths_t &preedit_segment_lengths, const standouts_t &preedit_standouts, S32 caret_position);
- virtual void markAsPreedit(S32 position, S32 length);
- virtual void getPreeditRange(S32 *position, S32 *length) const;
- virtual BOOL getPreeditLocation(S32 query_position, LLCoordGL *coord, LLRect *bounds, LLRect *control) const;
- virtual S32 getPreeditFontSize() const;
- virtual LLWString getPreeditString() const { return getWText(); }
+ /*virtual*/ void resetPreedit() override;
+ /*virtual*/ void updatePreedit(const LLWString &preedit_string,
+ const segment_lengths_t &preedit_segment_lengths, const standouts_t &preedit_standouts, S32 caret_position) override;
+ /*virtual*/ void markAsPreedit(S32 position, S32 length) override;
+ /*virtual*/ void getPreeditRange(S32 *position, S32 *length) const override;
+ /*virtual*/ BOOL getPreeditLocation(S32 query_position, LLCoordGL *coord, LLRect *bounds, LLRect *control) const override;
+ /*virtual*/ S32 getPreeditFontSize() const override;
+ /*virtual*/ LLWString getPreeditString() const override { return getWText(); }
void setText(const LLStringExplicit &new_text, bool use_size_limit);
@@ -395,6 +401,7 @@ protected:
BOOL mReadOnly;
BOOL mShowImageFocused;
+ BOOL mShowLabelFocused;
bool mUseBgColor;
@@ -405,6 +412,8 @@ protected:
LLHandle<LLContextMenu> mContextMenuHandle;
+ bool mShowContextMenu;
+
private:
// Instances that by default point to the statics but can be overidden in XML.
LLPointer<LLUIImage> mBgImage;
diff --git a/indra/llui/llloadingindicator.cpp b/indra/llui/llloadingindicator.cpp
index 1ede5b706f..e8b6b7e43b 100644
--- a/indra/llui/llloadingindicator.cpp
+++ b/indra/llui/llloadingindicator.cpp
@@ -34,7 +34,6 @@
// Project includes
#include "lluictrlfactory.h"
#include "lluiimage.h"
-#include "boost/foreach.hpp"
// registered in llui.cpp to avoid being left out by MS linker
//static LLDefaultChildRegistry::Register<LLLoadingIndicator> r("loading_indicator");
@@ -52,7 +51,7 @@ LLLoadingIndicator::LLLoadingIndicator(const Params& p)
void LLLoadingIndicator::initFromParams(const Params& p)
{
- BOOST_FOREACH(LLUIImage* image, p.images().image)
+ for (LLUIImage* image : p.images().image)
{
mImages.push_back(image);
}
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index 73ac72ac56..7381dc80a8 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -60,7 +60,6 @@
#include "v2math.h"
#include <set>
#include <boost/tokenizer.hpp>
-#include <boost/foreach.hpp>
// static
LLMenuHolderGL *LLMenuGL::sMenuContainer = NULL;
@@ -574,12 +573,17 @@ void LLMenuItemGL::onVisibilityChange(BOOL new_visibility)
// This class represents a separator.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LLMenuItemSeparatorGL::Params::Params()
+ : on_visible("on_visible")
{
}
LLMenuItemSeparatorGL::LLMenuItemSeparatorGL(const LLMenuItemSeparatorGL::Params& p) :
LLMenuItemGL( p )
{
+ if (p.on_visible.isProvided())
+ {
+ mVisibleSignal.connect(initEnableCallback(p.on_visible));
+ }
}
//virtual
@@ -596,6 +600,15 @@ void LLMenuItemSeparatorGL::draw( void )
gl_line_2d( PAD, y, getRect().getWidth() - PAD, y );
}
+void LLMenuItemSeparatorGL::buildDrawLabel( void )
+{
+ if (mVisibleSignal.num_slots() > 0)
+ {
+ bool visible = mVisibleSignal(this, LLSD());
+ setVisible(visible);
+ }
+}
+
BOOL LLMenuItemSeparatorGL::handleMouseDown(S32 x, S32 y, MASK mask)
{
LLMenuGL* parent_menu = getMenu();
@@ -2148,7 +2161,7 @@ void LLMenuGL::arrange( void )
}
else
{
- BOOST_FOREACH(LLMenuItemGL* itemp, mItems)
+ for (LLMenuItemGL* itemp : mItems)
{
// do first so LLMenuGLItemCall can call on_visible to determine if visible
itemp->buildDrawLabel();
diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h
index 8194501f79..44ac61f20d 100644
--- a/indra/llui/llmenugl.h
+++ b/indra/llui/llmenugl.h
@@ -234,16 +234,23 @@ class LLMenuItemSeparatorGL : public LLMenuItemGL
public:
struct Params : public LLInitParam::Block<Params, LLMenuItemGL::Params>
{
- Params();
+ Optional<EnableCallbackParam > on_visible;
+ Params();
};
- LLMenuItemSeparatorGL(const LLMenuItemSeparatorGL::Params& p = LLMenuItemSeparatorGL::Params());
+
+ LLMenuItemSeparatorGL(const LLMenuItemSeparatorGL::Params& p = LLMenuItemSeparatorGL::Params());
/*virtual*/ void draw( void );
/*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 void buildDrawLabel();
+
/*virtual*/ U32 getNominalHeight( void ) const;
+
+private:
+ enable_signal_t mVisibleSignal;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp
index d736aa6634..907408f309 100644
--- a/indra/llui/llnotifications.cpp
+++ b/indra/llui/llnotifications.cpp
@@ -45,7 +45,6 @@
#include <algorithm>
#include <boost/regex.hpp>
-#include <boost/foreach.hpp>
const std::string NOTIFICATION_PERSIST_VERSION = "0.93";
@@ -444,14 +443,14 @@ LLNotificationTemplate::LLNotificationTemplate(const LLNotificationTemplate::Par
mSoundName = p.sound;
}
- BOOST_FOREACH(const LLNotificationTemplate::UniquenessContext& context, p.unique.contexts)
+ for (const LLNotificationTemplate::UniquenessContext& context : p.unique.contexts)
{
mUniqueContext.push_back(context.value);
}
LL_DEBUGS("Notifications") << "notification \"" << mName << "\": tag count is " << p.tags.size() << LL_ENDL;
- BOOST_FOREACH(const LLNotificationTemplate::Tag& tag, p.tags)
+ for (const LLNotificationTemplate::Tag& tag : p.tags)
{
LL_DEBUGS("Notifications") << " tag \"" << std::string(tag.value) << "\"" << LL_ENDL;
mTags.push_back(tag.value);
@@ -994,6 +993,7 @@ LLBoundListener LLNotificationChannelBase::connectChangedImpl(const LLEventListe
// all of the notifications that are already in the channel
// we use a special signal called "load" in case the channel wants to care
// only about new notifications
+ LLMutexLock lock(&mItemsMutex);
for (LLNotificationSet::iterator it = mItems.begin(); it != mItems.end(); ++it)
{
slot(LLSD().with("sigtype", "load").with("id", (*it)->id()));
@@ -1153,7 +1153,7 @@ LLNotificationChannel::LLNotificationChannel(const Params& p)
LLInstanceTracker<LLNotificationChannel, std::string>(p.name.isProvided() ? p.name : LLUUID::generateNewID().asString()),
mName(p.name.isProvided() ? p.name : LLUUID::generateNewID().asString())
{
- BOOST_FOREACH(const std::string& source, p.sources)
+ for (const std::string& source : p.sources)
{
connectToChannel(source);
}
@@ -1171,29 +1171,33 @@ LLNotificationChannel::LLNotificationChannel(const std::string& name,
connectToChannel(parent);
}
-bool LLNotificationChannel::isEmpty() const
+LLNotificationChannel::~LLNotificationChannel()
{
- return mItems.empty();
+ for (LLBoundListener &listener : mListeners)
+ {
+ listener.disconnect();
+ }
}
-S32 LLNotificationChannel::size() const
+bool LLNotificationChannel::isEmpty() const
{
- return mItems.size();
+ return mItems.empty();
}
-LLNotificationChannel::Iterator LLNotificationChannel::begin()
+S32 LLNotificationChannel::size() const
{
- return mItems.begin();
+ return mItems.size();
}
-LLNotificationChannel::Iterator LLNotificationChannel::end()
+size_t LLNotificationChannel::size()
{
- return mItems.end();
+ return mItems.size();
}
-size_t LLNotificationChannel::size()
+void LLNotificationChannel::forEachNotification(NotificationProcess process)
{
- return mItems.size();
+ LLMutexLock lock(&mItemsMutex);
+ std::for_each(mItems.begin(), mItems.end(), process);
}
std::string LLNotificationChannel::summarize()
@@ -1201,7 +1205,8 @@ std::string LLNotificationChannel::summarize()
std::string s("Channel '");
s += mName;
s += "'\n ";
- for (LLNotificationChannel::Iterator it = begin(); it != end(); ++it)
+ LLMutexLock lock(&mItemsMutex);
+ for (LLNotificationChannel::Iterator it = mItems.begin(); it != mItems.end(); ++it)
{
s += (*it)->summarize();
s += "\n ";
@@ -1213,14 +1218,14 @@ void LLNotificationChannel::connectToChannel( const std::string& channel_name )
{
if (channel_name.empty())
{
- LLNotifications::instance().connectChanged(
- boost::bind(&LLNotificationChannelBase::updateItem, this, _1));
+ mListeners.push_back(LLNotifications::instance().connectChanged(
+ boost::bind(&LLNotificationChannelBase::updateItem, this, _1)));
}
else
{
mParents.push_back(channel_name);
LLNotificationChannelPtr p = LLNotifications::instance().getChannel(channel_name);
- p->connectChanged(boost::bind(&LLNotificationChannelBase::updateItem, this, _1));
+ mListeners.push_back(p->connectChanged(boost::bind(&LLNotificationChannelBase::updateItem, this, _1)));
}
}
@@ -1521,7 +1526,7 @@ void replaceFormText(LLNotificationForm::Params& form, const std::string& patter
form.ignore.text = replace;
}
- BOOST_FOREACH(LLNotificationForm::FormElement& element, form.form_elements.elements)
+ for (LLNotificationForm::FormElement& element : form.form_elements.elements)
{
if (element.button.isChosen() && element.button.text() == pattern)
{
@@ -1553,6 +1558,7 @@ bool LLNotifications::loadTemplates()
if (!success || root.isNull() || !root->hasName( "notifications" ))
{
+ LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"));
LL_ERRS() << "Problem reading XML from UI Notifications file: " << base_filename << LL_ENDL;
return false;
}
@@ -1563,25 +1569,26 @@ bool LLNotifications::loadTemplates()
if(!params.validateBlock())
{
+ LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"));
LL_ERRS() << "Problem reading XUI from UI Notifications file: " << base_filename << LL_ENDL;
return false;
}
mTemplates.clear();
- BOOST_FOREACH(LLNotificationTemplate::GlobalString& string, params.strings)
+ for (const LLNotificationTemplate::GlobalString& string : params.strings)
{
mGlobalStrings[string.name] = string.value;
}
std::map<std::string, LLNotificationForm::Params> form_templates;
- BOOST_FOREACH(LLNotificationTemplate::Template& notification_template, params.templates)
+ for (const LLNotificationTemplate::Template& notification_template : params.templates)
{
form_templates[notification_template.name] = notification_template.form;
}
- BOOST_FOREACH(LLNotificationTemplate::Params& notification, params.notifications)
+ for (LLNotificationTemplate::Params& notification : params.notifications)
{
if (notification.form_ref.form_template.isChosen())
{
@@ -1629,13 +1636,14 @@ bool LLNotifications::loadVisibilityRules()
if(!params.validateBlock())
{
+ LLError::LLUserWarningMsg::show(LLTrans::getString("MBMissingFile"));
LL_ERRS() << "Problem reading UI Notification Visibility Rules file: " << full_filename << LL_ENDL;
return false;
}
mVisibilityRules.clear();
- BOOST_FOREACH(LLNotificationVisibilityRule::Rule& rule, params.rules)
+ for (const LLNotificationVisibilityRule::Rule& rule : params.rules)
{
mVisibilityRules.push_back(LLNotificationVisibilityRulePtr(new LLNotificationVisibilityRule(rule)));
}
@@ -1728,6 +1736,7 @@ void LLNotifications::cancel(LLNotificationPtr pNotif)
void LLNotifications::cancelByName(const std::string& name)
{
+ LLMutexLock lock(&mItemsMutex);
std::vector<LLNotificationPtr> notifs_to_cancel;
for (LLNotificationSet::iterator it=mItems.begin(), end_it = mItems.end();
it != end_it;
@@ -1752,6 +1761,7 @@ void LLNotifications::cancelByName(const std::string& name)
void LLNotifications::cancelByOwner(const LLUUID ownerId)
{
+ LLMutexLock lock(&mItemsMutex);
std::vector<LLNotificationPtr> notifs_to_cancel;
for (LLNotificationSet::iterator it = mItems.begin(), end_it = mItems.end();
it != end_it;
@@ -1799,11 +1809,6 @@ LLNotificationPtr LLNotifications::find(LLUUID uuid)
}
}
-void LLNotifications::forEachNotification(NotificationProcess process)
-{
- std::for_each(mItems.begin(), mItems.end(), process);
-}
-
std::string LLNotifications::getGlobalString(const std::string& key) const
{
GlobalStringMap::const_iterator it = mGlobalStrings.find(key);
diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h
index 921398a693..8e61ff5259 100644
--- a/indra/llui/llnotifications.h
+++ b/indra/llui/llnotifications.h
@@ -738,16 +738,19 @@ class LLNotificationChannelBase :
{
LOG_CLASS(LLNotificationChannelBase);
public:
- LLNotificationChannelBase(LLNotificationFilter filter)
- : mFilter(filter),
- mItems()
- {}
+ LLNotificationChannelBase(LLNotificationFilter filter)
+ : mFilter(filter)
+ , mItems()
+ , mItemsMutex()
+ {}
+
virtual ~LLNotificationChannelBase()
{
// explicit cleanup for easier issue detection
mChanged.disconnect_all_slots();
mPassedFilter.disconnect_all_slots();
mFailedFilter.disconnect_all_slots();
+ LLMutexLock lock(&mItemsMutex);
mItems.clear();
}
// you can also connect to a Channel, so you can be notified of
@@ -786,6 +789,7 @@ protected:
LLStandardSignal mChanged;
LLStandardSignal mPassedFilter;
LLStandardSignal mFailedFilter;
+ LLMutex mItemsMutex;
// these are action methods that subclasses can override to take action
// on specific types of changes; the management of the mItems list is
@@ -835,7 +839,7 @@ public:
LLNotificationChannel(const Params& p = Params());
LLNotificationChannel(const std::string& name, const std::string& parent, LLNotificationFilter filter);
- virtual ~LLNotificationChannel() {}
+ virtual ~LLNotificationChannel();
typedef LLNotificationSet::iterator Iterator;
std::string getName() const { return mName; }
@@ -844,21 +848,23 @@ public:
{
return boost::iterator_range<parents_iter>(mParents);
}
-
- void connectToChannel(const std::string& channel_name);
-
+
bool isEmpty() const;
S32 size() const;
-
- Iterator begin();
- Iterator end();
- size_t size();
-
+ size_t size();
+
+ typedef boost::function<void(LLNotificationPtr)> NotificationProcess;
+ void forEachNotification(NotificationProcess process);
+
std::string summarize();
+protected:
+ void connectToChannel(const std::string& channel_name);
+
private:
std::string mName;
std::vector<std::string> mParents;
+ std::vector<LLBoundListener> mListeners;
};
// An interface class to provide a clean linker seam to the LLNotifications class.
@@ -913,7 +919,7 @@ public:
/* virtual */ LLNotificationPtr add(const std::string& name,
const LLSD& substitutions,
const LLSD& payload,
- LLNotificationFunctorRegistry::ResponseFunctor functor);
+ LLNotificationFunctorRegistry::ResponseFunctor functor) override;
LLNotificationPtr add(const LLNotification::Params& p);
void add(const LLNotificationPtr pNotif);
@@ -924,10 +930,6 @@ public:
void update(const LLNotificationPtr pNotif);
LLNotificationPtr find(LLUUID uuid);
-
- typedef boost::function<void (LLNotificationPtr)> NotificationProcess;
-
- void forEachNotification(NotificationProcess process);
// This is all stuff for managing the templates
// take your template out
@@ -964,8 +966,8 @@ public:
bool isVisibleByRules(LLNotificationPtr pNotification);
private:
- /*virtual*/ void initSingleton();
- /*virtual*/ void cleanupSingleton();
+ /*virtual*/ void initSingleton() override;
+ /*virtual*/ void cleanupSingleton() override;
void loadPersistentNotifications();
@@ -990,7 +992,7 @@ private:
bool mIgnoreAllNotifications;
- boost::scoped_ptr<LLNotificationsListener> mListener;
+ std::unique_ptr<LLNotificationsListener> mListener;
std::vector<LLNotificationChannelPtr> mDefaultChannels;
};
diff --git a/indra/llui/llnotificationslistener.cpp b/indra/llui/llnotificationslistener.cpp
index e73ba1fbe9..859222f907 100644
--- a/indra/llui/llnotificationslistener.cpp
+++ b/indra/llui/llnotificationslistener.cpp
@@ -32,7 +32,6 @@
#include "llnotificationtemplate.h"
#include "llsd.h"
#include "llui.h"
-#include <boost/foreach.hpp>
LLNotificationsListener::LLNotificationsListener(LLNotifications & notifications) :
LLEventAPI("LLNotifications",
@@ -149,11 +148,11 @@ void LLNotificationsListener::listChannelNotifications(const LLSD& params) const
if (channel)
{
LLSD notifications(LLSD::emptyArray());
- for (LLNotificationChannel::Iterator ni(channel->begin()), nend(channel->end());
- ni != nend; ++ni)
- {
- notifications.append(asLLSD(*ni));
- }
+ std::function<void(LLNotificationPtr)> func = [notifications](LLNotificationPtr ni) mutable
+ {
+ notifications.append(asLLSD(ni));
+ };
+ channel->forEachNotification(func);
response["notifications"] = notifications;
}
LLEventPumps::instance().obtain(params["reply"]).post(response);
diff --git a/indra/llui/llscrollbar.cpp b/indra/llui/llscrollbar.cpp
index fde6de4921..b2be9fb1e1 100644
--- a/indra/llui/llscrollbar.cpp
+++ b/indra/llui/llscrollbar.cpp
@@ -188,12 +188,12 @@ void LLScrollbar::setPageSize( S32 page_size )
}
}
-BOOL LLScrollbar::isAtBeginning()
+bool LLScrollbar::isAtBeginning() const
{
return mDocPos == 0;
}
-BOOL LLScrollbar::isAtEnd()
+bool LLScrollbar::isAtEnd() const
{
return mDocPos == getDocPosMax();
}
@@ -475,13 +475,15 @@ void LLScrollbar::reshape(S32 width, S32 height, BOOL called_from_parent)
{
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(up_button->getRect().mLeft, getRect().getHeight() - up_button->getRect().getHeight());
+ up_button->setOrigin(0, getRect().getHeight() - up_button->getRect().getHeight());
+ down_button->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());
- down_button->setOrigin(getRect().getWidth() - down_button->getRect().getWidth(), down_button->getRect().mBottom);
+ up_button->setOrigin(0, 0);
+ down_button->setOrigin(getRect().getWidth() - down_button->getRect().getWidth(), 0);
}
updateThumbRect();
}
@@ -591,7 +593,12 @@ void LLScrollbar::setValue(const LLSD& value)
BOOL LLScrollbar::handleKeyHere(KEY key, MASK mask)
{
- BOOL handled = FALSE;
+ if (getDocPosMax() == 0 && !getVisible())
+ {
+ return FALSE;
+ }
+
+ BOOL handled = FALSE;
switch( key )
{
diff --git a/indra/llui/llscrollbar.h b/indra/llui/llscrollbar.h
index 5f2f490d81..9be9d22db8 100644
--- a/indra/llui/llscrollbar.h
+++ b/indra/llui/llscrollbar.h
@@ -105,8 +105,8 @@ public:
bool setDocPos( S32 pos, BOOL update_thumb = TRUE );
S32 getDocPos() const { return mDocPos; }
- BOOL isAtBeginning();
- BOOL isAtEnd();
+ bool isAtBeginning() const;
+ bool isAtEnd() const;
// Setting both at once.
void setDocParams( S32 size, S32 pos );
diff --git a/indra/llui/llscrollcontainer.cpp b/indra/llui/llscrollcontainer.cpp
index 3db38bbfac..22d27b1f2a 100644
--- a/indra/llui/llscrollcontainer.cpp
+++ b/indra/llui/llscrollcontainer.cpp
@@ -70,6 +70,7 @@ LLScrollContainer::Params::Params()
bg_color("color"),
border_visible("border_visible"),
hide_scrollbar("hide_scrollbar"),
+ ignore_arrow_keys("ignore_arrow_keys"),
min_auto_scroll_rate("min_auto_scroll_rate", 100),
max_auto_scroll_rate("max_auto_scroll_rate", 1000),
max_auto_scroll_zone("max_auto_scroll_zone", 16),
@@ -86,6 +87,7 @@ LLScrollContainer::LLScrollContainer(const LLScrollContainer::Params& p)
mBackgroundColor(p.bg_color()),
mIsOpaque(p.is_opaque),
mHideScrollbar(p.hide_scrollbar),
+ mIgnoreArrowKeys(p.ignore_arrow_keys),
mReserveScrollCorner(p.reserve_scroll_corner),
mMinAutoScrollRate(p.min_auto_scroll_rate),
mMaxAutoScrollRate(p.max_auto_scroll_rate),
@@ -105,8 +107,8 @@ LLScrollContainer::LLScrollContainer(const LLScrollContainer::Params& p)
mBorder = LLUICtrlFactory::create<LLViewBorder> (params);
LLView::addChild( mBorder );
- mInnerRect.set( 0, getRect().getHeight(), getRect().getWidth(), 0 );
- mInnerRect.stretch( -getBorderWidth() );
+ mInnerRect = getLocalRect();
+ mInnerRect.stretch( -getBorderWidth() );
LLRect vertical_scroll_rect = mInnerRect;
vertical_scroll_rect.mLeft = vertical_scroll_rect.mRight - scrollbar_size;
@@ -124,8 +126,9 @@ LLScrollContainer::LLScrollContainer(const LLScrollContainer::Params& p)
mScrollbar[VERTICAL] = LLUICtrlFactory::create<LLScrollbar> (sbparams);
LLView::addChild( mScrollbar[VERTICAL] );
- LLRect horizontal_scroll_rect = mInnerRect;
- horizontal_scroll_rect.mTop = horizontal_scroll_rect.mBottom + scrollbar_size;
+ LLRect horizontal_scroll_rect;
+ horizontal_scroll_rect.mTop = scrollbar_size;
+ horizontal_scroll_rect.mRight = mInnerRect.getWidth();
sbparams.name("scrollable horizontal");
sbparams.rect(horizontal_scroll_rect);
sbparams.orientation(LLScrollbar::HORIZONTAL);
@@ -134,7 +137,7 @@ LLScrollContainer::LLScrollContainer(const LLScrollContainer::Params& p)
sbparams.page_size(mInnerRect.getWidth());
sbparams.step_size(VERTICAL_MULTIPLE);
sbparams.visible(false);
- sbparams.follows.flags(FOLLOWS_LEFT | FOLLOWS_RIGHT);
+ sbparams.follows.flags(FOLLOWS_LEFT | FOLLOWS_RIGHT | FOLLOWS_BOTTOM);
sbparams.change_callback(p.scroll_callback);
mScrollbar[HORIZONTAL] = LLUICtrlFactory::create<LLScrollbar> (sbparams);
LLView::addChild( mScrollbar[HORIZONTAL] );
@@ -203,10 +206,29 @@ void LLScrollContainer::reshape(S32 width, S32 height,
}
}
+// virtual
BOOL LLScrollContainer::handleKeyHere(KEY key, MASK mask)
{
+ if (mIgnoreArrowKeys)
+ {
+ switch(key)
+ {
+ case KEY_LEFT:
+ case KEY_RIGHT:
+ case KEY_UP:
+ case KEY_DOWN:
+ case KEY_PAGE_UP:
+ case KEY_PAGE_DOWN:
+ case KEY_HOME:
+ case KEY_END:
+ return FALSE;
+ default:
+ break;
+ }
+ }
+
// allow scrolled view to handle keystrokes in case it delegated keyboard focus
- // to the scroll container.
+ // to the scroll container.
// NOTE: this should not recurse indefinitely as handleKeyHere
// should not propagate to parent controls, so mScrolledView should *not*
// call LLScrollContainer::handleKeyHere in turn
diff --git a/indra/llui/llscrollcontainer.h b/indra/llui/llscrollcontainer.h
index c14099dbd5..79dc70cac9 100644
--- a/indra/llui/llscrollcontainer.h
+++ b/indra/llui/llscrollcontainer.h
@@ -63,7 +63,8 @@ public:
Optional<bool> is_opaque,
reserve_scroll_corner,
border_visible,
- hide_scrollbar;
+ hide_scrollbar,
+ ignore_arrow_keys;
Optional<F32> min_auto_scroll_rate,
max_auto_scroll_rate;
Optional<U32> max_auto_scroll_zone;
@@ -98,8 +99,10 @@ public:
void pageDown(S32 overlap = 0);
void goToTop();
void goToBottom();
- bool isAtTop() { return mScrollbar[VERTICAL]->isAtBeginning(); }
- bool isAtBottom() { return mScrollbar[VERTICAL]->isAtEnd(); }
+ bool isAtTop() const { return mScrollbar[VERTICAL]->isAtBeginning(); }
+ bool isAtBottom() const { return mScrollbar[VERTICAL]->isAtEnd(); }
+ S32 getDocPosVertical() const { return mScrollbar[VERTICAL]->getDocPos(); }
+ S32 getDocPosHorizontal() const { return mScrollbar[HORIZONTAL]->getDocPos(); }
S32 getBorderWidth() const;
// LLView functionality
@@ -147,6 +150,7 @@ private:
F32 mMaxAutoScrollRate;
U32 mMaxAutoScrollZone;
bool mHideScrollbar;
+ bool mIgnoreArrowKeys;
};
diff --git a/indra/llui/llscrollingpanellist.cpp b/indra/llui/llscrollingpanellist.cpp
index b6f2eb8ba2..3a819e7d06 100644
--- a/indra/llui/llscrollingpanellist.cpp
+++ b/indra/llui/llscrollingpanellist.cpp
@@ -37,53 +37,44 @@ static LLDefaultChildRegistry::Register<LLScrollingPanelList> r("scrolling_panel
// This could probably be integrated with LLScrollContainer -SJB
+LLScrollingPanelList::Params::Params()
+ : is_horizontal("is_horizontal")
+ , padding("padding")
+ , spacing("spacing")
+{
+}
+
+LLScrollingPanelList::LLScrollingPanelList(const Params& p)
+ : LLUICtrl(p)
+ , mIsHorizontal(p.is_horizontal)
+ , mPadding(p.padding.isProvided() ? p.padding : DEFAULT_PADDING)
+ , mSpacing(p.spacing.isProvided() ? p.spacing : DEFAULT_SPACING)
+{
+}
+
void LLScrollingPanelList::clearPanels()
{
deleteAllChildren();
mPanelList.clear();
-
- LLRect rc = getRect();
- rc.setLeftTopAndSize(rc.mLeft, rc.mTop, 1, 1);
- setRect(rc);
-
- notifySizeChanged(rc.getHeight());
+ rearrange();
}
-S32 LLScrollingPanelList::addPanel( LLScrollingPanel* panel )
+S32 LLScrollingPanelList::addPanel(LLScrollingPanel* panel, bool back)
{
- addChildInBack( panel );
- mPanelList.push_front( panel );
-
- // Resize this view
- S32 total_height = 0;
- S32 max_width = 0;
- S32 cur_gap = 0;
- for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
- iter != mPanelList.end(); ++iter)
+ if (back)
{
- LLScrollingPanel *childp = *iter;
- total_height += childp->getRect().getHeight() + cur_gap;
- max_width = llmax( max_width, childp->getRect().getWidth() );
- cur_gap = GAP_BETWEEN_PANELS;
+ addChild(panel);
+ mPanelList.push_back(panel);
}
- LLRect rc = getRect();
- rc.setLeftTopAndSize(rc.mLeft, rc.mTop, max_width, total_height);
- setRect(rc);
-
- notifySizeChanged(rc.getHeight());
-
- // Reposition each of the child views
- S32 cur_y = total_height;
- for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
- iter != mPanelList.end(); ++iter)
+ else
{
- LLScrollingPanel *childp = *iter;
- cur_y -= childp->getRect().getHeight();
- childp->translate( -childp->getRect().mLeft, cur_y - childp->getRect().mBottom);
- cur_y -= GAP_BETWEEN_PANELS;
+ addChildInBack(panel);
+ mPanelList.push_front(panel);
}
- return total_height;
+ rearrange();
+
+ return mIsHorizontal ? getRect().getWidth() : getRect().getHeight();
}
void LLScrollingPanelList::removePanel(LLScrollingPanel* panel)
@@ -100,7 +91,7 @@ void LLScrollingPanelList::removePanel(LLScrollingPanel* panel)
break;
}
}
- if(iter != mPanelList.end())
+ if (iter != mPanelList.end())
{
removePanel(index);
}
@@ -120,62 +111,104 @@ void LLScrollingPanelList::removePanel( U32 panel_index )
mPanelList.erase( mPanelList.begin() + panel_index );
}
- const S32 GAP_BETWEEN_PANELS = 6;
+ rearrange();
+}
- // Resize this view
- S32 total_height = 0;
- S32 max_width = 0;
- S32 cur_gap = 0;
- for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
+void LLScrollingPanelList::updatePanels(BOOL allow_modify)
+{
+ for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
iter != mPanelList.end(); ++iter)
- {
+ {
LLScrollingPanel *childp = *iter;
- total_height += childp->getRect().getHeight() + cur_gap;
- max_width = llmax( max_width, childp->getRect().getWidth() );
- cur_gap = GAP_BETWEEN_PANELS;
+ childp->updatePanel(allow_modify);
+ }
+}
+
+void LLScrollingPanelList::rearrange()
+{
+ // Resize this view
+ S32 new_width, new_height;
+ if (!mPanelList.empty())
+ {
+ new_width = new_height = mPadding * 2;
+ for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
+ iter != mPanelList.end(); ++iter)
+ {
+ LLScrollingPanel* childp = *iter;
+ const LLRect& rect = childp->getRect();
+ if (mIsHorizontal)
+ {
+ new_width += rect.getWidth() + mSpacing;
+ new_height = llmax(new_height, rect.getHeight());
+ }
+ else
+ {
+ new_height += rect.getHeight() + mSpacing;
+ new_width = llmax(new_width, rect.getWidth());
+ }
+ }
+
+ if (mIsHorizontal)
+ {
+ new_width -= mSpacing;
+ }
+ else
+ {
+ new_height -= mSpacing;
+ }
}
+ else
+ {
+ new_width = new_height = 1;
+ }
+
LLRect rc = getRect();
- rc.setLeftTopAndSize(rc.mLeft, rc.mTop, max_width, total_height);
- setRect(rc);
+ if (mIsHorizontal || !followsRight())
+ {
+ rc.mRight = rc.mLeft + new_width;
+ }
+ if (!mIsHorizontal || !followsBottom())
+ {
+ rc.mBottom = rc.mTop - new_height;
+ }
- notifySizeChanged(rc.getHeight());
+ if (rc.mRight != getRect().mRight || rc.mBottom != getRect().mBottom)
+ {
+ setRect(rc);
+ notifySizeChanged();
+ }
// Reposition each of the child views
- S32 cur_y = total_height;
+ S32 pos = mIsHorizontal ? mPadding : rc.getHeight() - mPadding;
for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
- iter != mPanelList.end(); ++iter)
+ iter != mPanelList.end(); ++iter)
{
- LLScrollingPanel *childp = *iter;
- cur_y -= childp->getRect().getHeight();
- childp->translate( -childp->getRect().mLeft, cur_y - childp->getRect().mBottom);
- cur_y -= GAP_BETWEEN_PANELS;
+ LLScrollingPanel* childp = *iter;
+ const LLRect& rect = childp->getRect();
+ if (mIsHorizontal)
+ {
+ childp->translate(pos - rect.mLeft, rc.getHeight() - mPadding - rect.mTop);
+ pos += rect.getWidth() + mSpacing;
+ }
+ else
+ {
+ childp->translate(mPadding - rect.mLeft, pos - rect.mTop);
+ pos -= rect.getHeight() + mSpacing;
+ }
}
}
-void LLScrollingPanelList::updatePanels(BOOL allow_modify)
-{
- for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
- iter != mPanelList.end(); ++iter)
- {
- LLScrollingPanel *childp = *iter;
- childp->updatePanel(allow_modify);
- }
-}
-
void LLScrollingPanelList::updatePanelVisiblilty()
{
// Determine visibility of children.
- S32 BORDER_WIDTH = 2; // HACK
- LLRect parent_local_rect = getParent()->getRect();
- parent_local_rect.stretch( -BORDER_WIDTH );
-
LLRect parent_screen_rect;
- getParent()->localPointToScreen(
- BORDER_WIDTH, 0,
+ getParent()->localPointToScreen(
+ mPadding, mPadding,
&parent_screen_rect.mLeft, &parent_screen_rect.mBottom );
- getParent()->localPointToScreen(
- parent_local_rect.getWidth() - BORDER_WIDTH, parent_local_rect.getHeight() - BORDER_WIDTH,
+ getParent()->localPointToScreen(
+ getParent()->getRect().getWidth() - mPadding,
+ getParent()->getRect().getHeight() - mPadding,
&parent_screen_rect.mRight, &parent_screen_rect.mTop );
for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
@@ -207,11 +240,12 @@ void LLScrollingPanelList::draw()
LLUICtrl::draw();
}
-void LLScrollingPanelList::notifySizeChanged(S32 height)
+void LLScrollingPanelList::notifySizeChanged()
{
LLSD info;
info["action"] = "size_changes";
- info["height"] = height;
+ info["height"] = getRect().getHeight();
+ info["width"] = getRect().getWidth();
notifyParent(info);
}
diff --git a/indra/llui/llscrollingpanellist.h b/indra/llui/llscrollingpanellist.h
index e8df176ec3..d625039427 100644
--- a/indra/llui/llscrollingpanellist.h
+++ b/indra/llui/llscrollingpanellist.h
@@ -45,18 +45,24 @@ public:
/*
- * A set of panels that are displayed in a vertical sequence inside a scroll container.
+ * A set of panels that are displayed in a sequence inside a scroll container.
*/
class LLScrollingPanelList : public LLUICtrl
{
public:
struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
- {};
- LLScrollingPanelList(const Params& p)
- : LLUICtrl(p)
- {}
+ {
+ Optional<bool> is_horizontal;
+ Optional<S32> padding;
+ Optional<S32> spacing;
+
+ Params();
+ };
+
+ LLScrollingPanelList(const Params& p);
- static const S32 GAP_BETWEEN_PANELS = 6;
+ static const S32 DEFAULT_SPACING = 6;
+ static const S32 DEFAULT_PADDING = 2;
typedef std::deque<LLScrollingPanel*> panel_list_t;
@@ -65,11 +71,18 @@ public:
virtual void draw();
void clearPanels();
- S32 addPanel( LLScrollingPanel* panel );
- void removePanel( LLScrollingPanel* panel );
- void removePanel( U32 panel_index );
+ S32 addPanel(LLScrollingPanel* panel, bool back = false);
+ void removePanel(LLScrollingPanel* panel);
+ void removePanel(U32 panel_index);
void updatePanels(BOOL allow_modify);
- const panel_list_t& getPanelList() { return mPanelList; }
+ void rearrange();
+
+ const panel_list_t& getPanelList() const { return mPanelList; }
+ bool getIsHorizontal() const { return mIsHorizontal; }
+ void setPadding(S32 padding) { mPadding = padding; rearrange(); }
+ void setSpacing(S32 spacing) { mSpacing = spacing; rearrange(); }
+ S32 getPadding() const { return mPadding; }
+ S32 getSpacing() const { return mSpacing; }
private:
void updatePanelVisiblilty();
@@ -77,7 +90,11 @@ private:
/**
* Notify parent about size change, makes sense when used inside accordion
*/
- void notifySizeChanged(S32 height);
+ void notifySizeChanged();
+
+ bool mIsHorizontal;
+ S32 mPadding;
+ S32 mSpacing;
panel_list_t mPanelList;
};
diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp
index 219667f766..f982dc99e8 100644
--- a/indra/llui/llscrolllistctrl.cpp
+++ b/indra/llui/llscrolllistctrl.cpp
@@ -411,7 +411,7 @@ void LLScrollListCtrl::clearRows()
LLScrollListItem* LLScrollListCtrl::getFirstSelected() const
{
item_list::const_iterator iter;
- for(iter = mItemList.begin(); iter != mItemList.end(); iter++)
+ for (iter = mItemList.begin(); iter != mItemList.end(); iter++)
{
LLScrollListItem* item = *iter;
if (item->getSelected())
@@ -1269,7 +1269,7 @@ BOOL LLScrollListCtrl::selectItemByLabel(const std::string& label, BOOL case_sen
LLScrollListItem* item = getItemByLabel(label, case_sensitive, column);
bool found = NULL != item;
- if(found)
+ if (found)
{
selectItem(item, -1);
}
@@ -2747,7 +2747,7 @@ BOOL LLScrollListCtrl::setSort(S32 column_idx, BOOL ascending)
S32 LLScrollListCtrl::getLinesPerPage()
{
//if mPageLines is NOT provided display all item
- if(mPageLines)
+ if (mPageLines)
{
return mPageLines;
}
diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h
index 73b4fb036a..326589a329 100644
--- a/indra/llui/llscrolllistctrl.h
+++ b/indra/llui/llscrolllistctrl.h
@@ -253,7 +253,7 @@ public:
S32 getItemIndex( LLScrollListItem* item ) const;
S32 getItemIndex( const LLUUID& item_id ) const;
- void setCommentText( const std::string& comment_text);
+ void setCommentText( const std::string& comment_text);
LLScrollListItem* addSeparator(EAddPosition pos);
// "Simple" interface: use this when you're creating a list that contains only unique strings, only
@@ -263,7 +263,7 @@ public:
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 );
+ LLScrollListItem* getItemByLabel(const std::string& item, BOOL case_sensitive = TRUE, S32 column = 0);
const std::string getSelectedItemLabel(S32 column = 0) const;
LLSD getSelectedValue();
@@ -322,7 +322,7 @@ public:
virtual S32 getScrollPos() const;
virtual void setScrollPos( S32 pos );
- S32 getSearchColumn();
+ S32 getSearchColumn();
void setSearchColumn(S32 column) { mSearchColumn = column; }
S32 getColumnIndexFromOffset(S32 x);
S32 getColumnOffsetFromIndex(S32 index);
@@ -371,13 +371,13 @@ public:
// Used "internally" by the scroll bar.
void onScrollChange( S32 new_pos, LLScrollbar* src );
- static void onClickColumn(void *userdata);
+ static void onClickColumn(void *userdata);
- virtual void updateColumns(bool force_update = false);
- S32 calcMaxContentWidth();
- bool updateColumnWidths();
+ virtual void updateColumns(bool force_update = false);
+ S32 calcMaxContentWidth();
+ bool updateColumnWidths();
- void setHeadingHeight(S32 heading_height);
+ void setHeadingHeight(S32 heading_height);
/**
* Sets max visible lines without scroolbar, if this value equals to 0,
* then display all items.
@@ -398,18 +398,20 @@ public:
virtual void deselect();
virtual BOOL canDeselect() const;
- void setNumDynamicColumns(S32 num) { mNumDynamicWidthColumns = num; }
- void updateStaticColumnWidth(LLScrollListColumn* col, S32 new_width);
- S32 getTotalStaticColumnWidth() { return mTotalStaticColumnWidth; }
+ void setNumDynamicColumns(S32 num) { mNumDynamicWidthColumns = num; }
+ void updateStaticColumnWidth(LLScrollListColumn* col, S32 new_width);
+ S32 getTotalStaticColumnWidth() { return mTotalStaticColumnWidth; }
std::string getSortColumnName();
BOOL getSortAscending() { return mSortColumns.empty() ? TRUE : mSortColumns.back().second; }
BOOL hasSortOrder() const;
void clearSortOrder();
- void setAlternateSort() { mAlternateSort = true; }
+ void setAlternateSort() { mAlternateSort = TRUE; }
- S32 selectMultiple( uuid_vec_t ids );
+ void selectPrevItem(BOOL extend_selection = FALSE);
+ void selectNextItem(BOOL extend_selection = FALSE);
+ S32 selectMultiple(uuid_vec_t ids);
// conceptually const, but mutates mItemList
void updateSort() const;
// sorts a list without affecting the permanent sort order (so further list insertions can be unsorted, for example)
@@ -454,8 +456,6 @@ protected:
void updateLineHeight();
private:
- void selectPrevItem(BOOL extend_selection);
- void selectNextItem(BOOL extend_selection);
void drawItems();
void updateLineHeightInsert(LLScrollListItem* item);
diff --git a/indra/llui/llsearcheditor.cpp b/indra/llui/llsearcheditor.cpp
index bafeef41fb..8bf135f10c 100644
--- a/indra/llui/llsearcheditor.cpp
+++ b/indra/llui/llsearcheditor.cpp
@@ -104,6 +104,14 @@ LLSearchEditor::LLSearchEditor(const LLSearchEditor::Params& p)
}
}
+LLSearchEditor::~LLSearchEditor()
+{
+ mSearchButton = NULL;
+ mClearButton = NULL;
+ mSearchEditor->deleteAllChildren();
+ deleteAllChildren();
+}
+
//virtual
void LLSearchEditor::draw()
{
@@ -178,6 +186,10 @@ void LLSearchEditor::setFocus( BOOL b )
void LLSearchEditor::onClearButtonClick(const LLSD& data)
{
setText(LLStringUtil::null);
+ if (mTextChangedCallback)
+ {
+ mTextChangedCallback(this, getValue());
+ }
mSearchEditor->onCommit(); // force keystroke callback
}
diff --git a/indra/llui/llsearcheditor.h b/indra/llui/llsearcheditor.h
index c0f3c1d60c..bd51988d07 100644
--- a/indra/llui/llsearcheditor.h
+++ b/indra/llui/llsearcheditor.h
@@ -74,7 +74,7 @@ protected:
friend class LLUICtrlFactory;
public:
- virtual ~LLSearchEditor() {}
+ virtual ~LLSearchEditor();
/*virtual*/ void draw();
diff --git a/indra/llui/llspellcheck.h b/indra/llui/llspellcheck.h
index 3da5e30955..14f9b44fe4 100644
--- a/indra/llui/llspellcheck.h
+++ b/indra/llui/llspellcheck.h
@@ -47,7 +47,7 @@ public:
protected:
void addToDictFile(const std::string& dict_path, const std::string& word);
void initHunspell(const std::string& dict_language);
- void initSingleton();
+ void initSingleton() override;
public:
typedef std::list<std::string> dict_list_t;
diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp
index 8c841540a5..6aeae0f291 100644
--- a/indra/llui/lltabcontainer.cpp
+++ b/indra/llui/lltabcontainer.cpp
@@ -605,6 +605,7 @@ BOOL LLTabContainer::handleMouseDown( S32 x, S32 y, MASK mask )
LLButton* tab_button = getTab(index)->mButton;
gFocusMgr.setMouseCapture(this);
tab_button->setFocus(TRUE);
+ mMouseDownTimer.start();
}
}
if (handled) {
@@ -653,7 +654,11 @@ BOOL LLTabContainer::handleHover( S32 x, S32 y, MASK mask )
handled = LLPanel::handleHover(x, y, mask);
}
- commitHoveredButton(x, y);
+ F32 drag_delay = 0.25f; // filter out clicks from dragging
+ if (mMouseDownTimer.getElapsedTimeF32() > drag_delay)
+ {
+ commitHoveredButton(x, y);
+ }
return handled;
}
@@ -699,6 +704,7 @@ BOOL LLTabContainer::handleMouseUp( S32 x, S32 y, MASK mask )
}
commitHoveredButton(x, y);
+ mMouseDownTimer.stop();
LLPanel* cur_panel = getCurrentPanel();
if (hasMouseCapture())
{
@@ -1002,7 +1008,7 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel)
}
else
{
- //Scip tab button space if they are invisible(EXT - 576)
+ // Skip tab button space if tabs are invisible (EXT-576)
tab_panel_top = getRect().getHeight();
tab_panel_bottom = LLPANEL_BORDER_WIDTH;
}
@@ -1017,9 +1023,9 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel)
}
else
{
- tab_panel_rect = LLRect(LLPANEL_BORDER_WIDTH,
+ tab_panel_rect = LLRect(LLPANEL_BORDER_WIDTH * 3,
tab_panel_top,
- getRect().getWidth()-LLPANEL_BORDER_WIDTH,
+ getRect().getWidth() - LLPANEL_BORDER_WIDTH * 2,
tab_panel_bottom );
}
child->setFollowsAll();
@@ -1106,7 +1112,7 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel)
p.follows.flags = p.follows.flags() | FOLLOWS_TOP;
}
else
- {
+ {
p.name("htab_"+std::string(child->getName()));
p.visible(false);
p.image_unselected(tab_img);
@@ -1510,25 +1516,23 @@ BOOL LLTabContainer::selectTab(S32 which)
LLTabTuple* selected_tuple = getTab(which);
if (!selected_tuple)
- {
return FALSE;
- }
-
+
LLSD cbdata;
if (selected_tuple->mTabPanel)
cbdata = selected_tuple->mTabPanel->getName();
- BOOL res = FALSE;
- if( !mValidateSignal || (*mValidateSignal)( this, cbdata ) )
+ BOOL result = FALSE;
+ if (!mValidateSignal || (*mValidateSignal)(this, cbdata))
{
- res = setTab(which);
- if (res && mCommitSignal)
+ result = setTab(which);
+ if (result && mCommitSignal)
{
(*mCommitSignal)(this, cbdata);
}
}
-
- return res;
+
+ return result;
}
// private
@@ -2143,14 +2147,19 @@ void LLTabContainer::commitHoveredButton(S32 x, S32 y)
{
if (!getTabsHidden() && hasMouseCapture())
{
- for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
+ for (tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
{
- LLTabTuple* tuple = *iter;
- S32 local_x = x - tuple->mButton->getRect().mLeft;
- S32 local_y = y - tuple->mButton->getRect().mBottom;
- if (tuple->mButton->pointInView(local_x, local_y) && tuple->mButton->getEnabled() && !tuple->mTabPanel->getVisible())
+ LLButton* button = (*iter)->mButton;
+ LLPanel* panel = (*iter)->mTabPanel;
+ if (button->getEnabled() && button->getVisible() && !panel->getVisible())
{
- tuple->mButton->onCommit();
+ S32 local_x = x - button->getRect().mLeft;
+ S32 local_y = y - button->getRect().mBottom;
+ if (button->pointInView(local_x, local_y))
+ {
+ button->onCommit();
+ break;
+ }
}
}
}
diff --git a/indra/llui/lltabcontainer.h b/indra/llui/lltabcontainer.h
index 8f8cedb1b9..aa4a08c4ff 100644
--- a/indra/llui/lltabcontainer.h
+++ b/indra/llui/lltabcontainer.h
@@ -320,6 +320,7 @@ private:
LLUIColor mTabsFlashingColor;
S32 mTabIconCtrlPad;
bool mUseTabEllipses;
+ LLFrameTimer mMouseDownTimer;
};
#endif // LL_TABCONTAINER_H
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index b6d27a3211..50feee8a47 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -29,6 +29,8 @@
#include "lltextbase.h"
+#include "llemojidictionary.h"
+#include "llemojihelper.h"
#include "lllocalcliprect.h"
#include "llmenugl.h"
#include "llscrollcontainer.h"
@@ -161,10 +163,12 @@ LLTextBase::Params::Params()
line_spacing("line_spacing"),
max_text_length("max_length", 255),
font_shadow("font_shadow"),
+ text_valign("text_valign"),
wrap("wrap"),
trusted_content("trusted_content", true),
always_show_icons("always_show_icons", false),
use_ellipses("use_ellipses", false),
+ use_color("use_color", true),
parse_urls("parse_urls", false),
force_urls_external("force_urls_external", false),
parse_highlights("parse_highlights", false)
@@ -208,6 +212,7 @@ LLTextBase::LLTextBase(const LLTextBase::Params &p)
mVPad(p.v_pad),
mHAlign(p.font_halign),
mVAlign(p.font_valign),
+ mTextVAlign(p.text_valign.isProvided() ? p.text_valign.getValue() : p.font_valign.getValue()),
mLineSpacingMult(p.line_spacing.multiple),
mLineSpacingPixels(p.line_spacing.pixels),
mClip(p.clip),
@@ -222,6 +227,7 @@ LLTextBase::LLTextBase(const LLTextBase::Params &p)
mPlainText ( p.plain_text ),
mWordWrap(p.wrap),
mUseEllipses( p.use_ellipses ),
+ mUseColor(p.use_color),
mParseHTML(p.parse_urls),
mForceUrlsExternal(p.force_urls_external),
mParseHighlights(p.parse_highlights),
@@ -582,7 +588,7 @@ void LLTextBase::drawCursor()
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),
- LLFontGL::LEFT, mVAlign,
+ LLFontGL::LEFT, mTextVAlign,
LLFontGL::NORMAL,
LLFontGL::NO_SHADOW,
1);
@@ -896,6 +902,28 @@ S32 LLTextBase::insertStringNoUndo(S32 pos, const LLWString &wstr, LLTextBase::s
}
}
+ // Insert special segments where necessary (insertSegment takes care of splitting normal text segments around them for us)
+ {
+ LLStyleSP emoji_style;
+ LLEmojiDictionary* ed = LLEmojiDictionary::instanceExists() ? LLEmojiDictionary::getInstance() : NULL;
+ for (S32 text_kitty = 0, text_len = wstr.size(); text_kitty < text_len; text_kitty++)
+ {
+ llwchar code = wstr[text_kitty];
+ bool isEmoji = ed ? ed->isEmoji(code) : LLStringOps::isEmoji(code);
+ if (isEmoji)
+ {
+ if (!emoji_style)
+ {
+ emoji_style = new LLStyle(getStyleParams());
+ emoji_style->setFont(LLFontGL::getFontEmoji());
+ }
+
+ S32 new_seg_start = pos + text_kitty;
+ insertSegment(new LLEmojiTextSegment(emoji_style, new_seg_start, new_seg_start + 1, *this));
+ }
+ }
+ }
+
getViewModel()->getEditableDisplay().insert(pos, wstr);
if ( truncate() )
@@ -1079,6 +1107,7 @@ void LLTextBase::insertSegment(LLTextSegmentPtr segment_to_insert)
needsReflow(reflow_start_index);
}
+//virtual
BOOL LLTextBase::handleMouseDown(S32 x, S32 y, MASK mask)
{
// handle triple click
@@ -1133,6 +1162,7 @@ BOOL LLTextBase::handleMouseDown(S32 x, S32 y, MASK mask)
return LLUICtrl::handleMouseDown(x, y, mask);
}
+//virtual
BOOL LLTextBase::handleMouseUp(S32 x, S32 y, MASK mask)
{
LLTextSegmentPtr cur_segment = getSegmentAtLocalPos(x, y);
@@ -1152,6 +1182,7 @@ BOOL LLTextBase::handleMouseUp(S32 x, S32 y, MASK mask)
return LLUICtrl::handleMouseUp(x, y, mask);
}
+//virtual
BOOL LLTextBase::handleMiddleMouseDown(S32 x, S32 y, MASK mask)
{
LLTextSegmentPtr cur_segment = getSegmentAtLocalPos(x, y);
@@ -1163,6 +1194,7 @@ BOOL LLTextBase::handleMiddleMouseDown(S32 x, S32 y, MASK mask)
return LLUICtrl::handleMiddleMouseDown(x, y, mask);
}
+//virtual
BOOL LLTextBase::handleMiddleMouseUp(S32 x, S32 y, MASK mask)
{
LLTextSegmentPtr cur_segment = getSegmentAtLocalPos(x, y);
@@ -1174,6 +1206,7 @@ BOOL LLTextBase::handleMiddleMouseUp(S32 x, S32 y, MASK mask)
return LLUICtrl::handleMiddleMouseUp(x, y, mask);
}
+//virtual
BOOL LLTextBase::handleRightMouseDown(S32 x, S32 y, MASK mask)
{
LLTextSegmentPtr cur_segment = getSegmentAtLocalPos(x, y);
@@ -1185,6 +1218,7 @@ BOOL LLTextBase::handleRightMouseDown(S32 x, S32 y, MASK mask)
return LLUICtrl::handleRightMouseDown(x, y, mask);
}
+//virtual
BOOL LLTextBase::handleRightMouseUp(S32 x, S32 y, MASK mask)
{
LLTextSegmentPtr cur_segment = getSegmentAtLocalPos(x, y);
@@ -1196,6 +1230,7 @@ BOOL LLTextBase::handleRightMouseUp(S32 x, S32 y, MASK mask)
return LLUICtrl::handleRightMouseUp(x, y, mask);
}
+//virtual
BOOL LLTextBase::handleDoubleClick(S32 x, S32 y, MASK mask)
{
//Don't start triple click timer if user have clicked on scrollbar
@@ -1215,6 +1250,7 @@ BOOL LLTextBase::handleDoubleClick(S32 x, S32 y, MASK mask)
return LLUICtrl::handleDoubleClick(x, y, mask);
}
+//virtual
BOOL LLTextBase::handleHover(S32 x, S32 y, MASK mask)
{
LLTextSegmentPtr cur_segment = getSegmentAtLocalPos(x, y);
@@ -1226,6 +1262,7 @@ BOOL LLTextBase::handleHover(S32 x, S32 y, MASK mask)
return LLUICtrl::handleHover(x, y, mask);
}
+//virtual
BOOL LLTextBase::handleScrollWheel(S32 x, S32 y, S32 clicks)
{
LLTextSegmentPtr cur_segment = getSegmentAtLocalPos(x, y);
@@ -1237,6 +1274,7 @@ BOOL LLTextBase::handleScrollWheel(S32 x, S32 y, S32 clicks)
return LLUICtrl::handleScrollWheel(x, y, clicks);
}
+//virtual
BOOL LLTextBase::handleToolTip(S32 x, S32 y, MASK mask)
{
LLTextSegmentPtr cur_segment = getSegmentAtLocalPos(x, y);
@@ -1248,7 +1286,20 @@ BOOL LLTextBase::handleToolTip(S32 x, S32 y, MASK mask)
return LLUICtrl::handleToolTip(x, y, mask);
}
+//virtual
+const std::string LLTextBase::getToolTip() const
+{
+ if (sDebugUnicode)
+ {
+ std::string text = getText();
+ std::string tooltip = utf8str_showBytesUTF8(text);
+ return tooltip;
+ }
+
+ return LLUICtrl::getToolTip();
+}
+//virtual
void LLTextBase::reshape(S32 width, S32 height, BOOL called_from_parent)
{
if (width != getRect().getWidth() || height != getRect().getHeight() || LLView::sForceReshape)
@@ -1275,6 +1326,7 @@ void LLTextBase::reshape(S32 width, S32 height, BOOL called_from_parent)
}
}
+//virtual
void LLTextBase::draw()
{
// reflow if needed, on demand
@@ -1985,21 +2037,8 @@ LLTextBase::segment_set_t::const_iterator LLTextBase::getEditableSegIterContaini
LLTextBase::segment_set_t::iterator LLTextBase::getSegIterContaining(S32 index)
{
-
static LLPointer<LLIndexSegment> index_segment = new LLIndexSegment();
- S32 text_len = 0;
- if (!useLabel())
- {
- text_len = getLength();
- }
- else
- {
- text_len = mLabel.getWString().length();
- }
-
- if (index > text_len) { return mSegments.end(); }
-
// when there are no segments, we return the end iterator, which must be checked by caller
if (mSegments.size() <= 1) { return mSegments.begin(); }
@@ -2013,18 +2052,6 @@ LLTextBase::segment_set_t::const_iterator LLTextBase::getSegIterContaining(S32 i
{
static LLPointer<LLIndexSegment> index_segment = new LLIndexSegment();
- S32 text_len = 0;
- if (!useLabel())
- {
- text_len = getLength();
- }
- else
- {
- text_len = mLabel.getWString().length();
- }
-
- if (index > text_len) { return mSegments.end(); }
-
// when there are no segments, we return the end iterator, which must be checked by caller
if (mSegments.size() <= 1) { return mSegments.begin(); }
@@ -2188,8 +2215,8 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para
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))
+ while (LLUrlRegistry::instance().findUrl(text, match,
+ boost::bind(&LLTextBase::replaceUrl, this, _1, _2, _3), isContentTrusted() || mAlwaysShowIcons))
{
start = match.getStart();
end = match.getEnd()+1;
@@ -2437,18 +2464,18 @@ void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 hig
LLStyle::Params normal_style_params(style_params);
normal_style_params.font.style("NORMAL");
LLStyleConstSP normal_sp(new LLStyle(normal_style_params));
- segments.push_back(new LLOnHoverChangeableTextSegment(sp, normal_sp, segment_start, segment_end, *this ));
+ segments.push_back(new LLOnHoverChangeableTextSegment(sp, normal_sp, segment_start, segment_end, *this));
}
else
{
- segments.push_back(new LLNormalTextSegment(sp, segment_start, segment_end, *this ));
+ segments.push_back(new LLNormalTextSegment(sp, segment_start, segment_end, *this));
}
insertStringNoUndo(getLength(), wide_text, &segments);
}
// Set the cursor and scroll position
- if( selection_start != selection_end )
+ if (selection_start != selection_end)
{
mSelectionStart = selection_start;
mSelectionEnd = selection_end;
@@ -2456,7 +2483,7 @@ void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 hig
mIsSelecting = was_selecting;
setCursorPos(cursor_pos);
}
- else if( cursor_was_at_end )
+ else if (cursor_was_at_end)
{
setCursorPos(getLength());
}
@@ -2468,25 +2495,28 @@ 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)
{
- if (new_text.empty()) return;
+ if (new_text.empty())
+ {
+ return;
+ }
std::string::size_type start = 0;
- std::string::size_type pos = new_text.find("\n",start);
+ std::string::size_type pos = new_text.find("\n", start);
- while(pos!=-1)
+ while (pos != std::string::npos)
{
- if(pos!=start)
+ 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_on_hover_only);
}
appendLineBreakSegment(style_params);
start = pos+1;
- pos = new_text.find("\n",start);
+ pos = new_text.find("\n", start);
}
- std::string str = std::string(new_text,start,new_text.length()-start);
- appendAndHighlightTextImpl(str,highlight_part, style_params, underline_on_hover_only);
+ std::string str = std::string(new_text, start, new_text.length() - start);
+ appendAndHighlightTextImpl(str, highlight_part, style_params, underline_on_hover_only);
}
@@ -3318,12 +3348,13 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele
font->render(text, start,
rect,
color,
- LLFontGL::LEFT, mEditor.mVAlign,
+ LLFontGL::LEFT, mEditor.mTextVAlign,
LLFontGL::NORMAL,
mStyle->getShadowType(),
length,
&right_x,
- mEditor.getUseEllipses());
+ mEditor.getUseEllipses(),
+ mEditor.getUseColor());
}
rect.mLeft = right_x;
@@ -3337,12 +3368,13 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele
font->render(text, start,
rect,
mStyle->getSelectedColor().get(),
- LLFontGL::LEFT, mEditor.mVAlign,
+ LLFontGL::LEFT, mEditor.mTextVAlign,
LLFontGL::NORMAL,
LLFontGL::NO_SHADOW,
length,
&right_x,
- mEditor.getUseEllipses());
+ mEditor.getUseEllipses(),
+ mEditor.getUseColor());
}
rect.mLeft = right_x;
if( selection_end < seg_end )
@@ -3354,12 +3386,13 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele
font->render(text, start,
rect,
color,
- LLFontGL::LEFT, mEditor.mVAlign,
+ LLFontGL::LEFT, mEditor.mTextVAlign,
LLFontGL::NORMAL,
mStyle->getShadowType(),
length,
&right_x,
- mEditor.getUseEllipses());
+ mEditor.getUseEllipses(),
+ mEditor.getUseColor());
}
return right_x;
}
@@ -3591,6 +3624,33 @@ const S32 LLLabelTextSegment::getLength() const
}
//
+// LLEmojiTextSegment
+//
+LLEmojiTextSegment::LLEmojiTextSegment(LLStyleConstSP style, S32 start, S32 end, LLTextBase& editor)
+ : LLNormalTextSegment(style, start, end, editor)
+{
+}
+
+LLEmojiTextSegment::LLEmojiTextSegment(const LLColor4& color, S32 start, S32 end, LLTextBase& editor, BOOL is_visible)
+ : LLNormalTextSegment(color, start, end, editor, is_visible)
+{
+}
+
+BOOL LLEmojiTextSegment::handleToolTip(S32 x, S32 y, MASK mask)
+{
+ if (mTooltip.empty())
+ {
+ LLWString emoji = getWText().substr(getStart(), getEnd() - getStart());
+ if (!emoji.empty())
+ {
+ mTooltip = LLEmojiHelper::instance().getToolTip(emoji[0]);
+ }
+ }
+
+ return LLNormalTextSegment::handleToolTip(x, y, mask);
+}
+
+//
// LLOnHoverChangeableTextSegment
//
diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h
index 3611ab0499..9d3c54fbee 100644
--- a/indra/llui/lltextbase.h
+++ b/indra/llui/lltextbase.h
@@ -178,6 +178,18 @@ protected:
/*virtual*/ const S32 getLength() const;
};
+// Text segment that represents a single emoji character that has a different style (=font size) than the rest of
+// the document it belongs to
+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);
+
+ bool canEdit() const override { return false; }
+ BOOL handleToolTip(S32 x, S32 y, MASK mask) override;
+};
+
// Text segment that changes it's style depending of mouse pointer position ( is it inside or outside segment)
class LLOnHoverChangeableTextSegment : public LLNormalTextSegment
{
@@ -273,7 +285,7 @@ typedef LLPointer<LLTextSegment> LLTextSegmentPtr;
/// as LLTextEditor and LLTextBox. It implements shared functionality
/// such as Url highlighting and opening.
///
-class LLTextBase
+class LLTextBase
: public LLUICtrl,
protected LLEditMenuHandler,
public LLSpellCheckMenuHandler,
@@ -316,6 +328,7 @@ public:
plain_text,
wrap,
use_ellipses,
+ use_color,
parse_urls,
force_urls_external,
parse_highlights,
@@ -335,55 +348,58 @@ public:
Optional<LLFontGL::ShadowType> font_shadow;
+ Optional<LLFontGL::VAlign> text_valign;
+
Params();
};
// LLMouseHandler interface
- /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
- /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
- /*virtual*/ BOOL handleMiddleMouseDown(S32 x, S32 y, MASK mask);
- /*virtual*/ BOOL handleMiddleMouseUp(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*/ BOOL handleHover(S32 x, S32 y, MASK mask);
- /*virtual*/ BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
- /*virtual*/ BOOL handleToolTip(S32 x, S32 y, MASK mask);
+ /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask) override;
+ /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask) override;
+ /*virtual*/ BOOL handleMiddleMouseDown(S32 x, S32 y, MASK mask) override;
+ /*virtual*/ BOOL handleMiddleMouseUp(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*/ BOOL handleHover(S32 x, S32 y, MASK mask) override;
+ /*virtual*/ BOOL handleScrollWheel(S32 x, S32 y, S32 clicks) override;
+ /*virtual*/ BOOL handleToolTip(S32 x, S32 y, MASK mask) override;
// LLView interface
- /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
- /*virtual*/ void draw();
+ /*virtual*/ const std::string getToolTip() const override;
+ /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE) override;
+ /*virtual*/ void draw() override;
// LLUICtrl interface
- /*virtual*/ BOOL acceptsTextInput() const { return !mReadOnly; }
- /*virtual*/ void setColor( const LLColor4& c );
+ /*virtual*/ BOOL acceptsTextInput() const override { return !mReadOnly; }
+ /*virtual*/ void setColor(const LLColor4& c) override;
virtual void setReadOnlyColor(const LLColor4 &c);
- virtual void onVisibilityChange( BOOL new_visibility );
+ /*virtual*/ void onVisibilityChange(BOOL new_visibility) override;
- /*virtual*/ void setValue(const LLSD& value );
- /*virtual*/ LLTextViewModel* getViewModel() const;
+ /*virtual*/ void setValue(const LLSD& value) override;
+ /*virtual*/ LLTextViewModel* getViewModel() const override;
// LLEditMenuHandler interface
- /*virtual*/ BOOL canDeselect() const;
- /*virtual*/ void deselect();
+ /*virtual*/ BOOL canDeselect() const override;
+ /*virtual*/ void deselect() override;
- virtual void onFocusReceived();
- virtual void onFocusLost();
+ virtual void onFocusReceived() override;
+ virtual void onFocusLost() override;
void setParseHTML(bool parse_html) { mParseHTML = parse_html; }
// LLSpellCheckMenuHandler overrides
- /*virtual*/ bool getSpellCheck() const;
+ /*virtual*/ bool getSpellCheck() const override;
- /*virtual*/ const std::string& getSuggestion(U32 index) const;
- /*virtual*/ U32 getSuggestionCount() const;
- /*virtual*/ void replaceWithSuggestion(U32 index);
+ /*virtual*/ const std::string& getSuggestion(U32 index) const override;
+ /*virtual*/ U32 getSuggestionCount() const override;
+ /*virtual*/ void replaceWithSuggestion(U32 index) override;
- /*virtual*/ void addToDictionary();
- /*virtual*/ bool canAddToDictionary() const;
+ /*virtual*/ void addToDictionary() override;
+ /*virtual*/ bool canAddToDictionary() const override;
- /*virtual*/ void addToIgnore();
- /*virtual*/ bool canAddToIgnore() const;
+ /*virtual*/ void addToIgnore() override;
+ /*virtual*/ bool canAddToIgnore() const override;
// Spell checking helper functions
std::string getMisspelledWord(U32 pos) const;
@@ -394,6 +410,7 @@ public:
// used by LLTextSegment layout code
bool getWordWrap() { return mWordWrap; }
bool getUseEllipses() { return mUseEllipses; }
+ bool getUseColor() { return mUseColor; }
bool truncate(); // returns true of truncation occurred
bool isContentTrusted() {return mTrustedContent;}
@@ -416,7 +433,7 @@ public:
void appendText(const std::string &new_text, bool prepend_newline, const LLStyle::Params& input_params = LLStyle::Params());
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;
const std::string& getLabel() { return mLabel.getString(); }
const LLWString& getWlabel() { return mLabel.getWString();}
@@ -633,7 +650,8 @@ protected:
S32 normalizeUri(std::string& uri);
protected:
- virtual std::string _getSearchText() const
+ // virtual
+ std::string _getSearchText() const override
{
return mLabel.getString() + getToolTip();
}
@@ -687,8 +705,9 @@ protected:
// configuration
S32 mHPad; // padding on left of text
S32 mVPad; // padding above text
- LLFontGL::HAlign mHAlign;
- LLFontGL::VAlign mVAlign;
+ LLFontGL::HAlign mHAlign; // horizontal alignment of the document in its entirety
+ LLFontGL::VAlign mVAlign; // vertical alignment of the document in its entirety
+ LLFontGL::VAlign mTextVAlign; // vertical alignment of a text segment within a single line of text
F32 mLineSpacingMult; // multiple of line height used as space for a single line of text (e.g. 1.5 to get 50% padding)
S32 mLineSpacingPixels; // padding between lines
bool mBorderVisible;
@@ -697,6 +716,7 @@ protected:
bool mParseHighlights; // highlight user-defined keywords
bool mWordWrap;
bool mUseEllipses;
+ bool mUseColor;
bool mTrackEnd; // if true, keeps scroll position at end of document during resize
bool mReadOnly;
bool mBGVisible; // render background?
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index c83ed4c3e1..7150052b65 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -43,6 +43,7 @@
#include "llmath.h"
#include "llclipboard.h"
+#include "llemojihelper.h"
#include "llscrollbar.h"
#include "llstl.h"
#include "llstring.h"
@@ -238,6 +239,7 @@ LLTextEditor::Params::Params()
default_color("default_color"),
commit_on_focus_lost("commit_on_focus_lost", false),
show_context_menu("show_context_menu"),
+ show_emoji_helper("show_emoji_helper"),
enable_tooltip_paste("enable_tooltip_paste")
{
addSynonym(prevalidate_callback, "text_type");
@@ -258,6 +260,7 @@ LLTextEditor::LLTextEditor(const LLTextEditor::Params& p) :
mTabsToNextField(p.ignore_tab),
mPrevalidateFunc(p.prevalidate_callback()),
mShowContextMenu(p.show_context_menu),
+ mShowEmojiHelper(p.show_emoji_helper),
mEnableTooltipPaste(p.enable_tooltip_paste),
mPassDelete(FALSE),
mKeepSelectionOnReturn(false)
@@ -505,6 +508,16 @@ void LLTextEditor::getSegmentsInRange(LLTextEditor::segment_vec_t& segments_out,
}
}
+void LLTextEditor::setShowEmojiHelper(bool show)
+{
+ if (!mShowEmojiHelper)
+ {
+ LLEmojiHelper::instance().hideHelper(this);
+ }
+
+ mShowEmojiHelper = show;
+}
+
BOOL LLTextEditor::selectionContainsLineBreaks()
{
if (hasSelection())
@@ -668,6 +681,28 @@ void LLTextEditor::selectByCursorPosition(S32 prev_cursor_pos, S32 next_cursor_p
endSelection();
}
+void LLTextEditor::insertEmoji(llwchar emoji)
+{
+ LL_INFOS() << "LLTextEditor::insertEmoji(" << wchar_utf8_preview(emoji) << ")" << LL_ENDL;
+ auto styleParams = LLStyle::Params();
+ styleParams.font = LLFontGL::getFontEmoji();
+ auto segment = new LLEmojiTextSegment(new LLStyle(styleParams), mCursorPos, mCursorPos + 1, *this);
+ insert(mCursorPos, LLWString(1, emoji), false, segment);
+ setCursorPos(mCursorPos + 1);
+}
+
+void LLTextEditor::handleEmojiCommit(llwchar emoji)
+{
+ S32 shortCodePos;
+ if (LLEmojiHelper::isCursorInEmojiCode(getWText(), mCursorPos, &shortCodePos))
+ {
+ remove(shortCodePos, mCursorPos - shortCodePos, true);
+ setCursorPos(shortCodePos);
+
+ insertEmoji(emoji);
+ }
+}
+
BOOL LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask)
{
BOOL handled = FALSE;
@@ -934,6 +969,12 @@ BOOL LLTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask)
S32 LLTextEditor::execute( TextCmd* cmd )
{
+ if (!mReadOnly && mShowEmojiHelper)
+ {
+ // Any change to our contents should always hide the helper
+ LLEmojiHelper::instance().hideHelper(this);
+ }
+
S32 delta = 0;
if( cmd->execute(this, &delta) )
{
@@ -983,7 +1024,7 @@ S32 LLTextEditor::remove(S32 pos, S32 length, bool group_with_next_op)
// store text segments
getSegmentsInRange(segments_to_remove, pos, pos + length, false);
- if(pos <= end_pos)
+ if (pos <= end_pos)
{
removedChar = execute( new TextCmdRemove( pos, group_with_next_op, end_pos - pos, segments_to_remove ) );
}
@@ -1007,11 +1048,12 @@ S32 LLTextEditor::overwriteChar(S32 pos, llwchar wc)
// a pseudo-tab (up to for spaces in a row)
void LLTextEditor::removeCharOrTab()
{
- if( !getEnabled() )
+ if (!getEnabled())
{
return;
}
- if( mCursorPos > 0 )
+
+ if (mCursorPos > 0)
{
S32 chars_to_remove = 1;
@@ -1023,14 +1065,14 @@ void LLTextEditor::removeCharOrTab()
if (offset > 0)
{
chars_to_remove = offset % SPACES_PER_TAB;
- if( chars_to_remove == 0 )
+ if (chars_to_remove == 0)
{
chars_to_remove = SPACES_PER_TAB;
}
- for( S32 i = 0; i < chars_to_remove; i++ )
+ for (S32 i = 0; i < chars_to_remove; i++)
{
- if (text[ mCursorPos - i - 1] != ' ')
+ if (text[mCursorPos - i - 1] != ' ')
{
// Fewer than a full tab's worth of spaces, so
// just delete a single character.
@@ -1044,8 +1086,10 @@ void LLTextEditor::removeCharOrTab()
for (S32 i = 0; i < chars_to_remove; i++)
{
setCursorPos(mCursorPos - 1);
- remove( mCursorPos, 1, FALSE );
+ remove(mCursorPos, 1, false);
}
+
+ tryToShowEmojiHelper();
}
else
{
@@ -1056,7 +1100,7 @@ void LLTextEditor::removeCharOrTab()
// Remove a single character from the text
S32 LLTextEditor::removeChar(S32 pos)
{
- return remove( pos, 1, FALSE );
+ return remove(pos, 1, false);
}
void LLTextEditor::removeChar()
@@ -1065,10 +1109,12 @@ void LLTextEditor::removeChar()
{
return;
}
+
if (mCursorPos > 0)
{
setCursorPos(mCursorPos - 1);
removeChar(mCursorPos);
+ tryToShowEmojiHelper();
}
else
{
@@ -1127,6 +1173,7 @@ void LLTextEditor::addChar(llwchar wc)
}
setCursorPos(mCursorPos + addChar( mCursorPos, wc ));
+ tryToShowEmojiHelper();
if (!mReadOnly && mAutoreplaceCallback != NULL)
{
@@ -1146,6 +1193,37 @@ void LLTextEditor::addChar(llwchar wc)
}
}
+void LLTextEditor::showEmojiHelper()
+{
+ if (mReadOnly || !mShowEmojiHelper)
+ return;
+
+ const LLRect cursorRect(getLocalRectFromDocIndex(mCursorPos));
+ auto cb = [this](llwchar emoji) { insertEmoji(emoji); };
+ LLEmojiHelper::instance().showHelper(this, cursorRect.mLeft, cursorRect.mTop, LLStringUtil::null, cb);
+}
+
+void LLTextEditor::tryToShowEmojiHelper()
+{
+ if (mReadOnly || !mShowEmojiHelper)
+ return;
+
+ S32 shortCodePos;
+ LLWString wtext(getWText());
+ if (LLEmojiHelper::isCursorInEmojiCode(wtext, mCursorPos, &shortCodePos))
+ {
+ const LLRect cursorRect(getLocalRectFromDocIndex(shortCodePos));
+ const LLWString wpart(wtext.substr(shortCodePos, mCursorPos - shortCodePos));
+ const std::string part(wstring_to_utf8str(wpart));
+ auto cb = [this](llwchar emoji) { handleEmojiCommit(emoji); };
+ LLEmojiHelper::instance().showHelper(this, cursorRect.mLeft, cursorRect.mTop, part, cb);
+ }
+ else
+ {
+ LLEmojiHelper::instance().hideHelper();
+ }
+}
+
void LLTextEditor::addLineBreakChar(BOOL group_together)
{
if( !getEnabled() )
@@ -1778,6 +1856,11 @@ BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask )
}
else
{
+ if (!mReadOnly && mShowEmojiHelper && LLEmojiHelper::instance().handleKey(this, key, mask))
+ {
+ return TRUE;
+ }
+
if (mEnableTooltipPaste &&
LLToolTipMgr::instance().toolTipVisible() &&
LLToolTipMgr::instance().isTooltipPastable() &&
@@ -1820,6 +1903,12 @@ BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask )
{
resetCursorBlink();
needsScroll();
+
+ if (mShowEmojiHelper)
+ {
+ // Dismiss the helper whenever we handled a key that it didn't
+ LLEmojiHelper::instance().hideHelper(this);
+ }
}
return handled;
@@ -1838,7 +1927,12 @@ BOOL LLTextEditor::handleUnicodeCharHere(llwchar uni_char)
// Handle most keys only if the text editor is writeable.
if( !mReadOnly )
{
- if( mAutoIndent && '}' == uni_char )
+ if (mShowEmojiHelper && uni_char < 0x80 && LLEmojiHelper::instance().handleKey(this, (KEY)uni_char, MASK_NONE))
+ {
+ return TRUE;
+ }
+
+ if( mAutoIndent && '}' == uni_char )
{
unindentLineBeforeCloseBrace();
}
@@ -2601,6 +2695,7 @@ BOOL LLTextEditor::importBuffer(const char* buffer, S32 length )
char* text = new char[ text_len + 1];
if (text == NULL)
{
+ LLError::LLUserWarningMsg::showOutOfMemory();
LL_ERRS() << "Memory allocation failure." << LL_ENDL;
return FALSE;
}
diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h
index f3939248c2..521405ec25 100644
--- a/indra/llui/lltexteditor.h
+++ b/indra/llui/lltexteditor.h
@@ -60,6 +60,7 @@ public:
ignore_tab,
commit_on_focus_lost,
show_context_menu,
+ show_emoji_helper,
enable_tooltip_paste,
auto_indent;
@@ -91,6 +92,9 @@ public:
static S32 spacesPerTab();
+ void insertEmoji(llwchar emoji);
+ void handleEmojiCommit(llwchar emoji);
+
// mousehandler overrides
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
@@ -202,6 +206,10 @@ public:
void setShowContextMenu(bool show) { mShowContextMenu = show; }
bool getShowContextMenu() const { return mShowContextMenu; }
+ void showEmojiHelper();
+ void setShowEmojiHelper(bool show);
+ bool getShowEmojiHelper() const { return mShowEmojiHelper; }
+
void setPassDelete(BOOL b) { mPassDelete = b; }
protected:
@@ -248,6 +256,7 @@ protected:
S32 insert(S32 pos, const LLWString &wstr, bool group_with_next_op, LLTextSegmentPtr segment);
S32 remove(S32 pos, S32 length, bool group_with_next_op);
+ void tryToShowEmojiHelper();
void focusLostHelper();
void updateAllowingLanguageInput();
BOOL hasPreeditString() const;
@@ -318,6 +327,7 @@ private:
BOOL mAllowEmbeddedItems;
bool mShowContextMenu;
+ bool mShowEmojiHelper;
bool mEnableTooltipPaste;
bool mPassDelete;
bool mKeepSelectionOnReturn; // disabling of removing selected text after pressing of Enter
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index 2707f7a15c..204b8b9984 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -27,7 +27,6 @@
#include "linden_common.h"
-#include <boost/foreach.hpp>
#include "lltoolbar.h"
#include "llcommandmanager.h"
@@ -219,7 +218,7 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p)
mCenteringStack->addChild(LLUICtrlFactory::create<LLLayoutPanel>(border_panel_p));
- BOOST_FOREACH(LLCommandId id, p.commands)
+ for (const auto& id : p.commands)
{
addCommand(id);
}
@@ -417,7 +416,7 @@ BOOL LLToolBar::handleRightMouseDown(S32 x, S32 y, MASK mask)
// Determine which button the mouse was over during the click in case the context menu action
// is intended to affect the button.
mRightMouseTargetButton = NULL;
- BOOST_FOREACH(LLToolBarButton* button, mButtons)
+ for (LLToolBarButton* button : mButtons)
{
LLRect button_rect;
button->localRectToOtherView(button->getLocalRect(), &button_rect, this);
@@ -505,7 +504,7 @@ void LLToolBar::setButtonType(LLToolBarEnums::ButtonType button_type)
void LLToolBar::resizeButtonsInRow(std::vector<LLToolBarButton*>& buttons_in_row, S32 max_row_girth)
{
// make buttons in current row all same girth
- BOOST_FOREACH(LLToolBarButton* button, buttons_in_row)
+ for (LLToolBarButton* button : buttons_in_row)
{
if (getOrientation(mSideType) == LLLayoutStack::HORIZONTAL)
{
@@ -693,7 +692,7 @@ void LLToolBar::updateLayoutAsNeeded()
std::vector<LLToolBarButton*> buttons_in_row;
- BOOST_FOREACH(LLToolBarButton* button, mButtons)
+ for (LLToolBarButton* button : mButtons)
{
button->reshape(button->mWidthRange.getMin(), button->mDesiredHeight);
button->autoResize();
@@ -878,7 +877,7 @@ void LLToolBar::createButtons()
{
std::set<LLUUID> set_flashing;
- BOOST_FOREACH(LLToolBarButton* button, mButtons)
+ for (LLToolBarButton* button : mButtons)
{
if (button->getFlashTimer() && button->getFlashTimer()->isFlashingInProgress())
{
@@ -896,7 +895,7 @@ void LLToolBar::createButtons()
mButtonMap.clear();
mRightMouseTargetButton = NULL;
- BOOST_FOREACH(LLCommandId& command_id, mButtonCommands)
+ for (const LLCommandId& command_id : mButtonCommands)
{
LLToolBarButton* button = createButton(command_id);
mButtons.push_back(button);
diff --git a/indra/llui/lltooltip.cpp b/indra/llui/lltooltip.cpp
index c4b132317f..bea46f4a6f 100644
--- a/indra/llui/lltooltip.cpp
+++ b/indra/llui/lltooltip.cpp
@@ -164,6 +164,7 @@ LLToolTip::LLToolTip(const LLToolTip::Params& p)
: LLPanel(p),
mHasClickCallback(p.click_callback.isProvided()),
mPadding(p.padding),
+ mMaxWidth(p.max_width),
mTextBox(NULL),
mInfoButton(NULL),
mPlayMediaButton(NULL),
@@ -274,7 +275,7 @@ void LLToolTip::initFromParams(const LLToolTip::Params& p)
// do this *after* we've had our size set in LLPanel::initFromParams();
const S32 REALLY_LARGE_HEIGHT = 10000;
- mTextBox->reshape(p.max_width, REALLY_LARGE_HEIGHT);
+ mTextBox->reshape(mMaxWidth, REALLY_LARGE_HEIGHT);
if (p.styled_message.isProvided())
{
@@ -290,16 +291,21 @@ void LLToolTip::initFromParams(const LLToolTip::Params& p)
mTextBox->setText(p.message());
}
- S32 text_width = llmin(p.max_width(), mTextBox->getTextPixelWidth() + 1);
+ mIsTooltipPastable = p.allow_paste_tooltip;
+
+ updateTextBox();
+ snapToChildren();
+}
+
+void LLToolTip::updateTextBox()
+{
+ S32 text_width = llmin(mMaxWidth, mTextBox->getTextPixelWidth() + 1);
S32 text_height = mTextBox->getTextPixelHeight();
mTextBox->reshape(text_width, text_height);
- if (mInfoButton)
- {
- LLRect text_rect = mTextBox->getRect();
- LLRect icon_rect = mInfoButton->getRect();
- mTextBox->translate(0, icon_rect.getCenterY() - text_rect.getCenterY());
- }
-
+}
+
+void LLToolTip::snapToChildren()
+{
// reshape tooltip panel to fit text box
LLRect tooltip_rect = calcBoundingRect();
tooltip_rect.mTop += mPadding;
@@ -307,11 +313,16 @@ void LLToolTip::initFromParams(const LLToolTip::Params& p)
tooltip_rect.mBottom = 0;
tooltip_rect.mLeft = 0;
- mTextBox->reshape(mTextBox->getRect().getWidth(), llmax(mTextBox->getRect().getHeight(), tooltip_rect.getHeight() - 2 * mPadding));
+ if (mInfoButton)
+ {
+ mTextBox->reshape(mTextBox->getRect().getWidth(), llmax(mTextBox->getRect().getHeight(), tooltip_rect.getHeight() - 2 * mPadding));
- setShape(tooltip_rect);
+ LLRect text_rect = mTextBox->getRect();
+ LLRect icon_rect = mInfoButton->getRect();
+ mInfoButton->translate(0, text_rect.getCenterY() - icon_rect.getCenterY());
+ }
- mIsTooltipPastable = p.allow_paste_tooltip;
+ setShape(tooltip_rect);
}
void LLToolTip::setVisible(BOOL visible)
@@ -432,7 +443,16 @@ void LLToolTipMgr::createToolTip(const LLToolTip::Params& params)
}
tooltip_params.rect = LLRect (0, 1, 1, 0);
- mToolTip = LLUICtrlFactory::create<LLToolTip> (tooltip_params);
+ if (tooltip_params.create_callback.isProvided())
+ {
+ mToolTip = tooltip_params.create_callback()(tooltip_params);
+ if (mToolTip == NULL)
+ {
+ return;
+ }
+ }
+ else
+ mToolTip = LLUICtrlFactory::create<LLToolTip> (tooltip_params);
gToolTipView->addChild(mToolTip);
@@ -482,7 +502,7 @@ void LLToolTipMgr::show(const LLToolTip::Params& params)
{
if (!params.styled_message.isProvided()
&& (!params.message.isProvided() || params.message().empty())
- && !params.image.isProvided()) return;
+ && !params.image.isProvided() && !params.create_callback.isProvided()) return;
// fill in default tooltip params from tool_tip.xml
LLToolTip::Params params_with_defaults(params);
diff --git a/indra/llui/lltooltip.h b/indra/llui/lltooltip.h
index 6ff7c0671a..fef5e7c75f 100644
--- a/indra/llui/lltooltip.h
+++ b/indra/llui/lltooltip.h
@@ -68,6 +68,7 @@ public:
struct Params : public LLInitParam::Block<Params, LLPanel::Params>
{
typedef boost::function<void(void)> click_callback_t;
+ typedef boost::function<LLToolTip*(LLToolTip::Params)> create_callback_t;
Optional<std::string> message;
Multiple<StyledText> styled_message;
@@ -84,6 +85,8 @@ public:
Optional<bool> time_based_media,
web_based_media,
media_playing;
+ Optional<create_callback_t> create_callback;
+ Optional<LLSD> create_params;
Optional<click_callback_t> click_callback,
click_playmedia_callback,
click_homepage_callback;
@@ -105,12 +108,16 @@ public:
bool hasClickCallback();
LLToolTip(const Params& p);
- void initFromParams(const LLToolTip::Params& params);
+ virtual void initFromParams(const LLToolTip::Params& params);
void getToolTipMessage(std::string & message);
bool isTooltipPastable() { return mIsTooltipPastable; }
-private:
+protected:
+ void updateTextBox();
+ void snapToChildren();
+
+protected:
class LLTextBox* mTextBox;
class LLButton* mInfoButton;
class LLButton* mPlayMediaButton;
@@ -120,6 +127,7 @@ private:
LLFrameTimer mVisibleTimer;
bool mHasClickCallback;
S32 mPadding; // pixels
+ S32 mMaxWidth;
bool mIsTooltipPastable;
};
diff --git a/indra/llui/lltransutil.cpp b/indra/llui/lltransutil.cpp
index 5da722a72b..6c486f29ba 100644
--- a/indra/llui/lltransutil.cpp
+++ b/indra/llui/lltransutil.cpp
@@ -44,8 +44,13 @@ bool LLTransUtil::parseStrings(const std::string& xml_filename, const std::set<s
bool success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root, LLDir::ALL_SKINS);
if (!success)
{
+ const std::string error_string =
+ "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);
gDirUtilp->dumpCurrentDirectories(LLError::LEVEL_WARN);
- LL_ERRS() << "Couldn't load string table " << xml_filename << ". Please reinstall viewer from https://secondlife.com/support/downloads/ and contact https://support.secondlife.com if issue persists after reinstall." << LL_ENDL;
+ LL_ERRS() << "Couldn't load string table " << xml_filename << " " << errno << LL_ENDL;
return false;
}
@@ -60,6 +65,7 @@ bool LLTransUtil::parseLanguageStrings(const std::string& xml_filename)
if (!success)
{
+ LLError::LLUserWarningMsg::showMissingFiles();
LL_ERRS() << "Couldn't load localization table " << xml_filename << LL_ENDL;
return false;
}
diff --git a/indra/llui/llui.h b/indra/llui/llui.h
index 30dbd7248f..86b23c8c93 100644
--- a/indra/llui/llui.h
+++ b/indra/llui/llui.h
@@ -76,7 +76,8 @@ enum EDragAndDropType
DAD_WIDGET = 16,
DAD_PERSON = 17,
DAD_SETTINGS = 18,
- DAD_COUNT = 19, // number of types in this enum
+ DAD_MATERIAL = 19,
+ DAD_COUNT = 20, // number of types in this enum
};
// Reasons for drags to be denied.
diff --git a/indra/llui/lluicolortable.cpp b/indra/llui/lluicolortable.cpp
index 096336045c..f43bdf1fdc 100644
--- a/indra/llui/lluicolortable.cpp
+++ b/indra/llui/lluicolortable.cpp
@@ -32,7 +32,6 @@
#include "llui.h"
#include "lluicolortable.h"
#include "lluictrlfactory.h"
-#include <boost/foreach.hpp>
LLUIColorTable::ColorParams::ColorParams()
: value("value"),
@@ -208,7 +207,7 @@ bool LLUIColorTable::loadFromSettings()
// pass constraint=LLDir::ALL_SKINS because we want colors.xml from every
// skin dir
- BOOST_FOREACH(std::string colors_path,
+ for (const std::string& colors_path :
gDirUtilp->findSkinnedFilenames(LLDir::SKINBASE, "colors.xml", LLDir::ALL_SKINS))
{
result |= loadFromFilename(colors_path, mLoadedColors);
diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp
index 2196ba201b..7eb9ae69fb 100644
--- a/indra/llui/lluictrl.cpp
+++ b/indra/llui/lluictrl.cpp
@@ -531,6 +531,15 @@ void LLUICtrl::setControlVariable(LLControlVariable* control)
}
}
+void LLUICtrl::removeControlVariable()
+{
+ if (mControlVariable)
+ {
+ mControlConnection.disconnect();
+ mControlVariable = NULL;
+ }
+}
+
//virtual
void LLUICtrl::setControlName(const std::string& control_name, LLView *context)
{
@@ -759,25 +768,20 @@ void LLUICtrl::setIsChrome(BOOL is_chrome)
// virtual
BOOL LLUICtrl::getIsChrome() const
-{
+{
+ if (mIsChrome)
+ return TRUE;
+
LLView* parent_ctrl = getParent();
- while(parent_ctrl)
+ while (parent_ctrl)
{
- if(parent_ctrl->isCtrl())
- {
- break;
- }
+ if (parent_ctrl->isCtrl())
+ return ((LLUICtrl*)parent_ctrl)->getIsChrome();
+
parent_ctrl = parent_ctrl->getParent();
}
-
- if(parent_ctrl)
- {
- return mIsChrome || ((LLUICtrl*)parent_ctrl)->getIsChrome();
- }
- else
- {
- return mIsChrome ;
- }
+
+ return FALSE;
}
diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h
index 67dd24341c..cffb9933d4 100644
--- a/indra/llui/lluictrl.h
+++ b/indra/llui/lluictrl.h
@@ -175,6 +175,7 @@ public:
bool setControlValue(const LLSD& value);
void setControlVariable(LLControlVariable* control);
virtual void setControlName(const std::string& control, LLView *context = NULL);
+ void removeControlVariable();
LLControlVariable* getControlVariable() { return mControlVariable; }
@@ -263,7 +264,7 @@ public:
class LLTextInputFilter : public LLQueryFilter, public LLSingleton<LLTextInputFilter>
{
LLSINGLETON_EMPTY_CTOR(LLTextInputFilter);
- /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const
+ /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const override
{
return filterResult_t(view->isCtrl() && static_cast<const LLUICtrl *>(view)->acceptsTextInput(), TRUE);
}
diff --git a/indra/llui/lluistring.h b/indra/llui/lluistring.h
index 07e02de6d8..b1089a3903 100644
--- a/indra/llui/lluistring.h
+++ b/indra/llui/lluistring.h
@@ -61,6 +61,7 @@ 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() { delete mArgs; }
void assign(const std::string& instring);
diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp
index 6a9070634c..05d821f5d8 100644
--- a/indra/llui/llurlentry.cpp
+++ b/indra/llui/llurlentry.cpp
@@ -35,7 +35,9 @@
#include "llavatarnamecache.h"
#include "llcachename.h"
+#include "llkeyboard.h"
#include "llregex.h"
+#include "llscrolllistctrl.h" // for LLUrlEntryKeybinding file parsing
#include "lltrans.h"
#include "lluicolortable.h"
#include "message.h"
@@ -232,14 +234,20 @@ bool LLUrlEntryBase::isWikiLinkCorrect(const std::string &labeled_url) const
std::string LLUrlEntryBase::urlToLabelWithGreyQuery(const std::string &url) const
{
+ if (url.empty())
+ {
+ return url;
+ }
LLUriParser up(escapeUrl(url));
- up.normalize();
-
- std::string label;
- up.extractParts();
- up.glueFirst(label);
+ if (up.normalize() == 0)
+ {
+ std::string label;
+ up.extractParts();
+ up.glueFirst(label);
- return unescapeUrl(label);
+ return unescapeUrl(label);
+ }
+ return std::string();
}
std::string LLUrlEntryBase::urlToGreyQuery(const std::string &url) const
@@ -1609,3 +1617,122 @@ std::string LLUrlEntryIPv6::getUrl(const std::string &string) const
{
return string;
}
+
+
+//
+// LLUrlEntryKeybinding Displays currently assigned key
+//
+LLUrlEntryKeybinding::LLUrlEntryKeybinding()
+ : LLUrlEntryBase()
+ , pHandler(NULL)
+{
+ mPattern = boost::regex(APP_HEADER_REGEX "/keybinding/\\w+(\\?mode=\\w+)?$",
+ boost::regex::perl | boost::regex::icase);
+ mMenuName = "menu_url_experience.xml";
+
+ initLocalization();
+}
+
+std::string LLUrlEntryKeybinding::getLabel(const std::string& url, const LLUrlLabelCallback& cb)
+{
+ std::string control = getControlName(url);
+
+ std::map<std::string, LLLocalizationData>::iterator iter = mLocalizations.find(control);
+
+ std::string keybind;
+ if (pHandler)
+ {
+ keybind = pHandler->getKeyBindingAsString(getMode(url), control);
+ }
+
+ if (iter != mLocalizations.end())
+ {
+ return iter->second.mLocalization + ": " + keybind;
+ }
+
+ return control + ": " + keybind;
+}
+
+std::string LLUrlEntryKeybinding::getTooltip(const std::string& url) const
+{
+ std::string control = getControlName(url);
+
+ std::map<std::string, LLLocalizationData>::const_iterator iter = mLocalizations.find(control);
+ if (iter != mLocalizations.end())
+ {
+ return iter->second.mTooltip;
+ }
+ return url;
+}
+
+std::string LLUrlEntryKeybinding::getControlName(const std::string& url) const
+{
+ std::string search = "/keybinding/";
+ size_t pos_start = url.find(search);
+ if (pos_start == std::string::npos)
+ {
+ return std::string();
+ }
+ pos_start += search.size();
+
+ size_t pos_end = url.find("?mode=");
+ if (pos_end == std::string::npos)
+ {
+ pos_end = url.size();
+ }
+ return url.substr(pos_start, pos_end - pos_start);
+}
+
+std::string LLUrlEntryKeybinding::getMode(const std::string& url) const
+{
+ std::string search = "?mode=";
+ size_t pos_start = url.find(search);
+ if (pos_start == std::string::npos)
+ {
+ return std::string();
+ }
+ pos_start += search.size();
+ return url.substr(pos_start, url.size() - pos_start);
+}
+
+void LLUrlEntryKeybinding::initLocalization()
+{
+ initLocalizationFromFile("control_table_contents_movement.xml");
+ initLocalizationFromFile("control_table_contents_camera.xml");
+ initLocalizationFromFile("control_table_contents_editing.xml");
+ initLocalizationFromFile("control_table_contents_media.xml");
+}
+
+void LLUrlEntryKeybinding::initLocalizationFromFile(const std::string& filename)
+{
+ LLXMLNodePtr xmlNode;
+ LLScrollListCtrl::Contents contents;
+ if (!LLUICtrlFactory::getLayeredXMLNode(filename, xmlNode))
+ {
+ LL_WARNS() << "Failed to load " << filename << LL_ENDL;
+ return;
+ }
+ LLXUIParser parser;
+ parser.readXUI(xmlNode, contents, filename);
+
+ if (!contents.validateBlock())
+ {
+ LL_WARNS() << "Failed to validate " << filename << LL_ENDL;
+ return;
+ }
+
+ for (LLInitParam::ParamIterator<LLScrollListItem::Params>::const_iterator row_it = contents.rows.begin();
+ row_it != contents.rows.end();
+ ++row_it)
+ {
+ std::string control = row_it->value.getValue().asString();
+ if (!control.empty() && control != "menu_separator")
+ {
+ mLocalizations[control] =
+ LLLocalizationData(
+ row_it->columns.begin()->value.getValue().asString(),
+ row_it->columns.begin()->tool_tip.getValue()
+ );
+ }
+ }
+}
diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h
index 63a1506731..5d0f5479f6 100644
--- a/indra/llui/llurlentry.h
+++ b/indra/llui/llurlentry.h
@@ -550,4 +550,37 @@ public:
std::string mHostPath;
};
+class LLKeyBindingToStringHandler;
+
+///
+/// LLUrlEntryKeybinding A way to access keybindings and show currently used one in text.
+/// secondlife:///app/keybinding/control_name
+class LLUrlEntryKeybinding: public LLUrlEntryBase
+{
+public:
+ LLUrlEntryKeybinding();
+ /*virtual*/ std::string getLabel(const std::string& url, const LLUrlLabelCallback& cb);
+ /*virtual*/ std::string getTooltip(const std::string& url) const;
+ void setHandler(LLKeyBindingToStringHandler* handler) {pHandler = handler;}
+private:
+ std::string getControlName(const std::string& url) const;
+ std::string getMode(const std::string& url) const;
+ void initLocalization();
+ void initLocalizationFromFile(const std::string& filename);
+
+ struct LLLocalizationData
+ {
+ LLLocalizationData() {}
+ LLLocalizationData(const std::string& localization, const std::string& tooltip)
+ : mLocalization(localization)
+ , mTooltip(tooltip)
+ {}
+ std::string mLocalization;
+ std::string mTooltip;
+ };
+
+ std::map<std::string, LLLocalizationData> mLocalizations;
+ LLKeyBindingToStringHandler* pHandler;
+};
+
#endif
diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp
index 23f3dca3fb..f1df7699e2 100644
--- a/indra/llui/llurlregistry.cpp
+++ b/indra/llui/llurlregistry.cpp
@@ -73,6 +73,8 @@ LLUrlRegistry::LLUrlRegistry()
registerUrl(new LLUrlEntryPlace());
registerUrl(new LLUrlEntryInventory());
registerUrl(new LLUrlEntryExperienceProfile());
+ mUrlEntryKeybinding = new LLUrlEntryKeybinding();
+ registerUrl(mUrlEntryKeybinding);
//LLUrlEntrySL and LLUrlEntrySLLabel have more common pattern,
//so it should be registered in the end of list
registerUrl(new LLUrlEntrySL());
@@ -219,8 +221,10 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL
if (match_entry == mUrlEntryTrusted)
{
LLUriParser up(url);
- up.normalize();
- url = up.normalizedUri();
+ if (up.normalize() == 0)
+ {
+ url = up.normalizedUri();
+ }
}
match.setValues(match_start, match_end,
@@ -307,3 +311,9 @@ bool LLUrlRegistry::isUrl(const LLWString &text)
}
return false;
}
+
+void LLUrlRegistry::setKeybindingHandler(LLKeyBindingToStringHandler* handler)
+{
+ LLUrlEntryKeybinding *entry = (LLUrlEntryKeybinding*)mUrlEntryKeybinding;
+ entry->setHandler(handler);
+}
diff --git a/indra/llui/llurlregistry.h b/indra/llui/llurlregistry.h
index efafe543ab..186447c0be 100644
--- a/indra/llui/llurlregistry.h
+++ b/indra/llui/llurlregistry.h
@@ -36,6 +36,8 @@
#include <string>
#include <vector>
+class LLKeyBindingToStringHandler;
+
/// This default callback for findUrl() simply ignores any label updates
void LLUrlRegistryNullCallback(const std::string &url,
const std::string &label,
@@ -88,6 +90,9 @@ public:
bool isUrl(const std::string &text);
bool isUrl(const LLWString &text);
+ // Set handler for url registry to be capable of parsing and populating keybindings
+ void setKeybindingHandler(LLKeyBindingToStringHandler* handler);
+
private:
std::vector<LLUrlEntryBase *> mUrlEntry;
LLUrlEntryBase* mUrlEntryTrusted;
@@ -96,6 +101,7 @@ private:
LLUrlEntryBase* mUrlEntryHTTPLabel;
LLUrlEntryBase* mUrlEntrySLLabel;
LLUrlEntryBase* mUrlEntryNoLink;
+ LLUrlEntryBase* mUrlEntryKeybinding;
};
#endif
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index 3344300635..5768ceacd3 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -32,7 +32,6 @@
#include <sstream>
#include <boost/tokenizer.hpp>
-#include <boost/foreach.hpp>
#include <boost/bind.hpp>
#include "llrender.h"
@@ -60,6 +59,8 @@ static const S32 LINE_HEIGHT = 15;
S32 LLView::sDepth = 0;
bool LLView::sDebugRects = false;
+bool LLView::sDebugUnicode = false;
+bool LLView::sDebugCamera = false;
bool LLView::sIsRectDirty = false;
LLRect LLView::sDirtyRect;
bool LLView::sDebugRectsShowNames = true;
@@ -311,7 +312,13 @@ bool LLView::addChild(LLView* child, S32 tab_group)
}
child->mParentView = this;
- updateBoundingRect();
+ if (getVisible() && child->getVisible())
+ {
+ // if child isn't visible it won't affect bounding rect
+ // if current view is not visible it will be recalculated
+ // on visibility change
+ updateBoundingRect();
+ }
mLastTabGroup = tab_group;
return true;
}
@@ -514,7 +521,7 @@ BOOL LLView::focusNext(LLView::child_list_t & result)
{
next = result.rbegin();
}
- if((*next)->isCtrl())
+ if ((*next)->isCtrl() && ((LLUICtrl*)*next)->hasTabStop())
{
LLUICtrl * ctrl = static_cast<LLUICtrl*>(*next);
ctrl->setFocus(TRUE);
@@ -581,11 +588,12 @@ void LLView::deleteAllChildren()
delete viewp;
mChildList.pop_front();
}
+ updateBoundingRect();
}
void LLView::setAllChildrenEnabled(BOOL b)
{
- BOOST_FOREACH(LLView* viewp, mChildList)
+ for (LLView* viewp : mChildList)
{
viewp->setEnabled(b);
}
@@ -614,7 +622,7 @@ void LLView::onVisibilityChange ( BOOL new_visibility )
{
BOOL old_visibility;
BOOL log_visibility_change = LLViewerEventRecorder::instance().getLoggingStatus();
- BOOST_FOREACH(LLView* viewp, mChildList)
+ for (LLView* viewp : mChildList)
{
if (!viewp)
{
@@ -718,7 +726,7 @@ LLView* LLView::childrenHandleCharEvent(const std::string& desc, const METHOD& m
{
if ( getVisible() && getEnabled() )
{
- BOOST_FOREACH(LLView* viewp, mChildList)
+ for (LLView* viewp : mChildList)
{
if ((viewp->*method)(c, mask, TRUE))
{
@@ -737,7 +745,7 @@ LLView* LLView::childrenHandleCharEvent(const std::string& desc, const METHOD& m
template <typename METHOD, typename XDATA>
LLView* LLView::childrenHandleMouseEvent(const METHOD& method, S32 x, S32 y, XDATA extra, bool allow_mouse_block)
{
- BOOST_FOREACH(LLView* viewp, mChildList)
+ for (LLView* viewp : mChildList)
{
S32 local_x = x - viewp->getRect().mLeft;
S32 local_y = y - viewp->getRect().mBottom;
@@ -766,7 +774,7 @@ LLView* LLView::childrenHandleMouseEvent(const METHOD& method, S32 x, S32 y, XDA
LLView* LLView::childrenHandleToolTip(S32 x, S32 y, MASK mask)
{
- BOOST_FOREACH(LLView* viewp, mChildList)
+ for (LLView* viewp : mChildList)
{
S32 local_x = x - viewp->getRect().mLeft;
S32 local_y = y - viewp->getRect().mBottom;
@@ -798,7 +806,7 @@ LLView* LLView::childrenHandleDragAndDrop(S32 x, S32 y, MASK mask,
// default to not accepting drag and drop, will be overridden by handler
*accept = ACCEPT_NO;
- BOOST_FOREACH(LLView* viewp, mChildList)
+ for (LLView* viewp : mChildList)
{
S32 local_x = x - viewp->getRect().mLeft;
S32 local_y = y - viewp->getRect().mBottom;
@@ -824,7 +832,7 @@ LLView* LLView::childrenHandleDragAndDrop(S32 x, S32 y, MASK mask,
LLView* LLView::childrenHandleHover(S32 x, S32 y, MASK mask)
{
- BOOST_FOREACH(LLView* viewp, mChildList)
+ for (LLView* viewp : mChildList)
{
S32 local_x = x - viewp->getRect().mLeft;
S32 local_y = y - viewp->getRect().mBottom;
@@ -852,7 +860,7 @@ LLView* LLView::childFromPoint(S32 x, S32 y, bool recur)
if (!getVisible())
return NULL;
- BOOST_FOREACH(LLView* viewp, mChildList)
+ for (LLView* viewp : mChildList)
{
S32 local_x = x - viewp->getRect().mLeft;
S32 local_y = y - viewp->getRect().mBottom;
@@ -879,6 +887,17 @@ LLView* LLView::childFromPoint(S32 x, S32 y, bool recur)
return 0;
}
+F32 LLView::getTooltipTimeout()
+{
+ static LLCachedControl<F32> tooltip_fast_delay(*LLUI::getInstance()->mSettingGroups["config"], "ToolTipFastDelay", 0.1f);
+ static LLCachedControl<F32> tooltip_delay(*LLUI::getInstance()->mSettingGroups["config"], "ToolTipDelay", 0.7f);
+ // allow "scrubbing" over ui by showing next tooltip immediately
+ // if previous one was still visible
+ return (F32)(LLToolTipMgr::instance().toolTipVisible()
+ ? tooltip_fast_delay
+ : tooltip_delay);
+}
+
BOOL LLView::handleToolTip(S32 x, S32 y, MASK mask)
{
BOOL handled = FALSE;
@@ -888,14 +907,7 @@ BOOL LLView::handleToolTip(S32 x, S32 y, MASK mask)
std::string tooltip = getToolTip();
if (!tooltip.empty())
{
- static LLCachedControl<F32> tooltip_fast_delay(*LLUI::getInstance()->mSettingGroups["config"], "ToolTipFastDelay", 0.1f);
- static LLCachedControl<F32> tooltip_delay(*LLUI::getInstance()->mSettingGroups["config"], "ToolTipDelay", 0.7f);
static LLCachedControl<bool> allow_ui_tooltips(*LLUI::getInstance()->mSettingGroups["config"], "BasicUITooltips", true);
- // allow "scrubbing" over ui by showing next tooltip immediately
- // if previous one was still visible
- F32 timeout = LLToolTipMgr::instance().toolTipVisible()
- ? tooltip_fast_delay
- : tooltip_delay;
// Even if we don't show tooltips, consume the event, nothing below should show tooltip
if (allow_ui_tooltips)
@@ -903,7 +915,7 @@ BOOL LLView::handleToolTip(S32 x, S32 y, MASK mask)
LLToolTipMgr::instance().show(LLToolTip::Params()
.message(tooltip)
.sticky_rect(calcScreenRect())
- .delay_time(timeout));
+ .delay_time(getTooltipTimeout()));
}
handled = TRUE;
}
@@ -1013,7 +1025,7 @@ BOOL LLView::handleUnicodeChar(llwchar uni_char, BOOL called_from_parent)
handled = handleUnicodeCharHere(uni_char);
if (handled && LLView::sDebugKeys)
{
- LL_INFOS() << "Unicode key handled by " << getName() << LL_ENDL;
+ LL_INFOS() << "Unicode key " << wchar_utf8_preview(uni_char) << " is handled by " << getName() << LL_ENDL;
}
}
}
@@ -1325,8 +1337,7 @@ void LLView::drawDebugRect()
std::string debug_text = llformat("%s (%d x %d)", getName().c_str(),
debug_rect.getWidth(), debug_rect.getHeight());
LLFontGL::getFontSansSerifSmall()->renderUTF8(debug_text, 0, (F32)x, (F32)y, border_color,
- LLFontGL::HCENTER, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
- S32_MAX, S32_MAX, NULL, FALSE);
+ LLFontGL::HCENTER, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW);
}
}
LLUI::popMatrix();
@@ -1368,7 +1379,7 @@ void LLView::reshape(S32 width, S32 height, BOOL called_from_parent)
mRect.mTop = getRect().mBottom + height;
// move child views according to reshape flags
- BOOST_FOREACH(LLView* viewp, mChildList)
+ for (LLView* viewp : mChildList)
{
if (viewp != NULL)
{
@@ -1440,7 +1451,7 @@ LLRect LLView::calcBoundingRect()
{
LLRect local_bounding_rect = LLRect::null;
- BOOST_FOREACH(LLView* childp, mChildList)
+ for (LLView* childp : mChildList)
{
// ignore invisible and "top" children when calculating bounding rect
// such as combobox popups
@@ -1603,7 +1614,7 @@ LLView* LLView::findChildView(const std::string& name, BOOL recurse) const
LL_PROFILE_ZONE_SCOPED_CATEGORY_UI;
// Look for direct children *first*
- BOOST_FOREACH(LLView* childp, mChildList)
+ for (LLView* childp : mChildList)
{
llassert(childp);
if (childp->getName() == name)
@@ -1614,7 +1625,7 @@ LLView* LLView::findChildView(const std::string& name, BOOL recurse) const
if (recurse)
{
// Look inside each child as well.
- BOOST_FOREACH(LLView* childp, mChildList)
+ for (LLView* childp : mChildList)
{
llassert(childp);
LLView* viewp = childp->findChildView(name, recurse);
@@ -1742,23 +1753,26 @@ LLCoordGL getNeededTranslation(const LLRect& input, const LLRect& constraint, S3
const S32 KEEP_ONSCREEN_PIXELS_WIDTH = llmin(min_overlap_pixels, input.getWidth());
const S32 KEEP_ONSCREEN_PIXELS_HEIGHT = llmin(min_overlap_pixels, input.getHeight());
- if( input.mRight - KEEP_ONSCREEN_PIXELS_WIDTH < constraint.mLeft )
+ if (KEEP_ONSCREEN_PIXELS_WIDTH <= constraint.getWidth() &&
+ KEEP_ONSCREEN_PIXELS_HEIGHT <= constraint.getHeight())
{
- delta.mX = constraint.mLeft - (input.mRight - KEEP_ONSCREEN_PIXELS_WIDTH);
- }
- else if( input.mLeft + KEEP_ONSCREEN_PIXELS_WIDTH > constraint.mRight )
- {
- delta.mX = constraint.mRight - (input.mLeft + KEEP_ONSCREEN_PIXELS_WIDTH);
- }
+ if (input.mRight - KEEP_ONSCREEN_PIXELS_WIDTH < constraint.mLeft)
+ {
+ delta.mX = constraint.mLeft - (input.mRight - KEEP_ONSCREEN_PIXELS_WIDTH);
+ }
+ else if (input.mLeft + KEEP_ONSCREEN_PIXELS_WIDTH > constraint.mRight)
+ {
+ delta.mX = constraint.mRight - (input.mLeft + KEEP_ONSCREEN_PIXELS_WIDTH);
+ }
- if( input.mTop > constraint.mTop )
- {
- delta.mY = constraint.mTop - input.mTop;
- }
- else
- if( input.mTop - KEEP_ONSCREEN_PIXELS_HEIGHT < constraint.mBottom )
- {
- delta.mY = constraint.mBottom - (input.mTop - KEEP_ONSCREEN_PIXELS_HEIGHT);
+ if (input.mTop > constraint.mTop)
+ {
+ delta.mY = constraint.mTop - input.mTop;
+ }
+ else if (input.mTop - KEEP_ONSCREEN_PIXELS_HEIGHT < constraint.mBottom)
+ {
+ delta.mY = constraint.mBottom - (input.mTop - KEEP_ONSCREEN_PIXELS_HEIGHT);
+ }
}
return delta;
@@ -1769,13 +1783,19 @@ LLCoordGL getNeededTranslation(const LLRect& input, const LLRect& constraint, S3
// (Why top and left? That's where the drag bars are for floaters.)
BOOL LLView::translateIntoRect(const LLRect& constraint, S32 min_overlap_pixels)
{
- LLCoordGL translation = getNeededTranslation(getRect(), constraint, min_overlap_pixels);
+ return translateRectIntoRect(getRect(), constraint, min_overlap_pixels);
+}
+
+BOOL LLView::translateRectIntoRect(const LLRect& rect, const LLRect& constraint, S32 min_overlap_pixels)
+{
+ LLCoordGL translation = getNeededTranslation(rect, constraint, min_overlap_pixels);
if (translation.mX != 0 || translation.mY != 0)
{
translate(translation.mX, translation.mY);
return TRUE;
}
+
return FALSE;
}
@@ -1955,7 +1975,7 @@ private:
class SortByTabOrder : public LLQuerySorter, public LLSingleton<SortByTabOrder>
{
LLSINGLETON_EMPTY_CTOR(SortByTabOrder);
- /*virtual*/ void sort(LLView * parent, LLView::child_list_t &children) const
+ /*virtual*/ void sort(LLView * parent, LLView::child_list_t &children) const override
{
children.sort(CompareByTabOrder(parent->getTabOrder(), parent->getDefaultTabGroup()));
}
@@ -1979,7 +1999,7 @@ const LLViewQuery & LLView::getTabOrderQuery()
class LLFocusRootsFilter : public LLQueryFilter, public LLSingleton<LLFocusRootsFilter>
{
LLSINGLETON_EMPTY_CTOR(LLFocusRootsFilter);
- /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const
+ /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const override
{
return filterResult_t(view->isCtrl() && view->isFocusRoot(), !view->isFocusRoot());
}
@@ -2789,7 +2809,7 @@ S32 LLView::notifyParent(const LLSD& info)
bool LLView::notifyChildren(const LLSD& info)
{
bool ret = false;
- BOOST_FOREACH(LLView* childp, mChildList)
+ for (LLView* childp : mChildList)
{
ret = ret || childp->notifyChildren(info);
}
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index 8aa97aac39..c14a8bdce3 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -111,7 +111,7 @@ public:
Alternative<std::string> string;
Alternative<U32> flags;
- Follows();
+ Follows();
};
struct Params : public LLInitParam::Block<Params>
@@ -243,6 +243,7 @@ public:
ECursorType getHoverCursor() { return mHoverCursor; }
+ static F32 getTooltipTimeout();
virtual const std::string getToolTip() const { return mToolTipMsg.getString(); }
void sendChildToFront(LLView* child);
@@ -368,6 +369,7 @@ public:
virtual void translate( S32 x, S32 y );
void setOrigin( S32 x, S32 y ) { mRect.translate( x - mRect.mLeft, y - mRect.mBottom ); }
BOOL translateIntoRect( const LLRect& constraint, S32 min_overlap_pixels = S32_MAX);
+ BOOL translateRectIntoRect( const LLRect& rect, const LLRect& constraint, S32 min_overlap_pixels = S32_MAX);
BOOL translateIntoRectWithExclusion( const LLRect& inside, const LLRect& exclude, S32 min_overlap_pixels = S32_MAX);
void centerWithin(const LLRect& bounds);
@@ -657,8 +659,14 @@ public:
// Draw debug rectangles around widgets to help with alignment and spacing
static bool sDebugRects;
- static bool sIsRectDirty;
- static LLRect sDirtyRect;
+ // Show hexadecimal byte values of unicode symbols in a tooltip
+ static bool sDebugUnicode;
+
+ // Show camera position and direction in Camera Controls floater
+ static bool sDebugCamera;
+
+ static bool sIsRectDirty;
+ static LLRect sDirtyRect;
// Draw widget names and sizes when drawing debug rectangles, turning this
// off is useful to make the rectangles themselves easier to see.
@@ -701,20 +709,16 @@ template <class T> T* LLView::getChild(const std::string& name, BOOL recurse) co
if (!result)
{
result = LLUICtrlFactory::getDefaultWidget<T>(name);
-
- if (result)
+ if (!result)
{
- // *NOTE: You cannot call mFoo = getChild<LLFoo>("bar")
- // in a floater or panel constructor. The widgets will not
- // be ready. Instead, put it in postBuild().
- LL_WARNS() << "Making dummy " << typeid(T).name() << " named \"" << name << "\" in " << getName() << LL_ENDL;
- }
- else
- {
- LL_WARNS() << "Failed to create dummy " << typeid(T).name() << LL_ENDL;
- return NULL;
+ LL_ERRS() << "Failed to create dummy " << typeid(T).name() << LL_ENDL;
}
+ // *NOTE: You cannot call mFoo = getChild<LLFoo>("bar")
+ // in a floater or panel constructor. The widgets will not
+ // be ready. Instead, put it in postBuild().
+ LL_WARNS() << "Making dummy " << typeid(T).name() << " named \"" << name << "\" in " << getName() << LL_ENDL;
+
getDefaultWidgetContainer().addChild(result);
}
}
diff --git a/indra/llui/llviewquery.h b/indra/llui/llviewquery.h
index 21bb1be26f..4bc9c4a08e 100644
--- a/indra/llui/llviewquery.h
+++ b/indra/llui/llviewquery.h
@@ -55,37 +55,37 @@ public:
class LLLeavesFilter : public LLQueryFilter, public LLSingleton<LLLeavesFilter>
{
LLSINGLETON_EMPTY_CTOR(LLLeavesFilter);
- /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const;
+ /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const override;
};
class LLRootsFilter : public LLQueryFilter, public LLSingleton<LLRootsFilter>
{
LLSINGLETON_EMPTY_CTOR(LLRootsFilter);
- /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const;
+ /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const override;
};
class LLVisibleFilter : public LLQueryFilter, public LLSingleton<LLVisibleFilter>
{
LLSINGLETON_EMPTY_CTOR(LLVisibleFilter);
- /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const;
+ /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const override;
};
class LLEnabledFilter : public LLQueryFilter, public LLSingleton<LLEnabledFilter>
{
LLSINGLETON_EMPTY_CTOR(LLEnabledFilter);
- /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const;
+ /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const override;
};
class LLTabStopFilter : public LLQueryFilter, public LLSingleton<LLTabStopFilter>
{
LLSINGLETON_EMPTY_CTOR(LLTabStopFilter);
- /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const;
+ /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const override;
};
class LLCtrlFilter : public LLQueryFilter, public LLSingleton<LLCtrlFilter>
{
LLSINGLETON_EMPTY_CTOR(LLCtrlFilter);
- /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const;
+ /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const override;
};
template <class T>