summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llbutton.cpp85
-rw-r--r--indra/llui/llbutton.h6
-rw-r--r--indra/llui/llcheckboxctrl.cpp6
-rw-r--r--indra/llui/llcheckboxctrl.h7
-rw-r--r--indra/llui/llcombobox.cpp6
-rw-r--r--indra/llui/llcombobox.h8
-rw-r--r--indra/llui/llcontainerview.cpp2
-rw-r--r--indra/llui/lldraghandle.h4
-rw-r--r--indra/llui/llfloater.cpp44
-rw-r--r--indra/llui/llfloater.h43
-rw-r--r--indra/llui/llflyoutbutton.cpp2
-rw-r--r--indra/llui/lliconctrl.cpp2
-rw-r--r--indra/llui/lllayoutstack.cpp8
-rw-r--r--indra/llui/lllineeditor.cpp8
-rw-r--r--indra/llui/lllineeditor.h6
-rw-r--r--indra/llui/llmenugl.cpp16
-rw-r--r--indra/llui/llmenugl.h14
-rw-r--r--indra/llui/llmultifloater.cpp3
-rw-r--r--indra/llui/llmultislider.cpp2
-rw-r--r--indra/llui/llmultisliderctrl.cpp2
-rw-r--r--indra/llui/llpanel.cpp18
-rw-r--r--indra/llui/llpanel.h4
-rw-r--r--indra/llui/llprogressbar.cpp2
-rw-r--r--indra/llui/llradiogroup.cpp11
-rw-r--r--indra/llui/llradiogroup.h9
-rw-r--r--indra/llui/llresizebar.h6
-rw-r--r--indra/llui/llscrollbar.cpp2
-rw-r--r--indra/llui/llscrollcontainer.cpp10
-rw-r--r--indra/llui/llscrollcontainer.h5
-rw-r--r--indra/llui/llscrollingpanellist.cpp2
-rw-r--r--indra/llui/llscrolllistcolumn.cpp2
-rw-r--r--indra/llui/llscrolllistctrl.cpp8
-rw-r--r--indra/llui/llscrolllistctrl.h7
-rw-r--r--indra/llui/llsearcheditor.cpp2
-rw-r--r--indra/llui/llslider.cpp2
-rw-r--r--indra/llui/llsliderctrl.cpp2
-rw-r--r--indra/llui/llspinctrl.cpp2
-rw-r--r--indra/llui/llstatview.cpp10
-rw-r--r--indra/llui/llstatview.h10
-rw-r--r--indra/llui/lltabcontainer.cpp4
-rw-r--r--indra/llui/lltextbox.cpp6
-rw-r--r--indra/llui/lltextbox.h7
-rw-r--r--indra/llui/lltexteditor.cpp4
-rw-r--r--indra/llui/llui.cpp22
-rw-r--r--indra/llui/llui.h6
-rw-r--r--indra/llui/lluictrl.cpp4
-rw-r--r--indra/llui/lluictrl.h8
-rw-r--r--indra/llui/lluictrlfactory.cpp503
-rw-r--r--indra/llui/lluictrlfactory.h171
-rw-r--r--indra/llui/lluiimage.h4
-rw-r--r--indra/llui/llview.cpp20
-rw-r--r--indra/llui/llview.h27
-rw-r--r--indra/llui/llviewborder.cpp8
-rw-r--r--indra/llui/llviewborder.h2
54 files changed, 875 insertions, 309 deletions
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp
index f2aa9c0d4c..9ad27e7c41 100644
--- a/indra/llui/llbutton.cpp
+++ b/indra/llui/llbutton.cpp
@@ -32,7 +32,6 @@
#include "linden_common.h"
-#define INSTANTIATE_GETCHILD_BUTTON
#include "llbutton.h"
// Linden library includes
@@ -53,7 +52,7 @@
#include "llrender.h"
#include "lluictrlfactory.h"
-static LLDefaultWidgetRegistry::Register<LLButton> r("button");
+static LLDefaultChildRegistry::Register<LLButton> r("button");
// globals loaded from settings.xml
S32 LLBUTTON_H_PAD = 0;
@@ -61,8 +60,6 @@ S32 LLBUTTON_V_PAD = 0;
S32 BTN_HEIGHT_SMALL= 0;
S32 BTN_HEIGHT = 0;
-template LLButton* LLView::getChild<LLButton>( const std::string& name, BOOL recurse, BOOL create_if_missing ) const;
-
LLButton::Params::Params()
: label_selected("label_selected"), // requires is_toggle true
label_dropshadow("label_shadow", true),
@@ -146,7 +143,7 @@ LLButton::LLButton(const LLButton::Params& p)
mFadeWhenDisabled(FALSE)
{
static LLUICachedControl<S32> llbutton_orig_h_pad ("UIButtonOrigHPad", 0);
- static Params default_params(LLUICtrlFactory::getDefaultParams<Params>());
+ static Params default_params(LLUICtrlFactory::getDefaultParams<LLButton>());
//if we aren't a picture_style button set label as name if not provided
if (!p.picture_style.isProvided() || !p.picture_style)
@@ -328,25 +325,27 @@ BOOL LLButton::handleKeyHere(KEY key, MASK mask )
BOOL LLButton::handleMouseDown(S32 x, S32 y, MASK mask)
{
- // Route future Mouse messages here preemptively. (Release on mouse up.)
- gFocusMgr.setMouseCapture( this );
-
- if (hasTabStop() && !getIsChrome())
+ if (!childrenHandleMouseDown(x, y, mask))
{
- setFocus(TRUE);
- }
+ // Route future Mouse messages here preemptively. (Release on mouse up.)
+ gFocusMgr.setMouseCapture( this );
- mMouseDownSignal(this, LLSD());
+ if (hasTabStop() && !getIsChrome())
+ {
+ setFocus(TRUE);
+ }
- mMouseDownTimer.start();
- mMouseDownFrame = (S32) LLFrameTimer::getFrameCount();
- mMouseHeldDownCount = 0;
-
- if (getSoundFlags() & MOUSE_DOWN)
- {
- make_ui_sound("UISndClick");
- }
+ mMouseDownSignal(this, LLSD());
+ mMouseDownTimer.start();
+ mMouseDownFrame = (S32) LLFrameTimer::getFrameCount();
+ mMouseHeldDownCount = 0;
+
+ if (getSoundFlags() & MOUSE_DOWN)
+ {
+ make_ui_sound("UISndClick");
+ }
+ }
return TRUE;
}
@@ -381,20 +380,26 @@ BOOL LLButton::handleMouseUp(S32 x, S32 y, MASK mask)
LLUICtrl::onCommit();
}
}
+ else
+ {
+ childrenHandleMouseUp(x, y, mask);
+ }
return TRUE;
}
BOOL LLButton::handleRightMouseDown(S32 x, S32 y, MASK mask)
{
- // Route future Mouse messages here preemptively. (Release on mouse up.)
- gFocusMgr.setMouseCapture( this );
-
- if (hasTabStop() && !getIsChrome())
+ if (!childrenHandleRightMouseDown(x, y, mask))
{
- setFocus(TRUE);
- }
+ // Route future Mouse messages here preemptively. (Release on mouse up.)
+ gFocusMgr.setMouseCapture( this );
+ if (hasTabStop() && !getIsChrome())
+ {
+ setFocus(TRUE);
+ }
+ }
return TRUE;
}
@@ -412,6 +417,10 @@ BOOL LLButton::handleRightMouseUp(S32 x, S32 y, MASK mask)
mRightClickSignal(this, getValue());
}
}
+ else
+ {
+ childrenHandleRightMouseUp(x, y, mask);
+ }
return TRUE;
}
@@ -429,21 +438,23 @@ void LLButton::onMouseLeave(S32 x, S32 y, MASK mask)
BOOL LLButton::handleHover(S32 x, S32 y, MASK mask)
{
- if (mMouseDownTimer.getStarted())
+ if (!childrenHandleHover(x, y, mask))
{
- F32 elapsed = getHeldDownTime();
- if( mHeldDownDelay <= elapsed && mHeldDownFrameDelay <= (S32)LLFrameTimer::getFrameCount() - mMouseDownFrame)
+ if (mMouseDownTimer.getStarted())
{
- LLSD param;
- param["count"] = mMouseHeldDownCount++;
- mHeldDownSignal(this, param);
+ F32 elapsed = getHeldDownTime();
+ if( mHeldDownDelay <= elapsed && mHeldDownFrameDelay <= (S32)LLFrameTimer::getFrameCount() - mMouseDownFrame)
+ {
+ LLSD param;
+ param["count"] = mMouseHeldDownCount++;
+ mHeldDownSignal(this, param);
+ }
}
- }
-
- // We only handle the click if the click both started and ended within us
- getWindow()->setCursor(UI_CURSOR_ARROW);
- lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << llendl;
+ // We only handle the click if the click both started and ended within us
+ getWindow()->setCursor(UI_CURSOR_ARROW);
+ lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << llendl;
+ }
return TRUE;
}
diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h
index 1398e5c14b..3fa62cc351 100644
--- a/indra/llui/llbutton.h
+++ b/indra/llui/llbutton.h
@@ -352,11 +352,5 @@ private:
LLFrameTimer mFlashingTimer;
};
-#ifdef LL_WINDOWS
-#ifndef INSTANTIATE_GETCHILD_BUTTON
-#pragma warning (disable : 4231)
-extern template LLButton* LLView::getChild<LLButton>( const std::string& name, BOOL recurse, BOOL create_if_missing ) const;
-#endif
-#endif
#endif // LL_LLBUTTON_H
diff --git a/indra/llui/llcheckboxctrl.cpp b/indra/llui/llcheckboxctrl.cpp
index 932a1b6297..b43f91e766 100644
--- a/indra/llui/llcheckboxctrl.cpp
+++ b/indra/llui/llcheckboxctrl.cpp
@@ -31,8 +31,6 @@
*/
// The mutants are coming!
-#define INSTANTIATE_GETCHILD_CHECKBOX
-
#include "linden_common.h"
#include "llcheckboxctrl.h"
@@ -50,9 +48,7 @@
const U32 MAX_STRING_LENGTH = 10;
-template LLCheckBoxCtrl* LLView::getChild<LLCheckBoxCtrl>( const std::string& name, BOOL recurse, BOOL create_if_missing ) const;
-
-static LLDefaultWidgetRegistry::Register<LLCheckBoxCtrl> r("check_box");
+static LLDefaultChildRegistry::Register<LLCheckBoxCtrl> r("check_box");
LLCheckBoxCtrl::Params::Params()
: text_enabled_color("text_enabled_color"),
diff --git a/indra/llui/llcheckboxctrl.h b/indra/llui/llcheckboxctrl.h
index 2f8f088a3e..2f8e8fdd23 100644
--- a/indra/llui/llcheckboxctrl.h
+++ b/indra/llui/llcheckboxctrl.h
@@ -126,11 +126,4 @@ protected:
};
-#ifdef LL_WINDOWS
-#ifndef INSTANTIATE_GETCHILD_CHECKBOX
-#pragma warning (disable : 4231)
-extern template LLCheckBoxCtrl* LLView::getChild<LLCheckBoxCtrl>( const std::string& name, BOOL recurse, BOOL create_if_missing ) const;
-#endif
-#endif
-
#endif // LL_LLCHECKBOXCTRL_H
diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp
index e19eacb774..5dfca4be16 100644
--- a/indra/llui/llcombobox.cpp
+++ b/indra/llui/llcombobox.cpp
@@ -33,8 +33,6 @@
// A control that displays the name of the chosen item, which when
// clicked shows a scrolling box of options.
-#define INSTANTIATE_GETCHILD_COMBOBOX
-
#include "linden_common.h"
// file includes
@@ -63,9 +61,7 @@ S32 LLCOMBOBOX_HEIGHT = 0;
S32 LLCOMBOBOX_WIDTH = 0;
S32 MAX_COMBO_WIDTH = 500;
-template LLComboBox* LLView::getChild<LLComboBox>( const std::string& name, BOOL recurse, BOOL create_if_missing ) const;
-
-static LLDefaultWidgetRegistry::Register<LLComboBox> register_combo_box("combo_box");
+static LLDefaultChildRegistry::Register<LLComboBox> register_combo_box("combo_box");
void LLComboBox::PreferredPositionValues::declareValues()
{
diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h
index cb5f72dcbe..4c0d10dc40 100644
--- a/indra/llui/llcombobox.h
+++ b/indra/llui/llcombobox.h
@@ -234,12 +234,4 @@ private:
commit_callback_t mTextEntryCallback;
commit_callback_t mSelectionCallback;
};
-
-#ifdef LL_WINDOWS
-#ifndef INSTANTIATE_GETCHILD_COMBOBOX
-#pragma warning (disable : 4231)
-extern template LLComboBox* LLView::getChild<LLComboBox>( const std::string& name, BOOL recurse, BOOL create_if_missing ) const;
-#endif
-#endif
-
#endif
diff --git a/indra/llui/llcontainerview.cpp b/indra/llui/llcontainerview.cpp
index 40cc430e25..96948b659f 100644
--- a/indra/llui/llcontainerview.cpp
+++ b/indra/llui/llcontainerview.cpp
@@ -42,7 +42,7 @@
#include "llscrollcontainer.h"
#include "lluictrlfactory.h"
-static LLDefaultWidgetRegistry::Register<LLContainerView> r("container_view");
+static LLDefaultChildRegistry::Register<LLContainerView> r("container_view");
LLContainerView::LLContainerView(const LLContainerView::Params& p)
: LLView(p),
diff --git a/indra/llui/lldraghandle.h b/indra/llui/lldraghandle.h
index 0448c20068..86eef7c42c 100644
--- a/indra/llui/lldraghandle.h
+++ b/indra/llui/lldraghandle.h
@@ -53,8 +53,8 @@ public:
Optional<LLUIColor> drag_shadow_color;
Params()
- : drag_highlight_color("", LLUIColorTable::instance().getColor("DefaultHighlightLight")),
- drag_shadow_color("", LLUIColorTable::instance().getColor("DefaultShadowDark"))
+ : drag_highlight_color("drag_highlight_color", LLUIColorTable::instance().getColor("DefaultHighlightLight")),
+ drag_shadow_color("drag_shadow_color", LLUIColorTable::instance().getColor("DefaultShadowDark"))
{
mouse_opaque(true);
follows.flags(FOLLOWS_ALL);
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index d37459c040..c8bbdb0a56 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -191,7 +191,7 @@ bool LLFloater::KeyCompare::equate(const LLSD& a, const LLSD& b)
//static
const LLFloater::Params& LLFloater::getDefaultParams()
{
- return LLUICtrlFactory::getDefaultParams<LLFloater::Params>();
+ return LLUICtrlFactory::getDefaultParams<LLFloater>();
}
@@ -560,6 +560,7 @@ void LLFloater::openFloater(const LLSD& key)
setVisibleAndFrontmost(mAutoFocus);
}
+ mOpenSignal(this, getValue());
onOpen(key);
}
@@ -623,6 +624,7 @@ void LLFloater::closeFloater(bool app_quitting)
}
// Let floater do cleanup.
+ mCloseSignal(this, getValue());
onClose(app_quitting);
}
}
@@ -1709,6 +1711,33 @@ void LLFloater::buildButtons()
updateButtons();
}
+void LLFloater::initOpenCallback(const OpenCallbackParam& cb, open_signal_t& sig)
+{
+ if (cb.function.isProvided())
+ {
+ if (cb.parameter.isProvided())
+ sig.connect(boost::bind(cb.function(), _1, cb.parameter));
+ else
+ sig.connect(cb.function());
+ }
+ else
+ {
+ std::string function_name = cb.function_name;
+ open_callback_t* func = (CallbackRegistry<open_callback_t>::getValue(function_name));
+ if (func)
+ {
+ if (cb.parameter.isProvided())
+ sig.connect(boost::bind((*func), _1, cb.parameter));
+ else
+ sig.connect(*func);
+ }
+ else if (!function_name.empty())
+ {
+ llwarns << "No callback found for: '" << function_name << "' in control: " << getName() << llendl;
+ }
+ }
+}
+
/////////////////////////////////////////////////////
// LLFloaterView
@@ -2462,18 +2491,25 @@ void LLFloater::initFromParams(const LLFloater::Params& p)
{
mVisibilityControl = "t"; // flag to build mVisibilityControl name once mInstanceName is set
}
+
+ // open callback
+ if (p.open_callback.isProvided())
+ initOpenCallback(p.open_callback, mOpenSignal);
+ // close callback
+ if (p.close_callback.isProvided())
+ initOpenCallback(p.close_callback, mCloseSignal);
}
void LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, BOOL open_floater, LLXMLNodePtr output_node)
{
- Params params(LLUICtrlFactory::getDefaultParams<LLFloater::Params>());
+ Params params(LLUICtrlFactory::getDefaultParams<LLFloater>());
LLXUIParser::instance().readXUI(node, params);
if (output_node)
{
Params output_params(params);
setupParamsForExport(output_params, parent);
- Params default_params(LLUICtrlFactory::getDefaultParams<LLFloater::Params>());
+ Params default_params(LLUICtrlFactory::getDefaultParams<LLFloater>());
output_node->setName(node->getName()->mString);
LLXUIParser::instance().writeXUI(
output_node, output_params, &default_params);
@@ -2490,7 +2526,7 @@ void LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, BOOL open_floa
LLFloater::setFloaterHost((LLMultiFloater*) this);
}
- LLUICtrlFactory::createChildren(this, node, output_node);
+ LLUICtrlFactory::createChildren(this, node, child_registry_t::instance(), output_node);
if (node->hasName("multi_floater"))
{
diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h
index 3e80f1b284..c639f90390 100644
--- a/indra/llui/llfloater.h
+++ b/indra/llui/llfloater.h
@@ -105,6 +105,17 @@ public:
BUTTON_COUNT
};
+ typedef boost::function<void (LLUICtrl* ctrl, const LLSD& param)> open_callback_t;
+ typedef boost::signals2::signal<void (LLUICtrl* ctrl, const LLSD& param)> open_signal_t;
+
+ typedef boost::function<void (LLUICtrl* ctrl, const LLSD& param)> close_callback_t;
+ typedef boost::signals2::signal<void (LLUICtrl* ctrl, const LLSD& param)> close_signal_t;
+
+ struct OpenCallbackParam : public LLInitParam::Block<OpenCallbackParam, CallbackParam >
+ {
+ Optional<open_callback_t> function;
+ };
+
struct Params
: public LLInitParam::Block<Params, LLPanel::Params>
{
@@ -120,7 +131,10 @@ public:
can_tear_off,
save_rect,
save_visibility;
-
+
+ Optional<OpenCallbackParam> open_callback,
+ close_callback;
+
Params() :
title("title"),
short_title("short_title"),
@@ -132,7 +146,9 @@ public:
can_drag_on_left("can_drag_on_left", false),
can_tear_off("can_tear_off", true),
save_rect("save_rect", false),
- save_visibility("save_visibility", false)
+ save_visibility("save_visibility", false),
+ open_callback("open_callback"),
+ close_callback("close_callback")
{
name = "floater";
// defaults that differ from LLPanel:
@@ -289,8 +305,9 @@ protected:
void destroy() { die(); } // Don't call this directly. You probably want to call close(). JC
+ void initOpenCallback(const OpenCallbackParam& cb, open_signal_t& sig);
+
private:
-
void setForeground(BOOL b); // called only by floaterview
void cleanupHandles(); // remove handles to dead floaters
void createMinimizeButton();
@@ -299,11 +316,15 @@ private:
BOOL offerClickToButton(S32 x, S32 y, MASK mask, EFloaterButtons index);
void addResizeCtrls();
void addDragHandle();
-
+
+public:
+ typedef CallbackRegistry<open_callback_t> OpenCallbackRegistry;
+
protected:
std::string mRectControl;
std::string mVisibilityControl;
-
+ open_signal_t mOpenSignal;
+ open_signal_t mCloseSignal;
LLSD mKey; // Key used for retrieving instances; set (for now) by LLFLoaterReg
private:
@@ -378,6 +399,7 @@ private:
LLRootHandle<LLFloater> mHandle;
};
+
/////////////////////////////////////////////////////////////
// LLFloaterView
// Parent of all floating panels
@@ -441,9 +463,6 @@ private:
S32 mSnapOffsetRight;
};
-// singleton implementation for floaters
-// https://wiki.lindenlab.com/mediawiki/index.php?title=LLFloaterSingleton&oldid=164990
-
//*******************************************************
//* TO BE DEPRECATED
//*******************************************************
@@ -460,14 +479,6 @@ public:
static void hide(LLFloater* instance, const LLSD& key);
};
-
-// singleton implementation for floaters (provides visibility policy)
-// https://wiki.lindenlab.com/mediawiki/index.php?title=LLFloaterSingleton&oldid=164990
-
-template <class T> class LLFloaterSingleton : public LLUISingleton<T, VisibilityPolicy<LLFloater> >
-{
-};
-
//
// Globals
//
diff --git a/indra/llui/llflyoutbutton.cpp b/indra/llui/llflyoutbutton.cpp
index a99c3a4fe6..536919c072 100644
--- a/indra/llui/llflyoutbutton.cpp
+++ b/indra/llui/llflyoutbutton.cpp
@@ -35,7 +35,7 @@
// file includes
#include "llflyoutbutton.h"
-//static LLDefaultWidgetRegistry::Register<LLFlyoutButton> r2("flyout_button");
+//static LLDefaultChildRegistry::Register<LLFlyoutButton> r2("flyout_button");
const S32 FLYOUT_BUTTON_ARROW_WIDTH = 24;
diff --git a/indra/llui/lliconctrl.cpp b/indra/llui/lliconctrl.cpp
index eddfc71284..5c6ea663f3 100644
--- a/indra/llui/lliconctrl.cpp
+++ b/indra/llui/lliconctrl.cpp
@@ -42,7 +42,7 @@
#include "lluictrlfactory.h"
#include "lluiimage.h"
-static LLDefaultWidgetRegistry::Register<LLIconCtrl> r("icon");
+static LLDefaultChildRegistry::Register<LLIconCtrl> r("icon");
LLIconCtrl::Params::Params()
: image("image_name"),
diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp
index 39dac296ea..f1e7d791d4 100644
--- a/indra/llui/lllayoutstack.cpp
+++ b/indra/llui/lllayoutstack.cpp
@@ -38,7 +38,7 @@
#include "llresizebar.h"
#include "llcriticaldamp.h"
-static LLDefaultWidgetRegistry::Register<LLLayoutStack> register_layout_stack("layout_stack", &LLLayoutStack::fromXML);
+static LLDefaultChildRegistry::Register<LLLayoutStack> register_layout_stack("layout_stack", &LLLayoutStack::fromXML);
//
@@ -223,7 +223,7 @@ static void get_attribute_bool_and_write(LLXMLNodePtr node,
//static
LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node)
{
- LLLayoutStack::Params p(LLUICtrlFactory::getDefaultParams<LLLayoutStack::Params>());
+ LLLayoutStack::Params p(LLUICtrlFactory::getDefaultParams<LLLayoutStack>());
LLXUIParser::instance().readXUI(node, p);
// Export must happen before setupParams() mungles rectangles and before
@@ -233,7 +233,7 @@ LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr o
{
Params output_params(p);
setupParamsForExport(output_params, parent);
- LLLayoutStack::Params default_params(LLUICtrlFactory::getDefaultParams<LLLayoutStack::Params>());
+ LLLayoutStack::Params default_params(LLUICtrlFactory::getDefaultParams<LLLayoutStack>());
output_node->setName(node->getName()->mString);
LLXUIParser::instance().writeXUI(
output_node, output_params, &default_params);
@@ -296,7 +296,7 @@ LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr o
LLPanel::Params p;
LLPanel* panelp = LLUICtrlFactory::create<LLPanel>(p);
- LLView* new_child = LLUICtrlFactory::getInstance()->createFromXML(child_node, panelp, LLStringUtil::null, output_child, parent ? parent->getChildRegistry() : LLDefaultWidgetRegistry::instance());
+ LLView* new_child = LLUICtrlFactory::getInstance()->createFromXML(child_node, panelp, LLStringUtil::null, LLPanel::child_registry_t::instance(), output_child);
if (new_child)
{
// put child in new embedded panel
diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp
index 925f22d94e..f3afadca15 100644
--- a/indra/llui/lllineeditor.cpp
+++ b/indra/llui/lllineeditor.cpp
@@ -34,8 +34,6 @@
#include "linden_common.h"
-#define INSTANTIATE_GETCHILD_LINEEDITOR
-
#include "lllineeditor.h"
#include "lltexteditor.h"
@@ -72,9 +70,7 @@ const S32 SCROLL_INCREMENT_DEL = 4; // make space for baskspacing
const F32 AUTO_SCROLL_TIME = 0.05f;
const F32 TRIPLE_CLICK_INTERVAL = 0.3f; // delay between double and triple click. *TODO: make this equal to the double click interval?
-static LLDefaultWidgetRegistry::Register<LLLineEditor> r1("line_editor");
-
-template LLLineEditor* LLView::getChild<LLLineEditor>( const std::string& name, BOOL recurse, BOOL create_if_missing ) const;
+static LLDefaultChildRegistry::Register<LLLineEditor> r1("line_editor");
//
// Member functions
@@ -180,7 +176,7 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p)
LLViewBorder::Params border_p(p.border);
border_p.rect = border_rect;
border_p.follows.flags = FOLLOWS_ALL;
- border_p.bevel_type = LLViewBorder::BEVEL_IN;
+ border_p.bevel_style = LLViewBorder::BEVEL_IN;
mBorder = LLUICtrlFactory::create<LLViewBorder>(border_p);
addChild( mBorder );
diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h
index eb021bace9..4362cff2fe 100644
--- a/indra/llui/lllineeditor.h
+++ b/indra/llui/lllineeditor.h
@@ -392,12 +392,6 @@ private:
}; // end class LLLineEditor
-#ifdef LL_WINDOWS
-#ifndef INSTANTIATE_GETCHILD_LINEEDITOR
-#pragma warning (disable : 4231)
-extern template LLLineEditor* LLView::getChild<LLLineEditor>( const std::string& name, BOOL recurse, BOOL create_if_missing ) const;
-#endif
-#endif
namespace LLInitParam
{
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index e79afe76d8..4d2374a7e8 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -119,16 +119,12 @@ const F32 PIE_SHRINK_TIME = 0.2f; // time of transition between unbounded and bo
const F32 ACTIVATE_HIGHLIGHT_TIME = 0.3f;
-// widget registrars
-struct MenuRegistry : public LLWidgetRegistry<MenuRegistry>
-{};
-
static MenuRegistry::Register<LLMenuItemSeparatorGL> register_separator("menu_item_separator");
static MenuRegistry::Register<LLMenuItemCallGL> register_menu_item_call("menu_item_call");
static MenuRegistry::Register<LLMenuItemCheckGL> register_menu_item_check("menu_item_check");
static MenuRegistry::Register<LLMenuGL> register_menu("menu");
-static LLDefaultWidgetRegistry::Register<LLMenuGL> register_menu_default("menu");
+static LLDefaultChildRegistry::Register<LLMenuGL> register_menu_default("menu");
@@ -1666,12 +1662,6 @@ BOOL LLMenuGL::postBuild()
return LLUICtrl::postBuild();
}
-const widget_registry_t& LLMenuGL::getChildRegistry() const
-{
- return MenuRegistry::instance();
-}
-
-
// are we the childmost active menu and hence our jump keys should be enabled?
// or are we a free-standing torn-off menu (which uses jump keys too)
BOOL LLMenuGL::jumpKeysActive()
@@ -2885,7 +2875,7 @@ void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y)
/// Class LLMenuBarGL
///============================================================================
-static LLDefaultWidgetRegistry::Register<LLMenuBarGL> r2("menu_bar");
+static LLDefaultChildRegistry::Register<LLMenuBarGL> r2("menu_bar");
LLMenuBarGL::LLMenuBarGL( const Params& p )
: LLMenuGL(p),
@@ -3571,7 +3561,7 @@ void LLContextMenuBranch::setHighlight( BOOL highlight )
// class LLContextMenu
// A context menu
//-----------------------------------------------------------------------------
-static LLDefaultWidgetRegistry::Register<LLContextMenu> context_menu_register("context_menu");
+static LLDefaultChildRegistry::Register<LLContextMenu> context_menu_register("context_menu");
static MenuRegistry::Register<LLContextMenu> context_menu_register2("context_menu");
diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h
index ad257f46c2..ef27c2c9c8 100644
--- a/indra/llui/llmenugl.h
+++ b/indra/llui/llmenugl.h
@@ -81,7 +81,7 @@ public:
Params()
: shortcut("shortcut"),
- jump_key("", KEY_NONE),
+ jump_key("jump_key", KEY_NONE),
use_mac_ctrl("use_mac_ctrl", false),
rect("rect"),
left("left"),
@@ -356,6 +356,11 @@ private:
// it in the appendMenu() method.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// child widget registry
+struct MenuRegistry : public LLChildRegistry<MenuRegistry>
+{};
+
+
class LLMenuGL
: public LLUICtrl
{
@@ -374,7 +379,7 @@ public:
Optional<LLUIColor> bg_color;
Params()
- : jump_key("", KEY_NONE),
+ : jump_key("jump_key", KEY_NONE),
can_tear_off("tear_off", false),
drop_shadow("drop_shadow", true),
bg_visible("bg_visible", true),
@@ -388,6 +393,10 @@ public:
name = "menu";
}
};
+
+ // my valid children are contained in MenuRegistry
+ typedef MenuRegistry child_registry_t;
+
void initFromParams(const Params&);
protected:
@@ -410,7 +419,6 @@ public:
/*virtual*/ bool addChild(LLView* view, S32 tab_group = 0);
/*virtual*/ void removeChild( LLView* ctrl);
/*virtual*/ BOOL postBuild();
- /*virtual*/ const widget_registry_t& getChildRegistry() const;
virtual BOOL handleAcceleratorKey(KEY key, MASK mask);
diff --git a/indra/llui/llmultifloater.cpp b/indra/llui/llmultifloater.cpp
index c0fe7ff32d..22683d7950 100644
--- a/indra/llui/llmultifloater.cpp
+++ b/indra/llui/llmultifloater.cpp
@@ -275,6 +275,7 @@ void LLMultiFloater::selectPrevFloater()
void LLMultiFloater::showFloater(LLFloater* floaterp, LLTabContainer::eInsertionPoint insertion_point)
{
+ if(!floaterp) return;
// we won't select a panel that already is selected
// it is hard to do this internally to tab container
// as tab selection is handled via index and the tab at a given
@@ -288,7 +289,7 @@ void LLMultiFloater::showFloater(LLFloater* floaterp, LLTabContainer::eInsertion
void LLMultiFloater::removeFloater(LLFloater* floaterp)
{
- if ( floaterp->getHost() != this )
+ if (!floaterp || floaterp->getHost() != this )
return;
floater_data_map_t::iterator found_data_it = mFloaterDataMap.find(floaterp->getHandle());
diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp
index 099a79278a..0454771511 100644
--- a/indra/llui/llmultislider.cpp
+++ b/indra/llui/llmultislider.cpp
@@ -45,7 +45,7 @@
#include <sstream>
-static LLDefaultWidgetRegistry::Register<LLMultiSlider> r("multi_slider_bar");
+static LLDefaultChildRegistry::Register<LLMultiSlider> r("multi_slider_bar");
const F32 FLOAT_THRESHOLD = 0.00001f;
diff --git a/indra/llui/llmultisliderctrl.cpp b/indra/llui/llmultisliderctrl.cpp
index 312aceaaa2..1523d5d527 100644
--- a/indra/llui/llmultisliderctrl.cpp
+++ b/indra/llui/llmultisliderctrl.cpp
@@ -52,7 +52,7 @@
#include "llresmgr.h"
#include "lluictrlfactory.h"
-static LLDefaultWidgetRegistry::Register<LLMultiSliderCtrl> r("multi_slider");
+static LLDefaultChildRegistry::Register<LLMultiSliderCtrl> r("multi_slider");
const U32 MAX_STRING_LENGTH = 10;
LLMultiSliderCtrl::Params::Params()
diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp
index 6a6e15867b..2119ed4daf 100644
--- a/indra/llui/llpanel.cpp
+++ b/indra/llui/llpanel.cpp
@@ -56,11 +56,11 @@
#include "llbutton.h"
#include "lltabcontainer.h"
-static LLDefaultWidgetRegistry::Register<LLPanel> r1("panel", &LLPanel::fromXML);
+static LLDefaultChildRegistry::Register<LLPanel> r1("panel", &LLPanel::fromXML);
const LLPanel::Params& LLPanel::getDefaultParams()
{
- return LLUICtrlFactory::getDefaultParams<LLPanel::Params>();
+ return LLUICtrlFactory::getDefaultParams<LLPanel>();
}
LLPanel::Params::Params()
@@ -433,7 +433,7 @@ void LLPanel::initFromParams(const LLPanel::Params& p)
parseFollowsFlags(p);
setToolTip(p.tool_tip());
- setSaveToXML(p.serializable);
+ setSaveToXML(p.from_xui);
mHoverCursor = getCursorFromString(p.hover_cursor);
@@ -462,7 +462,7 @@ static LLFastTimer::DeclareTimer FTM_PANEL_POSTBUILD("Panel PostBuild");
BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node)
{
- const LLPanel::Params& default_params(LLUICtrlFactory::getDefaultParams<LLPanel::Params>());
+ const LLPanel::Params& default_params(LLUICtrlFactory::getDefaultParams<LLPanel>());
Params params(default_params);
{
@@ -499,7 +499,7 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu
// add children using dimensions from referenced xml for consistent layout
setShape(params.rect);
- LLUICtrlFactory::createChildren(this, referenced_xml);
+ LLUICtrlFactory::createChildren(this, referenced_xml, child_registry_t::instance());
}
LLXUIParser::instance().readXUI(node, params);
@@ -520,7 +520,7 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu
}
// add children
- LLUICtrlFactory::createChildren(this, node, output_node);
+ LLUICtrlFactory::createChildren(this, node, child_registry_t::instance(), output_node);
// Connect to parent after children are built, because tab containers
// do a reshape() on their child panels, which requires that the children
@@ -539,12 +539,6 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu
return TRUE;
}
-const widget_registry_t& LLPanel::getChildRegistry() const
-{
- // use default widget registry
- return LLDefaultWidgetRegistry::instance();
-}
-
bool LLPanel::hasString(const std::string& name)
{
return mUIStrings.find(name) != mUIStrings.end();
diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h
index c38e9df53b..ca3b2e7e23 100644
--- a/indra/llui/llpanel.h
+++ b/indra/llui/llpanel.h
@@ -93,6 +93,9 @@ public:
Params();
};
+ // valid children for LLPanel are stored in this registry
+ typedef LLDefaultChildRegistry child_registry_t;
+
protected:
friend class LLUICtrlFactory;
// RN: for some reason you can't just use LLUICtrlFactory::getDefaultParams as a default argument in VC8
@@ -165,7 +168,6 @@ public:
void initFromParams(const Params& p);
BOOL initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node = NULL);
- /*virtual*/ const widget_registry_t& getChildRegistry() const;
bool hasString(const std::string& name);
std::string getString(const std::string& name, const LLStringUtil::format_map_t& args) const;
diff --git a/indra/llui/llprogressbar.cpp b/indra/llui/llprogressbar.cpp
index 779967940a..12353e4c3e 100644
--- a/indra/llui/llprogressbar.cpp
+++ b/indra/llui/llprogressbar.cpp
@@ -46,7 +46,7 @@
#include "llfocusmgr.h"
#include "lluictrlfactory.h"
-static LLDefaultWidgetRegistry::Register<LLProgressBar> r("progress_bar");
+static LLDefaultChildRegistry::Register<LLProgressBar> r("progress_bar");
LLProgressBar::Params::Params()
: image_bar("image_bar"),
diff --git a/indra/llui/llradiogroup.cpp b/indra/llui/llradiogroup.cpp
index 70f98bd908..30adbb023c 100644
--- a/indra/llui/llradiogroup.cpp
+++ b/indra/llui/llradiogroup.cpp
@@ -44,10 +44,8 @@
#include "llfocusmgr.h"
#include "lluictrlfactory.h"
-static LLDefaultWidgetRegistry::Register<LLRadioGroup> r1("radio_group");
+static LLDefaultChildRegistry::Register<LLRadioGroup> r1("radio_group");
-struct RadioGroupRegistry : public LLWidgetRegistry<RadioGroupRegistry>
-{};
static RadioGroupRegistry::Register<LLRadioCtrl> register_radio_ctrl("radio_item");
@@ -72,7 +70,7 @@ LLRadioGroup::LLRadioGroup(const LLRadioGroup::Params& p)
LLViewBorder::Params params;
params.name("radio group border");
params.rect(LLRect(0, getRect().getHeight(), getRect().getWidth(), 0));
- params.bevel_type(LLViewBorder::BEVEL_NONE);
+ params.bevel_style(LLViewBorder::BEVEL_NONE);
LLViewBorder * vb = LLUICtrlFactory::create<LLViewBorder> (params);
addChild (vb);
}
@@ -82,11 +80,6 @@ LLRadioGroup::~LLRadioGroup()
{
}
-const widget_registry_t& LLRadioGroup::getChildRegistry() const
-{
- return RadioGroupRegistry::instance();
-}
-
// virtual
BOOL LLRadioGroup::postBuild()
{
diff --git a/indra/llui/llradiogroup.h b/indra/llui/llradiogroup.h
index 850d896e29..d04473fa44 100644
--- a/indra/llui/llradiogroup.h
+++ b/indra/llui/llradiogroup.h
@@ -70,6 +70,10 @@ protected:
friend class LLUICtrlFactory;
};
+
+struct RadioGroupRegistry : public LLChildRegistry<RadioGroupRegistry>
+{};
+
/*
* An invisible view containing multiple mutually exclusive toggling
* buttons (usually radio buttons). Automatically handles the mutex
@@ -86,6 +90,9 @@ public:
Params();
};
+ // my valid children are stored in this registry
+ typedef RadioGroupRegistry child_registry_t;
+
protected:
LLRadioGroup(const Params&);
friend class LLUICtrlFactory;
@@ -118,8 +125,6 @@ public:
// Update the control as needed. Userdata must be a pointer to the button.
void onClickButton(LLUICtrl* clicked_radio);
- virtual const widget_registry_t& getChildRegistry() const;
-
//========================================================================
LLCtrlSelectionInterface* getSelectionInterface() { return (LLCtrlSelectionInterface*)this; };
diff --git a/indra/llui/llresizebar.h b/indra/llui/llresizebar.h
index 4ad3d5035a..a7bc3c60f5 100644
--- a/indra/llui/llresizebar.h
+++ b/indra/llui/llresizebar.h
@@ -52,11 +52,11 @@ public:
Optional<bool> allow_double_click_snapping;
Params()
- : max_size("", S32_MAX),
- snapping_enabled("", true),
+ : max_size("max_size", S32_MAX),
+ snapping_enabled("snapping_enabled", true),
resizing_view("resizing_view"),
side("side"),
- allow_double_click_snapping("", true)
+ allow_double_click_snapping("allow_double_click_snapping", true)
{
name = "resize_bar";
}
diff --git a/indra/llui/llscrollbar.cpp b/indra/llui/llscrollbar.cpp
index 3f1ff34419..3312064131 100644
--- a/indra/llui/llscrollbar.cpp
+++ b/indra/llui/llscrollbar.cpp
@@ -48,7 +48,7 @@
#include "llrender.h"
#include "lluictrlfactory.h"
-static LLDefaultWidgetRegistry::Register<LLScrollbar> register_scrollbar("scroll_bar");
+static LLDefaultChildRegistry::Register<LLScrollbar> register_scrollbar("scroll_bar");
LLScrollbar::Params::Params()
: orientation ("orientation", HORIZONTAL),
diff --git a/indra/llui/llscrollcontainer.cpp b/indra/llui/llscrollcontainer.cpp
index 2a2e56a92c..ea4bd2526e 100644
--- a/indra/llui/llscrollcontainer.cpp
+++ b/indra/llui/llscrollcontainer.cpp
@@ -63,7 +63,7 @@ static const F32 AUTO_SCROLL_RATE_ACCEL = 120.f;
/// Class LLScrollContainer
///----------------------------------------------------------------------------
-static LLDefaultWidgetRegistry::Register<LLScrollContainer> r("scroll_container");
+static LLDefaultChildRegistry::Register<LLScrollContainer> r("scroll_container");
LLScrollContainer::Params::Params()
: is_opaque("opaque"),
@@ -91,7 +91,7 @@ LLScrollContainer::LLScrollContainer(const LLScrollContainer::Params& p)
LLViewBorder::Params params;
params.name("scroll border");
params.rect(border_rect);
- params.bevel_type(LLViewBorder::BEVEL_IN);
+ params.bevel_style(LLViewBorder::BEVEL_IN);
mBorder = LLUICtrlFactory::create<LLViewBorder> (params);
LLView::addChild( mBorder );
@@ -517,12 +517,6 @@ bool LLScrollContainer::addChild(LLView* view, S32 tab_group)
return ret_val;
}
-const widget_registry_t& LLScrollContainer::getChildRegistry() const
-{
- // a scroll container can contain any default widget
- return LLDefaultWidgetRegistry::instance();
-}
-
void LLScrollContainer::updateScroll()
{
if (!mScrolledView)
diff --git a/indra/llui/llscrollcontainer.h b/indra/llui/llscrollcontainer.h
index 26d8cc824e..9cbfbc94a1 100644
--- a/indra/llui/llscrollcontainer.h
+++ b/indra/llui/llscrollcontainer.h
@@ -68,6 +68,10 @@ public:
Params();
};
+
+ // my valid children are stored in this registry
+ typedef LLDefaultChildRegistry child_registry_t;
+
protected:
LLScrollContainer(const Params&);
friend class LLUICtrlFactory;
@@ -104,7 +108,6 @@ public:
virtual BOOL handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect);
virtual void draw();
virtual bool addChild(LLView* view, S32 tab_group = 0);
- virtual const widget_registry_t& getChildRegistry() const;
private:
// internal scrollbar handlers
diff --git a/indra/llui/llscrollingpanellist.cpp b/indra/llui/llscrollingpanellist.cpp
index 1f3a7f9fcf..0159cdd12c 100644
--- a/indra/llui/llscrollingpanellist.cpp
+++ b/indra/llui/llscrollingpanellist.cpp
@@ -35,7 +35,7 @@
#include "llscrollingpanellist.h"
-static LLDefaultWidgetRegistry::Register<LLScrollingPanelList> r("scrolling_panel_list");
+static LLDefaultChildRegistry::Register<LLScrollingPanelList> r("scrolling_panel_list");
/////////////////////////////////////////////////////////////////////
diff --git a/indra/llui/llscrolllistcolumn.cpp b/indra/llui/llscrolllistcolumn.cpp
index 02f09bd9b4..686e0b6cb7 100644
--- a/indra/llui/llscrolllistcolumn.cpp
+++ b/indra/llui/llscrolllistcolumn.cpp
@@ -291,7 +291,7 @@ void LLScrollListColumn::SortNames::declareValues()
//static
const LLScrollListColumn::Params& LLScrollListColumn::getDefaultParams()
{
- return LLUICtrlFactory::getDefaultParams<LLScrollListColumn::Params>();
+ return LLUICtrlFactory::getDefaultParams<LLScrollListColumn>();
}
diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp
index 6d91c784f7..75afbffc11 100644
--- a/indra/llui/llscrolllistctrl.cpp
+++ b/indra/llui/llscrolllistctrl.cpp
@@ -31,8 +31,6 @@
* $/LicenseInfo$
*/
-#define INSTANTIATE_GETCHILD_SCROLLLIST
-
#include "linden_common.h"
#include "llscrolllistctrl.h"
@@ -60,9 +58,7 @@
#include "lltextbox.h"
#include "llsdparam.h"
-template LLScrollListCtrl* LLView::getChild<LLScrollListCtrl>( const std::string& name, BOOL recurse, BOOL create_if_missing ) const;
-
-static LLDefaultWidgetRegistry::Register<LLScrollListCtrl> r("scroll_list");
+static LLDefaultChildRegistry::Register<LLScrollListCtrl> r("scroll_list");
// local structures & classes.
struct SortScrollListItem
@@ -225,7 +221,7 @@ LLScrollListCtrl::LLScrollListCtrl(const LLScrollListCtrl::Params& p)
LLViewBorder::Params params;
params.name("dig border");
params.rect(border_rect);
- params.bevel_type(LLViewBorder::BEVEL_IN);
+ params.bevel_style(LLViewBorder::BEVEL_IN);
mBorder = LLUICtrlFactory::create<LLViewBorder> (params);
addChild(mBorder);
}
diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h
index 8d200fb73f..63d07cecfd 100644
--- a/indra/llui/llscrolllistctrl.h
+++ b/indra/llui/llscrolllistctrl.h
@@ -453,11 +453,4 @@ private:
LLTextBox* mCommentTextBox;
}; // end class LLScrollListCtrl
-#ifdef LL_WINDOWS
-#ifndef INSTANTIATE_GETCHILD_SCROLLLIST
-#pragma warning (disable : 4231)
-extern template LLScrollListCtrl* LLView::getChild<LLScrollListCtrl>( const std::string& name, BOOL recurse, BOOL create_if_missing ) const;
-#endif
-#endif
-
#endif // LL_SCROLLLISTCTRL_H
diff --git a/indra/llui/llsearcheditor.cpp b/indra/llui/llsearcheditor.cpp
index 9522d32a8b..64583071a6 100644
--- a/indra/llui/llsearcheditor.cpp
+++ b/indra/llui/llsearcheditor.cpp
@@ -36,7 +36,7 @@
#include "llsearcheditor.h"
-//static LLDefaultWidgetRegistry::Register<LLSearchEditor> r2("search_editor");
+//static LLDefaultChildRegistry::Register<LLSearchEditor> r2("search_editor");
LLSearchEditor::LLSearchEditor(const LLSearchEditor::Params& p)
: LLUICtrl(p)
diff --git a/indra/llui/llslider.cpp b/indra/llui/llslider.cpp
index 66ed0d4e88..fa782a1063 100644
--- a/indra/llui/llslider.cpp
+++ b/indra/llui/llslider.cpp
@@ -43,7 +43,7 @@
#include "llimagegl.h"
#include "lluictrlfactory.h"
-static LLDefaultWidgetRegistry::Register<LLSlider> r1("slider_bar");
+static LLDefaultChildRegistry::Register<LLSlider> r1("slider_bar");
LLSlider::Params::Params()
: track_color("track_color"),
diff --git a/indra/llui/llsliderctrl.cpp b/indra/llui/llsliderctrl.cpp
index 3abd960792..12953fc261 100644
--- a/indra/llui/llsliderctrl.cpp
+++ b/indra/llui/llsliderctrl.cpp
@@ -53,7 +53,7 @@
const U32 MAX_STRING_LENGTH = 10;
-static LLDefaultWidgetRegistry::Register<LLSliderCtrl> r("slider");
+static LLDefaultChildRegistry::Register<LLSliderCtrl> r("slider");
LLSliderCtrl::LLSliderCtrl(const LLSliderCtrl::Params& p)
: LLF32UICtrl(p),
diff --git a/indra/llui/llspinctrl.cpp b/indra/llui/llspinctrl.cpp
index 943891c572..5893fcd64b 100644
--- a/indra/llui/llspinctrl.cpp
+++ b/indra/llui/llspinctrl.cpp
@@ -53,7 +53,7 @@
const U32 MAX_STRING_LENGTH = 32;
-static LLDefaultWidgetRegistry::Register<LLSpinCtrl> r2("spinner");
+static LLDefaultChildRegistry::Register<LLSpinCtrl> r2("spinner");
LLSpinCtrl::Params::Params()
: label_width("label_width"),
diff --git a/indra/llui/llstatview.cpp b/indra/llui/llstatview.cpp
index 6691f16c1e..ab4b0be97a 100644
--- a/indra/llui/llstatview.cpp
+++ b/indra/llui/llstatview.cpp
@@ -65,16 +65,6 @@ LLStatView::~LLStatView()
}
-// widget registrars
-struct StatViewRegistry : public LLWidgetRegistry<StatViewRegistry>
-{};
-
static StatViewRegistry::Register<LLStatBar> r1("stat_bar");
-const widget_registry_t& LLStatView::getChildRegistry() const
-{
- return StatViewRegistry::instance();
-}
-
-
diff --git a/indra/llui/llstatview.h b/indra/llui/llstatview.h
index 20aba7782b..eee4e2b7e4 100644
--- a/indra/llui/llstatview.h
+++ b/indra/llui/llstatview.h
@@ -39,6 +39,10 @@
class LLStatBar;
+// widget registrars
+struct StatViewRegistry : public LLChildRegistry<StatViewRegistry>
+{};
+
class LLStatView : public LLContainerView
{
public:
@@ -51,9 +55,11 @@ public:
follows.flags(FOLLOWS_TOP | FOLLOWS_LEFT);
}
};
- ~LLStatView();
- virtual const widget_registry_t& getChildRegistry() const;
+ // my valid children are stored in this registry
+ typedef StatViewRegistry child_registry_t;
+
+ ~LLStatView();
protected:
LLStatView(const Params&);
diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp
index 3391b1275c..3d5b5caead 100644
--- a/indra/llui/lltabcontainer.cpp
+++ b/indra/llui/lltabcontainer.cpp
@@ -99,8 +99,8 @@ struct LLPlaceHolderPanel : public LLPanel
LLPlaceHolderPanel(const Params& p) : LLPanel(p)
{}
};
-static LLDefaultWidgetRegistry::Register<LLPlaceHolderPanel> r1("placeholder");
-static LLDefaultWidgetRegistry::Register<LLTabContainer> r2("tab_container");
+static LLDefaultChildRegistry::Register<LLPlaceHolderPanel> r1("placeholder");
+static LLDefaultChildRegistry::Register<LLTabContainer> r2("tab_container");
LLTabContainer::Params::Params()
: tab_width("tab_width"),
diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp
index b812e876ef..56019171e1 100644
--- a/indra/llui/lltextbox.cpp
+++ b/indra/llui/lltextbox.cpp
@@ -30,17 +30,13 @@
* $/LicenseInfo$
*/
-#define INSTANTIATE_GETCHILD_TEXTBOX
-
#include "linden_common.h"
#include "lltextbox.h"
#include "lluictrlfactory.h"
#include "llfocusmgr.h"
#include "llwindow.h"
-template LLTextBox* LLView::getChild<LLTextBox>( const std::string& name, BOOL recurse, BOOL create_if_missing ) const;
-
-static LLDefaultWidgetRegistry::Register<LLTextBox> r("text");
+static LLDefaultChildRegistry::Register<LLTextBox> r("text");
LLTextBox::Params::Params()
: text_color("text_color"),
diff --git a/indra/llui/lltextbox.h b/indra/llui/lltextbox.h
index dca906decc..53d57ff785 100644
--- a/indra/llui/lltextbox.h
+++ b/indra/llui/lltextbox.h
@@ -159,11 +159,4 @@ private:
callback_t mClickedCallback;
};
-#ifdef LL_WINDOWS
-#ifndef INSTANTIATE_GETCHILD_TEXTBOX
-#pragma warning (disable : 4231)
-extern template LLTextBox* LLView::getChild<LLTextBox>( const std::string& name, BOOL recurse, BOOL create_if_missing ) const;
-#endif
-#endif
-
#endif
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index 6649264d9a..ce16f11d33 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -63,7 +63,7 @@
//
// Globals
//
-static LLDefaultWidgetRegistry::Register<LLTextEditor> r("simple_text_editor");
+static LLDefaultChildRegistry::Register<LLTextEditor> r("simple_text_editor");
//
// Constants
@@ -304,7 +304,7 @@ LLTextEditor::LLTextEditor(const LLTextEditor::Params& p)
LLViewBorder::Params params;
params.name("text ed border");
params.rect(getLocalRect());
- params.bevel_type(LLViewBorder::BEVEL_IN);
+ params.bevel_style(LLViewBorder::BEVEL_IN);
params.border_thickness(text_editor_border);
mBorder = LLUICtrlFactory::create<LLViewBorder> (params);
addChild( mBorder );
diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp
index 12875b4ed1..c08abf3caf 100644
--- a/indra/llui/llui.cpp
+++ b/indra/llui/llui.cpp
@@ -90,8 +90,8 @@ std::list<std::string> gUntranslated;
/*static*/ std::vector<std::string> LLUI::sXUIPaths;
// register searcheditor here
-static LLDefaultWidgetRegistry::Register<LLSearchEditor> register_search_editor("search_editor");
-static LLDefaultWidgetRegistry::Register<LLFlyoutButton> register_flyout_button("flyout_button");
+static LLDefaultChildRegistry::Register<LLSearchEditor> register_search_editor("search_editor");
+static LLDefaultChildRegistry::Register<LLFlyoutButton> register_flyout_button("flyout_button");
//
@@ -1934,8 +1934,8 @@ LLLocalClipRect::LLLocalClipRect(const LLRect &rect, BOOL enabled)
namespace LLInitParam
{
- TypedParam<LLUIColor >::TypedParam(BlockDescriptor& descriptor, const char* name, const LLUIColor& value, ParamDescriptor::validation_func_t func)
- : super_t(descriptor, name, value, func),
+ TypedParam<LLUIColor >::TypedParam(BlockDescriptor& descriptor, const char* name, const LLUIColor& value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count)
+ : super_t(descriptor, name, value, func, min_count, max_count),
red("red"),
green("green"),
blue("blue"),
@@ -1964,11 +1964,11 @@ namespace LLInitParam
declare("blue", LLColor4::blue);
}
- TypedParam<const LLFontGL*>::TypedParam(BlockDescriptor& descriptor, const char* name, const LLFontGL*const value, ParamDescriptor::validation_func_t func)
- : super_t(descriptor, name, value, func),
- name("", std::string("")),
- size("size", std::string("")),
- style("style", std::string(""))
+ TypedParam<const LLFontGL*>::TypedParam(BlockDescriptor& descriptor, const char* name, const LLFontGL*const value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count)
+ : super_t(descriptor, name, value, func, min_count, max_count),
+ name(""),
+ size("size"),
+ style("style")
{}
const LLFontGL* TypedParam<const LLFontGL*>::getValueFromBlock() const
@@ -1995,8 +1995,8 @@ namespace LLInitParam
return mData.mValue;
}
- TypedParam<LLRect>::TypedParam(BlockDescriptor& descriptor, const char* name, const LLRect& value, ParamDescriptor::validation_func_t func)
- : super_t(descriptor, name, value, func),
+ TypedParam<LLRect>::TypedParam(BlockDescriptor& descriptor, const char* name, const LLRect& value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count)
+ : super_t(descriptor, name, value, func, min_count, max_count),
left("left"),
top("top"),
right("right"),
diff --git a/indra/llui/llui.h b/indra/llui/llui.h
index c0873247c0..c4cdbf2c14 100644
--- a/indra/llui/llui.h
+++ b/indra/llui/llui.h
@@ -706,7 +706,7 @@ namespace LLInitParam
width,
height;
- TypedParam(BlockDescriptor& descriptor, const char* name, const LLRect& value, ParamDescriptor::validation_func_t func);
+ TypedParam(BlockDescriptor& descriptor, const char* name, const LLRect& value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count);
LLRect getValueFromBlock() const;
};
@@ -729,7 +729,7 @@ namespace LLInitParam
Optional<F32> alpha;
Optional<std::string> control;
- TypedParam(BlockDescriptor& descriptor, const char* name, const LLUIColor& value, ParamDescriptor::validation_func_t func);
+ TypedParam(BlockDescriptor& descriptor, const char* name, const LLUIColor& value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count);
LLUIColor getValueFromBlock() const;
};
@@ -743,7 +743,7 @@ namespace LLInitParam
Optional<std::string> size;
Optional<std::string> style;
- TypedParam(BlockDescriptor& descriptor, const char* name, const LLFontGL* const value, ParamDescriptor::validation_func_t func);
+ TypedParam(BlockDescriptor& descriptor, const char* name, const LLFontGL* const value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count);
const LLFontGL* getValueFromBlock() const;
};
diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp
index 395bed7959..43430cba24 100644
--- a/indra/llui/lluictrl.cpp
+++ b/indra/llui/lluictrl.cpp
@@ -38,7 +38,7 @@
#include "llpanel.h"
#include "lluictrlfactory.h"
-static LLDefaultWidgetRegistry::Register<LLUICtrl> r("ui_ctrl");
+static LLDefaultChildRegistry::Register<LLUICtrl> r("ui_ctrl");
LLUICtrl::Params::Params()
: tab_stop("tab_stop", true),
@@ -116,7 +116,7 @@ void LLFocusableElement::setFocus(BOOL b)
//static
const LLUICtrl::Params& LLUICtrl::getDefaultParams()
{
- return LLUICtrlFactory::getDefaultParams<LLUICtrl::Params>();
+ return LLUICtrlFactory::getDefaultParams<LLUICtrl>();
}
diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h
index 2b9caa2a82..f4c7cf36f2 100644
--- a/indra/llui/lluictrl.h
+++ b/indra/llui/lluictrl.h
@@ -130,8 +130,8 @@ public:
Alternative<std::string> invisible;
ControlVisibility()
- : visible("make_visible_control"),
- invisible("make_invisible_control")
+ : visible("visiblity_control"),
+ invisible("invisiblity_control")
{}
};
struct Params : public LLInitParam::Block<Params, LLView::Params>
@@ -324,6 +324,10 @@ namespace LLInitParam
bool ParamCompare<LLUICtrl::focus_callback_t>::equals(
const LLUICtrl::focus_callback_t &a,
const LLUICtrl::focus_callback_t &b);
+
+ template<>
+ bool ParamCompare<LLLazyValue<LLColor4> >::equals(
+ const LLLazyValue<LLColor4> &a, const LLLazyValue<LLColor4> &b);
}
#endif // LL_LLUICTRL_H
diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp
index 24caf51159..9df22e39b4 100644
--- a/indra/llui/lluictrlfactory.cpp
+++ b/indra/llui/lluictrlfactory.cpp
@@ -85,7 +85,8 @@ LLFastTimer::DeclareTimer FTM_WIDGET_SETUP("Widget Setup");
//-----------------------------------------------------------------------------
// Register widgets that are purely data driven here so they get linked in
#include "llstatview.h"
-static LLDefaultWidgetRegistry::Register<LLStatView> register_stat_view("stat_view");
+static LLDefaultChildRegistry::Register<LLStatView>
+ register_stat_view("stat_view");
//-----------------------------------------------------------------------------
@@ -107,7 +108,7 @@ public:
};
-static LLDefaultWidgetRegistry::Register<LLUICtrlLocate> r1("locate");
+static LLDefaultChildRegistry::Register<LLUICtrlLocate> r1("locate");
//-----------------------------------------------------------------------------
// LLUICtrlFactory()
@@ -135,7 +136,7 @@ void LLUICtrlFactory::loadWidgetTemplate(const std::string& widget_tag, LLInitPa
}
//static
-void LLUICtrlFactory::createChildren(LLView* viewp, LLXMLNodePtr node, LLXMLNodePtr output_node)
+void LLUICtrlFactory::createChildren(LLView* viewp, LLXMLNodePtr node, const widget_registry_t& registry, LLXMLNodePtr output_node)
{
if (node.isNull()) return;
@@ -147,7 +148,7 @@ void LLUICtrlFactory::createChildren(LLView* viewp, LLXMLNodePtr node, LLXMLNode
outputChild = output_node->createChild("", FALSE);
}
- if (!instance().createFromXML(child_node, viewp, LLStringUtil::null, outputChild, viewp->getChildRegistry()))
+ if (!instance().createFromXML(child_node, viewp, LLStringUtil::null, registry, outputChild))
{
std::string child_name = std::string(child_node->getName()->mString);
llwarns << "Could not create widget named " << child_node->getName()->mString << llendl;
@@ -338,12 +339,12 @@ BOOL LLUICtrlFactory::buildPanel(LLPanel* panelp, const std::string& filename, L
LLFastTimer::DeclareTimer FTM_CREATE_FROM_XML("Create child widget");
-LLView *LLUICtrlFactory::createFromXML(LLXMLNodePtr node, LLView* parent, const std::string& filename, LLXMLNodePtr output_node, const widget_registry_t& registry)
+LLView *LLUICtrlFactory::createFromXML(LLXMLNodePtr node, LLView* parent, const std::string& filename, const widget_registry_t& registry, LLXMLNodePtr output_node)
{
LLFastTimer timer(FTM_CREATE_FROM_XML);
std::string ctrl_type = node->getName()->mString;
LLStringUtil::toLower(ctrl_type);
-
+
const LLWidgetCreatorFunc* funcp = registry.getValue(ctrl_type);
if (funcp == NULL)
{
@@ -448,11 +449,497 @@ void LLUICtrlFactory::popFactoryFunctions()
}
}
-const widget_registry_t& LLUICtrlFactory::getWidgetRegistry(LLView* viewp)
+
+//
+// LLRNGWriter - writes Relax NG schema files based on a param block
+//
+LLRNGWriter::LLRNGWriter()
+{
+ // register various callbacks for inspecting the contents of a param block
+ registerInspectFunc<bool>(boost::bind(&LLRNGWriter::writeAttribute, this, "boolean", _1, _2, _3, _4));
+ registerInspectFunc<std::string>(boost::bind(&LLRNGWriter::writeAttribute, this, "string", _1, _2, _3, _4));
+ registerInspectFunc<U8>(boost::bind(&LLRNGWriter::writeAttribute, this, "unsignedByte", _1, _2, _3, _4));
+ registerInspectFunc<S8>(boost::bind(&LLRNGWriter::writeAttribute, this, "signedByte", _1, _2, _3, _4));
+ registerInspectFunc<U16>(boost::bind(&LLRNGWriter::writeAttribute, this, "unsignedShort", _1, _2, _3, _4));
+ registerInspectFunc<S16>(boost::bind(&LLRNGWriter::writeAttribute, this, "signedShort", _1, _2, _3, _4));
+ registerInspectFunc<U32>(boost::bind(&LLRNGWriter::writeAttribute, this, "unsignedInt", _1, _2, _3, _4));
+ registerInspectFunc<S32>(boost::bind(&LLRNGWriter::writeAttribute, this, "integer", _1, _2, _3, _4));
+ registerInspectFunc<F32>(boost::bind(&LLRNGWriter::writeAttribute, this, "float", _1, _2, _3, _4));
+ registerInspectFunc<F64>(boost::bind(&LLRNGWriter::writeAttribute, this, "double", _1, _2, _3, _4));
+ registerInspectFunc<LLColor4>(boost::bind(&LLRNGWriter::writeAttribute, this, "string", _1, _2, _3, _4));
+ registerInspectFunc<LLUIColor>(boost::bind(&LLRNGWriter::writeAttribute, this, "string", _1, _2, _3, _4));
+ registerInspectFunc<LLUUID>(boost::bind(&LLRNGWriter::writeAttribute, this, "string", _1, _2, _3, _4));
+ registerInspectFunc<LLSD>(boost::bind(&LLRNGWriter::writeAttribute, this, "string", _1, _2, _3, _4));
+}
+
+void LLRNGWriter::writeRNG(const std::string& type_name, LLXMLNodePtr node, const LLInitParam::BaseBlock& block, const std::string& xml_namespace)
+{
+ mGrammarNode = node;
+ mGrammarNode->setName("grammar");
+ mGrammarNode->createChild("xmlns", true)->setStringValue("http://relaxng/ns/structure/1.0");
+ mGrammarNode->createChild("datatypeLibrary", true)->setStringValue("http://www.w3.org/2001/XMLSchema-datatypes");
+ mGrammarNode->createChild("ns", true)->setStringValue(xml_namespace);
+
+ node = mGrammarNode->createChild("start", false);
+ node = node->createChild("ref", false);
+ node->createChild("name", true)->setStringValue(type_name);
+
+ node = mGrammarNode->createChild("define", false);
+ node->createChild("name", true)->setStringValue(type_name);
+
+ mElementNode = node->createChild("element", false);
+ mElementNode->createChild("name", true)->setStringValue(type_name);
+
+ block.inspectBlock(*this);
+}
+
+void LLRNGWriter::writeAttribute(const std::string& type, const Parser::name_stack_t& stack, S32 min_count, S32 max_count, const std::vector<std::string>* possible_values)
+{
+ name_stack_t non_empty_names;
+ std::string attribute_name;
+ for (name_stack_t::const_iterator it = stack.begin();
+ it != stack.end();
+ ++it)
+ {
+ const std::string& name = it->first;
+ if (!name.empty())
+ {
+ non_empty_names.push_back(*it);
+ }
+ }
+
+ if (non_empty_names.empty()) return;
+
+ for (name_stack_t::const_iterator it = non_empty_names.begin();
+ it != non_empty_names.end();
+ ++it)
+ {
+ if (!attribute_name.empty())
+ {
+ attribute_name += ".";
+ }
+ attribute_name += it->first;
+ }
+
+ // singular attribute
+ if (non_empty_names.size() == 1)
+ {
+ if (max_count == 1)
+ {
+ LLXMLNodePtr node = getCardinalityNode(mElementNode, min_count, max_count)->createChild("attribute", false);
+ node->createChild("name", true)->setStringValue(attribute_name);
+ node->createChild("data", false)->createChild("type", true)->setStringValue(type);
+ }
+ }
+ // compound attribute
+ else
+ {
+ std::string element_name;
+
+ // traverse all but last element, leaving that as an attribute name
+ name_stack_t::const_iterator end_it = non_empty_names.end();
+ end_it--;
+
+ for (name_stack_t::const_iterator it = non_empty_names.begin();
+ it != end_it;
+ ++it)
+ {
+ if (it != non_empty_names.begin())
+ {
+ element_name += ".";
+ }
+ element_name += it->first;
+ }
+
+ elements_map_t::iterator found_it = mElementsWritten.find(element_name);
+ if (found_it != mElementsWritten.end())
+ {
+ // reuse existing element
+ LLXMLNodePtr choice_node = found_it->second;
+
+ LLXMLNodePtr node = choice_node->mChildren->head;
+ node = getCardinalityNode(node, min_count, max_count)->createChild("attribute", false);
+ node->createChild("name", true)->setStringValue(attribute_name);
+ node->createChild("data", false)->createChild("type", true)->setStringValue(type);
+
+ node = choice_node->mChildren->head->mNext->mChildren->head;
+ node = getCardinalityNode(node, min_count, max_count)->createChild("attribute", false);
+ node->createChild("name", true)->setStringValue(non_empty_names.back().first);
+ node->createChild("data", false)->createChild("type", true)->setStringValue(type);
+ }
+ else
+ {
+ LLXMLNodePtr choice_node = mElementNode->createChild("choice", false);
+
+ LLXMLNodePtr node = choice_node->createChild("group", false);
+ node = getCardinalityNode(node, min_count, max_count)->createChild("attribute", false);
+ node->createChild("name", true)->setStringValue(attribute_name);
+ node->createChild("data", false)->createChild("type", true)->setStringValue(type);
+
+ node = choice_node->createChild("element", false);
+ node->createChild("name", true)->setStringValue(element_name);
+ node = getCardinalityNode(node, min_count, max_count)->createChild("attribute", false);
+ node->createChild("name", true)->setStringValue(non_empty_names.back().first);
+ node->createChild("data", false)->createChild("type", true)->setStringValue(type);
+
+ node = choice_node->createChild("element", false);
+ node->createChild("name", true)->setStringValue(type + "." + element_name);
+ node->createChild("ref", true)->createChild("name", true)->setStringValue(element_name);
+
+ mElementsWritten[element_name] = choice_node;
+ }
+ }
+}
+
+LLXMLNodePtr LLRNGWriter::getCardinalityNode(LLXMLNodePtr parent_node, S32 min_count, S32 max_count)
+{
+ // unlinked by default, meaning this attribute is forbidden
+ LLXMLNodePtr count_node = new LLXMLNode();
+ if (min_count >= 1)
+ {
+ if (max_count == 1 && min_count == 1)
+ {
+ // just add raw element, will count as 1 and only 1
+ count_node = mElementNode;
+ }
+ else
+ {
+ count_node = mElementNode->createChild("oneOrMore", false);
+ }
+ }
+ else
+ {
+ if (max_count == 1)
+ {
+ count_node = mElementNode->createChild("optional", false);
+ }
+ else if (max_count > 1)
+ {
+ count_node = mElementNode->createChild("zeroOrMore", false);
+ }
+ }
+ return count_node;
+}
+//
+// LLXSDWriter
+//
+LLXSDWriter::LLXSDWriter()
+{
+ registerInspectFunc<bool>(boost::bind(&LLXSDWriter::writeAttribute, this, "xs:boolean", _1, _2, _3, _4));
+ registerInspectFunc<std::string>(boost::bind(&LLXSDWriter::writeAttribute, this, "xs:string", _1, _2, _3, _4));
+ registerInspectFunc<U8>(boost::bind(&LLXSDWriter::writeAttribute, this, "xs:unsignedByte", _1, _2, _3, _4));
+ registerInspectFunc<S8>(boost::bind(&LLXSDWriter::writeAttribute, this, "xs:signedByte", _1, _2, _3, _4));
+ registerInspectFunc<U16>(boost::bind(&LLXSDWriter::writeAttribute, this, "xs:unsignedShort", _1, _2, _3, _4));
+ registerInspectFunc<S16>(boost::bind(&LLXSDWriter::writeAttribute, this, "xs:signedShort", _1, _2, _3, _4));
+ registerInspectFunc<U32>(boost::bind(&LLXSDWriter::writeAttribute, this, "xs:unsignedInt", _1, _2, _3, _4));
+ registerInspectFunc<S32>(boost::bind(&LLXSDWriter::writeAttribute, this, "xs:integer", _1, _2, _3, _4));
+ registerInspectFunc<F32>(boost::bind(&LLXSDWriter::writeAttribute, this, "xs:float", _1, _2, _3, _4));
+ registerInspectFunc<F64>(boost::bind(&LLXSDWriter::writeAttribute, this, "xs:double", _1, _2, _3, _4));
+ registerInspectFunc<LLColor4>(boost::bind(&LLXSDWriter::writeAttribute, this, "xs:string", _1, _2, _3, _4));
+ registerInspectFunc<LLUIColor>(boost::bind(&LLXSDWriter::writeAttribute, this, "xs:string", _1, _2, _3, _4));
+ registerInspectFunc<LLUUID>(boost::bind(&LLXSDWriter::writeAttribute, this, "xs:string", _1, _2, _3, _4));
+ registerInspectFunc<LLSD>(boost::bind(&LLXSDWriter::writeAttribute, this, "xs:string", _1, _2, _3, _4));
+}
+
+void LLXSDWriter::writeXSD(const std::string& type_name, LLXMLNodePtr node, const LLInitParam::BaseBlock& block, const std::string& xml_namespace)
+{
+ mSchemaNode = node;
+ node->setName("xs:schema");
+ node->createChild("attributeFormDefault", true)->setStringValue("unqualified");
+ node->createChild("elementFormDefault", true)->setStringValue("qualified");
+ node->createChild("targetNamespace", true)->setStringValue(xml_namespace);
+ node->createChild("xmlns:xs", true)->setStringValue("http://www.w3.org/2001/XMLSchema");
+ node->createChild("xmlns", true)->setStringValue(xml_namespace);
+
+ node = node->createChild("xs:complexType", false);
+ node->createChild("name", true)->setStringValue(type_name);
+ node->createChild("mixed", true)->setStringValue("true");
+
+ mAttributeNode = node;
+ mElementNode = node->createChild("xs:choice", false);
+ mElementNode->createChild("minOccurs", true)->setStringValue("0");
+ mElementNode->createChild("maxOccurs", true)->setStringValue("unbounded");
+ block.inspectBlock(*this);
+
+ // duplicate element choices
+ LLXMLNodeList children;
+ mElementNode->getChildren("xs:element", children, FALSE);
+ for (LLXMLNodeList::iterator child_it = children.begin(); child_it != children.end(); ++child_it)
+ {
+ LLXMLNodePtr child_copy = child_it->second->deepCopy();
+ std::string child_name;
+ child_copy->getAttributeString("name", child_name);
+ child_copy->setAttributeString("name", type_name + "." + child_name);
+ mElementNode->addChild(child_copy);
+ }
+
+ LLXMLNodePtr element_declaration_node = mSchemaNode->createChild("xs:element", false);
+ element_declaration_node->createChild("name", true)->setStringValue(type_name);
+ element_declaration_node->createChild("type", true)->setStringValue(type_name);
+}
+
+void LLXSDWriter::writeAttribute(const std::string& type, const Parser::name_stack_t& stack, S32 min_count, S32 max_count, const std::vector<std::string>* possible_values)
+{
+ name_stack_t non_empty_names;
+ std::string attribute_name;
+ for (name_stack_t::const_iterator it = stack.begin();
+ it != stack.end();
+ ++it)
+ {
+ const std::string& name = it->first;
+ if (!name.empty())
+ {
+ non_empty_names.push_back(*it);
+ }
+ }
+
+ for (name_stack_t::const_iterator it = non_empty_names.begin();
+ it != non_empty_names.end();
+ ++it)
+ {
+ if (!attribute_name.empty())
+ {
+ attribute_name += ".";
+ }
+ attribute_name += it->first;
+ }
+
+ // only flag non-nested attributes as mandatory, nested attributes have variant syntax
+ // that can't be properly constrained in XSD
+ // e.g. <foo mandatory.value="bar"/> vs <foo><mandatory value="bar"/></foo>
+ bool attribute_mandatory = min_count == 1 && max_count == 1 && non_empty_names.size() == 1;
+
+ // don't bother supporting "Multiple" params as xml attributes
+ if (max_count <= 1)
+ {
+ // add compound attribute to root node
+ addAttributeToSchema(mAttributeNode, attribute_name, type, attribute_mandatory, possible_values);
+ }
+
+ // now generated nested elements for compound attributes
+ if (non_empty_names.size() > 1 && !attribute_mandatory)
+ {
+ std::string element_name;
+
+ // traverse all but last element, leaving that as an attribute name
+ name_stack_t::const_iterator end_it = non_empty_names.end();
+ end_it--;
+
+ for (name_stack_t::const_iterator it = non_empty_names.begin();
+ it != end_it;
+ ++it)
+ {
+ if (it != non_empty_names.begin())
+ {
+ element_name += ".";
+ }
+ element_name += it->first;
+ }
+
+ std::string short_attribute_name = non_empty_names.back().first;
+
+ LLXMLNodePtr complex_type_node;
+
+ // find existing element node here, starting at tail of child list
+ if (mElementNode->mChildren.notNull())
+ {
+ for(LLXMLNodePtr element = mElementNode->mChildren->tail;
+ element.notNull();
+ element = element->mPrev)
+ {
+ std::string name;
+ if(element->getAttributeString("name", name) && name == element_name)
+ {
+ complex_type_node = element->mChildren->head;
+ break;
+ }
+ }
+ }
+ //create complex_type node
+ //
+ //<xs:element
+ // maxOccurs="1"
+ // minOccurs="0"
+ // name="name">
+ // <xs:complexType>
+ // </xs:complexType>
+ //</xs:element>
+ if(complex_type_node.isNull())
+ {
+ complex_type_node = mElementNode->createChild("xs:element", false);
+
+ complex_type_node->createChild("minOccurs", true)->setIntValue(min_count);
+ complex_type_node->createChild("maxOccurs", true)->setIntValue(max_count);
+ complex_type_node->createChild("name", true)->setStringValue(element_name);
+ complex_type_node = complex_type_node->createChild("xs:complexType", false);
+ }
+
+ addAttributeToSchema(complex_type_node, short_attribute_name, type, false, possible_values);
+ }
+}
+
+void LLXSDWriter::addAttributeToSchema(LLXMLNodePtr type_declaration_node, const std::string& attribute_name, const std::string& type, bool mandatory, const std::vector<std::string>* possible_values)
{
- return viewp->getChildRegistry();
+ if (!attribute_name.empty())
+ {
+ LLXMLNodePtr new_enum_type_node;
+ if (possible_values != NULL)
+ {
+ // custom attribute type, for example
+ //<xs:simpleType>
+ // <xs:restriction
+ // base="xs:string">
+ // <xs:enumeration
+ // value="a" />
+ // <xs:enumeration
+ // value="b" />
+ // </xs:restriction>
+ // </xs:simpleType>
+ new_enum_type_node = new LLXMLNode("xs:simpleType", false);
+
+ LLXMLNodePtr restriction_node = new_enum_type_node->createChild("xs:restriction", false);
+ restriction_node->createChild("base", true)->setStringValue("xs:string");
+
+ for (std::vector<std::string>::const_iterator it = possible_values->begin();
+ it != possible_values->end();
+ ++it)
+ {
+ LLXMLNodePtr enum_node = restriction_node->createChild("xs:enumeration", false);
+ enum_node->createChild("value", true)->setStringValue(*it);
+ }
+ }
+
+ string_set_t& attributes_written = mAttributesWritten[type_declaration_node];
+
+ string_set_t::iterator found_it = std::lower_bound(attributes_written.begin(), attributes_written.end(), attribute_name);
+
+ // attribute not yet declared
+ if (found_it == attributes_written.end() || attributes_written.key_comp()(attribute_name, *found_it))
+ {
+ attributes_written.insert(found_it, attribute_name);
+
+ LLXMLNodePtr attribute_node = type_declaration_node->createChild("xs:attribute", false);
+
+ // attribute name
+ attribute_node->createChild("name", true)->setStringValue(attribute_name);
+
+ if (new_enum_type_node.notNull())
+ {
+ attribute_node->addChild(new_enum_type_node);
+ }
+ else
+ {
+ // simple attribute type
+ attribute_node->createChild("type", true)->setStringValue(type);
+ }
+
+ // required or optional
+ attribute_node->createChild("use", true)->setStringValue(mandatory ? "required" : "optional");
+ }
+ // attribute exists...handle collision of same name attributes with potentially different types
+ else
+ {
+ LLXMLNodePtr attribute_declaration;
+ if (type_declaration_node.notNull())
+ {
+ for(LLXMLNodePtr node = type_declaration_node->mChildren->tail;
+ node.notNull();
+ node = node->mPrev)
+ {
+ std::string name;
+ if (node->getAttributeString("name", name) && name == attribute_name)
+ {
+ attribute_declaration = node;
+ break;
+ }
+ }
+ }
+
+ bool new_type_is_enum = new_enum_type_node.notNull();
+ bool existing_type_is_enum = !attribute_declaration->hasAttribute("type");
+
+ // either type is enum, revert to string in collision
+ // don't bother to check for enum equivalence
+ if (new_type_is_enum || existing_type_is_enum)
+ {
+ if (attribute_declaration->hasAttribute("type"))
+ {
+ attribute_declaration->setAttributeString("type", "xs:string");
+ }
+ else
+ {
+ attribute_declaration->createChild("type", true)->setStringValue("xs:string");
+ }
+ attribute_declaration->deleteChildren("xs:simpleType");
+ }
+ else
+ {
+ // check for collision of different standard types
+ std::string existing_type;
+ attribute_declaration->getAttributeString("type", existing_type);
+ // if current type is not the same as the new type, revert to strnig
+ if (existing_type != type)
+ {
+ // ...than use most general type, string
+ attribute_declaration->setAttributeString("type", "string");
+ }
+ }
+ }
+ }
}
+//
+// LLXUIXSDWriter
+//
+void LLXUIXSDWriter::writeXSD(const std::string& type_name, const std::string& path, const LLInitParam::BaseBlock& block)
+{
+ std::string file_name(path);
+ file_name += type_name + ".xsd";
+ LLXMLNodePtr root_nodep = new LLXMLNode();
+
+ LLXSDWriter::writeXSD(type_name, root_nodep, block, "http://www.lindenlab.com/xui");
+
+ // add includes for all possible children
+ const std::type_info* type = *LLWidgetTypeRegistry::instance().getValue(type_name);
+ const widget_registry_t* widget_registryp = LLChildRegistryRegistry::instance().getValue(type);
+
+ // add include declarations for all valid children
+ for (widget_registry_t::Registrar::registry_map_t::const_iterator it = widget_registryp->currentRegistrar().beginItems();
+ it != widget_registryp->currentRegistrar().endItems();
+ ++it)
+ {
+ std::string widget_name = it->first;
+ if (widget_name == type_name)
+ {
+ continue;
+ }
+ LLXMLNodePtr nodep = new LLXMLNode("xs:include", false);
+ nodep->createChild("schemaLocation", true)->setStringValue(widget_name + ".xsd");
+
+ // add to front of schema
+ mSchemaNode->addChild(nodep, mSchemaNode);
+ }
+
+ // add choices for valid children
+ if (widget_registryp)
+ {
+ for (widget_registry_t::Registrar::registry_map_t::const_iterator it = widget_registryp->currentRegistrar().beginItems();
+ it != widget_registryp->currentRegistrar().endItems();
+ ++it)
+ {
+ std::string widget_name = it->first;
+ //<xs:element name="widget_name" type="widget_name">
+ LLXMLNodePtr widget_node = mElementNode->createChild("xs:element", false);
+ widget_node->createChild("name", true)->setStringValue(widget_name);
+ widget_node->createChild("type", true)->setStringValue(widget_name);
+ }
+ }
+
+ LLFILE* xsd_file = LLFile::fopen(file_name.c_str(), "w");
+ LLXMLNode::writeHeaderToFile(xsd_file);
+ root_nodep->writeToFile(xsd_file);
+ fclose(xsd_file);
+}
//
// LLXUIParser
diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h
index f8d584bc75..894c77888c 100644
--- a/indra/llui/lluictrlfactory.h
+++ b/indra/llui/lluictrlfactory.h
@@ -41,11 +41,64 @@
#include <boost/function.hpp>
#include <iosfwd>
#include <stack>
+#include <set>
class LLPanel;
class LLFloater;
class LLView;
+class LLRNGWriter : public LLInitParam::Parser
+{
+ LOG_CLASS(LLRNGWriter);
+public:
+ void writeRNG(const std::string& name, LLXMLNodePtr node, const LLInitParam::BaseBlock& block, const std::string& xml_namespace);
+
+ /*virtual*/ std::string getCurrentElementName() { return LLStringUtil::null; }
+
+ LLRNGWriter();
+
+private:
+ LLXMLNodePtr getCardinalityNode(LLXMLNodePtr parent_node, S32 min_count, S32 max_count);
+
+ void writeAttribute(const std::string& type, const Parser::name_stack_t&, S32 min_count, S32 max_count, const std::vector<std::string>* possible_values);
+ LLXMLNodePtr mElementNode;
+ LLXMLNodePtr mGrammarNode;
+
+ typedef std::map<std::string, LLXMLNodePtr> elements_map_t;
+ elements_map_t mElementsWritten;
+};
+
+
+class LLXSDWriter : public LLInitParam::Parser
+{
+ LOG_CLASS(LLXSDWriter);
+public:
+ void writeXSD(const std::string& name, LLXMLNodePtr node, const LLInitParam::BaseBlock& block, const std::string& xml_namespace);
+
+ /*virtual*/ std::string getCurrentElementName() { return LLStringUtil::null; }
+
+ LLXSDWriter();
+
+protected:
+ void writeAttribute(const std::string& type, const Parser::name_stack_t&, S32 min_count, S32 max_count, const std::vector<std::string>* possible_values);
+ void addAttributeToSchema(LLXMLNodePtr nodep, const std::string& attribute_name, const std::string& type, bool mandatory, const std::vector<std::string>* possible_values);
+ LLXMLNodePtr mAttributeNode;
+ LLXMLNodePtr mElementNode;
+ LLXMLNodePtr mSchemaNode;
+
+ typedef std::set<std::string> string_set_t;
+ typedef std::map<LLXMLNodePtr, string_set_t> attributes_map_t;
+ attributes_map_t mAttributesWritten;
+};
+
+// NOTE: DOES NOT WORK YET
+// should support child widgets for XUI
+class LLXUIXSDWriter : public LLXSDWriter
+{
+public:
+ void writeXSD(const std::string& name, const std::string& path, const LLInitParam::BaseBlock& block);
+};
+
class LLXUIParser : public LLInitParam::Parser, public LLSingleton<LLXUIParser>
{
LOG_CLASS(LLXUIParser);
@@ -118,13 +171,23 @@ typedef boost::function<LLView* (LLXMLNodePtr node, LLView *parent, LLXMLNodePtr
typedef LLRegistry<std::string, LLWidgetCreatorFunc> widget_registry_t;
+// sort functor for typeid maps
+struct LLCompareTypeID
+{
+ bool operator()(const std::type_info* lhs, const std::type_info* rhs) const
+ {
+ return lhs->before(*rhs);
+ }
+};
+
+// lookup widget constructor funcs by widget name
template <typename DERIVED_TYPE>
-class LLWidgetRegistry : public LLRegistrySingleton<std::string, LLWidgetCreatorFunc, DERIVED_TYPE>
+class LLChildRegistry : public LLRegistrySingleton<std::string, LLWidgetCreatorFunc, DERIVED_TYPE>
{
public:
typedef LLRegistrySingleton<std::string, LLWidgetCreatorFunc, DERIVED_TYPE> super_t;
// local static instance for registering a particular widget
- template<typename T, typename PARAM_BLOCK = typename T::Params>
+ template<typename T>
class Register : public super_t::StaticRegistrar
{
public:
@@ -133,35 +196,40 @@ public:
};
protected:
- LLWidgetRegistry() {}
+ LLChildRegistry() {}
};
-class LLDefaultWidgetRegistry : public LLWidgetRegistry<LLDefaultWidgetRegistry>
+class LLDefaultChildRegistry : public LLChildRegistry<LLDefaultChildRegistry>
{
protected:
- LLDefaultWidgetRegistry() {}
- friend class LLSingleton<LLDefaultWidgetRegistry>;
-};
-
-struct LLCompareTypeID
-{
- bool operator()(const std::type_info* lhs, const std::type_info* rhs) const
- {
- return lhs->before(*rhs);
- }
+ LLDefaultChildRegistry(){}
+ friend class LLSingleton<LLDefaultChildRegistry>;
};
+// lookup widget name by type
+class LLWidgetNameRegistry
+: public LLRegistrySingleton<const std::type_info*, std::string, LLWidgetNameRegistry , LLCompareTypeID>
+{};
-class LLWidgetTemplateRegistry
-: public LLRegistrySingleton<const std::type_info*, std::string, LLWidgetTemplateRegistry, LLCompareTypeID>
+// lookup widget type by name
+class LLWidgetTypeRegistry
+: public LLRegistrySingleton<std::string, const std::type_info*, LLWidgetTypeRegistry>
{};
-// function used to create new default widgets via LLView::getChild<T>
+// lookup factory functions for default widget instances by widget type
typedef LLView* (*dummy_widget_creator_func_t)(const std::string&);
+class LLDefaultWidgetRegistry
+: public LLRegistrySingleton<const std::type_info*, dummy_widget_creator_func_t, LLDefaultWidgetRegistry, LLCompareTypeID>
+{};
-// used to register factory functions for default widget instances
-class LLDummyWidgetRegistry
-: public LLRegistrySingleton<const std::type_info*, dummy_widget_creator_func_t, LLDummyWidgetRegistry, LLCompareTypeID>
+// lookup function for generating empty param block by widget type
+typedef const LLInitParam::BaseBlock& (*empty_param_block_func_t)();
+class LLDefaultParamBlockRegistry
+: public LLRegistrySingleton<const std::type_info*, empty_param_block_func_t, LLDefaultParamBlockRegistry, LLCompareTypeID>
+{};
+
+class LLChildRegistryRegistry
+: public LLRegistrySingleton<const std::type_info*, widget_registry_t, LLChildRegistryRegistry>
{};
extern LLFastTimer::DeclareTimer FTM_WIDGET_SETUP;
@@ -176,26 +244,26 @@ private:
~LLUICtrlFactory();
// only partial specialization allowed in inner classes, so use extra dummy parameter
- template <typename T, int DUMMY>
- class ParamDefaults : public LLSingleton<ParamDefaults<T, DUMMY> >
+ template <typename PARAM_BLOCK, int DUMMY>
+ class ParamDefaults : public LLSingleton<ParamDefaults<PARAM_BLOCK, DUMMY> >
{
public:
ParamDefaults()
{
// recursively initialize from base class param block
- ((typename T::base_block_t&)mPrototype).fillFrom(ParamDefaults<typename T::base_block_t, DUMMY>::instance().get());
+ ((typename PARAM_BLOCK::base_block_t&)mPrototype).fillFrom(ParamDefaults<typename PARAM_BLOCK::base_block_t, DUMMY>::instance().get());
// after initializing base classes, look up template file for this param block
- std::string* param_block_tag = LLWidgetTemplateRegistry::instance().getValue(&typeid(T));
+ std::string* param_block_tag = LLWidgetNameRegistry::instance().getValue(&typeid(PARAM_BLOCK));
if (param_block_tag)
{
LLUICtrlFactory::loadWidgetTemplate(*param_block_tag, mPrototype);
}
}
- const T& get() { return mPrototype; }
+ const PARAM_BLOCK& get() { return mPrototype; }
private:
- T mPrototype;
+ PARAM_BLOCK mPrototype;
};
// base case for recursion, there are NO base classes of LLInitParam::BaseBlock
@@ -210,11 +278,12 @@ private:
public:
+ // get default parameter block for widget of a specific type
template<typename T>
- static const T& getDefaultParams()
+ static const typename T::Params& getDefaultParams()
{
//#pragma message("Generating ParamDefaults")
- return ParamDefaults<T, 0>::instance().get();
+ return ParamDefaults<typename T::Params, 0>::instance().get();
}
void buildFloater(LLFloater* floaterp, const std::string &filename, BOOL open_floater = TRUE, LLXMLNodePtr output_node = NULL);
@@ -252,12 +321,10 @@ public:
return widget;
}
- LLView* createFromXML(LLXMLNodePtr node, LLView* parent, const std::string& filename, LLXMLNodePtr output_node, const widget_registry_t& );
+ LLView* createFromXML(LLXMLNodePtr node, LLView* parent, const std::string& filename, const widget_registry_t&, LLXMLNodePtr output_node );
- static const widget_registry_t& getWidgetRegistry(LLView*);
-
template<typename T>
- static T* createFromFile(const std::string &filename, LLView *parent, LLXMLNodePtr output_node = NULL)
+ static T* createFromFile(const std::string &filename, LLView *parent, const widget_registry_t& registry, LLXMLNodePtr output_node = NULL)
{
//#pragma message("Generating LLUICtrlFactory::createFromFile")
T* widget = NULL;
@@ -283,7 +350,7 @@ public:
goto fail;
}
- LLView* view = getInstance()->createFromXML(root_node, parent, filename, output_node, getWidgetRegistry(parent));
+ LLView* view = getInstance()->createFromXML(root_node, parent, filename, registry, output_node);
if (view)
{
widget = dynamic_cast<T*>(view);
@@ -304,7 +371,7 @@ fail:
template<class T>
static T* getDefaultWidget(const std::string& name)
{
- dummy_widget_creator_func_t* dummy_func = LLDummyWidgetRegistry::instance().getValue(&typeid(T));
+ dummy_widget_creator_func_t* dummy_func = LLDefaultWidgetRegistry::instance().getValue(&typeid(T));
return dummy_func ? dynamic_cast<T*>((*dummy_func)(name)) : NULL;
}
@@ -317,23 +384,23 @@ fail:
return create<T>(params);
}
- template<typename T, typename PARAM_BLOCK>
+ template<typename T>
static T* defaultBuilder(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node)
{
LLFastTimer timer(FTM_WIDGET_SETUP);
//#pragma message("Generating LLUICtrlFactory::defaultBuilder")
- PARAM_BLOCK params(getDefaultParams<PARAM_BLOCK>());
+ typename T::Params params(getDefaultParams<T>());
LLXUIParser::instance().readXUI(node, params);
if (output_node)
{
// We always want to output top-left coordinates
- PARAM_BLOCK output_params(params);
+ typename T::Params output_params(params);
T::setupParamsForExport(output_params, parent);
// Export only the differences between this any default params
- PARAM_BLOCK default_params(getDefaultParams<PARAM_BLOCK>());
+ typename T::Params default_params(getDefaultParams<T>());
output_node->setName(node->getName()->mString);
LLXUIParser::instance().writeXUI(
output_node, output_params, &default_params);
@@ -361,8 +428,10 @@ fail:
S32 tab_group = params.tab_group.isProvided() ? params.tab_group() : -1;
setCtrlParent(widget, parent, tab_group);
}
+
+ typedef typename T::child_registry_t registry_t;
- createChildren(widget, node, output_node);
+ createChildren(widget, node, registry_t::instance(), output_node);
if (!widget->postBuild())
{
@@ -373,7 +442,7 @@ fail:
return widget;
}
- static void createChildren(LLView* viewp, LLXMLNodePtr node, LLXMLNodePtr output_node = NULL);
+ static void createChildren(LLView* viewp, LLXMLNodePtr node, const widget_registry_t&, LLXMLNodePtr output_node = NULL);
static bool getLayeredXMLNode(const std::string &filename, LLXMLNodePtr& root);
@@ -395,16 +464,28 @@ private:
std::vector<std::string> mFileNames;
};
+template<typename T>
+const LLInitParam::BaseBlock& getEmptyParamBlock()
+{
+ static typename T::Params params;
+ return params;
+}
+
// this is here to make gcc happy with reference to LLUICtrlFactory
template<typename DERIVED>
-template<typename T, typename PARAM_BLOCK>
-LLWidgetRegistry<DERIVED>::Register<T, PARAM_BLOCK>::Register(const char* tag, LLWidgetCreatorFunc func)
-: LLWidgetRegistry<DERIVED>::StaticRegistrar(tag, func.empty() ? (LLWidgetCreatorFunc)&LLUICtrlFactory::defaultBuilder<T, PARAM_BLOCK> : func)
+template<typename T>
+LLChildRegistry<DERIVED>::Register<T>::Register(const char* tag, LLWidgetCreatorFunc func)
+: LLChildRegistry<DERIVED>::StaticRegistrar(tag, func.empty() ? (LLWidgetCreatorFunc)&LLUICtrlFactory::defaultBuilder<T> : func)
{
+ const std::type_info* widget_type_infop = &typeid(T);
// associate parameter block type with template .xml file
- LLWidgetTemplateRegistry::instance().defaultRegistrar().add(&typeid(PARAM_BLOCK), tag);
+ LLWidgetNameRegistry ::instance().defaultRegistrar().add(&typeid(typename T::Params), tag);
// associate widget type with factory function
- LLDummyWidgetRegistry::instance().defaultRegistrar().add(&typeid(T), &LLUICtrlFactory::createDefaultWidget<T>);
+ LLDefaultWidgetRegistry::instance().defaultRegistrar().add(widget_type_infop, &LLUICtrlFactory::createDefaultWidget<T>);
+ LLWidgetTypeRegistry::instance().defaultRegistrar().add(tag, widget_type_infop);
+ LLDefaultParamBlockRegistry::instance().defaultRegistrar().add(widget_type_infop, &getEmptyParamBlock<T>);
+ typedef typename T::child_registry_t registry_t;
+ LLChildRegistryRegistry::instance().defaultRegistrar().add(widget_type_infop, registry_t::instance());
}
diff --git a/indra/llui/lluiimage.h b/indra/llui/lluiimage.h
index e3b473b5f6..0fb16876bf 100644
--- a/indra/llui/lluiimage.h
+++ b/indra/llui/lluiimage.h
@@ -95,8 +95,8 @@ namespace LLInitParam
public:
Optional<std::string> name;
- TypedParam(BlockDescriptor& descriptor, const char* name, super_t::value_assignment_t value, ParamDescriptor::validation_func_t func)
- : super_t(descriptor, name, value, func)
+ TypedParam(BlockDescriptor& descriptor, const char* name, super_t::value_assignment_t value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count)
+ : super_t(descriptor, name, value, func, min_count, max_count)
{
}
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index 29d0f6a168..777cf096ac 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -99,10 +99,15 @@ LLView::Params::Params()
left_delta("left_delta", S32_MAX),
center_horiz("center_horiz", false),
center_vert("center_vert", false),
- serializable("", false),
+ from_xui("from_xui", false),
user_resize("user_resize"),
auto_resize("auto_resize"),
- needs_translate("translate")
+ needs_translate("translate"),
+ xmlns("xmlns"),
+ xmlns_xsi("xmlns:xsi"),
+ xsi_schemaLocation("xsi:schemaLocation"),
+ xsi_type("xsi:type")
+
{
addSynonym(rect, "");
}
@@ -111,7 +116,7 @@ LLView::LLView(const LLView::Params& p)
: mName(p.name),
mParentView(NULL),
mReshapeFlags(FOLLOWS_NONE),
- mSaveToXML(p.serializable),
+ mSaveToXML(p.from_xui),
mIsFocusRoot(FALSE),
mLastVisible(FALSE),
mNextInsertionOrdinal(0),
@@ -2291,13 +2296,6 @@ LLControlVariable *LLView::findControl(const std::string& name)
return control_group.getControl(name);
}
-const widget_registry_t& LLView::getChildRegistry() const
-{
- static widget_registry_t empty_registry;
- return empty_registry;
-}
-
-
const S32 FLOATER_H_MARGIN = 15;
const S32 MIN_WIDGET_HEIGHT = 10;
const S32 VPAD = 4;
@@ -2418,7 +2416,7 @@ void LLView::setupParams(LLView::Params& p, LLView* parent)
const S32 VPAD = 4;
const S32 MIN_WIDGET_HEIGHT = 10;
- p.serializable(true);
+ p.from_xui(true);
// *NOTE: This will confuse export of floater/panel coordinates unless
// the default is also "topleft". JC
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index 422f62f602..5f6341daa6 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -138,6 +138,9 @@ virtual BOOL handleUnicodeCharHere(llwchar uni_char);
*
*/
+class LLViewWidgetRegistry : public LLChildRegistry<LLViewWidgetRegistry>
+{};
+
class LLView : public LLMouseHandler, public LLMortician
{
public:
@@ -157,15 +160,16 @@ public:
Mandatory<std::string> name;
Optional<bool> enabled,
- visible;
- Optional<bool> mouse_opaque;
- Optional<bool> use_bounding_rect;
+ visible,
+ mouse_opaque,
+ use_bounding_rect;
+
Optional<S32> tab_group,
default_tab_group;
Optional<std::string> tool_tip;
Optional<S32> sound_flags;
- Optional<bool> serializable;
+ Optional<bool> from_xui;
Optional<Follows> follows;
Optional<std::string> hover_cursor;
@@ -192,10 +196,17 @@ public:
//FIXME: get parent context involved in parsing traversal
Ignored user_resize,
auto_resize,
- needs_translate;
+ needs_translate,
+ xmlns,
+ xmlns_xsi,
+ xsi_schemaLocation,
+ xsi_type;
Params();
};
+
+ typedef LLViewWidgetRegistry child_registry_t;
+
void initFromParams(const LLView::Params&);
protected:
@@ -496,9 +507,6 @@ public:
return dynamic_cast<T*>(found_it->second);
}
- // determines allowable children when parsing XUI
- virtual const widget_registry_t& getChildRegistry() const;
-
//////////////////////////////////////////////
// statics
//////////////////////////////////////////////
@@ -647,6 +655,9 @@ template <class T> T* LLView::getChild(const std::string& name, BOOL recurse, BO
if (result)
{
+ // *NOTE: You cannot call mFoo = getChild<LLFoo>("bar")
+ // in a floater or panel constructor. The widgets will not
+ // be ready. Instead, put it in postBuild().
llwarns << "Making dummy " << typeid(T).name() << " named \"" << name << "\" in " << getName() << llendl;
}
else
diff --git a/indra/llui/llviewborder.cpp b/indra/llui/llviewborder.cpp
index a5b09671bb..860aa3302e 100644
--- a/indra/llui/llviewborder.cpp
+++ b/indra/llui/llviewborder.cpp
@@ -35,7 +35,7 @@
#include "llfocusmgr.h"
#include "lluictrlfactory.h"
-static LLDefaultWidgetRegistry::Register<LLViewBorder> r("view_border");
+static LLDefaultChildRegistry::Register<LLViewBorder> r("view_border");
void LLViewBorder::BevelValues::declareValues()
{
@@ -52,7 +52,7 @@ void LLViewBorder::StyleValues::declareValues()
}
LLViewBorder::Params::Params()
-: bevel_type("bevel_style", BEVEL_OUT),
+: bevel_style("bevel_style", BEVEL_OUT),
render_style("border_style", STYLE_LINE),
border_thickness("border_thickness"),
highlight_light_color("highlight_light_color"),
@@ -60,6 +60,8 @@ LLViewBorder::Params::Params()
shadow_light_color("shadow_light_color"),
shadow_dark_color("shadow_dark_color")
{
+ addSynonym(border_thickness, "thickness");
+ addSynonym(render_style, "style");
name = "view_border";
mouse_opaque = false;
follows.flags = FOLLOWS_ALL;
@@ -75,7 +77,7 @@ LLViewBorder::LLViewBorder(const LLViewBorder::Params& p)
mHighlightDark(p.highlight_dark_color()),
mShadowLight(p.shadow_light_color()),
mShadowDark(p.shadow_dark_color()),
- mBevel(p.bevel_type),
+ mBevel(p.bevel_style),
mStyle(p.render_style)
{}
diff --git a/indra/llui/llviewborder.h b/indra/llui/llviewborder.h
index 37e13fb181..92fd569325 100644
--- a/indra/llui/llviewborder.h
+++ b/indra/llui/llviewborder.h
@@ -55,7 +55,7 @@ public:
struct Params : public LLInitParam::Block<Params, LLView::Params>
{
- Optional<EBevel, BevelValues> bevel_type;
+ Optional<EBevel, BevelValues> bevel_style;
Optional<EStyle, StyleValues> render_style;
Optional<S32> border_thickness;