EXT-7368 FIXED Implemented new "empty_accordion_text" textbox to show help text when there are no visible tabs in accordion.

* Textbox always fit whole accordion.
* This text is updated with search_term (in link to open Search floater) when new filter substring is passed to accordion.
* Accordion is notified by its tabs when their visibility is changed.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/486/

--HG--
branch : product-engine
master
Mike Antipov 2010-06-04 13:29:25 +03:00
parent f41d06012b
commit e1189d0e2e
8 changed files with 110 additions and 1 deletions

View File

@ -66,8 +66,11 @@ LLAccordionCtrl::LLAccordionCtrl(const Params& params):LLPanel(params)
, mAutoScrolling( false )
, mAutoScrollRate( 0.f )
, mSelectedTab( NULL )
, mNoVisibleTabsHelpText(NULL)
{
mSingleExpansion = params.single_expansion;
initNoTabsWidget(params.empty_accordion_text);
mSingleExpansion = params.single_expansion;
if(mFitParent && !mSingleExpansion)
{
llinfos << "fit_parent works best when combined with single_expansion" << llendl;
@ -78,7 +81,10 @@ 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");
@ -168,6 +174,8 @@ BOOL LLAccordionCtrl::postBuild()
}
}
updateNoTabsHelpTextVisibility();
return TRUE;
}
@ -187,8 +195,15 @@ 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();
}
@ -359,6 +374,31 @@ void LLAccordionCtrl::removeCollapsibleCtrl(LLView* view)
}
}
void LLAccordionCtrl::initNoTabsWidget(const LLTextBox::Params& tb_params)
{
LLTextBox::Params tp = tb_params;
tp.rect(getLocalRect());
mNoVisibleTabsOrigString = 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()
{
S32 panel_left = BORDER_MARGIN; // Margin from left side of Splitter
@ -737,6 +777,20 @@ 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 ()
@ -745,6 +799,16 @@ void LLAccordionCtrl::reset ()
mScrollbar->setDocPos(0);
}
void LLAccordionCtrl::setFilterSubString(const std::string& filter_string)
{
LLStringUtil::format_map_t args;
args["[SEARCH_TERM]"] = LLURI::escape(filter_string);
std::string text = mNoVisibleTabsOrigString;
LLStringUtil::format(text, args);
mNoVisibleTabsHelpText->setValue(text);
}
S32 LLAccordionCtrl::calcExpandedTabHeight(S32 tab_index /* = 0 */, S32 available_height /* = 0 */)
{
if(tab_index < 0)

View File

@ -34,6 +34,7 @@
#define LL_ACCORDIONCTRL_H
#include "llpanel.h"
#include "lltextbox.h"
#include "llscrollbar.h"
#include <vector>
@ -64,10 +65,12 @@ public:
accordion tabs are responsible for scrolling their content.
*NOTE fit_parent works best when combined with single_expansion.
Accordion view should implement getRequiredRect() and provide valid height*/
Optional<LLTextBox::Params> empty_accordion_text;
Params()
: single_expansion("single_expansion",false)
, fit_parent("fit_parent", false)
, empty_accordion_text("empty_accordion_text")
{};
};
@ -105,7 +108,15 @@ public:
void reset ();
/**
* Sets filter substring as a search_term for help text when there are no any visible tabs.
*/
void setFilterSubString(const std::string& filter_string);
private:
void initNoTabsWidget(const LLTextBox::Params& tb_params);
void updateNoTabsHelpTextVisibility();
void arrangeSinge();
void arrangeMultiple();
@ -131,6 +142,8 @@ private:
bool mAutoScrolling;
F32 mAutoScrollRate;
LLAccordionCtrlTab* mSelectedTab;
LLTextBox* mNoVisibleTabsHelpText;
std::string mNoVisibleTabsOrigString;
};

View File

@ -409,6 +409,13 @@ void LLAccordionCtrlTab::changeOpenClose(bool is_open)
}
}
void LLAccordionCtrlTab::handleVisibilityChange(BOOL new_visibility)
{
LLUICtrl::handleVisibilityChange(new_visibility);
notifyParent(LLSD().with("child_visibility_change", new_visibility));
}
BOOL LLAccordionCtrlTab::handleMouseDown(S32 x, S32 y, MASK mask)
{
if(mCollapsible && mHeaderVisible && mCanOpenClose)

View File

@ -154,6 +154,11 @@ public:
// Call reshape after changing size
virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
/**
* Raises notifyParent event with "child_visibility_change" = new_visibility
*/
void handleVisibilityChange(BOOL new_visibility);
// Changes expand/collapse state and triggers expand/collapse callbacks
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);

View File

@ -500,6 +500,8 @@ void LLOutfitsList::onFilteredWearableItemsListRefresh(LLUICtrl* ctrl)
void LLOutfitsList::applyFilter(const std::string& new_filter_substring)
{
mAccordion->setFilterSubString(new_filter_substring);
for (outfits_map_t::iterator
iter = mOutfitsMap.begin(),
iter_end = mOutfitsMap.end();

View File

@ -1450,6 +1450,8 @@ void LLPanelPeople::showFriendsAccordionsIfNeeded()
LLAccordionCtrl* accordion = getChild<LLAccordionCtrl>("friends_accordion");
accordion->arrange();
// *TODO: new empty_accordion_text attribute was implemented in accordion (EXT-7368).
// this code should be refactored to use it
// keep help text in a synchronization with accordions visibility.
updateFriendListHelpText();
}

View File

@ -14,6 +14,7 @@
background_visible="true"
bg_alpha_color="DkGray2"
bg_opaque_color="DkGray2"
empty_accordion_text.value="Didn't find what you're looking for? Try [secondlife:///app/search/all/[SEARCH_TERM] Search]."
follows="all"
height="400"
layout="topleft"

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<accordion
height="100"
name="accordion"
width="200">
<empty_accordion_text
follows="all"
height="100"
h_pad="10"
name="no_visible_items_msg"
value="There are no visible content here."
v_pad="15"
width="200"
wrap="true "/>
</accordion>