summaryrefslogtreecommitdiff
path: root/indra/llui/llpanel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/llpanel.cpp')
-rwxr-xr-x[-rw-r--r--]indra/llui/llpanel.cpp346
1 files changed, 131 insertions, 215 deletions
diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp
index b2e08c48c5..ee90574161 100644..100755
--- a/indra/llui/llpanel.cpp
+++ b/indra/llui/llpanel.cpp
@@ -35,12 +35,11 @@
#include "llfontgl.h"
#include "llrect.h"
#include "llerror.h"
+#include "lldir.h"
#include "lltimer.h"
-#include "llaccordionctrltab.h"
#include "llbutton.h"
#include "llmenugl.h"
-//#include "llstatusbar.h"
#include "llui.h"
#include "llkeyboard.h"
#include "lllineeditor.h"
@@ -49,9 +48,10 @@
#include "lluictrl.h"
#include "lluictrlfactory.h"
#include "llviewborder.h"
-#include "lltabcontainer.h"
static LLDefaultChildRegistry::Register<LLPanel> r1("panel", &LLPanel::fromXML);
+LLPanel::factory_stack_t LLPanel::sFactoryStack;
+
// Compiler optimization, generate extern template
template class LLPanel* LLView::getChild<class LLPanel>(
@@ -84,9 +84,9 @@ LLPanel::Params::Params()
filename("filename"),
class_name("class"),
help_topic("help_topic"),
- visible_callback("visible_callback")
+ visible_callback("visible_callback"),
+ accepts_badge("accepts_badge")
{
- name = "panel";
addSynonym(background_visible, "bg_visible");
addSynonym(has_border, "border_visible");
addSynonym(label, "title");
@@ -95,6 +95,7 @@ LLPanel::Params::Params()
LLPanel::LLPanel(const LLPanel::Params& p)
: LLUICtrl(p),
+ LLBadgeHolder(p.accepts_badge),
mBgVisible(p.background_visible),
mBgOpaque(p.background_opaque),
mBgOpaqueColor(p.bg_opaque_color()),
@@ -118,8 +119,6 @@ LLPanel::LLPanel(const LLPanel::Params& p)
{
addBorder(p.border);
}
-
- mPanelHandle.bind(this);
}
LLPanel::~LLPanel()
@@ -164,8 +163,8 @@ void LLPanel::removeBorder()
// virtual
void LLPanel::clearCtrls()
{
- LLView::ctrl_list_t ctrls = getCtrlList();
- for (LLView::ctrl_list_t::iterator ctrl_it = ctrls.begin(); ctrl_it != ctrls.end(); ++ctrl_it)
+ LLPanel::ctrl_list_t ctrls = getCtrlList();
+ for (LLPanel::ctrl_list_t::iterator ctrl_it = ctrls.begin(); ctrl_it != ctrls.end(); ++ctrl_it)
{
LLUICtrl* ctrl = *ctrl_it;
ctrl->setFocus( FALSE );
@@ -176,14 +175,29 @@ void LLPanel::clearCtrls()
void LLPanel::setCtrlsEnabled( BOOL b )
{
- LLView::ctrl_list_t ctrls = getCtrlList();
- for (LLView::ctrl_list_t::iterator ctrl_it = ctrls.begin(); ctrl_it != ctrls.end(); ++ctrl_it)
+ LLPanel::ctrl_list_t ctrls = getCtrlList();
+ for (LLPanel::ctrl_list_t::iterator ctrl_it = ctrls.begin(); ctrl_it != ctrls.end(); ++ctrl_it)
{
LLUICtrl* ctrl = *ctrl_it;
ctrl->setEnabled( b );
}
}
+LLPanel::ctrl_list_t LLPanel::getCtrlList() const
+{
+ ctrl_list_t controls;
+ for(child_list_t::const_iterator it = getChildList()->begin(), end_it = getChildList()->end(); it != end_it; ++it)
+ {
+ LLView* viewp = *it;
+ if(viewp->isCtrl())
+ {
+ controls.push_back(static_cast<LLUICtrl*>(viewp));
+ }
+ }
+ return controls;
+}
+
+
void LLPanel::draw()
{
F32 alpha = getDrawContext().mAlpha;
@@ -191,6 +205,8 @@ void LLPanel::draw()
// draw background
if( mBgVisible )
{
+ alpha = getCurrentTransparency();
+
LLRect local_rect = getLocalRect();
if (mBgOpaque )
{
@@ -338,9 +354,9 @@ BOOL LLPanel::handleKeyHere( KEY key, MASK mask )
return handled;
}
-void LLPanel::handleVisibilityChange ( BOOL new_visibility )
+void LLPanel::onVisibilityChange ( BOOL new_visibility )
{
- LLUICtrl::handleVisibilityChange ( new_visibility );
+ LLUICtrl::onVisibilityChange ( new_visibility );
if (mVisibleSignal)
(*mVisibleSignal)(this, LLSD(new_visibility) ); // Pass BOOL as LLSD
}
@@ -368,7 +384,7 @@ void LLPanel::setBorderVisible(BOOL b)
}
}
-LLFastTimer::DeclareTimer FTM_PANEL_CONSTRUCTION("Panel Construction");
+LLTrace::BlockTimerStatHandle FTM_PANEL_CONSTRUCTION("Panel Construction");
LLView* LLPanel::fromXML(LLXMLNodePtr node, LLView* parent, LLXMLNodePtr output_node)
{
@@ -380,21 +396,20 @@ LLView* LLPanel::fromXML(LLXMLNodePtr node, LLView* parent, LLXMLNodePtr output_
LLPanel* panelp = NULL;
- {
- LLFastTimer timer(FTM_PANEL_CONSTRUCTION);
+ { LL_RECORD_BLOCK_TIME(FTM_PANEL_CONSTRUCTION);
if(!class_attr.empty())
{
panelp = LLRegisterPanelClass::instance().createPanelClass(class_attr);
if (!panelp)
{
- llwarns << "Panel class \"" << class_attr << "\" not registered." << llendl;
+ LL_WARNS() << "Panel class \"" << class_attr << "\" not registered." << LL_ENDL;
}
}
if (!panelp)
{
- panelp = LLUICtrlFactory::getInstance()->createFactoryPanel(name);
+ panelp = createFactoryPanel(name);
llassert(panelp);
if (!panelp)
@@ -407,20 +422,20 @@ LLView* LLPanel::fromXML(LLXMLNodePtr node, LLView* parent, LLXMLNodePtr output_
// factory panels may have registered their own factory maps
if (!panelp->getFactoryMap().empty())
{
- LLUICtrlFactory::instance().pushFactoryFunctions(&panelp->getFactoryMap());
+ sFactoryStack.push_back(&panelp->getFactoryMap());
}
// for local registry callbacks; define in constructor, referenced in XUI or postBuild
panelp->mCommitCallbackRegistrar.pushScope();
panelp->mEnableCallbackRegistrar.pushScope();
- panelp->initPanelXML(node, parent, output_node);
+ panelp->initPanelXML(node, parent, output_node, LLUICtrlFactory::getDefaultParams<LLPanel>());
panelp->mCommitCallbackRegistrar.popScope();
panelp->mEnableCallbackRegistrar.popScope();
if (!panelp->getFactoryMap().empty())
{
- LLUICtrlFactory::instance().popFactoryFunctions();
+ sFactoryStack.pop_back();
}
return panelp;
@@ -432,7 +447,7 @@ void LLPanel::initFromParams(const LLPanel::Params& p)
//and LLView::initFromParams will use them to set visible and enabled
setVisible(p.visible);
setEnabled(p.enabled);
-
+ setFocusRoot(p.focus_root);
setSoundFlags(p.sound_flags);
// control_name, tab_stop, focus_lost_callback, initial_value, rect, enabled, visible
@@ -444,8 +459,8 @@ void LLPanel::initFromParams(const LLPanel::Params& p)
setVisibleCallback(initCommitCallback(p.visible_callback));
}
- for (LLInitParam::ParamIterator<LocalizedString>::const_iterator it = p.strings().begin();
- it != p.strings().end();
+ for (LLInitParam::ParamIterator<LocalizedString>::const_iterator it = p.strings.begin();
+ it != p.strings.end();
++it)
{
mUIStrings[it->name] = it->value;
@@ -481,19 +496,19 @@ void LLPanel::initFromParams(const LLPanel::Params& p)
mBgAlphaImage = p.bg_alpha_image();
mBgOpaqueImageOverlay = p.bg_opaque_image_overlay;
mBgAlphaImageOverlay = p.bg_alpha_image_overlay;
+
+ setAcceptsBadge(p.accepts_badge);
}
-static LLFastTimer::DeclareTimer FTM_PANEL_SETUP("Panel Setup");
-static LLFastTimer::DeclareTimer FTM_EXTERNAL_PANEL_LOAD("Load Extern Panel Reference");
-static LLFastTimer::DeclareTimer FTM_PANEL_POSTBUILD("Panel PostBuild");
+static LLTrace::BlockTimerStatHandle FTM_PANEL_SETUP("Panel Setup");
+static LLTrace::BlockTimerStatHandle FTM_EXTERNAL_PANEL_LOAD("Load Extern Panel Reference");
+static LLTrace::BlockTimerStatHandle FTM_PANEL_POSTBUILD("Panel PostBuild");
-BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node)
+BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node, const LLPanel::Params& default_params)
{
- const LLPanel::Params& default_params(LLUICtrlFactory::getDefaultParams<LLPanel>());
Params params(default_params);
-
{
- LLFastTimer timer(FTM_PANEL_SETUP);
+ LL_RECORD_BLOCK_TIME(FTM_PANEL_SETUP);
LLXMLNodePtr referenced_xml;
std::string xml_filename = mXMLFilename;
@@ -505,32 +520,33 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu
setXMLFilename(xml_filename);
}
+ LLXUIParser parser;
+
if (!xml_filename.empty())
{
- LLUICtrlFactory::instance().pushFileName(xml_filename);
-
- LLFastTimer timer(FTM_EXTERNAL_PANEL_LOAD);
if (output_node)
{
//if we are exporting, we want to export the current xml
//not the referenced xml
- LLXUIParser::instance().readXUI(node, params, LLUICtrlFactory::getInstance()->getCurFileName());
+ parser.readXUI(node, params, LLUICtrlFactory::getInstance()->getCurFileName());
Params output_params(params);
setupParamsForExport(output_params, parent);
output_node->setName(node->getName()->mString);
- LLXUIParser::instance().writeXUI(
- output_node, output_params, &default_params);
+ parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params);
return TRUE;
}
+ LLUICtrlFactory::instance().pushFileName(xml_filename);
+
+ LL_RECORD_BLOCK_TIME(FTM_EXTERNAL_PANEL_LOAD);
if (!LLUICtrlFactory::getLayeredXMLNode(xml_filename, referenced_xml))
{
- llwarns << "Couldn't parse panel from: " << xml_filename << llendl;
+ LL_WARNS() << "Couldn't parse panel from: " << xml_filename << LL_ENDL;
return FALSE;
}
- LLXUIParser::instance().readXUI(referenced_xml, params, LLUICtrlFactory::getInstance()->getCurFileName());
+ parser.readXUI(referenced_xml, params, LLUICtrlFactory::getInstance()->getCurFileName());
// add children using dimensions from referenced xml for consistent layout
setShape(params.rect);
@@ -540,21 +556,20 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu
}
// ask LLUICtrlFactory for filename, since xml_filename might be empty
- LLXUIParser::instance().readXUI(node, params, LLUICtrlFactory::getInstance()->getCurFileName());
+ parser.readXUI(node, params, LLUICtrlFactory::getInstance()->getCurFileName());
if (output_node)
{
Params output_params(params);
setupParamsForExport(output_params, parent);
output_node->setName(node->getName()->mString);
- LLXUIParser::instance().writeXUI(
- output_node, output_params, &default_params);
+ parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params);
}
params.from_xui = true;
applyXUILayout(params, parent);
{
- LLFastTimer timer(FTM_PANEL_CONSTRUCTION);
+ LL_RECORD_BLOCK_TIME(FTM_PANEL_CONSTRUCTION);
initFromParams(params);
}
@@ -571,7 +586,7 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu
}
{
- LLFastTimer timer(FTM_PANEL_POSTBUILD);
+ LL_RECORD_BLOCK_TIME(FTM_PANEL_POSTBUILD);
postBuild();
}
}
@@ -596,11 +611,11 @@ std::string LLPanel::getString(const std::string& name, const LLStringUtil::form
std::string err_str("Failed to find string " + name + " in panel " + getName()); //*TODO: Translate
if(LLUI::sSettingGroups["config"]->getBOOL("QAMode"))
{
- llerrs << err_str << llendl;
+ LL_ERRS() << err_str << LL_ENDL;
}
else
{
- llwarns << err_str << llendl;
+ LL_WARNS() << err_str << LL_ENDL;
}
return LLStringUtil::null;
}
@@ -615,11 +630,11 @@ std::string LLPanel::getString(const std::string& name) const
std::string err_str("Failed to find string " + name + " in panel " + getName()); //*TODO: Translate
if(LLUI::sSettingGroups["config"]->getBOOL("QAMode"))
{
- llerrs << err_str << llendl;
+ LL_ERRS() << err_str << LL_ENDL;
}
else
{
- llwarns << err_str << llendl;
+ LL_WARNS() << err_str << LL_ENDL;
}
return LLStringUtil::null;
}
@@ -634,16 +649,6 @@ void LLPanel::childSetVisible(const std::string& id, bool visible)
}
}
-bool LLPanel::childIsVisible(const std::string& id) const
-{
- LLView* child = findChild<LLView>(id);
- if (child)
- {
- return (bool)child->getVisible();
- }
- return false;
-}
-
void LLPanel::childSetEnabled(const std::string& id, bool enabled)
{
LLView* child = findChild<LLView>(id);
@@ -653,55 +658,6 @@ void LLPanel::childSetEnabled(const std::string& id, bool enabled)
}
}
-void LLPanel::childSetTentative(const std::string& id, bool tentative)
-{
- LLUICtrl* child = findChild<LLUICtrl>(id);
- if (child)
- {
- child->setTentative(tentative);
- }
-}
-
-bool LLPanel::childIsEnabled(const std::string& id) const
-{
- LLView* child = findChild<LLView>(id);
- if (child)
- {
- return (bool)child->getEnabled();
- }
- return false;
-}
-
-
-void LLPanel::childSetToolTip(const std::string& id, const std::string& msg)
-{
- LLView* child = findChild<LLView>(id);
- if (child)
- {
- child->setToolTip(msg);
- }
-}
-
-void LLPanel::childSetRect(const std::string& id, const LLRect& rect)
-{
- LLView* child = findChild<LLView>(id);
- if (child)
- {
- child->setRect(rect);
- }
-}
-
-bool LLPanel::childGetRect(const std::string& id, LLRect& rect) const
-{
- LLView* child = findChild<LLView>(id);
- if (child)
- {
- rect = child->getRect();
- return true;
- }
- return false;
-}
-
void LLPanel::childSetFocus(const std::string& id, BOOL focus)
{
LLUICtrl* child = findChild<LLUICtrl>(id);
@@ -737,15 +693,6 @@ void LLPanel::childSetCommitCallback(const std::string& id, boost::function<void
}
}
-void LLPanel::childSetValidate(const std::string& id, boost::function<bool (const LLSD& data)> cb)
-{
- LLUICtrl* child = findChild<LLUICtrl>(id);
- if (child)
- {
- child->setValidateBeforeCommit(cb);
- }
-}
-
void LLPanel::childSetColor(const std::string& id, const LLColor4& color)
{
LLUICtrl* child = findChild<LLUICtrl>(id);
@@ -825,137 +772,106 @@ BOOL LLPanel::childSetLabelArg(const std::string& id, const std::string& key, co
return FALSE;
}
-BOOL LLPanel::childSetToolTipArg(const std::string& id, const std::string& key, const LLStringExplicit& text)
-{
- LLView* child = findChild<LLView>(id);
- if (child)
- {
- return child->setToolTipArg(key, text);
- }
- return FALSE;
-}
-
-void LLPanel::childShowTab(const std::string& id, const std::string& tabname, bool visible)
+void LLPanel::childSetAction(const std::string& id, const commit_signal_t::slot_type& function)
{
- LLTabContainer* child = findChild<LLTabContainer>(id);
- if (child)
+ LLButton* button = findChild<LLButton>(id);
+ if (button)
{
- child->selectTabByName(tabname);
+ button->setClickedCallback(function);
}
}
-LLPanel *LLPanel::childGetVisibleTab(const std::string& id) const
+void LLPanel::childSetAction(const std::string& id, boost::function<void(void*)> function, void* value)
{
- LLTabContainer* child = findChild<LLTabContainer>(id);
- if (child)
+ LLButton* button = findChild<LLButton>(id);
+ if (button)
{
- return child->getCurrentPanel();
+ button->setClickedCallback(boost::bind(function, value));
}
- return NULL;
}
-LLPanel* LLPanel::childGetVisibleTabWithHelp()
+boost::signals2::connection LLPanel::setVisibleCallback( const commit_signal_t::slot_type& cb )
{
- LLView *child;
-
- bfs_tree_iterator_t it = beginTreeBFS();
- // skip ourselves
- ++it;
- for (; it != endTreeBFS(); ++it)
+ if (!mVisibleSignal)
{
- child = *it;
- LLPanel *curTabPanel = NULL;
-
- // do we have a tab container?
- LLTabContainer *tab = dynamic_cast<LLTabContainer *>(child);
- if (tab && tab->getVisible())
- {
- curTabPanel = tab->getCurrentPanel();
- }
-
- // do we have an accordion tab?
- LLAccordionCtrlTab* accordion = dynamic_cast<LLAccordionCtrlTab *>(child);
- if (accordion && accordion->getDisplayChildren())
- {
- curTabPanel = dynamic_cast<LLPanel *>(accordion->getAccordionView());
- }
-
- // if we found a valid tab, does it have a help topic?
- if (curTabPanel && !curTabPanel->getHelpTopic().empty())
- {
- return curTabPanel;
- }
+ mVisibleSignal = new commit_signal_t();
}
- // couldn't find any active tabs with a help topic string
- return NULL;
+ return mVisibleSignal->connect(cb);
}
+static LLTrace::BlockTimerStatHandle FTM_BUILD_PANELS("Build Panels");
-LLPanel *LLPanel::childGetVisiblePanelWithHelp()
+//-----------------------------------------------------------------------------
+// buildPanel()
+//-----------------------------------------------------------------------------
+BOOL LLPanel::buildFromFile(const std::string& filename, const LLPanel::Params& default_params)
{
- LLView *child;
+ LL_RECORD_BLOCK_TIME(FTM_BUILD_PANELS);
+ BOOL didPost = FALSE;
+ LLXMLNodePtr root;
- bfs_tree_iterator_t it = beginTreeBFS();
- // skip ourselves
- ++it;
- for (; it != endTreeBFS(); ++it)
+ if (!LLUICtrlFactory::getLayeredXMLNode(filename, root))
{
- child = *it;
- // do we have a panel with a help topic?
- LLPanel *panel = dynamic_cast<LLPanel *>(child);
- if (panel && panel->getVisible() && !panel->getHelpTopic().empty())
- {
- return panel;
- }
+ LL_WARNS() << "Couldn't parse panel from: " << filename << LL_ENDL;
+ return didPost;
}
- // couldn't find any active panels with a help topic string
- return NULL;
-}
-
-void LLPanel::childSetAction(const std::string& id, const commit_signal_t::slot_type& function)
-{
- LLButton* button = findChild<LLButton>(id);
- if (button)
+ // root must be called panel
+ if( !root->hasName("panel" ) )
{
- button->setClickedCallback(function);
+ LL_WARNS() << "Root node should be named panel in : " << filename << LL_ENDL;
+ return didPost;
}
-}
-void LLPanel::childSetAction(const std::string& id, boost::function<void(void*)> function, void* value)
-{
- LLButton* button = findChild<LLButton>(id);
- if (button)
- {
- button->setClickedCallback(boost::bind(function, value));
- }
-}
+ LL_DEBUGS() << "Building panel " << filename << LL_ENDL;
-void LLPanel::childSetActionTextbox(const std::string& id, boost::function<void(void*)> function, void* value)
-{
- LLTextBox* textbox = findChild<LLTextBox>(id);
- if (textbox)
+ LLUICtrlFactory::instance().pushFileName(filename);
{
- textbox->setClickedCallback(boost::bind(function, value));
- }
-}
+ if (!getFactoryMap().empty())
+ {
+ sFactoryStack.push_back(&getFactoryMap());
+ }
+
+ // for local registry callbacks; define in constructor, referenced in XUI or postBuild
+ getCommitCallbackRegistrar().pushScope();
+ getEnableCallbackRegistrar().pushScope();
+
+ didPost = initPanelXML(root, NULL, NULL, default_params);
-void LLPanel::childSetControlName(const std::string& id, const std::string& control_name)
-{
- LLUICtrl* view = findChild<LLUICtrl>(id);
- if (view)
- {
- view->setControlName(control_name, NULL);
+ getCommitCallbackRegistrar().popScope();
+ getEnableCallbackRegistrar().popScope();
+
+ setXMLFilename(filename);
+
+ if (!getFactoryMap().empty())
+ {
+ sFactoryStack.pop_back();
+ }
}
+ LLUICtrlFactory::instance().popFileName();
+ return didPost;
}
-boost::signals2::connection LLPanel::setVisibleCallback( const commit_signal_t::slot_type& cb )
+//-----------------------------------------------------------------------------
+// createFactoryPanel()
+//-----------------------------------------------------------------------------
+LLPanel* LLPanel::createFactoryPanel(const std::string& name)
{
- if (!mVisibleSignal)
+ std::deque<const LLCallbackMap::map_t*>::iterator itor;
+ for (itor = sFactoryStack.begin(); itor != sFactoryStack.end(); ++itor)
{
- mVisibleSignal = new commit_signal_t();
- }
+ const LLCallbackMap::map_t* factory_map = *itor;
- return mVisibleSignal->connect(cb);
+ // Look up this panel's name in the map.
+ LLCallbackMap::map_const_iter_t iter = factory_map->find( name );
+ if (iter != factory_map->end())
+ {
+ // Use the factory to create the panel, instead of using a default LLPanel.
+ LLPanel *ret = (LLPanel*) iter->second.mCallback( iter->second.mData );
+ return ret;
+ }
+ }
+ LLPanel::Params panel_p;
+ return LLUICtrlFactory::create<LLPanel>(panel_p);
}