diff options
35 files changed, 550 insertions, 379 deletions
diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index 8a0513f246..27e96856b3 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -483,7 +483,7 @@ void LLFloaterReg::toggleToolbarFloaterInstance(const LLSD& sdname) { showInstance(name, key, TRUE); } - else if (!instance->hasFocus()) + else if (!instance->hasFocus() && !instance->getIsChrome()) { instance->setFocus(TRUE); } diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index 583bde360a..2518dbe3c7 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -60,7 +60,7 @@ public: typedef boost::function<void (LLLineEditor* caller)> keystroke_callback_t; - struct MaxLength : public LLInitParam::Choice<MaxLength> + struct MaxLength : public LLInitParam::ChoiceBlock<MaxLength> { Alternative<S32> bytes, chars; diff --git a/indra/llui/llloadingindicator.cpp b/indra/llui/llloadingindicator.cpp index c4eec1835c..6ac38f5ad4 100644 --- a/indra/llui/llloadingindicator.cpp +++ b/indra/llui/llloadingindicator.cpp @@ -34,6 +34,7 @@ // Project includes #include "lluictrlfactory.h" #include "lluiimage.h" +#include "boost/foreach.hpp" // registered in llui.cpp to avoid being left out by MS linker //static LLDefaultChildRegistry::Register<LLLoadingIndicator> r("loading_indicator"); @@ -51,11 +52,9 @@ LLLoadingIndicator::LLLoadingIndicator(const Params& p) void LLLoadingIndicator::initFromParams(const Params& p) { - for (LLInitParam::ParamIterator<LLUIImage*>::const_iterator it = p.images().image.begin(), end_it = p.images().image.end(); - it != end_it; - ++it) + BOOST_FOREACH(LLUIImage* image, p.images.image) { - mImages.push_back(it->getValue()); + mImages.push_back(image); } // Start timer for switching images. diff --git a/indra/llui/llloadingindicator.h b/indra/llui/llloadingindicator.h index 7c44478848..c1f979c111 100644 --- a/indra/llui/llloadingindicator.h +++ b/indra/llui/llloadingindicator.h @@ -51,7 +51,7 @@ class LLLoadingIndicator LOG_CLASS(LLLoadingIndicator); public: - struct Images : public LLInitParam::Block<Images> + struct Images : public LLInitParam::BatchBlock<Images> { Multiple<LLUIImage*> image; @@ -63,7 +63,7 @@ public: struct Params : public LLInitParam::Block<Params, LLUICtrl::Params> { Optional<F32> images_per_sec; - Batch<Images> images; + Optional<Images> images; Params() : images_per_sec("images_per_sec", 1.0f), diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index 0c4d4fc897..462d69be2e 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -201,7 +201,7 @@ public: FormInput(); }; - struct FormElement : public LLInitParam::Choice<FormElement> + struct FormElement : public LLInitParam::ChoiceBlock<FormElement> { Alternative<FormButton> button; Alternative<FormInput> input; @@ -312,7 +312,7 @@ public: Optional<LLNotificationContext*> context; Optional<void*> responder; - struct Functor : public LLInitParam::Choice<Functor> + struct Functor : public LLInitParam::ChoiceBlock<Functor> { Alternative<std::string> name; Alternative<LLNotificationFunctorRegistry::ResponseFunctor> function; diff --git a/indra/llui/llnotificationtemplate.h b/indra/llui/llnotificationtemplate.h index ab777d37a5..fb50c9c123 100644 --- a/indra/llui/llnotificationtemplate.h +++ b/indra/llui/llnotificationtemplate.h @@ -91,7 +91,7 @@ struct LLNotificationTemplate // <notification> <unique/> </notification> // as well as // <notification> <unique> <context></context> </unique>... - Flag dummy_val; + Optional<LLInitParam::Flag> dummy_val; public: Multiple<UniquenessContext> contexts; @@ -147,7 +147,7 @@ struct LLNotificationTemplate {} }; - struct FormRef : public LLInitParam::Choice<FormRef> + struct FormRef : public LLInitParam::ChoiceBlock<FormRef> { Alternative<LLNotificationForm::Params> form; Alternative<TemplateRef> form_template; diff --git a/indra/llui/llnotificationvisibilityrule.h b/indra/llui/llnotificationvisibilityrule.h index 78bdec2a8f..78788a275c 100644 --- a/indra/llui/llnotificationvisibilityrule.h +++ b/indra/llui/llnotificationvisibilityrule.h @@ -59,7 +59,7 @@ struct LLNotificationVisibilityRule {} }; - struct Rule : public LLInitParam::Choice<Rule> + struct Rule : public LLInitParam::ChoiceBlock<Rule> { Alternative<Filter> show; Alternative<Filter> hide; diff --git a/indra/llui/llscrolllistcolumn.h b/indra/llui/llscrolllistcolumn.h index 12baea8e0c..b4d4a6d05e 100644 --- a/indra/llui/llscrolllistcolumn.h +++ b/indra/llui/llscrolllistcolumn.h @@ -95,7 +95,7 @@ public: Optional<ESortDirection, SortNames> sort_direction; Optional<bool> sort_ascending; - struct Width : public LLInitParam::Choice<Width> + struct Width : public LLInitParam::ChoiceBlock<Width> { Alternative<bool> dynamic_width; Alternative<S32> pixel_width; @@ -112,7 +112,7 @@ public: Optional<Width> width; // either an image or label is used in column header - struct Header : public LLInitParam::Choice<Header> + struct Header : public LLInitParam::ChoiceBlock<Header> { Alternative<std::string> label; Alternative<LLUIImage*> image; diff --git a/indra/llui/llsdparam.cpp b/indra/llui/llsdparam.cpp index 04919e6991..4b69360e33 100644 --- a/indra/llui/llsdparam.cpp +++ b/indra/llui/llsdparam.cpp @@ -45,7 +45,7 @@ LLParamSDParser::LLParamSDParser() if (sReadFuncs.empty()) { - registerParserFuncs<LLInitParam::NoParamValue>(readNoValue, &LLParamSDParser::writeNoValue); + registerParserFuncs<LLInitParam::Flag>(readFlag, &LLParamSDParser::writeFlag); registerParserFuncs<S32>(readS32, &LLParamSDParser::writeTypedValue<S32>); registerParserFuncs<U32>(readU32, &LLParamSDParser::writeU32Param); registerParserFuncs<F32>(readF32, &LLParamSDParser::writeTypedValue<F32>); @@ -72,7 +72,7 @@ bool LLParamSDParser::writeU32Param(LLParamSDParser::parser_t& parser, const voi return true; } -bool LLParamSDParser::writeNoValue(LLParamSDParser::parser_t& parser, const void* val_ptr, const parser_t::name_stack_t& name_stack) +bool LLParamSDParser::writeFlag(LLParamSDParser::parser_t& parser, const void* val_ptr, const parser_t::name_stack_t& name_stack) { LLParamSDParser& sdparser = static_cast<LLParamSDParser&>(parser); if (!sdparser.mWriteRootSD) return false; @@ -226,7 +226,7 @@ LLSD* LLParamSDParser::getSDWriteNode(const parser_t::name_stack_t& name_stack) return sd_to_write; } -bool LLParamSDParser::readNoValue(Parser& parser, void* val_ptr) +bool LLParamSDParser::readFlag(Parser& parser, void* val_ptr) { LLParamSDParser& self = static_cast<LLParamSDParser&>(parser); return self.mCurReadSD == &NO_VALUE_MARKER; diff --git a/indra/llui/llsdparam.h b/indra/llui/llsdparam.h index f776c781b3..a371c28f68 100644 --- a/indra/llui/llsdparam.h +++ b/indra/llui/llsdparam.h @@ -63,9 +63,9 @@ private: LLSD* getSDWriteNode(const parser_t::name_stack_t& name_stack); static bool writeU32Param(Parser& parser, const void* value_ptr, const parser_t::name_stack_t& name_stack); - static bool writeNoValue(Parser& parser, const void* value_ptr, const parser_t::name_stack_t& name_stack); + static bool writeFlag(Parser& parser, const void* value_ptr, const parser_t::name_stack_t& name_stack); - static bool readNoValue(Parser& parser, void* val_ptr); + static bool readFlag(Parser& parser, void* val_ptr); static bool readS32(Parser& parser, void* val_ptr); static bool readU32(Parser& parser, void* val_ptr); static bool readF32(Parser& parser, void* val_ptr); diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index 7d545a1ba6..384d9116fc 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -237,7 +237,7 @@ public: friend class LLNormalTextSegment; friend class LLUICtrlFactory; - struct LineSpacingParams : public LLInitParam::Choice<LineSpacingParams> + struct LineSpacingParams : public LLInitParam::ChoiceBlock<LineSpacingParams> { Alternative<F32> multiple; Alternative<S32> pixels; diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 5300de38a0..762e738264 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -81,9 +81,6 @@ LLToolBar::Params::Params() button_icon_and_text("button_icon_and_text"), read_only("read_only", false), wrap("wrap", true), - min_button_width("min_button_width", 0), - max_button_width("max_button_width", S32_MAX), - button_height("button_height"), pad_left("pad_left"), pad_top("pad_top"), pad_right("pad_right"), @@ -101,9 +98,6 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) mNeedsLayout(false), mButtonPanel(NULL), mCenteringStack(NULL), - mMinButtonWidth(llmin(p.min_button_width(), p.max_button_width())), - mMaxButtonWidth(llmax(p.max_button_width(), p.min_button_width())), - mButtonHeight(p.button_height), mPadLeft(p.pad_left), mPadRight(p.pad_right), mPadTop(p.pad_top), @@ -202,16 +196,16 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p) bool LLToolBar::addCommand(const LLCommandId& commandId) { LLCommand * command = LLCommandManager::instance().getCommand(commandId); + if (!command) return false; - bool add_command = (command != NULL); - - if (add_command) - { mButtonCommands.push_back(commandId); - createButton(commandId); - } + LLToolBarButton* button = createButton(commandId); + mButtons.push_back(button); + mButtonPanel->addChild(button); + mButtonMap.insert(std::make_pair(commandId, button)); + mNeedsLayout = true; - return add_command; + return true; } void LLToolBar::clearCommandsList() @@ -224,21 +218,13 @@ void LLToolBar::clearCommandsList() bool LLToolBar::hasCommand(const LLCommandId& commandId) const { - bool has_command = false; - if (commandId != LLCommandId::null) { - BOOST_FOREACH(LLCommandId cmd, mButtonCommands) - { - if (cmd == commandId) - { - has_command = true; - break; - } - } + command_id_map::const_iterator it = mButtonMap.find(commandId); + return (it != mButtonMap.end()); } - return has_command; + return false; } bool LLToolBar::enableCommand(const LLCommandId& commandId, bool enabled) @@ -247,11 +233,10 @@ bool LLToolBar::enableCommand(const LLCommandId& commandId, bool enabled) if (commandId != LLCommandId::null) { - command_button = mButtonPanel->findChild<LLButton>(commandId.name()); - - if (command_button) + command_id_map::iterator it = mButtonMap.find(commandId); + if (it != mButtonMap.end()) { - command_button->setEnabled(enabled); + it->second->setEnabled(enabled); } } @@ -320,7 +305,7 @@ void LLToolBar::setButtonType(LLToolBarEnums::ButtonType button_type) bool regenerate_buttons = (mButtonType != button_type); mButtonType = button_type; - + if (regenerate_buttons) { createButtons(); @@ -334,7 +319,7 @@ void LLToolBar::resizeButtonsInRow(std::vector<LLToolBarButton*>& buttons_in_row { if (getOrientation(mSideType) == LLLayoutStack::HORIZONTAL) { - button->reshape(llclamp(button->getRect().getWidth(), mMinButtonWidth, mMaxButtonWidth), max_row_girth); + button->reshape(llclamp(button->getRect().getWidth(), button->mMinWidth, button->mMaxWidth), max_row_girth); } else // VERTICAL { @@ -393,10 +378,10 @@ void LLToolBar::updateLayoutAsNeeded() BOOST_FOREACH(LLToolBarButton* button, mButtons) { - button->reshape(mMinButtonWidth, mButtonHeight); + button->reshape(button->mMinWidth, button->mDesiredHeight); button->autoResize(); - S32 button_clamped_width = llclamp(button->getRect().getWidth(), mMinButtonWidth, mMaxButtonWidth); + S32 button_clamped_width = llclamp(button->getRect().getWidth(), button->mMinWidth, button->mMaxWidth); S32 button_length = (orientation == LLLayoutStack::HORIZONTAL) ? button_clamped_width : button->getRect().getHeight(); @@ -411,7 +396,7 @@ void LLToolBar::updateLayoutAsNeeded() { if (orientation == LLLayoutStack::VERTICAL) { // row girth (width in this case) is clamped to allowable button widths - max_row_girth = llclamp(max_row_girth, mMinButtonWidth, mMaxButtonWidth); + max_row_girth = llclamp(max_row_girth, button->mMinWidth, button->mMaxWidth); } // make buttons in current row all same girth @@ -512,14 +497,19 @@ void LLToolBar::createButtons() BOOST_FOREACH(LLCommandId& command_id, mButtonCommands) { - createButton(command_id); + LLToolBarButton* button = createButton(command_id); + mButtons.push_back(button); + mButtonPanel->addChild(button); + mButtonMap.insert(std::make_pair(command_id, button)); } + mNeedsLayout = true; + } -void LLToolBar::createButton(const LLCommandId& id) +LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) { LLCommand* commandp = LLCommandManager::instance().getCommand(id); - if (!commandp) return; + if (!commandp) return NULL; LLToolBarButton::Params button_p; button_p.name = id.name(); @@ -539,10 +529,9 @@ void LLToolBar::createButton(const LLCommandId& id) button->setHandleDragCallback(mHandleDragItemCallback); } - mButtons.push_back(button); - mButtonPanel->addChild(button); + button->setCommandId(id); + return button; - mNeedsLayout = true; } BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, @@ -570,11 +559,25 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, return handled; } -LLToolBarButton::LLToolBarButton(const Params& p) : LLButton(p) +LLToolBarButton::LLToolBarButton(const Params& p) +: LLButton(p), + mMouseDownX(0), + mMouseDownY(0), + mMinWidth(p.min_button_width), + mMaxWidth(p.max_button_width), + mDesiredHeight(p.desired_height), + mId("") { mUUID = LLUUID::LLUUID::generateNewID(p.name); } +BOOL LLToolBarButton::handleMouseDown(S32 x, S32 y, MASK mask) +{ + mMouseDownX = x; + mMouseDownY = y; + return LLButton::handleMouseDown(x, y, mask); +} + BOOL LLToolBarButton::handleHover( S32 x, S32 y, MASK mask ) { // llinfos << "Merov debug: handleHover, x = " << x << ", y = " << y << ", mouse = " << hasMouseCapture() << llendl; @@ -593,6 +596,10 @@ BOOL LLToolBarButton::handleHover( S32 x, S32 y, MASK mask ) handled = mHandleDragItemCallback(x,y,mUUID,LLAssetType::AT_WIDGET); } } + else + { + handled = LLButton::handleHover(x, y, mask); + } return handled; } diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 6dcf620861..10e5f49c0f 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -41,18 +41,37 @@ typedef boost::function<BOOL (EDragAndDropType type, void* data, const LLUUID& u class LLToolBarButton : public LLButton { + friend class LLToolBar; public: struct Params : public LLInitParam::Block<Params, LLButton::Params> { + Optional<S32> min_button_width, + max_button_width, + desired_height; + + Params() + : min_button_width("min_button_width", 0), + max_button_width("max_button_width", S32_MAX), + desired_height("desired_height", 20) + {} + }; LLToolBarButton(const Params& p); - virtual BOOL handleHover( S32 x, S32 y, MASK mask ); - + BOOL handleMouseDown(S32 x, S32 y, MASK mask); + BOOL handleHover(S32 x, S32 y, MASK mask); + void setCommandId(const LLCommandId& id) { mId = id; } + void setStartDragCallback(startdrag_callback_t cb) { mStartDragItemCallback = cb; } void setHandleDragCallback(handledrag_callback_t cb) { mHandleDragItemCallback = cb; } -protected: +private: + LLCommandId mId; + S32 mMouseDownX; + S32 mMouseDownY; + S32 mMinWidth; + S32 mMaxWidth; + S32 mDesiredHeight; bool mIsDragged; startdrag_callback_t mStartDragItemCallback; handledrag_callback_t mHandleDragItemCallback; @@ -111,10 +130,6 @@ public: Optional<bool> read_only, wrap; - Optional<S32> min_button_width, - max_button_width, - button_height; - Optional<S32> pad_left, pad_top, pad_right, @@ -145,6 +160,8 @@ public: void setHandleDragCallback(handledrag_callback_t cb) { mHandleDragItemCallback = cb; } void setHandleDropCallback(handledrop_callback_t cb) { mHandleDropCallback = cb; } + LLToolBarButton* createButton(const LLCommandId& id); + protected: friend class LLUICtrlFactory; LLToolBar(const Params&); @@ -167,7 +184,6 @@ private: void createContextMenu(); void updateLayoutAsNeeded(); void createButtons(); - void createButton(const LLCommandId& id); void resizeButtonsInRow(std::vector<LLToolBarButton*>& buttons_in_row, S32 max_row_girth); BOOL isSettingChecked(const LLSD& userdata); void onSettingEnable(const LLSD& userdata); @@ -177,6 +193,9 @@ private: std::list<LLToolBarButton*> mButtons; command_id_list_t mButtonCommands; + typedef std::map<LLCommandId, LLToolBarButton*> command_id_map; + command_id_map mButtonMap; + LLToolBarEnums::ButtonType mButtonType; LLLayoutStack* mCenteringStack; LLLayoutStack* mWrapStack; @@ -185,10 +204,7 @@ private: bool mWrap; bool mNeedsLayout; - S32 mMinButtonWidth, - mMaxButtonWidth, - mButtonHeight, - mPadLeft, + S32 mPadLeft, mPadRight, mPadTop, mPadBottom, diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 4f129ccfba..76a12e649b 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -2107,7 +2107,7 @@ namespace LLInitParam void ParamValue<LLUIColor, TypeValues<LLUIColor> >::updateValueFromBlock() { - if (control.isProvided()) + if (control.isProvided() && !control().empty()) { updateValue(LLUIColorTable::instance().getColor(control)); } @@ -2264,9 +2264,11 @@ namespace LLInitParam // in this case, that is left+width and bottom+height LLRect& value = getValue(); + right.set(value.mRight, false); left.set(value.mLeft, make_block_authoritative); width.set(value.getWidth(), make_block_authoritative); + top.set(value.mTop, false); bottom.set(value.mBottom, make_block_authoritative); height.set(value.getHeight(), make_block_authoritative); } diff --git a/indra/llui/llui.h b/indra/llui/llui.h index 7801a01ace..3afb7c65a9 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -365,7 +365,7 @@ template <typename T> LLRegisterWith<LLInitClassList> LLInitClass<T>::sRegister( template <typename T> LLRegisterWith<LLDestroyClassList> LLDestroyClass<T>::sRegister(&T::destroyClass); // useful parameter blocks -struct TimeIntervalParam : public LLInitParam::Choice<TimeIntervalParam> +struct TimeIntervalParam : public LLInitParam::ChoiceBlock<TimeIntervalParam> { Alternative<F32> seconds; Alternative<S32> frames; diff --git a/indra/llui/lluicolortable.h b/indra/llui/lluicolortable.h index 76518789ec..6a7a681d57 100644 --- a/indra/llui/lluicolortable.h +++ b/indra/llui/lluicolortable.h @@ -44,7 +44,7 @@ LOG_CLASS(LLUIColorTable); typedef std::map<std::string, LLUIColor> string_color_map_t; public: - struct ColorParams : LLInitParam::Choice<ColorParams> + struct ColorParams : LLInitParam::ChoiceBlock<ColorParams> { Alternative<LLColor4> value; Alternative<std::string> reference; diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index fc56e5fc35..a8a4e3191d 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -76,14 +76,14 @@ public: Optional<enable_callback_t> function; }; - struct EnableControls : public LLInitParam::Choice<EnableControls> + struct EnableControls : public LLInitParam::ChoiceBlock<EnableControls> { Alternative<std::string> enabled; Alternative<std::string> disabled; EnableControls(); }; - struct ControlVisibility : public LLInitParam::Choice<ControlVisibility> + struct ControlVisibility : public LLInitParam::ChoiceBlock<ControlVisibility> { Alternative<std::string> visible; Alternative<std::string> invisible; diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index 71c38237c1..d612ad5005 100644 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -125,12 +125,12 @@ private: // base case for recursion, there are NO base classes of LLInitParam::BaseBlock template<int DUMMY> - class ParamDefaults<LLInitParam::BaseBlockWithFlags, DUMMY> : public LLSingleton<ParamDefaults<LLInitParam::BaseBlockWithFlags, DUMMY> > + class ParamDefaults<LLInitParam::BaseBlock, DUMMY> : public LLSingleton<ParamDefaults<LLInitParam::BaseBlock, DUMMY> > { public: - const LLInitParam::BaseBlockWithFlags& get() { return mBaseBlock; } + const LLInitParam::BaseBlock& get() { return mBaseBlock; } private: - LLInitParam::BaseBlockWithFlags mBaseBlock; + LLInitParam::BaseBlock mBaseBlock; }; public: diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 9039366e7e..a1c46f3bf3 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -98,7 +98,7 @@ private: class LLView : public LLMouseHandler, public LLMortician, public LLFocusableElement { public: - struct Follows : public LLInitParam::Choice<Follows> + struct Follows : public LLInitParam::ChoiceBlock<Follows> { Alternative<std::string> string; Alternative<U32> flags; @@ -465,6 +465,20 @@ public: return dynamic_cast<T*>(widgetp); } + template <class T> T* getParentByType() const + { + LLView* parent = getParent(); + while(parent) + { + if (dynamic_cast<T*>(parent)) + { + return static_cast<T*>(parent); + } + parent = parent->getParent(); + } + return NULL; + } + ////////////////////////////////////////////// // statics ////////////////////////////////////////////// diff --git a/indra/llxuixml/llinitparam.cpp b/indra/llxuixml/llinitparam.cpp index c024fd405e..99016205c8 100644 --- a/indra/llxuixml/llinitparam.cpp +++ b/indra/llxuixml/llinitparam.cpp @@ -365,7 +365,7 @@ namespace LLInitParam // verify by calling readValue with NoParamValue type, an inherently unparseable type if (!names_left) { - NoParamValue no_value; + Flag no_value; return p.readValue(no_value); } diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index 69dcd474f7..71715d15cc 100644 --- a/indra/llxuixml/llinitparam.h +++ b/indra/llxuixml/llinitparam.h @@ -38,6 +38,9 @@ namespace LLInitParam { + // used to indicate no matching value to a given name when parsing + struct Flag{}; + template<typename T> const T& defaultValue() { static T value; return value; } template <typename T, bool IS_BOOST_FUNCTION = boost::is_convertible<T, boost::function_base>::value > @@ -65,6 +68,12 @@ namespace LLInitParam static bool equals(const LLSD &a, const LLSD &b) { return false; } }; + template<> + struct ParamCompare<Flag, false> + { + static bool equals(const Flag& a, const Flag& b) { return false; } + }; + // helper functions and classes typedef ptrdiff_t param_handle_t; @@ -275,9 +284,6 @@ namespace LLInitParam static S32 sNextParseGeneration; }; - // used to indicate no matching value to a given name when parsing - struct NoParamValue{}; - class BaseBlock; class Param @@ -385,36 +391,36 @@ namespace LLInitParam // "Multiple" constraint types, put here in root class to avoid ambiguity during use struct AnyAmount { - static U32 minCount() { return 0; } - static U32 maxCount() { return U32_MAX; } + enum { minCount = 0 }; + enum { maxCount = U32_MAX }; }; template<U32 MIN_AMOUNT> struct AtLeast { - static U32 minCount() { return MIN_AMOUNT; } - static U32 maxCount() { return U32_MAX; } + enum { minCount = MIN_AMOUNT }; + enum { maxCount = U32_MAX }; }; template<U32 MAX_AMOUNT> struct AtMost { - static U32 minCount() { return 0; } - static U32 maxCount() { return MAX_AMOUNT; } + enum { minCount = 0 }; + enum { maxCount = MAX_AMOUNT }; }; template<U32 MIN_AMOUNT, U32 MAX_AMOUNT> struct Between { - static U32 minCount() { return MIN_AMOUNT; } - static U32 maxCount() { return MAX_AMOUNT; } + enum { minCount = MIN_AMOUNT }; + enum { maxCount = MAX_AMOUNT }; }; template<U32 EXACT_COUNT> struct Exactly { - static U32 minCount() { return EXACT_COUNT; } - static U32 maxCount() { return EXACT_COUNT; } + enum { minCount = EXACT_COUNT }; + enum { maxCount = EXACT_COUNT }; }; // this typedef identifies derived classes as being blocks @@ -477,9 +483,9 @@ namespace LLInitParam void init(BlockDescriptor& descriptor, BlockDescriptor& base_descriptor, size_t block_size); - bool mergeBlockParam(bool param_provided, BlockDescriptor& block_data, const BaseBlock& other, bool overwrite) + bool mergeBlockParam(bool source_provided, bool dst_provided, BlockDescriptor& block_data, const BaseBlock& source, bool overwrite) { - return mergeBlock(block_data, other, overwrite); + return mergeBlock(block_data, source, overwrite); } // take all provided params from other and apply to self bool mergeBlock(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite); @@ -497,92 +503,6 @@ namespace LLInitParam const std::string& getParamName(const BlockDescriptor& block_data, const Param* paramp) const; }; - class BaseBlockWithFlags : public BaseBlock - { - public: - class FlagBase : public Param - { - public: - typedef FlagBase self_t; - - FlagBase(const char* name, BaseBlock* enclosing_block) : Param(enclosing_block) - { - if (LL_UNLIKELY(enclosing_block->mostDerivedBlockDescriptor().mInitializationState == BlockDescriptor::INITIALIZING)) - { - ParamDescriptorPtr param_descriptor = ParamDescriptorPtr(new ParamDescriptor( - enclosing_block->getHandleFromParam(this), - &mergeWith, - &deserializeParam, - &serializeParam, - NULL, - &inspectParam, - 0, 1)); - BaseBlock::addParam(enclosing_block->mostDerivedBlockDescriptor(), param_descriptor, name); - } - } - - bool isProvided() const { return anyProvided(); } - - private: - static bool mergeWith(Param& dst, const Param& src, bool overwrite) - { - const self_t& src_typed_param = static_cast<const self_t&>(src); - self_t& dst_typed_param = static_cast<self_t&>(dst); - - if (src_typed_param.isProvided() - && (overwrite || !dst_typed_param.isProvided())) - { - dst.setProvided(true); - return true; - } - return false; - } - - static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack, S32 generation) - { - self_t& typed_param = static_cast<self_t&>(param); - - // no further names in stack, parse value now - if (name_stack.first == name_stack.second) - { - typed_param.setProvided(true); - typed_param.enclosingBlock().paramChanged(param, true); - return true; - } - - return false; - } - - static void serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const Param* diff_param) - { - const self_t& typed_param = static_cast<const self_t&>(param); - const self_t* typed_diff_param = static_cast<const self_t*>(diff_param); - - if (!typed_param.isProvided()) return; - - if (!name_stack.empty()) - { - name_stack.back().second = parser.newParseGeneration(); - } - - // then try to serialize value directly - if (!typed_diff_param || !typed_diff_param->isProvided()) - { - if (!parser.writeValue(NoParamValue(), name_stack)) - { - return; - } - } - } - - static void inspectParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, S32 min_count, S32 max_count) - { - // tell parser about our actual type - parser.inspectValue<NoParamValue>(name_stack, min_count, max_count, NULL); - } - }; - }; - // these templates allow us to distinguish between template parameters // that derive from BaseBlock and those that don't template<typename T, typename Void = void> @@ -604,7 +524,7 @@ namespace LLInitParam typedef const T& value_assignment_t; ParamValue(): mValue() {} - ParamValue(const T& other) : mValue(other) {} + ParamValue(value_assignment_t other) : mValue(other) {} void setValue(value_assignment_t val) { @@ -621,6 +541,17 @@ namespace LLInitParam return mValue; } + operator value_assignment_t() const + { + return mValue; + } + + value_assignment_t operator()() const + { + return mValue; + } + + private: T mValue; }; @@ -644,7 +575,7 @@ namespace LLInitParam mValidated(false) {} - ParamValue(const T& other) + ParamValue(value_assignment_t other) : T(other), mKeyVersion(0), mValidatedVersion(-1), @@ -666,6 +597,16 @@ namespace LLInitParam { return *this; } + + operator value_assignment_t() const + { + return *this; + } + + value_assignment_t operator()() const + { + return *this; + } }; template<typename T, typename NAME_VALUE_LOOKUP = TypeValues<T> > @@ -801,11 +742,6 @@ namespace LLInitParam Param::enclosingBlock().paramChanged(*this, flag_as_provided); } - // implicit conversion - operator value_assignment_t() const { return param_value_t::getValue(); } - // explicit conversion - value_assignment_t operator()() const { return param_value_t::getValue(); } - protected: static bool mergeWith(Param& dst, const Param& src, bool overwrite) @@ -958,11 +894,6 @@ namespace LLInitParam } } - // implicit conversion - operator value_assignment_t() const { return param_value_t::getValue(); } - // explicit conversion - value_assignment_t operator()() const { return param_value_t::getValue(); } - protected: static bool mergeWith(Param& dst, const Param& src, bool overwrite) @@ -972,8 +903,7 @@ namespace LLInitParam if (src_typed_param.anyProvided()) { - bool param_provided = src_typed_param.isProvided() && (overwrite || !dst_typed_param.isProvided()); - if (dst_typed_param.mergeBlockParam(param_provided, param_value_t::selfBlockDescriptor(), src_typed_param, overwrite)) + if (dst_typed_param.mergeBlockParam(src_typed_param.isProvided(), dst_typed_param.isProvided(), param_value_t::selfBlockDescriptor(), src_typed_param, overwrite)) { dst_typed_param.clearValueName(); dst_typed_param.setProvided(true); @@ -992,8 +922,8 @@ namespace LLInitParam { public: typedef TypedParam<VALUE_TYPE, NAME_VALUE_LOOKUP, true, false> self_t; - typedef ParamValue<VALUE_TYPE, NAME_VALUE_LOOKUP> param_value_t; - typedef typename std::vector<param_value_t> container_t; + typedef ParamValue<VALUE_TYPE, NAME_VALUE_LOOKUP> param_value_t; + typedef typename std::vector<param_value_t> container_t; typedef const container_t& value_assignment_t; typedef VALUE_TYPE value_t; @@ -1118,6 +1048,8 @@ namespace LLInitParam // implicit conversion operator value_assignment_t() const { return mValues; } + // explicit conversion + value_assignment_t operator()() const { return mValues; } typedef typename container_t::iterator iterator; typedef typename container_t::const_iterator const_iterator; @@ -1169,7 +1101,7 @@ namespace LLInitParam public: typedef TypedParam<VALUE_TYPE, NAME_VALUE_LOOKUP, true, true> self_t; typedef ParamValue<VALUE_TYPE, NAME_VALUE_LOOKUP> param_value_t; - typedef typename std::vector<param_value_t> container_t; + typedef typename std::vector<param_value_t> container_t; typedef const container_t& value_assignment_t; typedef VALUE_TYPE value_t; typedef NAME_VALUE_LOOKUP name_value_lookup_t; @@ -1308,6 +1240,8 @@ namespace LLInitParam // implicit conversion operator value_assignment_t() const { return mValues; } + // explicit conversion + value_assignment_t operator()() const { return mValues; } typedef typename container_t::iterator iterator; typedef typename container_t::const_iterator const_iterator; @@ -1363,10 +1297,10 @@ namespace LLInitParam }; template <typename DERIVED_BLOCK> - class Choice : public BaseBlock + class ChoiceBlock : public BaseBlock { - typedef Choice<DERIVED_BLOCK> self_t; - typedef Choice<DERIVED_BLOCK> enclosing_block_t; + typedef ChoiceBlock<DERIVED_BLOCK> self_t; + typedef ChoiceBlock<DERIVED_BLOCK> enclosing_block_t; LOG_CLASS(self_t); public: @@ -1382,11 +1316,13 @@ namespace LLInitParam return mergeBlock(selfBlockDescriptor(), other, false); } - bool mergeBlockParam(bool param_provided, BlockDescriptor& block_data, const self_t& other, bool overwrite) + bool mergeBlockParam(bool source_provided, bool dest_provided, BlockDescriptor& block_data, const self_t& source, bool overwrite) { - if (param_provided) + bool source_override = source_provided && (overwrite || !dest_provided); + + if (source_override || source.mCurChoice == mCurChoice) { - return mergeBlock(block_data, other, overwrite); + return mergeBlock(block_data, source, overwrite); } return false; } @@ -1420,7 +1356,7 @@ namespace LLInitParam virtual BlockDescriptor& mostDerivedBlockDescriptor() { return selfBlockDescriptor(); } protected: - Choice() + ChoiceBlock() : mCurChoice(0) { BaseBlock::init(selfBlockDescriptor(), BaseBlock::selfBlockDescriptor(), sizeof(DERIVED_BLOCK)); @@ -1433,13 +1369,13 @@ namespace LLInitParam class Alternative : public TypedParam<T, NAME_VALUE_LOOKUP, false> { public: - friend class Choice<DERIVED_BLOCK>; + friend class ChoiceBlock<DERIVED_BLOCK>; typedef Alternative<T, NAME_VALUE_LOOKUP> self_t; typedef TypedParam<T, NAME_VALUE_LOOKUP, false, IsBlock<ParamValue<T, NAME_VALUE_LOOKUP> >::value> super_t; typedef typename super_t::value_assignment_t value_assignment_t; - explicit Alternative(const char* name, value_assignment_t val = defaultValue<T>()) + explicit Alternative(const char* name = "", value_assignment_t val = defaultValue<T>()) : super_t(DERIVED_BLOCK::selfBlockDescriptor(), name, val, NULL, 0, 1), mOriginalValue(val) { @@ -1454,10 +1390,19 @@ namespace LLInitParam } } - Alternative& operator=(value_assignment_t val) + void choose() + { + static_cast<enclosing_block_t&>(Param::enclosingBlock()).paramChanged(*this, true); + } + + void chooseAs(value_assignment_t val) + { + super_t::set(val); + } + + void operator=(value_assignment_t val) { super_t::set(val); - return *this; } void operator()(typename super_t::value_assignment_t val) @@ -1466,12 +1411,8 @@ namespace LLInitParam } operator value_assignment_t() const - { - if (static_cast<enclosing_block_t&>(Param::enclosingBlock()).getCurrentChoice() == this) - { - return super_t::getValue(); - } - return mOriginalValue; + { + return (*this)(); } value_assignment_t operator()() const @@ -1508,7 +1449,7 @@ namespace LLInitParam } }; - template <typename DERIVED_BLOCK, typename BASE_BLOCK = BaseBlockWithFlags> + template <typename DERIVED_BLOCK, typename BASE_BLOCK = BaseBlock> class Block : public BASE_BLOCK { @@ -1604,13 +1545,6 @@ namespace LLInitParam }; - class Flag : public BaseBlockWithFlags::FlagBase - { - public: - Flag(const char* name) : FlagBase(name, DERIVED_BLOCK::selfBlockDescriptor().mCurrentBlockPtr) - {} - }; - template <typename T, typename RANGE = BaseBlock::AnyAmount, typename NAME_VALUE_LOOKUP = TypeValues<T> > class Multiple : public TypedParam<T, NAME_VALUE_LOOKUP, true> { @@ -1623,7 +1557,7 @@ namespace LLInitParam typedef typename super_t::const_iterator const_iterator; explicit Multiple(const char* name = "") - : super_t(DERIVED_BLOCK::selfBlockDescriptor(), name, container_t(), &validate, RANGE::minCount(), RANGE::maxCount()) + : super_t(DERIVED_BLOCK::selfBlockDescriptor(), name, container_t(), &validate, RANGE::minCount, RANGE::maxCount) {} Multiple& operator=(value_assignment_t val) @@ -1641,100 +1575,10 @@ namespace LLInitParam static bool validate(const Param* paramp) { U32 num_valid = ((super_t*)paramp)->numValidElements(); - return RANGE::minCount() <= num_valid && num_valid <= RANGE::maxCount(); + return RANGE::minCount <= num_valid && num_valid <= RANGE::maxCount; } }; - template <typename T, typename RANGE = BaseBlock::AnyAmount, typename NAME_VALUE_LOOKUP = TypeValues<T> > - class Batch : private TypedParam<T, NAME_VALUE_LOOKUP, false> - { - public: - typedef ParamValue<T, NAME_VALUE_LOOKUP> param_value_t; - typedef TypedParam<T, NAME_VALUE_LOOKUP, false, IsBlock<param_value_t>::value> super_t; - typedef Batch<T, RANGE, NAME_VALUE_LOOKUP> self_t; - typedef typename super_t::value_assignment_t value_assignment_t; - typedef typename super_t::value_t value_t; - - struct BatchDefaultValue : public ParamDescriptor::UserData - { - BatchDefaultValue(const T& value) - : mValue(value) - {} - - T mValue; - }; - - explicit Batch(const char* name, value_assignment_t val) - : super_t(DERIVED_BLOCK::selfBlockDescriptor(), name, val, NULL, 0, 1), - mLastParseGeneration(-1) - { - BlockDescriptor& block_descriptor = DERIVED_BLOCK::selfBlockDescriptor(); - if (LL_UNLIKELY(block_descriptor.mInitializationState == BlockDescriptor::INITIALIZING)) - { - ParamDescriptorPtr param_descriptorp = block_descriptor.mCurrentBlockPtr->findParamDescriptor(*this); - - if (param_descriptorp) - { - param_descriptorp->mDeserializeFunc = &deserializeParam; - param_descriptorp->mUserData = new BatchDefaultValue(new param_value_t(val)); - } - } - } - - explicit Batch(const char* name = "") - : super_t(DERIVED_BLOCK::selfBlockDescriptor(), name, defaultValue<T>(), NULL, 0, 1), - mLastParseGeneration(-1) - { - BlockDescriptor& block_descriptor = DERIVED_BLOCK::selfBlockDescriptor(); - if (LL_UNLIKELY(block_descriptor.mInitializationState == BlockDescriptor::INITIALIZING)) - { - ParamDescriptorPtr param_descriptorp = block_descriptor.mCurrentBlockPtr->findParamDescriptor(*this); - - if (param_descriptorp) - { - param_descriptorp->mDeserializeFunc = &deserializeParam; - } - } - } - - Batch& operator=(value_assignment_t val) - { - set(val); - return *this; - } - - DERIVED_BLOCK& operator()(value_assignment_t val) - { - super_t::set(val); - return static_cast<DERIVED_BLOCK&>(Param::enclosingBlock()); - } - - using super_t::operator(); - - private: - static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack, S32 generation) - { - self_t& typed_param = static_cast<self_t&>(param); - - if (generation != typed_param.mLastParseGeneration) - { - ParamDescriptorPtr descriptor = typed_param.enclosingBlock().findParamDescriptor(param); - if (descriptor && static_cast<BatchDefaultValue*>(descriptor->mUserData)) - { - static_cast<param_value_t&>(typed_param) = (static_cast<BatchDefaultValue*>(descriptor->mUserData))->mValue; - } - else - { - static_cast<param_value_t&>(typed_param) = param_value_t(value_t()); - } - typed_param.mLastParseGeneration = generation; - } - return super_t::deserializeParam(param, parser, name_stack, generation); - } - - S32 mLastParseGeneration; - }; - class Deprecated : public Param { public: @@ -1769,6 +1613,7 @@ namespace LLInitParam } }; + // different semantics for documentation purposes, but functionally identical typedef Deprecated Ignored; protected: @@ -1790,6 +1635,100 @@ namespace LLInitParam }; + template <typename DERIVED_BLOCK, typename BASE_BLOCK = BaseBlock> + class BatchBlock + : public Block<DERIVED_BLOCK, BASE_BLOCK> + { + public: + typedef BatchBlock<DERIVED_BLOCK, BASE_BLOCK> self_t; + typedef Block<DERIVED_BLOCK, BASE_BLOCK> super_t; + + BatchBlock() + : mLastParseGeneration(-1) + {} + + bool deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, S32 generation) + { + if (generation != mLastParseGeneration) + { + // reset block + *static_cast<DERIVED_BLOCK*>(this) = defaultBatchValue(); + mLastParseGeneration = generation; + } + return super_t::deserializeBlock(p, name_stack, generation); + } + + bool mergeBlock(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite) + { + if (overwrite) + { + *static_cast<DERIVED_BLOCK*>(this) = defaultBatchValue(); + mLastParseGeneration = -1; + // merge individual parameters into destination + return super_t::mergeBlock(super_t::selfBlockDescriptor(), other, overwrite); + } + return false; + } + protected: + static const DERIVED_BLOCK& defaultBatchValue() + { + static DERIVED_BLOCK default_value; + return default_value; + } + + S32 mLastParseGeneration; + }; + + + + template<typename DERIVED_BLOCK, + typename BASE_BLOCK, + typename NAME_VALUE_LOOKUP> + class ParamValue <BatchBlock<DERIVED_BLOCK, BASE_BLOCK>, + NAME_VALUE_LOOKUP, + true> + : public Param, + protected BatchBlock<DERIVED_BLOCK, BASE_BLOCK> + { + typedef const BatchBlock<DERIVED_BLOCK, BASE_BLOCK>& value_assignment_t; + + ParamValue() + : BatchBlock<DERIVED_BLOCK, BASE_BLOCK>() + {} + + ParamValue(value_assignment_t other) + : BatchBlock<DERIVED_BLOCK, BASE_BLOCK>(other) + { + } + + void setValue(value_assignment_t val) + { + *this = val; + BatchBlock<DERIVED_BLOCK, BASE_BLOCK>::mLastParseGeneration = -1; + } + + value_assignment_t getValue() const + { + return *this; + } + + BatchBlock<DERIVED_BLOCK, BASE_BLOCK>& getValue() + { + return *this; + } + + operator value_assignment_t() const + { + return *this; + } + + value_assignment_t operator()() const + { + return *this; + } + + }; + template<typename T> class CustomParamValue : public Block<ParamValue<T, TypeValues<T> > >, @@ -1955,6 +1894,16 @@ namespace LLInitParam return mValue; } + operator value_assignment_t() const + { + return getValue(); + } + + value_assignment_t operator()() const + { + return getValue(); + } + S32 mKeyVersion; protected: @@ -1965,30 +1914,29 @@ namespace LLInitParam mValue = value; } - bool mergeBlockParam(bool param_provided, BlockDescriptor& block_data, const BaseBlock& other, bool overwrite) + bool mergeBlockParam(bool source_provided, bool dst_provided, BlockDescriptor& block_data, const BaseBlock& source, bool overwrite) { - if (param_provided) - { - return mergeBlock(block_data, other, overwrite); - } - return false; - } + bool source_override = source_provided && (overwrite || !dst_provided); - bool mergeBlock(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite) - { - const derived_t& src_typed_param = static_cast<const derived_t&>(other); + const derived_t& src_typed_param = static_cast<const derived_t&>(source); - if (src_typed_param.mValueAge == VALUE_AUTHORITATIVE) + if (source_override && src_typed_param.mValueAge == VALUE_AUTHORITATIVE) { // copy value over setValue(src_typed_param.getValue()); return true; } - else + // merge individual parameters into destination + if (mValueAge == VALUE_AUTHORITATIVE) { - // merge individual parameters into destination - return block_t::mergeBlock(block_t::selfBlockDescriptor(), src_typed_param, overwrite); + static_cast<derived_t*>(this)->updateBlockFromValue(dst_provided); } + return mergeBlock(block_data, source, overwrite); + } + + bool mergeBlock(BlockDescriptor& block_data, const BaseBlock& source, bool overwrite) + { + return block_t::mergeBlock(block_data, source, overwrite); } mutable S32 mValidatedVersion; diff --git a/indra/llxuixml/llxuiparser.cpp b/indra/llxuixml/llxuiparser.cpp index 4af077b22c..c60f656c2c 100644 --- a/indra/llxuixml/llxuiparser.cpp +++ b/indra/llxuixml/llxuiparser.cpp @@ -51,6 +51,136 @@ static LLInitParam::Parser::parser_read_func_map_t sXSDReadFuncs; static LLInitParam::Parser::parser_write_func_map_t sXSDWriteFuncs; static LLInitParam::Parser::parser_inspect_func_map_t sXSDInspectFuncs; +struct MaxOccur : public LLInitParam::ChoiceBlock<MaxOccur> +{ + Alternative<int> count; + Alternative<std::string> unbounded; + + MaxOccur() + : unbounded("", "unbounded") + {} +}; + +struct Occurs : public LLInitParam::Block<Occurs> +{ + Optional<S32> minOccurs; + Optional<MaxOccur> maxOccurs; + + Occurs() + : minOccurs("minOccurs"), + maxOccurs("maxOccurs") + { + minOccurs = 0; + maxOccurs.unbounded.choose(); + } +}; + + +typedef enum +{ + USE_REQUIRED, + USE_OPTIONAL +} EUse; + +namespace LLInitParam +{ + template<> + struct TypeValues<EUse> : public TypeValuesHelper<EUse> + { + static void declareValues() + { + declare("required", USE_REQUIRED); + declare("optional", USE_OPTIONAL); + } + }; +} + +struct Name : public LLInitParam::Block<Name> +{ + Mandatory<std::string> name; + + Name() + : name("name") + {} +}; + +struct Attribute : public LLInitParam::Block<Attribute> +{ + Mandatory<Name> name; + Mandatory<std::string> type; + Mandatory<EUse> use; + + Attribute() + : name("name"), + type("type"), + use("use") + { + } +}; + +struct ComplexType : public LLInitParam::Block<ComplexType> +{ + Multiple<Attribute> attribute; + //Multiple<struct Element> elements; + Optional<bool> mixed; + + ComplexType() + : attribute("xs:attribute"), + //elements("xs:element"), + mixed("mixed") + { + mixed = true; + } +}; + +struct Element : public LLInitParam::Block<Element, Occurs> +{ + Mandatory<ComplexType> complexType; + Mandatory<Name> name; + + Element() + : complexType("xs:complexType") + {} +}; + +struct Elements : public LLInitParam::Block<Elements, Occurs> +{ + Multiple<Element> elements; + + Elements() + : elements("xs:element") + {} +}; + +struct Schema : public LLInitParam::Block<Schema> +{ +private: + Mandatory<std::string> targetNamespace, + xmlns; + +public: + Optional<std::string> attributeFormDefault, + elementFormDefault, + xs; + + Optional<Elements> elements; + + void setNameSpace(const std::string& ns) {targetNamespace = ns; xmlns = ns;} + + Schema() + : attributeFormDefault("attributeFormDefault"), + elementFormDefault("elementFormDefault"), + xs("xmlns:xs"), + targetNamespace("targetNamespace"), + xmlns("xmlns"), + elements("xs:choice") + { + attributeFormDefault = "unqualified"; + elementFormDefault = "qualified"; + xs = "http://www.w3.org/2001/XMLSchema"; + } + +}; // // LLXSDWriter @@ -388,7 +518,7 @@ LLXUIParser::LLXUIParser() { if (sXUIReadFuncs.empty()) { - registerParserFuncs<LLInitParam::NoParamValue>(readNoValue, writeNoValue); + registerParserFuncs<LLInitParam::Flag>(readFlag, writeFlag); registerParserFuncs<bool>(readBoolValue, writeBoolValue); registerParserFuncs<std::string>(readStringValue, writeStringValue); registerParserFuncs<U8>(readU8Value, writeU8Value); @@ -645,13 +775,13 @@ LLXMLNodePtr LLXUIParser::getNode(const name_stack_t& stack) return (out_node == mWriteRootNode ? LLXMLNodePtr(NULL) : out_node); } -bool LLXUIParser::readNoValue(Parser& parser, void* val_ptr) +bool LLXUIParser::readFlag(Parser& parser, void* val_ptr) { LLXUIParser& self = static_cast<LLXUIParser&>(parser); return self.mCurReadNode == DUMMY_NODE; } -bool LLXUIParser::writeNoValue(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeFlag(Parser& parser, const void* val_ptr, const name_stack_t& stack) { // just create node LLXUIParser& self = static_cast<LLXUIParser&>(parser); @@ -1083,7 +1213,7 @@ LLSimpleXUIParser::LLSimpleXUIParser(LLSimpleXUIParser::element_start_callback_t { if (sSimpleXUIReadFuncs.empty()) { - registerParserFuncs<LLInitParam::NoParamValue>(readNoValue); + registerParserFuncs<LLInitParam::Flag>(readFlag); registerParserFuncs<bool>(readBoolValue); registerParserFuncs<std::string>(readStringValue); registerParserFuncs<U8>(readU8Value); @@ -1376,7 +1506,7 @@ void LLSimpleXUIParser::parserError(const std::string& message) #endif } -bool LLSimpleXUIParser::readNoValue(Parser& parser, void* val_ptr) +bool LLSimpleXUIParser::readFlag(Parser& parser, void* val_ptr) { LLSimpleXUIParser& self = static_cast<LLSimpleXUIParser&>(parser); return self.mCurAttributeValueBegin == NO_VALUE_MARKER; diff --git a/indra/llxuixml/llxuiparser.h b/indra/llxuixml/llxuiparser.h index 0c38c4da93..42a79b4100 100644 --- a/indra/llxuixml/llxuiparser.h +++ b/indra/llxuixml/llxuiparser.h @@ -116,7 +116,7 @@ private: bool readAttributes(LLXMLNodePtr nodep, LLInitParam::BaseBlock& block); //reader helper functions - static bool readNoValue(Parser& parser, void* val_ptr); + static bool readFlag(Parser& parser, void* val_ptr); static bool readBoolValue(Parser& parser, void* val_ptr); static bool readStringValue(Parser& parser, void* val_ptr); static bool readU8Value(Parser& parser, void* val_ptr); @@ -133,7 +133,7 @@ private: static bool readSDValue(Parser& parser, void* val_ptr); //writer helper functions - static bool writeNoValue(Parser& parser, const void* val_ptr, const name_stack_t&); + static bool writeFlag(Parser& parser, const void* val_ptr, const name_stack_t&); static bool writeBoolValue(Parser& parser, const void* val_ptr, const name_stack_t&); static bool writeStringValue(Parser& parser, const void* val_ptr, const name_stack_t&); static bool writeU8Value(Parser& parser, const void* val_ptr, const name_stack_t&); @@ -197,7 +197,7 @@ public: private: //reader helper functions - static bool readNoValue(Parser&, void* val_ptr); + static bool readFlag(Parser&, void* val_ptr); static bool readBoolValue(Parser&, void* val_ptr); static bool readStringValue(Parser&, void* val_ptr); static bool readU8Value(Parser&, void* val_ptr); diff --git a/indra/newview/app_settings/commands.xml b/indra/newview/app_settings/commands.xml index 224c1b4b48..77bf7cace3 100644 --- a/indra/newview/app_settings/commands.xml +++ b/indra/newview/app_settings/commands.xml @@ -70,7 +70,7 @@ label_ref="Command_HowTo_Label" tooltip_ref="Command_HowTo_Tooltip" function="Floater.ToolbarToggle" - parameter="floater_help_browser" + parameter="help_browser" /> <command name="inventory" available_in_toybox="true" @@ -142,7 +142,7 @@ label_ref="Command_Profile_Label" tooltip_ref="Command_Profile_Tooltip" function="Floater.ToolbarToggle" - parameter="profile" + parameter="my_profile" /> <command name="search" available_in_toybox="true" diff --git a/indra/newview/llfloatertoybox.cpp b/indra/newview/llfloatertoybox.cpp index d7f114043d..7a6afb4e33 100644 --- a/indra/newview/llfloatertoybox.cpp +++ b/indra/newview/llfloatertoybox.cpp @@ -61,6 +61,8 @@ BOOL LLFloaterToybox::postBuild() center(); mBtnRestoreDefaults = getChild<LLButton>("btn_restore_defaults"); + mBtnRestoreDefaults->setCommitCallback(boost::bind(&LLToolBarView::loadDefaultToolbars)); + mToolBar = getChild<LLToolBar>("toybox_toolbar"); LLCommandManager& cmdMgr = LLCommandManager::instance(); diff --git a/indra/newview/llnamelistctrl.h b/indra/newview/llnamelistctrl.h index d64fdbe6a5..ca9956dc53 100644 --- a/indra/newview/llnamelistctrl.h +++ b/indra/newview/llnamelistctrl.h @@ -61,7 +61,7 @@ public: {} }; - struct NameColumn : public LLInitParam::Choice<NameColumn> + struct NameColumn : public LLInitParam::ChoiceBlock<NameColumn> { Alternative<S32> column_index; Alternative<std::string> column_name; diff --git a/indra/newview/lltoolbarview.cpp b/indra/newview/lltoolbarview.cpp index 929486a185..5822f682df 100644 --- a/indra/newview/lltoolbarview.cpp +++ b/indra/newview/lltoolbarview.cpp @@ -129,7 +129,7 @@ bool LLToolBarView::addCommand(const LLCommandId& command, LLToolBar* toolbar) } bool LLToolBarView::loadToolbars(bool force_default) -{ +{ LLToolBarView::ToolbarSet toolbar_set; // Load the toolbars.xml file @@ -219,6 +219,19 @@ bool LLToolBarView::loadToolbars(bool force_default) return true; } +//static +bool LLToolBarView::loadDefaultToolbars() +{ + bool retval = false; + + if (gToolBarView) + { + retval = gToolBarView->loadToolbars(true); + } + + return retval; +} + void LLToolBarView::saveToolbars() const { // Build the parameter tree from the toolbar data diff --git a/indra/newview/lltoolbarview.h b/indra/newview/lltoolbarview.h index 4e1b855e3d..b7d3a4033a 100644 --- a/indra/newview/lltoolbarview.h +++ b/indra/newview/lltoolbarview.h @@ -51,7 +51,7 @@ public: struct Toolbar : public LLInitParam::Block<Toolbar> { Mandatory<U32> button_display_mode; - Multiple<LLCommandId::Params> commands; + Multiple<LLCommandId::Params> commands; Toolbar(); }; struct ToolbarSet : public LLInitParam::Block<ToolbarSet> @@ -66,18 +66,18 @@ public: virtual ~LLToolBarView(); virtual BOOL postBuild(); virtual void draw(); - // Toolbar view interface with the rest of the world // Checks if the commandId is being used somewhere in one of the toolbars bool hasCommand(const LLCommandId& commandId) const; // Loads the toolbars from the existing user or default settings bool loadToolbars(bool force_default = false); // return false if load fails - bool loadDefaultToolbars() { return loadToolbars(true); } + static bool loadDefaultToolbars(); + static void startDragItem( S32 x, S32 y, const LLUUID& uuid); static BOOL handleDragItem( S32 x, S32 y, const LLUUID& uuid, LLAssetType::EType type); static BOOL handleDrop( EDragAndDropType cargo_type, void* cargo_data, const LLUUID& folder_id); - + protected: friend class LLUICtrlFactory; LLToolBarView(const Params&); @@ -93,6 +93,10 @@ private: LLToolBar* mToolbarLeft; LLToolBar* mToolbarRight; LLToolBar* mToolbarBottom; + bool mDragging; + LLToolBarButton* mDragButton; + S32 mMouseX; + S32 mMouseY; static bool sDragStarted; }; diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 30ef8b8a29..c64488251a 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -1342,7 +1342,8 @@ LLUIImagePtr LLUIImageList::getUIImageByID(const LLUUID& image_id, S32 priority) const BOOL use_mips = FALSE; const LLRect scale_rect = LLRect::null; - return loadUIImageByID(image_id, use_mips, scale_rect, (LLViewerTexture::EBoostLevel)priority); + const LLRect clip_rect = LLRect::null; + return loadUIImageByID(image_id, use_mips, scale_rect, clip_rect, (LLViewerTexture::EBoostLevel)priority); } LLUIImagePtr LLUIImageList::getUIImage(const std::string& image_name, S32 priority) @@ -1356,32 +1357,33 @@ LLUIImagePtr LLUIImageList::getUIImage(const std::string& image_name, S32 priori const BOOL use_mips = FALSE; const LLRect scale_rect = LLRect::null; - return loadUIImageByName(image_name, image_name, use_mips, scale_rect, (LLViewerTexture::EBoostLevel)priority); + const LLRect clip_rect = LLRect::null; + return loadUIImageByName(image_name, image_name, use_mips, scale_rect, clip_rect, (LLViewerTexture::EBoostLevel)priority); } LLUIImagePtr LLUIImageList::loadUIImageByName(const std::string& name, const std::string& filename, - BOOL use_mips, const LLRect& scale_rect, LLViewerTexture::EBoostLevel boost_priority ) + BOOL use_mips, const LLRect& scale_rect, const LLRect& clip_rect, LLViewerTexture::EBoostLevel boost_priority ) { if (boost_priority == LLViewerTexture::BOOST_NONE) { boost_priority = LLViewerTexture::BOOST_UI; } LLViewerFetchedTexture* imagep = LLViewerTextureManager::getFetchedTextureFromFile(filename, MIPMAP_NO, boost_priority); - return loadUIImage(imagep, name, use_mips, scale_rect); + return loadUIImage(imagep, name, use_mips, scale_rect, clip_rect); } LLUIImagePtr LLUIImageList::loadUIImageByID(const LLUUID& id, - BOOL use_mips, const LLRect& scale_rect, LLViewerTexture::EBoostLevel boost_priority) + BOOL use_mips, const LLRect& scale_rect, const LLRect& clip_rect, LLViewerTexture::EBoostLevel boost_priority) { if (boost_priority == LLViewerTexture::BOOST_NONE) { boost_priority = LLViewerTexture::BOOST_UI; } LLViewerFetchedTexture* imagep = LLViewerTextureManager::getFetchedTexture(id, MIPMAP_NO, boost_priority); - return loadUIImage(imagep, id.asString(), use_mips, scale_rect); + return loadUIImage(imagep, id.asString(), use_mips, scale_rect, clip_rect); } -LLUIImagePtr LLUIImageList::loadUIImage(LLViewerFetchedTexture* imagep, const std::string& name, BOOL use_mips, const LLRect& scale_rect) +LLUIImagePtr LLUIImageList::loadUIImage(LLViewerFetchedTexture* imagep, const std::string& name, BOOL use_mips, const LLRect& scale_rect, const LLRect& clip_rect) { if (!imagep) return NULL; @@ -1402,13 +1404,14 @@ LLUIImagePtr LLUIImageList::loadUIImage(LLViewerFetchedTexture* imagep, const st LLUIImageLoadData* datap = new LLUIImageLoadData; datap->mImageName = name; datap->mImageScaleRegion = scale_rect; + datap->mImageClipRegion = clip_rect; imagep->setLoadedCallback(onUIImageLoaded, 0, FALSE, FALSE, datap, NULL); } return new_imagep; } -LLUIImagePtr LLUIImageList::preloadUIImage(const std::string& name, const std::string& filename, BOOL use_mips, const LLRect& scale_rect) +LLUIImagePtr LLUIImageList::preloadUIImage(const std::string& name, const std::string& filename, BOOL use_mips, const LLRect& scale_rect, const LLRect& clip_rect) { // look for existing image uuid_ui_image_map_t::iterator found_it = mUIImages.find(name); @@ -1418,7 +1421,7 @@ LLUIImagePtr LLUIImageList::preloadUIImage(const std::string& name, const std::s llerrs << "UI Image " << name << " already loaded." << llendl; } - return loadUIImageByName(name, filename, use_mips, scale_rect); + return loadUIImageByName(name, filename, use_mips, scale_rect, clip_rect); } //static @@ -1432,6 +1435,7 @@ void LLUIImageList::onUIImageLoaded( BOOL success, LLViewerFetchedTexture *src_v LLUIImageLoadData* image_datap = (LLUIImageLoadData*)user_data; std::string ui_image_name = image_datap->mImageName; LLRect scale_rect = image_datap->mImageScaleRegion; + LLRect clip_rect = image_datap->mImageClipRegion; if (final) { delete image_datap; @@ -1448,9 +1452,21 @@ void LLUIImageList::onUIImageLoaded( BOOL success, LLViewerFetchedTexture *src_v // from power-of-2 gl image if (success && imagep.notNull() && src_vi && (src_vi->getUrl().compare(0, 7, "file://")==0)) { - F32 clip_x = (F32)src_vi->getOriginalWidth() / (F32)src_vi->getFullWidth(); - F32 clip_y = (F32)src_vi->getOriginalHeight() / (F32)src_vi->getFullHeight(); - imagep->setClipRegion(LLRectf(0.f, clip_y, clip_x, 0.f)); + F32 full_width = (F32)src_vi->getFullWidth(); + F32 full_height = (F32)src_vi->getFullHeight(); + F32 clip_x = (F32)src_vi->getOriginalWidth() / full_width; + F32 clip_y = (F32)src_vi->getOriginalHeight() / full_height; + if (clip_rect != LLRect::null) + { + imagep->setClipRegion(LLRectf(llclamp((F32)clip_rect.mLeft / full_width, 0.f, 1.f), + llclamp((F32)clip_rect.mTop / full_height, 0.f, 1.f), + llclamp((F32)clip_rect.mRight / full_width, 0.f, 1.f), + llclamp((F32)clip_rect.mBottom / full_height, 0.f, 1.f))); + } + else + { + imagep->setClipRegion(LLRectf(0.f, clip_y, clip_x, 0.f)); + } if (scale_rect != LLRect::null) { imagep->setScaleRegion( @@ -1471,6 +1487,7 @@ struct UIImageDeclaration : public LLInitParam::Block<UIImageDeclaration> Optional<std::string> file_name; Optional<bool> preload; Optional<LLRect> scale; + Optional<LLRect> clip; Optional<bool> use_mips; UIImageDeclaration() @@ -1478,6 +1495,7 @@ struct UIImageDeclaration : public LLInitParam::Block<UIImageDeclaration> file_name("file_name"), preload("preload", false), scale("scale"), + clip("clip"), use_mips("use_mips", false) {} }; @@ -1572,7 +1590,7 @@ bool LLUIImageList::initFromFile() { continue; } - preloadUIImage(image.name, file_name, image.use_mips, image.scale); + preloadUIImage(image.name, file_name, image.use_mips, image.scale, image.clip); } if (cur_pass == PASS_DECODE_NOW && !gSavedSettings.getBOOL("NoPreload")) diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h index 7f4dd0ae88..e0a362596d 100644 --- a/indra/newview/llviewertexturelist.h +++ b/indra/newview/llviewertexturelist.h @@ -220,24 +220,27 @@ public: bool initFromFile(); - LLPointer<LLUIImage> preloadUIImage(const std::string& name, const std::string& filename, BOOL use_mips, const LLRect& scale_rect); + LLPointer<LLUIImage> preloadUIImage(const std::string& name, const std::string& filename, BOOL use_mips, const LLRect& scale_rect, const LLRect& clip_rect); static void onUIImageLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* src_aux, S32 discard_level, BOOL final, void* userdata ); private: LLPointer<LLUIImage> loadUIImageByName(const std::string& name, const std::string& filename, BOOL use_mips = FALSE, const LLRect& scale_rect = LLRect::null, + const LLRect& clip_rect = LLRect::null, LLViewerTexture::EBoostLevel boost_priority = LLViewerTexture::BOOST_UI); LLPointer<LLUIImage> loadUIImageByID(const LLUUID& id, BOOL use_mips = FALSE, const LLRect& scale_rect = LLRect::null, + const LLRect& clip_rect = LLRect::null, LLViewerTexture::EBoostLevel boost_priority = LLViewerTexture::BOOST_UI); - LLPointer<LLUIImage> loadUIImage(LLViewerFetchedTexture* imagep, const std::string& name, BOOL use_mips = FALSE, const LLRect& scale_rect = LLRect::null); + LLPointer<LLUIImage> loadUIImage(LLViewerFetchedTexture* imagep, const std::string& name, BOOL use_mips = FALSE, const LLRect& scale_rect = LLRect::null, const LLRect& clip_rect = LLRect::null); struct LLUIImageLoadData { std::string mImageName; LLRect mImageScaleRegion; + LLRect mImageClipRegion; }; typedef std::map< std::string, LLPointer<LLUIImage> > uuid_ui_image_map_t; diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index 4462fb792f..68773947ec 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -473,7 +473,11 @@ with the same filename but different name <texture name="Resize_Corner" file_name="windows/Resize_Corner.png" preload="true" /> - <texture name="Rounded_Rect" file_name="Rounded_Rect.png" preload="true" scale.left="6" scale.top="24" scale.right="58" scale.bottom="6" /> + <texture name="Rounded_Rect" file_name="Rounded_Rect.png" preload="true" scale.left="6" scale.top="26" scale.right="58" scale.bottom="6" /> + <texture name="Rounded_Rect_Top" file_name="Rounded_Rect.png" preload="true" scale.left="6" scale.top="8" scale.right="58" scale.bottom="0" clip.left="0" clip.right="64" clip.bottom="16" clip.top="32" /> + <texture name="Rounded_Rect_Bottom" file_name="Rounded_Rect.png" preload="true" scale.left="6" scale.top="16" scale.right="58" scale.bottom="8" clip.left="0" clip.right="64" clip.bottom="0" clip.top="16" /> + <texture name="Rounded_Rect_Left" file_name="Rounded_Rect.png" preload="true" scale.left="6" scale.top="26" scale.right="32" scale.bottom="6" clip.left="0" clip.right="32" clip.bottom="0" clip.top="32" /> + <texture name="Rounded_Rect_Right" file_name="Rounded_Rect.png" preload="true" scale.left="0" scale.top="26" scale.right="26" scale.bottom="6" clip.left="32" clip.right="64" clip.bottom="0" clip.top="32" /> <texture name="Rounded_Square" file_name="rounded_square.j2c" preload="true" scale.left="16" scale.top="16" scale.right="112" scale.bottom="16" /> <texture name="Row_Selection" file_name="navbar/Row_Selection.png" preload="false" /> diff --git a/indra/newview/skins/default/xui/en/floater_toybox.xml b/indra/newview/skins/default/xui/en/floater_toybox.xml index feb19571b2..de39032cbf 100644 --- a/indra/newview/skins/default/xui/en/floater_toybox.xml +++ b/indra/newview/skins/default/xui/en/floater_toybox.xml @@ -48,8 +48,8 @@ button_display_mode="icons_with_text" follows="all" left="20" - max_button_width="140" - min_button_width="70" + button_icon_and_text.max_button_width="140" + button_icon_and_text.min_button_width="70" name="toybox_toolbar" pad_left="5" pad_right="5" diff --git a/indra/newview/skins/default/xui/en/main_view.xml b/indra/newview/skins/default/xui/en/main_view.xml index d8f593715f..cf566d7d23 100644 --- a/indra/newview/skins/default/xui/en/main_view.xml +++ b/indra/newview/skins/default/xui/en/main_view.xml @@ -100,12 +100,12 @@ visible="false" width="500"/> </layout_panel> - <layout_panel auto_resize="false" + <!--<layout_panel auto_resize="false" min_height="33" height="33" mouse_opaque="false" name="bottom_tray_container" - visible="false"/> + visible="false"/>--> </layout_stack> </layout_panel> </layout_stack> diff --git a/indra/newview/skins/default/xui/en/panel_toolbar_view.xml b/indra/newview/skins/default/xui/en/panel_toolbar_view.xml index fa7632920b..44da813f61 100644 --- a/indra/newview/skins/default/xui/en/panel_toolbar_view.xml +++ b/indra/newview/skins/default/xui/en/panel_toolbar_view.xml @@ -33,13 +33,13 @@ follows="all" mouse_opaque="false"> <layout_panel name="left_toolbar_panel" - fit_content="true" auto_resize="false" user_resize="false" height="500" width="30" mouse_opaque="false"> <toolbar follows="left|top|bottom" + button_panel.bg_opaque_image="Rounded_Rect_Right" name="toolbar_left" height="500" width="30" @@ -54,13 +54,13 @@ user_resize="false" mouse_opaque="false"/> <layout_panel name="right_toolbar_panel" - fit_content="true" auto_resize="false" user_resize="false" height="500" width="30" mouse_opaque="false"> <toolbar + button_panel.bg_opaque_image="Rounded_Rect_Left" follows="right|top|bottom" name="toolbar_right" height="500" @@ -74,13 +74,13 @@ </layout_stack> </layout_panel> <layout_panel name="bottom_toolbar_panel" - fit_content="true" auto_resize="false" user_resize="false" height="30" width="1024" mouse_opaque="false"> <toolbar layout="topleft" + button_panel.bg_opaque_image="Rounded_Rect_Top" name="toolbar_bottom" height="30" width="1024" diff --git a/indra/newview/skins/default/xui/en/widgets/toolbar.xml b/indra/newview/skins/default/xui/en/widgets/toolbar.xml index 32bc88cc9a..8422e3943d 100644 --- a/indra/newview/skins/default/xui/en/widgets/toolbar.xml +++ b/indra/newview/skins/default/xui/en/widgets/toolbar.xml @@ -1,22 +1,33 @@ <?xml version="1.0" encoding="utf-8" standalone="yes" ?> -<toolbar button_height="30" - pad_left="5" - pad_right="5" - pad_top="5" - pad_bottom="5" - pad_between="5" +<toolbar pad_left="1" + pad_right="1" + pad_top="1" + pad_bottom="1" + pad_between="1" mouse_opaque="false" read_only="false"> <button_panel name="button_panel" bg_opaque_image="Rounded_Rect" background_visible="true" + bg_opaque_image_overlay="MouseGray" background_opaque="true"/> - <button_icon_and_text follows="left|top" + <button_icon_and_text imgoverlay_label_space="7" + min_button_width="70" + max_button_width="140" + desired_height="24" + pad_left="10" + pad_right="10" + follows="left|top" chrome="true" image_overlay_alignment="left" use_ellipses="true" auto_resize="true"/> - <button_icon follows="left|top" + <button_icon pad_left="10" + pad_right="10" + desired_height="35" + min_button_width="35" + max_button_width="35" + follows="left|top" label="" chrome="true" use_ellipses="true" |