Merge branch 'DRTVWR-591-maint-X' of https://github.com/secondlife/viewer

# Conflicts:
#	indra/newview/skins/default/xui/en/floater_region_info.xml
master
Ansariel 2023-10-11 15:51:48 +02:00
commit db79f0637c
22 changed files with 576 additions and 574 deletions

View File

@ -1362,9 +1362,17 @@ bool LLStringUtil::formatDatetime(std::string& replacement, std::string token,
}
else
{
#if 0
// EXT-1565 : Zai Lynch, James Linden : 15/Oct/09
// [BSI] Feedback: Viewer clock mentions SLT, but would prefer it to show PST/PDT
// "slt" = Second Life Time, which is deprecated.
// If not utc or user local time, fallback to Pacific time
replacement = LLStringOps::getPacificDaylightTime() ? "PDT" : "PST";
#else
// SL-20370 : Steeltoe Linden : 29/Sep/23
// Change "PDT" to "SLT" on menu bar
replacement = "SLT";
#endif
}
return true;
}

View File

@ -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)
addCollapsibleCtrl(*it);
arrange ();
if(mSingleExpansion)
for (std::vector<LLUICtrl*>::reverse_iterator it = accordion_tabs.rbegin();
it < accordion_tabs.rend(); ++it)
{
if(!mAccordionTabs[0]->getDisplayChildren())
addCollapsibleCtrl(*it);
}
arrange();
if (mSingleExpansion)
{
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);
}
@ -337,9 +337,9 @@ void LLAccordionCtrl::addCollapsibleCtrl(LLView* view, bool aArrange)
// </FS:ND>
{
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);
@ -380,7 +380,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());
@ -388,39 +388,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();
}
@ -428,28 +428,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
{
@ -462,67 +462,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());
}
@ -530,70 +530,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);
show_hide_scrollbar(getRect().getWidth(),getRect().getHeight());
return;
ctrlSetLeftTopAndSize(accordion_tab, panel_rect.mLeft, panel_top, panel_width, panel_height);
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;
@ -601,14 +598,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
@ -621,51 +618,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
@ -698,42 +696,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"));
@ -744,17 +743,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;
@ -772,12 +771,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)
{
@ -794,7 +793,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)
@ -813,9 +812,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;
@ -825,7 +824,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;
}
@ -845,15 +844,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();
@ -888,7 +888,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);
@ -918,7 +918,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;
}
@ -926,9 +926,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();
}
@ -938,7 +938,7 @@ S32 LLAccordionCtrl::calcExpandedTabHeight(S32 tab_index /* = 0 */, S32 availabl
}
}
if(0 == num_expanded)
if (0 == num_expanded)
{
return available_height;
}

View File

@ -151,7 +151,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

View File

@ -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)
{
changeOpenClose(getDisplayChildren());
return TRUE;
}
}
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_SUBTRACT || key == KEY_LEFT) && 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 (getDisplayChildren())
{
changeOpenClose(getDisplayChildren());
return TRUE;
}
}
if (key == KEY_DOWN && mask == MASK_NONE)
{
// 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;
}

View File

@ -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&);

View File

