summaryrefslogtreecommitdiff
path: root/indra/llui/llaccordionctrl.cpp
diff options
context:
space:
mode:
authorTofu Linden <tofu.linden@lindenlab.com>2010-04-07 13:37:37 +0100
committerTofu Linden <tofu.linden@lindenlab.com>2010-04-07 13:37:37 +0100
commit4533d1b59b2e8fc534ad3de7a896aaa8514fe653 (patch)
tree38b4d2398d66a0e18cd8e4dcd47efba0ad5326a1 /indra/llui/llaccordionctrl.cpp
parent92f630871386bafc4548eb9beb45063e40b6139c (diff)
parentadce2ecdf8f3a0efcd4907699d286012124ac496 (diff)
merge from viewer-trunk
Diffstat (limited to 'indra/llui/llaccordionctrl.cpp')
-rw-r--r--indra/llui/llaccordionctrl.cpp242
1 files changed, 27 insertions, 215 deletions
diff --git a/indra/llui/llaccordionctrl.cpp b/indra/llui/llaccordionctrl.cpp
index f9ffaaa646..cdcf780d2e 100644
--- a/indra/llui/llaccordionctrl.cpp
+++ b/indra/llui/llaccordionctrl.cpp
@@ -2,25 +2,31 @@
* @file llaccordionctrl.cpp
* @brief Accordion panel implementation
*
- * $LicenseInfo:firstyear=2009&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2009&license=viewergpl$
+ *
+ * Copyright (c) 2009, 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.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab. Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
- * 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.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
- * 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
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
*
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#include "linden_common.h"
@@ -59,14 +65,8 @@ LLAccordionCtrl::LLAccordionCtrl(const Params& params):LLPanel(params)
, mFitParent(params.fit_parent)
, mAutoScrolling( false )
, mAutoScrollRate( 0.f )
- , mSelectedTab( NULL )
- , mTabComparator( NULL )
- , mNoVisibleTabsHelpText(NULL)
- , mNoVisibleTabsOrigString(params.no_visible_tabs_text.initial_value().asString())
{
- initNoTabsWidget(params.no_matched_tabs_text);
-
- mSingleExpansion = params.single_expansion;
+ mSingleExpansion = params.single_expansion;
if(mFitParent && !mSingleExpansion)
{
llinfos << "fit_parent works best when combined with single_expansion" << llendl;
@@ -76,11 +76,7 @@ LLAccordionCtrl::LLAccordionCtrl(const Params& params):LLPanel(params)
LLAccordionCtrl::LLAccordionCtrl() : LLPanel()
, mAutoScrolling( false )
, mAutoScrollRate( 0.f )
- , mSelectedTab( NULL )
- , mNoVisibleTabsHelpText(NULL)
{
- initNoTabsWidget(LLTextBox::Params());
-
mSingleExpansion = false;
mFitParent = false;
LLUICtrlFactory::getInstance()->buildPanel(this, "accordion_parent.xml");
@@ -170,8 +166,6 @@ BOOL LLAccordionCtrl::postBuild()
}
}
- updateNoTabsHelpTextVisibility();
-
return TRUE;
}
@@ -191,15 +185,8 @@ void LLAccordionCtrl::reshape(S32 width, S32 height, BOOL called_from_parent)
rcLocal.mRight = rcLocal.mLeft + width;
rcLocal.mTop = rcLocal.mBottom + height;
- // get textbox a chance to reshape its content
- mNoVisibleTabsHelpText->reshape(width, height, called_from_parent);
-
setRect(rcLocal);
- // assume that help text is always fit accordion.
- // necessary text paddings can be set via h_pad and v_pad
- mNoVisibleTabsHelpText->setRect(getLocalRect());
-
arrange();
}
@@ -342,63 +329,12 @@ void LLAccordionCtrl::addCollapsibleCtrl(LLView* view)
LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(view);
if(!accordion_tab)
return;
- if(std::find(beginChild(), endChild(), accordion_tab) == endChild())
+ if(std::find(getChildList()->begin(),getChildList()->end(),accordion_tab) == getChildList()->end())
addChild(accordion_tab);
mAccordionTabs.push_back(accordion_tab);
-
+
accordion_tab->setDropDownStateChangedCallback( boost::bind(&LLAccordionCtrl::onCollapseCtrlCloseOpen, this, mAccordionTabs.size() - 1) );
- arrange();
-}
-
-void LLAccordionCtrl::removeCollapsibleCtrl(LLView* view)
-{
- LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(view);
- if(!accordion_tab)
- return;
-
- if(std::find(beginChild(), endChild(), accordion_tab) != endChild())
- removeChild(accordion_tab);
-
- for (std::vector<LLAccordionCtrlTab*>::iterator iter = mAccordionTabs.begin();
- iter != mAccordionTabs.end(); ++iter)
- {
- if (accordion_tab == (*iter))
- {
- mAccordionTabs.erase(iter);
- break;
- }
- }
-
- // if removed is selected - reset selection
- if (mSelectedTab == view)
- {
- mSelectedTab = NULL;
- }
-}
-void LLAccordionCtrl::initNoTabsWidget(const LLTextBox::Params& tb_params)
-{
- LLTextBox::Params tp = tb_params;
- tp.rect(getLocalRect());
- mNoMatchedTabsOrigString = tp.initial_value().asString();
- mNoVisibleTabsHelpText = LLUICtrlFactory::create<LLTextBox>(tp, this);
-}
-
-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)
- {
- if ((*it)->getVisible())
- {
- visible_exists = true;
- break;
- }
- }
-
- mNoVisibleTabsHelpText->setVisible(!visible_exists);
}
void LLAccordionCtrl::arrangeSinge()
@@ -524,8 +460,6 @@ void LLAccordionCtrl::arrangeMultiple()
void LLAccordionCtrl::arrange()
{
- updateNoTabsHelpTextVisibility();
-
if( mAccordionTabs.size() == 0)
{
//We do not arrange if we do not have what should be arranged
@@ -544,8 +478,6 @@ void LLAccordionCtrl::arrange()
S32 panel_height = getRect().getHeight() - 2*BORDER_MARGIN;
- 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());
@@ -716,60 +648,19 @@ S32 LLAccordionCtrl::notifyParent(const LLSD& info)
LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
if(accordion_tab->hasFocus() && i>0)
{
- bool prev_visible_tab_found = false;
while(i>0)
{
if(mAccordionTabs[--i]->getVisible())
- {
- prev_visible_tab_found = true;
break;
- }
- }
-
- if (prev_visible_tab_found)
- {
- accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
- accordion_tab->notify(LLSD().with("action","select_last"));
- return 1;
}
- break;
- }
- }
- return 0;
- }
- else if(str_action == "select_current")
- {
- for(size_t i=0;i<mAccordionTabs.size();++i)
- {
- // Set selection to the currently focused tab.
- if(mAccordionTabs[i]->hasFocus())
- {
- if (mAccordionTabs[i] != mSelectedTab)
- {
- if (mSelectedTab)
- {
- mSelectedTab->setSelected(false);
- }
- mSelectedTab = mAccordionTabs[i];
- mSelectedTab->setSelected(true);
- }
-
+
+ accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]);
+ accordion_tab->notify(LLSD().with("action","select_last"));
return 1;
}
}
return 0;
}
- else if(str_action == "deselect_current")
- {
- // Reset selection to the currently selected tab.
- if (mSelectedTab)
- {
- mSelectedTab->setSelected(false);
- mSelectedTab = NULL;
- return 1;
- }
- return 0;
- }
}
else if (info.has("scrollToShowRect"))
{
@@ -794,20 +685,6 @@ S32 LLAccordionCtrl::notifyParent(const LLSD& info)
}
return 1;
}
- else if (info.has("child_visibility_change"))
- {
- BOOL new_visibility = info["child_visibility_change"];
- if (new_visibility)
- {
- // there is at least one visible tab
- mNoVisibleTabsHelpText->setVisible(FALSE);
- }
- else
- {
- // it could be the latest visible tab, check all of them
- updateNoTabsHelpTextVisibility();
- }
- }
return LLPanel::notifyParent(info);
}
void LLAccordionCtrl::reset ()
@@ -816,71 +693,6 @@ void LLAccordionCtrl::reset ()
mScrollbar->setDocPos(0);
}
-void LLAccordionCtrl::expandDefaultTab()
-{
- if (mAccordionTabs.size() > 0)
- {
- LLAccordionCtrlTab* tab = mAccordionTabs.front();
-
- if (!tab->getDisplayChildren())
- {
- tab->setDisplayChildren(true);
- }
-
- for (size_t i = 1; i < mAccordionTabs.size(); ++i)
- {
- tab = mAccordionTabs[i];
-
- if (tab->getDisplayChildren())
- {
- tab->setDisplayChildren(false);
- }
- }
-
- arrange();
- }
-}
-
-void LLAccordionCtrl::sort()
-{
- if (!mTabComparator)
- {
- llwarns << "No comparator specified for sorting accordion tabs." << llendl;
- return;
- }
-
- std::sort(mAccordionTabs.begin(), mAccordionTabs.end(), LLComparatorAdaptor(*mTabComparator));
- arrange();
-}
-
-void LLAccordionCtrl::setFilterSubString(const std::string& filter_string)
-{
- LLStringUtil::format_map_t args;
- args["[SEARCH_TERM]"] = LLURI::escape(filter_string);
- std::string text = filter_string.empty() ? mNoVisibleTabsOrigString : mNoMatchedTabsOrigString;
- LLStringUtil::format(text, args);
-
- mNoVisibleTabsHelpText->setValue(text);
-}
-
-const LLAccordionCtrlTab* LLAccordionCtrl::getExpandedTab() const
-{
- typedef std::vector<LLAccordionCtrlTab*>::const_iterator tabs_const_iterator;
-
- const LLAccordionCtrlTab* result = 0;
-
- for (tabs_const_iterator i = mAccordionTabs.begin(); i != mAccordionTabs.end(); ++i)
- {
- if ((*i)->isExpanded())
- {
- result = *i;
- break;
- }
- }
-
- return result;
-}
-
S32 LLAccordionCtrl::calcExpandedTabHeight(S32 tab_index /* = 0 */, S32 available_height /* = 0 */)
{
if(tab_index < 0)