summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorLeyla Farazha <leyla@lindenlab.com>2011-10-10 17:09:31 -0700
committerLeyla Farazha <leyla@lindenlab.com>2011-10-10 17:09:31 -0700
commit5b1301ea8a0e50f2d15700a7e93be7628f6feec8 (patch)
treef536cbca14fa0cd81d75e7d354bd75b370c18091 /indra/llui
parentfd03ae299bfaf83789e511912d99d204c0833e7f (diff)
parent2d1431b2f0bb903be9259cbcae630f605d9c208c (diff)
merge
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llcommandmanager.cpp4
-rw-r--r--indra/llui/llcommandmanager.h11
-rw-r--r--indra/llui/llfloater.cpp6
-rw-r--r--indra/llui/llnotifications.cpp72
-rw-r--r--indra/llui/llsdparam.cpp258
-rw-r--r--indra/llui/llsdparam.h67
-rw-r--r--indra/llui/lltoolbar.cpp92
-rw-r--r--indra/llui/lltoolbar.h14
-rw-r--r--indra/llui/tests/llurlentry_stub.cpp2
-rw-r--r--indra/llui/tests/llurlentry_test.cpp1
-rw-r--r--indra/llui/tests/llurlmatch_test.cpp4
11 files changed, 307 insertions, 224 deletions
diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp
index 9ce7533e1b..d8e035a320 100644
--- a/indra/llui/llcommandmanager.cpp
+++ b/indra/llui/llcommandmanager.cpp
@@ -41,7 +41,7 @@
// LLCommandId class
//
-const LLCommandId LLCommandId::null("null command");
+const LLCommandId LLCommandId::null = LLCommandId();
//
// LLCommand class
@@ -152,7 +152,7 @@ bool LLCommandManager::load()
if (!commandsParams.validateBlock())
{
- llerrs << "Unable to validate commands param block from file: " << commands_file << llendl;
+ llerrs << "Invalid commands file: " << commands_file << llendl;
return false;
}
diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h
index 8f9f956ec7..fdad7cd1b5 100644
--- a/indra/llui/llcommandmanager.h
+++ b/indra/llui/llcommandmanager.h
@@ -50,6 +50,12 @@ public:
{}
};
+ LLCommandId()
+ : mName("null command")
+ {
+ mUUID = LLUUID::generateNewID(mName);
+ }
+
LLCommandId(const std::string& name)
: mName(name)
{
@@ -62,10 +68,9 @@ public:
mUUID = LLUUID::generateNewID(p.name);
}
- LLCommandId(const LLUUID& uuid)
- : mName(""),
+ LLCommandId(const std::string& name, const LLUUID& uuid)
+ : mName(name),
mUUID(uuid)
-
{
}
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index f85e46e28d..90c41e99dc 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -849,9 +849,9 @@ void LLFloater::applyRectControl()
if (mRectControl.size() > 1)
{
const LLRect& rect = getControlGroup()->getRect(mRectControl);
- if (rect.getWidth() > 0 && rect.getHeight() > 0)
+ if (rect.notEmpty())
{
- translate( rect.mLeft - getRect().mLeft, rect.mBottom - getRect().mBottom);
+ setOrigin(rect.mLeft, rect.mBottom);
if (mResizable)
{
reshape(llmax(mMinWidth, rect.getWidth()), llmax(mMinHeight, rect.getHeight()));
@@ -2558,7 +2558,7 @@ void LLFloaterView::adjustToFitScreen(LLFloater* floater, BOOL allow_partial_out
}
// move window fully onscreen
- if (floater->translateIntoRect( getLocalRect(), allow_partial_outside ))
+ if (floater->translateIntoRect( getSnapRect(), allow_partial_outside ))
{
floater->clearSnapTarget();
}
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp
index ffe5908a9d..8f7025a9a6 100644
--- a/indra/llui/llnotifications.cpp
+++ b/indra/llui/llnotifications.cpp
@@ -46,6 +46,7 @@
#include <algorithm>
#include <boost/regex.hpp>
+#include <boost/foreach.hpp>
const std::string NOTIFICATION_PERSIST_VERSION = "0.93";
@@ -416,23 +417,17 @@ LLNotificationTemplate::LLNotificationTemplate(const LLNotificationTemplate::Par
mSoundEffect = LLUUID(LLUI::sSettingGroups["config"]->getString(p.sound));
}
- for(LLInitParam::ParamIterator<LLNotificationTemplate::UniquenessContext>::const_iterator it = p.unique.contexts.begin(),
- end_it = p.unique.contexts.end();
- it != end_it;
- ++it)
+ BOOST_FOREACH(const LLNotificationTemplate::UniquenessContext& context, p.unique.contexts)
{
- mUniqueContext.push_back(it->value);
+ mUniqueContext.push_back(context.value);
}
lldebugs << "notification \"" << mName << "\": tag count is " << p.tags.size() << llendl;
- for(LLInitParam::ParamIterator<LLNotificationTemplate::Tag>::const_iterator it = p.tags.begin(),
- end_it = p.tags.end();
- it != end_it;
- ++it)
+ BOOST_FOREACH(const LLNotificationTemplate::Tag& tag, p.tags)
{
- lldebugs << " tag \"" << std::string(it->value) << "\"" << llendl;
- mTags.push_back(it->value);
+ lldebugs << " tag \"" << std::string(tag.value) << "\"" << llendl;
+ mTags.push_back(tag.value);
}
mForm = LLNotificationFormPtr(new LLNotificationForm(p.name, p.form_ref.form));
@@ -1397,14 +1392,12 @@ void replaceFormText(LLNotificationForm::Params& form, const std::string& patter
{
form.ignore.text = replace;
}
- for (LLInitParam::ParamIterator<LLNotificationForm::FormElement>::iterator it = form.form_elements.elements.begin(),
- end_it = form.form_elements.elements.end();
- it != end_it;
- ++it)
+
+ BOOST_FOREACH(LLNotificationForm::FormElement& element, form.form_elements.elements)
{
- if (it->button.isChosen() && it->button.text() == pattern)
+ if (element.button.isChosen() && element.button.text() == pattern)
{
- it->button.text = replace;
+ element.button.text = replace;
}
}
}
@@ -1453,48 +1446,42 @@ bool LLNotifications::loadTemplates()
mTemplates.clear();
- for(LLInitParam::ParamIterator<LLNotificationTemplate::GlobalString>::const_iterator it = params.strings.begin(), end_it = params.strings.end();
- it != end_it;
- ++it)
+ BOOST_FOREACH(LLNotificationTemplate::GlobalString& string, params.strings)
{
- mGlobalStrings[it->name] = it->value;
+ mGlobalStrings[string.name] = string.value;
}
std::map<std::string, LLNotificationForm::Params> form_templates;
- for(LLInitParam::ParamIterator<LLNotificationTemplate::Template>::const_iterator it = params.templates.begin(), end_it = params.templates.end();
- it != end_it;
- ++it)
+ BOOST_FOREACH(LLNotificationTemplate::Template& notification_template, params.templates)
{
- form_templates[it->name] = it->form;
+ form_templates[notification_template.name] = notification_template.form;
}
- for(LLInitParam::ParamIterator<LLNotificationTemplate::Params>::iterator it = params.notifications.begin(), end_it = params.notifications.end();
- it != end_it;
- ++it)
+ BOOST_FOREACH(LLNotificationTemplate::Params& notification, params.notifications)
{
- if (it->form_ref.form_template.isChosen())
+ if (notification.form_ref.form_template.isChosen())
{
// replace form contents from template
- it->form_ref.form = form_templates[it->form_ref.form_template.name];
- if(it->form_ref.form_template.yes_text.isProvided())
+ notification.form_ref.form = form_templates[notification.form_ref.form_template.name];
+ if(notification.form_ref.form_template.yes_text.isProvided())
{
- replaceFormText(it->form_ref.form, "$yestext", it->form_ref.form_template.yes_text);
+ replaceFormText(notification.form_ref.form, "$yestext", notification.form_ref.form_template.yes_text);
}
- if(it->form_ref.form_template.no_text.isProvided())
+ if(notification.form_ref.form_template.no_text.isProvided())
{
- replaceFormText(it->form_ref.form, "$notext", it->form_ref.form_template.no_text);
+ replaceFormText(notification.form_ref.form, "$notext", notification.form_ref.form_template.no_text);
}
- if(it->form_ref.form_template.cancel_text.isProvided())
+ if(notification.form_ref.form_template.cancel_text.isProvided())
{
- replaceFormText(it->form_ref.form, "$canceltext", it->form_ref.form_template.cancel_text);
+ replaceFormText(notification.form_ref.form, "$canceltext", notification.form_ref.form_template.cancel_text);
}
- if(it->form_ref.form_template.ignore_text.isProvided())
+ if(notification.form_ref.form_template.ignore_text.isProvided())
{
- replaceFormText(it->form_ref.form, "$ignoretext", it->form_ref.form_template.ignore_text);
+ replaceFormText(notification.form_ref.form, "$ignoretext", notification.form_ref.form_template.ignore_text);
}
}
- mTemplates[it->name] = LLNotificationTemplatePtr(new LLNotificationTemplate(*it));
+ mTemplates[notification.name] = LLNotificationTemplatePtr(new LLNotificationTemplate(notification));
}
return true;
@@ -1517,12 +1504,9 @@ bool LLNotifications::loadVisibilityRules()
mVisibilityRules.clear();
- for(LLInitParam::ParamIterator<LLNotificationVisibilityRule::Rule>::iterator it = params.rules.begin(),
- end_it = params.rules.end();
- it != end_it;
- ++it)
+ BOOST_FOREACH(LLNotificationVisibilityRule::Rule& rule, params.rules)
{
- mVisibilityRules.push_back(LLNotificationVisibilityRulePtr(new LLNotificationVisibilityRule(*it)));
+ mVisibilityRules.push_back(LLNotificationVisibilityRulePtr(new LLNotificationVisibilityRule(rule)));
}
return true;
diff --git a/indra/llui/llsdparam.cpp b/indra/llui/llsdparam.cpp
index 4b69360e33..da50c0ff39 100644
--- a/indra/llui/llsdparam.cpp
+++ b/indra/llui/llsdparam.cpp
@@ -34,6 +34,7 @@
static LLInitParam::Parser::parser_read_func_map_t sReadFuncs;
static LLInitParam::Parser::parser_write_func_map_t sWriteFuncs;
static LLInitParam::Parser::parser_inspect_func_map_t sInspectFuncs;
+static const LLSD NO_VALUE_MARKER;
//
// LLParamSDParser
@@ -60,29 +61,34 @@ LLParamSDParser::LLParamSDParser()
}
// special case handling of U32 due to ambiguous LLSD::assign overload
-bool LLParamSDParser::writeU32Param(LLParamSDParser::parser_t& parser, const void* val_ptr, const parser_t::name_stack_t& name_stack)
+bool LLParamSDParser::writeU32Param(LLParamSDParser::parser_t& parser, const void* val_ptr, parser_t::name_stack_t& name_stack)
{
LLParamSDParser& sdparser = static_cast<LLParamSDParser&>(parser);
if (!sdparser.mWriteRootSD) return false;
- LLSD* sd_to_write = sdparser.getSDWriteNode(name_stack);
- if (!sd_to_write) return false;
+ parser_t::name_stack_range_t range(name_stack.begin(), name_stack.end());
+ LLSD& sd_to_write = LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, range);
+ sd_to_write.assign((S32)*((const U32*)val_ptr));
- sd_to_write->assign((S32)*((const U32*)val_ptr));
return true;
}
-bool LLParamSDParser::writeFlag(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, parser_t::name_stack_t& name_stack)
{
LLParamSDParser& sdparser = static_cast<LLParamSDParser&>(parser);
if (!sdparser.mWriteRootSD) return false;
- LLSD* sd_to_write = sdparser.getSDWriteNode(name_stack);
- if (!sd_to_write) return false;
+ parser_t::name_stack_range_t range(name_stack.begin(), name_stack.end());
+ LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, range);
return true;
}
+void LLParamSDParser::submit(LLInitParam::BaseBlock& block, const LLSD& sd, LLInitParam::Parser::name_stack_t& name_stack)
+{
+ mCurReadSD = &sd;
+ block.submitValue(name_stack, *this);
+}
void LLParamSDParser::readSD(const LLSD& sd, LLInitParam::BaseBlock& block, bool silent)
{
@@ -90,7 +96,8 @@ void LLParamSDParser::readSD(const LLSD& sd, LLInitParam::BaseBlock& block, bool
mNameStack.clear();
setParseSilently(silent);
- readSDValues(sd, block);
+ LLParamSDParserUtilities::readSDValues(boost::bind(&LLParamSDParser::submit, this, boost::ref(block), _1, _2), sd, mNameStack);
+ //readSDValues(sd, block);
}
void LLParamSDParser::writeSD(LLSD& sd, const LLInitParam::BaseBlock& block)
@@ -100,43 +107,6 @@ void LLParamSDParser::writeSD(LLSD& sd, const LLInitParam::BaseBlock& block)
block.serializeBlock(*this);
}
-const LLSD NO_VALUE_MARKER;
-
-void LLParamSDParser::readSDValues(const LLSD& sd, LLInitParam::BaseBlock& block)
-{
- if (sd.isMap())
- {
- for (LLSD::map_const_iterator it = sd.beginMap();
- it != sd.endMap();
- ++it)
- {
- mNameStack.push_back(make_pair(it->first, newParseGeneration()));
- readSDValues(it->second, block);
- mNameStack.pop_back();
- }
- }
- else if (sd.isArray())
- {
- for (LLSD::array_const_iterator it = sd.beginArray();
- it != sd.endArray();
- ++it)
- {
- mNameStack.back().second = newParseGeneration();
- readSDValues(*it, block);
- }
- }
- else if (sd.isUndefined())
- {
- mCurReadSD = &NO_VALUE_MARKER;
- block.submitValue(mNameStack, *this);
- }
- else
- {
- mCurReadSD = &sd;
- block.submitValue(mNameStack, *this);
- }
-}
-
/*virtual*/ std::string LLParamSDParser::getCurrentElementName()
{
std::string full_name = "sd";
@@ -150,81 +120,6 @@ void LLParamSDParser::readSDValues(const LLSD& sd, LLInitParam::BaseBlock& block
return full_name;
}
-LLSD* LLParamSDParser::getSDWriteNode(const parser_t::name_stack_t& name_stack)
-{
- //TODO: implement nested LLSD writing
- LLSD* sd_to_write = mWriteRootSD;
- bool new_traversal = false;
- for (name_stack_t::const_iterator it = name_stack.begin(), prev_it = mNameStack.begin();
- it != name_stack.end();
- ++it)
- {
- bool new_array_entry = false;
- if (prev_it == mNameStack.end())
- {
- new_traversal = true;
- }
- else
- {
- if (!new_traversal // have not diverged yet from previous trace
- && prev_it->first == it->first // names match
- && prev_it->second != it->second) // versions differ
- {
- // name stacks match, but version numbers differ in last place.
- // create a different entry at this point using an LLSD array
- new_array_entry = true;
- }
- if (prev_it->first != it->first // names differ
- || prev_it->second != it->second) // versions differ
- {
- // at this point we have diverged from our last trace
- // so any elements referenced here are new
- new_traversal = true;
- }
- }
-
- LLSD* child_sd = it->first.empty() ? sd_to_write : &(*sd_to_write)[it->first];
-
- if (child_sd->isArray())
- {
- if (new_traversal)
- {
- // write to new element at end
- sd_to_write = &(*child_sd)[child_sd->size()];
- }
- else
- {
- // write to last of existing elements, or first element if empty
- sd_to_write = &(*child_sd)[llmax(0, child_sd->size() - 1)];
- }
- }
- else
- {
- if (new_array_entry && !child_sd->isArray())
- {
- // copy child contents into first element of an array
- LLSD new_array = LLSD::emptyArray();
- new_array.append(*child_sd);
- // assign array to slot that previously held the single value
- *child_sd = new_array;
- // return next element in that array
- sd_to_write = &((*child_sd)[1]);
- }
- else
- {
- sd_to_write = child_sd;
- }
- }
- if (prev_it != mNameStack.end())
- {
- ++prev_it;
- }
- }
- mNameStack = name_stack;
-
- //llinfos << ll_pretty_print_sd(*mWriteRootSD) << llendl;
- return sd_to_write;
-}
bool LLParamSDParser::readFlag(Parser& parser, void* val_ptr)
{
@@ -312,3 +207,126 @@ bool LLParamSDParser::readSD(Parser& parser, void* val_ptr)
*((LLSD*)val_ptr) = *self.mCurReadSD;
return true;
}
+
+// static
+LLSD& LLParamSDParserUtilities::getSDWriteNode(LLSD& input, LLInitParam::Parser::name_stack_range_t& name_stack_range)
+{
+ LLSD* sd_to_write = &input;
+
+ for (LLInitParam::Parser::name_stack_t::iterator it = name_stack_range.first;
+ it != name_stack_range.second;
+ ++it)
+ {
+ bool new_traversal = it->second;
+
+ LLSD* child_sd = it->first.empty() ? sd_to_write : &(*sd_to_write)[it->first];
+
+ if (child_sd->isArray())
+ {
+ if (new_traversal)
+ {
+ // write to new element at end
+ sd_to_write = &(*child_sd)[child_sd->size()];
+ }
+ else
+ {
+ // write to last of existing elements, or first element if empty
+ sd_to_write = &(*child_sd)[llmax(0, child_sd->size() - 1)];
+ }
+ }
+ else
+ {
+ if (new_traversal
+ && child_sd->isDefined()
+ && !child_sd->isArray())
+ {
+ // copy child contents into first element of an array
+ LLSD new_array = LLSD::emptyArray();
+ new_array.append(*child_sd);
+ // assign array to slot that previously held the single value
+ *child_sd = new_array;
+ // return next element in that array
+ sd_to_write = &((*child_sd)[1]);
+ }
+ else
+ {
+ sd_to_write = child_sd;
+ }
+ }
+ it->second = false;
+ }
+
+ return *sd_to_write;
+}
+
+//static
+void LLParamSDParserUtilities::readSDValues(read_sd_cb_t cb, const LLSD& sd, LLInitParam::Parser::name_stack_t& stack)
+{
+ if (sd.isMap())
+ {
+ for (LLSD::map_const_iterator it = sd.beginMap();
+ it != sd.endMap();
+ ++it)
+ {
+ stack.push_back(make_pair(it->first, true));
+ readSDValues(cb, it->second, stack);
+ stack.pop_back();
+ }
+ }
+ else if (sd.isArray())
+ {
+ for (LLSD::array_const_iterator it = sd.beginArray();
+ it != sd.endArray();
+ ++it)
+ {
+ stack.back().second = true;
+ readSDValues(cb, *it, stack);
+ }
+ }
+ else if (sd.isUndefined())
+ {
+ if (!cb.empty())
+ {
+ cb(NO_VALUE_MARKER, stack);
+ }
+ }
+ else
+ {
+ if (!cb.empty())
+ {
+ cb(sd, stack);
+ }
+ }
+}
+
+namespace LLInitParam
+{
+ // LLSD specialization
+ // block param interface
+ bool ParamValue<LLSD, TypeValues<LLSD>, false>::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, bool new_name)
+ {
+ LLSD& sd = LLParamSDParserUtilities::getSDWriteNode(mValue, name_stack);
+
+ LLSD::String string;
+
+ if (p.readValue<LLSD::String>(string))
+ {
+ sd = string;
+ return true;
+ }
+ return false;
+ }
+
+ //static
+ void ParamValue<LLSD, TypeValues<LLSD>, false>::serializeElement(Parser& p, const LLSD& sd, Parser::name_stack_t& name_stack)
+ {
+ p.writeValue<LLSD::String>(sd.asString(), name_stack);
+ }
+
+ void ParamValue<LLSD, TypeValues<LLSD>, false>::serializeBlock(Parser& p, Parser::name_stack_t name_stack, const BaseBlock* diff_block) const
+ {
+ // read from LLSD value and serialize out to parser (which could be LLSD, XUI, etc)
+ Parser::name_stack_t stack;
+ LLParamSDParserUtilities::readSDValues(boost::bind(&serializeElement, boost::ref(p), _1, _2), mValue, stack);
+ }
+}
diff --git a/indra/llui/llsdparam.h b/indra/llui/llsdparam.h
index a371c28f68..784358d038 100644
--- a/indra/llui/llsdparam.h
+++ b/indra/llui/llsdparam.h
@@ -29,6 +29,15 @@
#define LL_LLSDPARAM_H
#include "llinitparam.h"
+#include "boost/function.hpp"
+
+struct LLParamSDParserUtilities
+{
+ static LLSD& getSDWriteNode(LLSD& input, LLInitParam::Parser::name_stack_range_t& name_stack_range);
+
+ typedef boost::function<void (const LLSD&, LLInitParam::Parser::name_stack_t&)> read_sd_cb_t;
+ static void readSDValues(read_sd_cb_t cb, const LLSD& sd, LLInitParam::Parser::name_stack_t& stack = LLInitParam::Parser::name_stack_t());
+};
class LLParamSDParser
: public LLInitParam::Parser
@@ -45,25 +54,23 @@ public:
/*virtual*/ std::string getCurrentElementName();
private:
- void readSDValues(const LLSD& sd, LLInitParam::BaseBlock& block);
+ void submit(LLInitParam::BaseBlock& block, const LLSD& sd, LLInitParam::Parser::name_stack_t& name_stack);
template<typename T>
- static bool writeTypedValue(Parser& parser, const void* val_ptr, const parser_t::name_stack_t& name_stack)
+ static bool writeTypedValue(Parser& parser, const void* val_ptr, parser_t::name_stack_t& name_stack)
{
LLParamSDParser& sdparser = static_cast<LLParamSDParser&>(parser);
if (!sdparser.mWriteRootSD) return false;
- LLSD* sd_to_write = sdparser.getSDWriteNode(name_stack);
- if (!sd_to_write) return false;
+ LLInitParam::Parser::name_stack_range_t range(name_stack.begin(), name_stack.end());
+ LLSD& sd_to_write = LLParamSDParserUtilities::getSDWriteNode(*sdparser.mWriteRootSD, range);
- sd_to_write->assign(*((const T*)val_ptr));
+ sd_to_write.assign(*((const T*)val_ptr));
return true;
}
- 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 writeFlag(Parser& parser, const void* value_ptr, const parser_t::name_stack_t& name_stack);
+ static bool writeU32Param(Parser& parser, const void* value_ptr, parser_t::name_stack_t& name_stack);
+ static bool writeFlag(Parser& parser, const void* value_ptr, parser_t::name_stack_t& name_stack);
static bool readFlag(Parser& parser, void* val_ptr);
static bool readS32(Parser& parser, void* val_ptr);
@@ -85,29 +92,29 @@ private:
template<typename T>
class LLSDParamAdapter : public T
+{
+public:
+ LLSDParamAdapter() {}
+ LLSDParamAdapter(const LLSD& sd)
{
- public:
- LLSDParamAdapter() {}
- LLSDParamAdapter(const LLSD& sd)
- {
- LLParamSDParser parser;
- parser.readSD(sd, *this);
- }
-
- operator LLSD() const
- {
- LLParamSDParser parser;
- LLSD sd;
- parser.writeSD(sd, *this);
- return sd;
- }
+ LLParamSDParser parser;
+ parser.readSD(sd, *this);
+ }
+
+ operator LLSD() const
+ {
+ LLParamSDParser parser;
+ LLSD sd;
+ parser.writeSD(sd, *this);
+ return sd;
+ }
- LLSDParamAdapter(const T& val)
- : T(val)
- {
- T::operator=(val);
- }
- };
+ LLSDParamAdapter(const T& val)
+ : T(val)
+ {
+ T::operator=(val);
+ }
+};
#endif // LL_LLSDPARAM_H
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index c34fbcd4f5..6332b2674a 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -33,6 +33,7 @@
#include "llcommandmanager.h"
#include "llmenugl.h"
#include "lltrans.h"
+#include "llinventory.h"
// uncomment this and remove the one in llui.cpp when there is an external reference to this translation unit
// thanks, MSVC!
@@ -86,6 +87,7 @@ LLToolBar::Params::Params()
pad_right("pad_right"),
pad_bottom("pad_bottom"),
pad_between("pad_between"),
+ min_girth("min_girth"),
button_panel("button_panel")
{}
@@ -103,6 +105,7 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p)
mPadTop(p.pad_top),
mPadBottom(p.pad_bottom),
mPadBetween(p.pad_between),
+ mMinGirth(p.min_girth),
mPopupMenuHandle(),
mStartDragItemCallback(NULL),
mHandleDragItemCallback(NULL),
@@ -111,6 +114,8 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p)
{
mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT] = p.button_icon_and_text;
mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_ONLY] = p.button_icon;
+ mDraggedCommand = LLCommandId::null;
+ mRank = 0;
}
LLToolBar::~LLToolBar()
@@ -201,17 +206,24 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank)
{
LLCommand * command = LLCommandManager::instance().getCommand(commandId);
if (!command) return false;
-
+ llinfos << "Merov debug : addCommand, " << commandId.name() << ", " << commandId.uuid() << llendl;
+
// Create the button and do the things that don't need ordering
LLToolBarButton* button = createButton(commandId);
mButtonPanel->addChild(button);
- mButtonMap.insert(std::make_pair(commandId, button));
+ LLCommandId temp_command = commandId;
+ if (commandId.name() == "Drag Tool")
+ {
+ temp_command = LLCommandId("Drag Tool");
+ }
+ mButtonMap.insert(std::make_pair(temp_command.uuid(), button));
+
// Insert the command and button in the right place in their respective lists
if ((rank >= mButtonCommands.size()) || (rank < 0))
{
// In that case, back load
- mButtonCommands.push_back(commandId);
+ mButtonCommands.push_back(temp_command);
mButtons.push_back(button);
}
else
@@ -226,7 +238,7 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank)
rank--;
}
// ...then insert
- mButtonCommands.insert(it_command,commandId);
+ mButtonCommands.insert(it_command,temp_command);
mButtons.insert(it_button,button);
}
@@ -239,14 +251,20 @@ bool LLToolBar::removeCommand(const LLCommandId& commandId)
{
if (!hasCommand(commandId)) return false;
+ llinfos << "Merov debug : removeCommand, " << commandId.name() << ", " << commandId.uuid() << llendl;
// First erase the map record
- command_id_map::iterator it = mButtonMap.find(commandId);
+ LLCommandId temp_command = commandId;
+ if (commandId.name() == "Drag Tool")
+ {
+ temp_command = LLCommandId("Drag Tool");
+ }
+ command_id_map::iterator it = mButtonMap.find(temp_command.uuid());
mButtonMap.erase(it);
// Now iterate on the commands and buttons to identify the relevant records
std::list<LLToolBarButton*>::iterator it_button = mButtons.begin();
command_id_list_t::iterator it_command = mButtonCommands.begin();
- while (*it_command != commandId)
+ while (*it_command != temp_command)
{
++it_button;
++it_command;
@@ -274,7 +292,12 @@ bool LLToolBar::hasCommand(const LLCommandId& commandId) const
{
if (commandId != LLCommandId::null)
{
- command_id_map::const_iterator it = mButtonMap.find(commandId);
+ LLCommandId temp_command = commandId;
+ if (commandId.name() == "Drag Tool")
+ {
+ temp_command = LLCommandId("Drag Tool");
+ }
+ command_id_map::const_iterator it = mButtonMap.find(temp_command.uuid());
return (it != mButtonMap.end());
}
@@ -287,7 +310,12 @@ bool LLToolBar::enableCommand(const LLCommandId& commandId, bool enabled)
if (commandId != LLCommandId::null)
{
- command_id_map::iterator it = mButtonMap.find(commandId);
+ LLCommandId temp_command = commandId;
+ if (commandId.name() == "Drag Tool")
+ {
+ temp_command = LLCommandId("Drag Tool");
+ }
+ command_id_map::iterator it = mButtonMap.find(temp_command.uuid());
if (it != mButtonMap.end())
{
it->second->setEnabled(enabled);
@@ -505,7 +533,7 @@ void LLToolBar::updateLayoutAsNeeded()
button_rect.setLeftTopAndSize(cur_row, panel_rect.mTop - cur_start, button_clamped_width, button->getRect().getHeight());
}
button->setShape(button_rect);
-
+
buttons_in_row.push_back(button);
row_running_length += button_length + mPadBetween;
@@ -517,6 +545,8 @@ void LLToolBar::updateLayoutAsNeeded()
S32 total_girth = cur_row // current row position...
+ max_row_girth // ...incremented by size of final row...
+ girth_pad_end; // ...plus padding reserved on end
+ total_girth = llmax(total_girth,mMinGirth);
+
max_row_length = llmax(max_row_length, row_running_length - mPadBetween + row_pad_end);
resizeButtonsInRow(buttons_in_row, max_row_girth);
@@ -588,6 +618,12 @@ void LLToolBar::draw()
}
}
}
+ // HACK!!!
+ if (!mDragAndDropTarget)
+ {
+ removeCommand(mDraggedCommand);
+ mDraggedCommand = LLCommandId::null;
+ }
updateLayoutAsNeeded();
// rect may have shifted during layout
@@ -618,7 +654,12 @@ void LLToolBar::createButtons()
LLToolBarButton* button = createButton(command_id);
mButtons.push_back(button);
mButtonPanel->addChild(button);
- mButtonMap.insert(std::make_pair(command_id, button));
+ LLCommandId temp_command = command_id;
+ if (command_id.name() == "Drag Tool")
+ {
+ temp_command = LLCommandId("Drag Tool");
+ }
+ mButtonMap.insert(std::make_pair(temp_command.uuid(), button));
}
mNeedsLayout = true;
}
@@ -709,7 +750,31 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
*accept = (handled ? ACCEPT_YES_SINGLE : ACCEPT_NO);
// We'll use that flag to change the visual aspect of the toolbar target on draw()
- mDragAndDropTarget = handled;
+ mDragAndDropTarget = false;
+
+ // HACK!!!
+ if (!isReadOnly() && handled)
+ {
+ if (!drop)
+ {
+ LLInventoryItem* inv_item = (LLInventoryItem*)cargo_data;
+ LLAssetType::EType type = inv_item->getType();
+ if (type == LLAssetType::AT_WIDGET)
+ {
+ mRank = getRankFromPosition(x, y);
+ mDraggedCommand = LLCommandId("Drag Tool",inv_item->getUUID());
+ removeCommand(mDraggedCommand);
+ addCommand(mDraggedCommand,mRank);
+ mDragAndDropTarget = true;
+ }
+ }
+ else
+ {
+ removeCommand(mDraggedCommand);
+ mDraggedCommand = LLCommandId::null;
+ }
+
+ }
return handled;
}
@@ -723,7 +788,10 @@ LLToolBarButton::LLToolBarButton(const Params& p)
mId(""),
mIsEnabledSignal(NULL),
mIsRunningSignal(NULL),
- mIsStartingSignal(NULL)
+ mIsStartingSignal(NULL),
+ mIsDragged(false),
+ mStartDragItemCallback(NULL),
+ mHandleDragItemCallback(NULL)
{
mButtonFlashRate = 0.0;
mButtonFlashCount = 0;
diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h
index 4fac081130..84fa7ec0df 100644
--- a/indra/llui/lltoolbar.h
+++ b/indra/llui/lltoolbar.h
@@ -47,8 +47,8 @@ class LLToolBarButton : public LLButton
public:
struct Params : public LLInitParam::Block<Params, LLButton::Params>
{
- Optional<LLUI::RangeS32> button_width;
- Optional<S32> desired_height;
+ Optional<LLUI::RangeS32::Params> button_width;
+ Optional<S32> desired_height;
Params()
: button_width("button_width"),
@@ -141,7 +141,8 @@ public:
pad_top,
pad_right,
pad_bottom,
- pad_between;
+ pad_between,
+ min_girth;
// get rid of this
Multiple<LLCommandId::Params> commands;
@@ -183,6 +184,8 @@ protected:
tool_handledrag_callback_t mHandleDragItemCallback;
tool_handledrop_callback_t mHandleDropCallback;
bool mDragAndDropTarget;
+ int mRank;
+ LLCommandId mDraggedCommand;
public:
// Methods used in loading and saving toolbar settings
@@ -204,7 +207,7 @@ private:
typedef std::list<LLToolBarButton*> toolbar_button_list;
toolbar_button_list mButtons;
command_id_list_t mButtonCommands;
- typedef std::map<LLCommandId, LLToolBarButton*> command_id_map;
+ typedef std::map<LLUUID, LLToolBarButton*> command_id_map;
command_id_map mButtonMap;
LLToolBarEnums::ButtonType mButtonType;
@@ -219,7 +222,8 @@ private:
mPadRight,
mPadTop,
mPadBottom,
- mPadBetween;
+ mPadBetween,
+ mMinGirth;
LLToolBarButton::Params mButtonParams[LLToolBarEnums::BTNTYPE_COUNT];
diff --git a/indra/llui/tests/llurlentry_stub.cpp b/indra/llui/tests/llurlentry_stub.cpp
index d522123260..c8303bfc89 100644
--- a/indra/llui/tests/llurlentry_stub.cpp
+++ b/indra/llui/tests/llurlentry_stub.cpp
@@ -124,7 +124,7 @@ namespace LLInitParam
{
descriptor.mCurrentBlockPtr = this;
}
- bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, S32 generation){ return true; }
+ bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, bool new_name){ return true; }
void BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t name_stack, const LLInitParam::BaseBlock* diff_block) const {}
bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack, S32 min_value, S32 max_value) const { return true; }
bool BaseBlock::mergeBlock(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite) { return true; }
diff --git a/indra/llui/tests/llurlentry_test.cpp b/indra/llui/tests/llurlentry_test.cpp
index 2f814f4200..c1fb050206 100644
--- a/indra/llui/tests/llurlentry_test.cpp
+++ b/indra/llui/tests/llurlentry_test.cpp
@@ -72,7 +72,6 @@ S32 LLUIImage::getHeight() const
namespace LLInitParam
{
- S32 Parser::sNextParseGeneration = 0;
BlockDescriptor::BlockDescriptor() {}
ParamDescriptor::ParamDescriptor(param_handle_t p,
merge_func_t merge_func,
diff --git a/indra/llui/tests/llurlmatch_test.cpp b/indra/llui/tests/llurlmatch_test.cpp
index fb6a2eabf1..9dbccf125a 100644
--- a/indra/llui/tests/llurlmatch_test.cpp
+++ b/indra/llui/tests/llurlmatch_test.cpp
@@ -66,8 +66,6 @@ namespace LLInitParam
BaseBlock::BaseBlock() {}
BaseBlock::~BaseBlock() {}
- S32 Parser::sNextParseGeneration = 0;
-
BlockDescriptor::BlockDescriptor() {}
ParamDescriptor::ParamDescriptor(param_handle_t p,
merge_func_t merge_func,
@@ -98,7 +96,7 @@ namespace LLInitParam
mEnclosingBlockOffset = 0x7FFFffff & ((U32)(my_addr - block_addr));
}
- bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, S32 generation){ return true; }
+ bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, bool new_name){ return true; }
void BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t name_stack, const LLInitParam::BaseBlock* diff_block) const {}
bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack, S32 min_count, S32 max_count) const { return true; }
bool BaseBlock::mergeBlock(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite) { return true; }