@ -1210,7 +1210,7 @@ void LLFlatListView::onFocusReceived()
{
if (size())
{
mSelectedItemsBorder->setVisible(TRUE);
mSelectedItemsBorder->setVisible(TRUE);
}
gEditMenuHandler = this;
}
@ -1219,7 +1219,7 @@ void LLFlatListView::onFocusLost()
{
mSelectedItemsBorder->setVisible(FALSE);
// Route menu back to the default
if( gEditMenuHandler == this )
if (gEditMenuHandler == this)
{
gEditMenuHandler = NULL;
}
@ -1228,16 +1228,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();
@ -1250,6 +1250,7 @@ S32 LLFlatListView::notify(const LLSD& info)
notifyParentItemsRectChanged();
return 1;
}
return 0;
}
@ -1261,10 +1262,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))
@ -1273,6 +1272,7 @@ void LLFlatListView::detachItems(std::vector<LLPanel*>& detached_items)
mItemsPanel->removeChild(pItem);
detached_items.push_back(pItem);
}
iter++;
}
if (!detached_items.empty())
{
@ -1280,13 +1280,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.
@ -1299,16 +1298,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)
@ -1318,7 +1315,9 @@ void LLFlatListView::detachItems(std::vector<LLPanel*>& detached_items)
delete item_pair;
break;
}
iter++;
}
detached_iter++;
}
rearrangeItems();
}
@ -1334,7 +1333,6 @@ LLFlatListViewEx::Params::Params()
: no_items_msg("no_items_msg")
, no_filtered_items_msg("no_filtered_items_msg")
{
}
LLFlatListViewEx::LLFlatListViewEx(const Params& p)
@ -1344,7 +1342,6 @@ LLFlatListViewEx::LLFlatListViewEx(const Params& p)
, mForceShowingUnmatchedItems(false)
, mHasMatchedItems(false)
{
}
void LLFlatListViewEx::updateNoItemsMessage(const std::string& filter_string)
@ -1364,7 +1361,6 @@ void LLFlatListViewEx::updateNoItemsMessage(const std::string& filter_string)
// list does not contain any items at all
setNoItemsCommentText(mNoItemsMsg);
}
}
bool LLFlatListViewEx::getForceShowingUnmatchedItems()
@ -1377,26 +1373,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
{
@ -1404,36 +1402,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()

View File

@ -308,6 +308,7 @@ public:
virtual S32 notify(const LLSD& info) ;
virtual ~LLFlatListView();
protected:
/** Pairs LLpanel representing a single item LLPanel and LLSD associated with it */
@ -383,7 +384,9 @@ protected:
LLRect getLastSelectedItemRect();
void ensureSelectedVisible();
void ensureSelectedVisible();
const pairs_list_t& getItemPairs() { return mItemPairs; }
private:
@ -496,14 +499,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
@ -527,7 +530,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;

View File

@ -311,7 +311,7 @@ void FSFloaterWearableFavorites::handleRemove()
void FSFloaterWearableFavorites::onFilterEdit(const std::string& search_string)
{
mItemsList->setFilterSubString(search_string);
mItemsList->setFilterSubString(search_string, true);
mItemsList->setNoItemsCommentText(getString("empty_list"));
}

View File

@ -240,7 +240,7 @@ void LLInventoryItemsList::refresh()
case REFRESH_LIST_SORT:
{
// Filter, sort, rearrange and notify parent about shape changes
filterItems();
filterItems(true, true);
if (mAddedItems.size() == 0)
{

View File

@ -51,20 +51,20 @@ public:
/**
* Let list know items need to be refreshed in next doIdle()
*/
void setNeedsRefresh(bool needs_refresh){ mRefreshState = needs_refresh ? REFRESH_ALL : REFRESH_COMPLETE; }
void setNeedsRefresh(bool needs_refresh) { mRefreshState = needs_refresh ? REFRESH_ALL : REFRESH_COMPLETE; }
U32 getNeedsRefresh(){ return mRefreshState; }
U32 getNeedsRefresh() { return mRefreshState; }
/**
* Sets the flag indicating that the list needs to be refreshed even if it is
* not currently visible.
*/
void setForceRefresh(bool force_refresh){ mForceRefresh = force_refresh; }
void setForceRefresh(bool force_refresh) { mForceRefresh = force_refresh; }
/**
* If refreshes when invisible.
*/
bool getForceRefresh(){ return mForceRefresh; }
bool getForceRefresh() { return mForceRefresh; }
virtual bool selectItemByValue(const LLSD& value, bool select = true);

View File

@ -433,8 +433,7 @@ bool compareGalleryItem(LLOutfitGalleryItem* item1, LLOutfitGalleryItem* item2)
}
void LLOutfitGallery::reArrangeRows(S32 row_diff)
{
{
std::vector<LLOutfitGalleryItem*> buf_items = mItems;
for (std::vector<LLOutfitGalleryItem*>::const_reverse_iterator it = buf_items.rbegin(); it != buf_items.rend(); ++it)
{
@ -446,16 +445,24 @@ void LLOutfitGallery::reArrangeRows(S32 row_diff)
}
mHiddenItems.clear();
mItemsInRow+= row_diff;
mItemsInRow += row_diff;
updateGalleryWidth();
std::sort(buf_items.begin(), buf_items.end(), compareGalleryItem);
std::string cur_filter = getFilterSubString();
LLStringUtil::toUpper(cur_filter);
for (std::vector<LLOutfitGalleryItem*>::const_iterator it = buf_items.begin(); it != buf_items.end(); ++it)
{
(*it)->setHidden(false);
applyFilter(*it,sFilterSubString);
std::string outfit_name = (*it)->getItemName();
LLStringUtil::toUpper(outfit_name);
bool hidden = (std::string::npos == outfit_name.find(cur_filter));
(*it)->setHidden(hidden);
addToGallery(*it);
}
updateMessageVisibility();
}
@ -725,9 +732,9 @@ LLOutfitGallery::~LLOutfitGallery()
}
}
void LLOutfitGallery::setFilterSubString(const std::string& string)
// virtual
void LLOutfitGallery::onFilterSubStringChanged(const std::string& new_string, const std::string& old_string)
{
sFilterSubString = string;
reArrangeRows();
}
@ -743,20 +750,6 @@ void LLOutfitGallery::onHighlightBaseOutfit(LLUUID base_id, LLUUID prev_id)
}
}
void LLOutfitGallery::applyFilter(LLOutfitGalleryItem* item, const std::string& filter_substring)
{
if (!item) return;
std::string outfit_name = item->getItemName();
LLStringUtil::toUpper(outfit_name);
std::string cur_filter = filter_substring;
LLStringUtil::toUpper(cur_filter);
bool hidden = (std::string::npos == outfit_name.find(cur_filter));
item->setHidden(hidden);
}
void LLOutfitGallery::onSetSelectedOutfitByUUID(const LLUUID& outfit_uuid)
{
}
@ -904,11 +897,11 @@ bool LLOutfitGallery::hasDefaultImage(const LLUUID& outfit_cat_id)
void LLOutfitGallery::updateMessageVisibility()
{
if(mItems.empty())
if (mItems.empty())
{
mMessageTextBox->setVisible(TRUE);
mScrollPanel->setVisible(FALSE);
std::string message = sFilterSubString.empty()? getString("no_outfits_msg") : getString("no_matched_outfits_msg");
std::string message = getString(getFilterSubString().empty() ? "no_outfits_msg" : "no_matched_outfits_msg");
mMessageTextBox->setValue(message);
}
else

View File

@ -90,7 +90,7 @@ public:
void wearSelectedOutfit();
/*virtual*/ void setFilterSubString(const std::string& string);
/*virtual*/ void onFilterSubStringChanged(const std::string& new_string, const std::string& old_string);
/*virtual*/ void getCurrentCategories(uuid_vec_t& vcur);
/*virtual*/ void updateAddedCategory(LLUUID cat_id);
@ -117,8 +117,6 @@ protected:
/*virtual*/ void onExpandAllFolders() {}
/*virtual*/ LLOutfitListGearMenuBase* createGearMenu();
void applyFilter(LLOutfitGalleryItem* item, const std::string& filter_substring);
private:
LLUUID getPhotoAssetId(const LLUUID& outfit_id);
LLUUID getDefaultPhoto();

View File

@ -201,7 +201,7 @@ void LLOutfitsList::updateAddedCategory(LLUUID cat_id)
list->setCommitCallback(boost::bind(&LLOutfitsList::onListSelectionChange, this, _1));
// Setting list refresh callback to apply filter on list change.
list->setRefreshCompleteCallback(boost::bind(&LLOutfitsList::onFilteredWearableItemsListRefresh, this, _1));
list->setRefreshCompleteCallback(boost::bind(&LLOutfitsList::onRefreshComplete, this, _1));
list->setRightMouseDownCallback(boost::bind(&LLOutfitsList::onWearableItemsListRightClick, this, _1, _2, _3));
@ -212,19 +212,17 @@ void LLOutfitsList::updateAddedCategory(LLUUID cat_id)
// Further list updates will be triggered by the category observer.
list->updateList(cat_id);
// If filter is currently applied we store the initial tab state and
// open it to show matched items if any.
if (!sFilterSubString.empty())
// If filter is currently applied we store the initial tab state.
if (!getFilterSubString().empty())
{
tab->notifyChildren(LLSD().with("action", "store_state"));
tab->setDisplayChildren(true);
// Setting mForceRefresh flag will make the list refresh its contents
// even if it is not currently visible. This is required to apply the
// filter to the newly added list.
list->setForceRefresh(true);
list->setFilterSubString(sFilterSubString);
list->setFilterSubString(getFilterSubString(), false);
}
}
@ -383,14 +381,6 @@ void LLOutfitsList::onSetSelectedOutfitByUUID(const LLUUID& outfit_uuid)
}
}
// virtual
void LLOutfitsList::setFilterSubString(const std::string& string)
{
applyFilter(string);
sFilterSubString = string;
}
// virtual
bool LLOutfitListBase::isActionEnabled(const LLSD& userdata)
{
@ -564,9 +554,9 @@ void LLOutfitsList::restoreOutfitSelection(LLAccordionCtrlTab* tab, const LLUUID
}
}
void LLOutfitsList::onFilteredWearableItemsListRefresh(LLUICtrl* ctrl)
void LLOutfitsList::onRefreshComplete(LLUICtrl* ctrl)
{
if (!ctrl || sFilterSubString.empty())
if (!ctrl || getFilterSubString().empty())
return;
for (outfits_map_t::iterator
@ -580,57 +570,50 @@ void LLOutfitsList::onFilteredWearableItemsListRefresh(LLUICtrl* ctrl)
LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(tab->getAccordionView());
if (list != ctrl) continue;
applyFilterToTab(iter->first, tab, sFilterSubString);
applyFilterToTab(iter->first, tab, getFilterSubString());
}
}
void LLOutfitsList::applyFilter(const std::string& new_filter_substring)
// virtual
void LLOutfitsList::onFilterSubStringChanged(const std::string& new_string, const std::string& old_string)
{
mAccordion->setFilterSubString(new_filter_substring);
mAccordion->setFilterSubString(new_string);
for (outfits_map_t::iterator
iter = mOutfitsMap.begin(),
iter_end = mOutfitsMap.end();
iter != iter_end; ++iter)
outfits_map_t::iterator iter = mOutfitsMap.begin(), iter_end = mOutfitsMap.end();
while (iter != iter_end)
{
LLAccordionCtrlTab* tab = iter->second;
const LLUUID& category_id = iter->first;
LLAccordionCtrlTab* tab = iter++->second;
if (!tab) continue;
bool more_restrictive = sFilterSubString.size() < new_filter_substring.size() && !new_filter_substring.substr(0, sFilterSubString.size()).compare(sFilterSubString);
// Restore tab visibility in case of less restrictive filter
// to compare it with updated string if it was previously hidden.
if (!more_restrictive)
{
tab->setVisible(TRUE);
}
LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(tab->getAccordionView());
if (list)
{
list->setFilterSubString(new_filter_substring);
list->setFilterSubString(new_string, tab->getDisplayChildren());
}
if(sFilterSubString.empty() && !new_filter_substring.empty())
if (old_string.empty())
{
//store accordion tab state when filter is not empty
tab->notifyChildren(LLSD().with("action","store_state"));
// Store accordion tab state when filter is not empty
tab->notifyChildren(LLSD().with("action", "store_state"));
}
if (!new_filter_substring.empty())
if (!new_string.empty())
{
applyFilterToTab(iter->first, tab, new_filter_substring);
applyFilterToTab(category_id, tab, new_string);
}
else
{
// restore tab title when filter is empty
tab->setVisible(TRUE);
// Restore tab title when filter is empty
tab->setTitle(tab->getTitle());
//restore accordion state after all those accodrion tab manipulations
tab->notifyChildren(LLSD().with("action","restore_state"));
// Restore accordion state after all those accodrion tab manipulations
tab->notifyChildren(LLSD().with("action", "restore_state"));
// Try restoring the tab selection.
restoreOutfitSelection(tab, iter->first);
restoreOutfitSelection(tab, category_id);
}
}
@ -656,11 +639,11 @@ void LLOutfitsList::applyFilterToTab(
if (std::string::npos == title.find(cur_filter))
{
// hide tab if its title doesn't pass filter
// and it has no visible items
// Hide tab if its title doesn't pass filter
// and it has no matched items
tab->setVisible(list->hasMatchedItems());
// remove title highlighting because it might
// Remove title highlighting because it might
// have been previously highlighted by less restrictive filter
tab->setTitle(tab->getTitle());
@ -672,18 +655,6 @@ void LLOutfitsList::applyFilterToTab(
// Try restoring the tab selection.
restoreOutfitSelection(tab, category_id);
}
if (tab->getVisible())
{
// Open tab if it has passed the filter.
tab->setDisplayChildren(true);
}
else
{
// Set force refresh flag to refresh not visible list
// when some changes occur in it.
list->setForceRefresh(true);
}
}
bool LLOutfitsList::canWearSelected()
@ -768,11 +739,10 @@ void LLOutfitsList::onCOFChanged()
// These links UUIDs are not the same UUIDs that we have in each wearable items list.
// So we collect base items' UUIDs to find them or links that point to them in wearable
// items lists and update their worn state there.
for (LLInventoryModel::item_array_t::const_iterator iter = item_array.begin();
iter != item_array.end();
++iter)
LLInventoryModel::item_array_t::const_iterator array_iter = item_array.begin(), array_end = item_array.end();
while (array_iter < array_end)
{
vnew.push_back((*iter)->getLinkedUUID());
vnew.push_back((*(array_iter++))->getLinkedUUID());
}
// We need to update only items that were added or removed from COF.
@ -781,20 +751,20 @@ void LLOutfitsList::onCOFChanged()
// Store the ids of items currently linked from COF.
mCOFLinkedItems = vnew;
for (outfits_map_t::iterator iter = mOutfitsMap.begin();
iter != mOutfitsMap.end();
++iter)
// Append removed ids to added ids because we should update all of them.
vadded.reserve(vadded.size() + vremoved.size());
vadded.insert(vadded.end(), vremoved.begin(), vremoved.end());
vremoved.clear();
outfits_map_t::iterator map_iter = mOutfitsMap.begin(), map_end = mOutfitsMap.end();
while (map_iter != map_end)
{
LLAccordionCtrlTab* tab = iter->second;
LLAccordionCtrlTab* tab = (map_iter++)->second;
if (!tab) continue;
LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(tab->getAccordionView());
if (!list) continue;
// Append removed ids to added ids because we should update all of them.
vadded.reserve(vadded.size() + vremoved.size());
vadded.insert(vadded.end(), vremoved.begin(), vremoved.end());
// Every list updates the labels of changed items or
// the links that point to these items.
list->updateChangedItems(vadded);

View File

@ -244,7 +244,7 @@ public:
//void performAction(std::string action);
/*virtual*/ void setFilterSubString(const std::string& string);
/*virtual*/ void onFilterSubStringChanged(const std::string& new_string, const std::string& old_string);
/*virtual*/ void getSelectedItemsUUIDs(uuid_vec_t& selected_uuids) const;
@ -315,12 +315,7 @@ private:
* Called upon list refresh event to update tab visibility depending on
* the results of applying filter to the title and list items of the tab.
*/
void onFilteredWearableItemsListRefresh(LLUICtrl* ctrl);
/**
* Highlights filtered items and hides tabs which haven't passed filter.
*/
void applyFilter(const std::string& new_filter_substring);
void onRefreshComplete(LLUICtrl* ctrl);
/**
* Applies filter to the given tab

View File

@ -28,7 +28,6 @@
#include "llpanelappearancetab.h"
#include "llinventoryfunctions.h"
#include "llinventorymodel.h"
#include "llviewerinventory.h"
@ -37,7 +36,31 @@
#include "rlvhandler.h"
// [/RLVa:KB]
//virtual
std::string LLPanelAppearanceTab::sRecentFilterSubString;
void LLPanelAppearanceTab::setFilterSubString(const std::string& new_string)
{
if (new_string != mFilterSubString)
{
std::string old_string = mFilterSubString;
mFilterSubString = new_string;
onFilterSubStringChanged(mFilterSubString, old_string);
}
sRecentFilterSubString = new_string;
}
void LLPanelAppearanceTab::checkFilterSubString()
{
if (sRecentFilterSubString != mFilterSubString)
{
std::string old_string = mFilterSubString;
mFilterSubString = sRecentFilterSubString;
onFilterSubStringChanged(mFilterSubString, old_string);
}
}
// virtual
bool LLPanelAppearanceTab::canTakeOffSelected()
{
uuid_vec_t selected_uuids;

View File

@ -35,13 +35,17 @@ public:
LLPanelAppearanceTab() : LLPanel() {}
virtual ~LLPanelAppearanceTab() {}
virtual void setFilterSubString(const std::string& string) = 0;
void setFilterSubString(const std::string& new_string);
void checkFilterSubString();
virtual void onFilterSubStringChanged(const std::string& new_string, const std::string& old_string) = 0;
virtual bool isActionEnabled(const LLSD& userdata) = 0;
virtual void getSelectedItemsUUIDs(uuid_vec_t& selected_uuids) const {}
static const std::string& getFilterSubString() { return sFilterSubString; }
const std::string& getFilterSubString() { return mFilterSubString; }
protected:
@ -50,7 +54,10 @@ protected:
*/
bool canTakeOffSelected();
static std::string sFilterSubString;
private:
std::string mFilterSubString;
static std::string sRecentFilterSubString;
};
#endif //LL_LLPANELAPPEARANCETAB_H

View File

@ -748,7 +748,7 @@ void LLPanelOutfitEdit::onSearchEdit(const std::string& string)
if (mSearchString == "")
{
mInventoryItemsPanel->setFilterSubString(LLStringUtil::null);
mWearableItemsList->setFilterSubString(LLStringUtil::null);
mWearableItemsList->setFilterSubString(LLStringUtil::null, true);
// re-open folders that were initially open
mSavedFolderState->setApply(TRUE);
mInventoryItemsPanel->getRootFolder()->applyFunctorRecursively(*mSavedFolderState);
@ -778,8 +778,7 @@ void LLPanelOutfitEdit::onSearchEdit(const std::string& string)
// set new filter string
mInventoryItemsPanel->setFilterSubString(mSearchString);
mWearableItemsList->setFilterSubString(mSearchString);
mWearableItemsList->setFilterSubString(mSearchString, true);
}
void LLPanelOutfitEdit::onPlusBtnClicked(void)

View File

@ -28,19 +28,19 @@
#include "llpaneloutfitsinventory.h"
#include "llnotificationsutil.h"
#include "lltabcontainer.h"
#include "llagentwearables.h"
#include "llappearancemgr.h"
#include "llfloatersidepanelcontainer.h"
#include "llinventoryfunctions.h"
#include "llinventorymodelbackgroundfetch.h"
#include "llagentwearables.h"
#include "llappearancemgr.h"
#include "lloutfitobserver.h"
#include "llnotificationsutil.h"
#include "lloutfitgallery.h"
#include "lloutfitobserver.h"
#include "lloutfitslist.h"
#include "llpanelappearancetab.h"
#include "llpanelwearing.h"
#include "llsidepanelappearance.h"
#include "lltabcontainer.h"
#include "llviewercontrol.h"
#include "llviewerfoldertype.h"
@ -176,25 +176,12 @@ void LLPanelOutfitsInventory::onSearchEdit(const std::string& string)
{
if (!mActivePanel) return;
mFilterSubString = string;
if (string == "")
{
mActivePanel->setFilterSubString(LLStringUtil::null);
}
if (!LLInventoryModelBackgroundFetch::instance().inventoryFetchStarted())
{
llassert(false); // this should have been done on startup
LLInventoryModelBackgroundFetch::instance().start();
}
if (mActivePanel->getFilterSubString().empty() && string.empty())
{
// current filter and new filter empty, do nothing
return;
}
// set new filter string
mActivePanel->setFilterSubString(string);
}
@ -342,6 +329,7 @@ bool LLPanelOutfitsInventory::isActionEnabled(const LLSD& userdata)
{
return mActivePanel && mActivePanel->isActionEnabled(userdata);
}
// List Commands //
//////////////////////////////////////////////////////////////////////////////////
@ -370,7 +358,7 @@ void LLPanelOutfitsInventory::onTabChange()
mActivePanel = dynamic_cast<LLPanelAppearanceTab*>(mAppearanceTabs->getCurrentPanel());
if (!mActivePanel) return;
mActivePanel->setFilterSubString(mFilterSubString);
mActivePanel->checkFilterSubString();
mActivePanel->onOpen(LLSD());
updateVerbs();
@ -397,8 +385,6 @@ bool LLPanelOutfitsInventory::isOutfitsGalleryPanelActive() const
return mActivePanel->getName() == OUTFIT_GALLERY_TAB_NAME;
}
void LLPanelOutfitsInventory::setWearablesLoading(bool val)
{
updateVerbs();

View File

@ -76,7 +76,6 @@ protected:
private:
LLTabContainer* mAppearanceTabs;
std::string mFilterSubString;
// <FS:Ansariel> FIRE-17626: Attachment count in appearance floater
LLInventoryCategoriesObserver* mCategoriesObserver;

View File

@ -243,8 +243,6 @@ protected:
//////////////////////////////////////////////////////////////////////////
std::string LLPanelAppearanceTab::sFilterSubString = LLStringUtil::null;
static LLPanelInjector<LLPanelWearing> t_panel_wearing("panel_wearing");
LLPanelWearing::LLPanelWearing()
@ -368,10 +366,11 @@ void LLPanelWearing::startUpdateTimer()
}
// virtual
void LLPanelWearing::setFilterSubString(const std::string& string)
void LLPanelWearing::onFilterSubStringChanged(const std::string& new_string, const std::string& old_string)
{
sFilterSubString = string;
mCOFItemsList->setFilterSubString(sFilterSubString);
mCOFItemsList->setFilterSubString(new_string, true);
mAccordionCtrl->arrange();
}
// virtual

View File

@ -62,7 +62,7 @@ public:
/*virtual*/ void onOpen(const LLSD& info);
/*virtual*/ void setFilterSubString(const std::string& string);
/*virtual*/ void onFilterSubStringChanged(const std::string& new_string, const std::string& old_string);
/*virtual*/ bool isActionEnabled(const LLSD& userdata);

View File

@ -979,35 +979,27 @@ void LLWearableItemsList::updateList(const LLUUID& category_id)
void LLWearableItemsList::updateChangedItems(const uuid_vec_t& changed_items_uuids)
{
// nothing to update
if (changed_items_uuids.empty()) return;
if (changed_items_uuids.empty())
return;
typedef std::vector<LLPanel*> item_panel_list_t;
item_panel_list_t items;
getItems(items);
for (item_panel_list_t::iterator items_iter = items.begin();
items_iter != items.end();
++items_iter)
uuid_vec_t::const_iterator uuids_begin = changed_items_uuids.begin(), uuids_end = changed_items_uuids.end();
pairs_const_iterator_t pairs_iter = getItemPairs().begin(), pairs_end = getItemPairs().end();
while (pairs_iter != pairs_end)
{
LLPanelInventoryListItemBase* item = dynamic_cast<LLPanelInventoryListItemBase*>(*items_iter);
if (!item) continue;
LLPanel* panel = (*(pairs_iter++))->first;
LLPanelInventoryListItemBase* item = dynamic_cast<LLPanelInventoryListItemBase*>(panel);
if (!item)
continue;
LLViewerInventoryItem* inv_item = item->getItem();
if (!inv_item) continue;
if (!inv_item)
continue;
LLUUID linked_uuid = inv_item->getLinkedUUID();
for (uuid_vec_t::const_iterator iter = changed_items_uuids.begin();
iter != changed_items_uuids.end();
++iter)
{
if (linked_uuid == *iter)
{
item->setNeedsRefresh(true);
break;
}
}
if (std::find(uuids_begin, uuids_end, linked_uuid) != uuids_end)
{
item->setNeedsRefresh(true);
}
}
}