summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llkeywords.cpp81
-rw-r--r--indra/llui/llkeywords.h33
-rw-r--r--indra/llui/llsdparam.cpp2
-rw-r--r--indra/llui/llsdparam.h7
-rw-r--r--indra/llui/lltoolbar.cpp47
-rw-r--r--indra/llui/lltoolbar.h4
-rw-r--r--indra/llui/llurlaction.cpp28
-rw-r--r--indra/llui/llurlaction.h21
8 files changed, 167 insertions, 56 deletions
diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp
index ceec9c7eb1..c1cd04186b 100644
--- a/indra/llui/llkeywords.cpp
+++ b/indra/llui/llkeywords.cpp
@@ -57,6 +57,22 @@ LLKeywords::LLKeywords() : mLoaded(FALSE)
{
}
+inline BOOL LLKeywordToken::isTail(const llwchar* s) const
+{
+ BOOL res = TRUE;
+ const llwchar* t = mDelimiter.c_str();
+ S32 len = mDelimiter.size();
+ for (S32 i=0; i<len; i++)
+ {
+ if (s[i] != t[i])
+ {
+ res = FALSE;
+ break;
+ }
+ }
+ return res;
+}
+
LLKeywords::~LLKeywords()
{
std::for_each(mWordTokenMap.begin(), mWordTokenMap.end(), DeletePairedPointer());
@@ -106,6 +122,7 @@ BOOL LLKeywords::loadFromFile( const std::string& filename )
std::string SOL_LINE("[line ");
std::string SOL_ONE_SIDED_DELIMITER("[one_sided_delimiter ");
std::string SOL_TWO_SIDED_DELIMITER("[two_sided_delimiter ");
+ std::string SOL_DOUBLE_QUOTATION_MARKS("[double_quotation_marks ");
LLColor3 cur_color( 1, 0, 0 );
LLKeywordToken::TOKEN_TYPE cur_type = LLKeywordToken::WORD;
@@ -137,6 +154,12 @@ BOOL LLKeywords::loadFromFile( const std::string& filename )
cur_type = LLKeywordToken::TWO_SIDED_DELIMITER;
continue;
}
+ else if( line.find(SOL_DOUBLE_QUOTATION_MARKS) == 0 )
+ {
+ cur_color = readColor( line.substr(SOL_DOUBLE_QUOTATION_MARKS.size()) );
+ cur_type = LLKeywordToken::DOUBLE_QUOTATION_MARKS;
+ continue;
+ }
else if( line.find(SOL_ONE_SIDED_DELIMITER) == 0 )
{
cur_color = readColor( line.substr(SOL_ONE_SIDED_DELIMITER.size()) );
@@ -154,10 +177,26 @@ BOOL LLKeywords::loadFromFile( const std::string& filename )
if( !token_buffer.empty() && token_word_iter != word_tokens.end() )
{
- // first word is keyword
+ // first word is the keyword or a left delimiter
std::string keyword = (*token_word_iter);
LLStringUtil::trim(keyword);
+ // second word may be a right delimiter
+ std::string delimiter;
+ if (cur_type == LLKeywordToken::TWO_SIDED_DELIMITER)
+ {
+ while (delimiter.length() == 0 && ++token_word_iter != word_tokens.end())
+ {
+ delimiter = *token_word_iter;
+ LLStringUtil::trim(delimiter);
+ }
+ }
+ else if (cur_type == LLKeywordToken::DOUBLE_QUOTATION_MARKS)
+ {
+ // Closing delimiter is identical to the opening one.
+ delimiter = keyword;
+ }
+
// following words are tooltip
std::string tool_tip;
while (++token_word_iter != word_tokens.end())
@@ -170,11 +209,11 @@ BOOL LLKeywords::loadFromFile( const std::string& filename )
{
// Replace : with \n for multi-line tool tips.
LLStringUtil::replaceChar( tool_tip, ':', '\n' );
- addToken(cur_type, keyword, cur_color, tool_tip );
+ addToken(cur_type, keyword, cur_color, tool_tip, delimiter );
}
else
{
- addToken(cur_type, keyword, cur_color, LLStringUtil::null );
+ addToken(cur_type, keyword, cur_color, LLStringUtil::null, delimiter );
}
}
}
@@ -189,23 +228,26 @@ BOOL LLKeywords::loadFromFile( const std::string& filename )
void LLKeywords::addToken(LLKeywordToken::TOKEN_TYPE type,
const std::string& key_in,
const LLColor3& color,
- const std::string& tool_tip_in )
+ const std::string& tool_tip_in,
+ const std::string& delimiter_in)
{
LLWString key = utf8str_to_wstring(key_in);
LLWString tool_tip = utf8str_to_wstring(tool_tip_in);
+ LLWString delimiter = utf8str_to_wstring(delimiter_in);
switch(type)
{
case LLKeywordToken::WORD:
- mWordTokenMap[key] = new LLKeywordToken(type, color, key, tool_tip);
+ mWordTokenMap[key] = new LLKeywordToken(type, color, key, tool_tip, LLWStringUtil::null);
break;
case LLKeywordToken::LINE:
- mLineTokenList.push_front(new LLKeywordToken(type, color, key, tool_tip));
+ mLineTokenList.push_front(new LLKeywordToken(type, color, key, tool_tip, LLWStringUtil::null));
break;
case LLKeywordToken::TWO_SIDED_DELIMITER:
+ case LLKeywordToken::DOUBLE_QUOTATION_MARKS:
case LLKeywordToken::ONE_SIDED_DELIMITER:
- mDelimiterTokenList.push_front(new LLKeywordToken(type, color, key, tool_tip));
+ mDelimiterTokenList.push_front(new LLKeywordToken(type, color, key, tool_tip, delimiter));
break;
default:
@@ -357,7 +399,7 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW
}
// cur is now at the first non-whitespace character of a new line
-
+
// Line start tokens
{
BOOL line_done = FALSE;
@@ -418,14 +460,15 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW
S32 seg_end = 0;
seg_start = cur - base;
- cur += cur_delimiter->getLength();
+ cur += cur_delimiter->getLengthHead();
- if( cur_delimiter->getType() == LLKeywordToken::TWO_SIDED_DELIMITER )
+ LLKeywordToken::TOKEN_TYPE type = cur_delimiter->getType();
+ if( type == LLKeywordToken::TWO_SIDED_DELIMITER || type == LLKeywordToken::DOUBLE_QUOTATION_MARKS )
{
- while( *cur && !cur_delimiter->isHead(cur))
+ while( *cur && !cur_delimiter->isTail(cur))
{
// Check for an escape sequence.
- if (*cur == '\\')
+ if (type == LLKeywordToken::DOUBLE_QUOTATION_MARKS && *cur == '\\')
{
// Count the number of backslashes.
S32 num_backslashes = 0;
@@ -435,10 +478,10 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW
between_delimiters++;
cur++;
}
- // Is the next character the end delimiter?
- if (cur_delimiter->isHead(cur))
+ // If the next character is the end delimiter?
+ if (cur_delimiter->isTail(cur))
{
- // Is there was an odd number of backslashes, then this delimiter
+ // If there was an odd number of backslashes, then this delimiter
// does not end the sequence.
if (num_backslashes % 2 == 1)
{
@@ -461,13 +504,13 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW
if( *cur )
{
- cur += cur_delimiter->getLength();
- seg_end = seg_start + between_delimiters + 2 * cur_delimiter->getLength();
+ cur += cur_delimiter->getLengthHead();
+ seg_end = seg_start + between_delimiters + cur_delimiter->getLengthHead() + cur_delimiter->getLengthTail();
}
else
{
// eof
- seg_end = seg_start + between_delimiters + cur_delimiter->getLength();
+ seg_end = seg_start + between_delimiters + cur_delimiter->getLengthHead();
}
}
else
@@ -479,7 +522,7 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW
between_delimiters++;
cur++;
}
- seg_end = seg_start + between_delimiters + cur_delimiter->getLength();
+ seg_end = seg_start + between_delimiters + cur_delimiter->getLengthHead();
}
insertSegments(wtext, *seg_list,cur_delimiter, text_len, seg_start, seg_end, defaultColor, editor);
diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h
index f6d75b7e75..ac34015393 100644
--- a/indra/llui/llkeywords.h
+++ b/indra/llui/llkeywords.h
@@ -41,23 +41,44 @@ typedef LLPointer<LLTextSegment> LLTextSegmentPtr;
class LLKeywordToken
{
public:
- enum TOKEN_TYPE { WORD, LINE, TWO_SIDED_DELIMITER, ONE_SIDED_DELIMITER };
+ /**
+ * @brief Types of tokens/delimters being parsed.
+ *
+ * @desc Tokens/delimiters that need to be identified/highlighted. All are terminated if an EOF is encountered.
+ * - WORD are keywords in the normal sense, i.e. constants, events, etc.
+ * - LINE are for entire lines (currently only flow control labels use this).
+ * - ONE_SIDED_DELIMITER are for open-ended delimiters which are terminated by EOL.
+ * - TWO_SIDED_DELIMITER are for delimiters that end with a different delimiter than they open with.
+ * - DOUBLE_QUOTATION_MARKS are for delimiting areas using the same delimiter to open and close.
+ */
+ enum TOKEN_TYPE
+ {
+ WORD,
+ LINE,
+ TWO_SIDED_DELIMITER,
+ ONE_SIDED_DELIMITER,
+ DOUBLE_QUOTATION_MARKS
+ };
- LLKeywordToken( TOKEN_TYPE type, const LLColor3& color, const LLWString& token, const LLWString& tool_tip )
+ LLKeywordToken( TOKEN_TYPE type, const LLColor3& color, const LLWString& token, const LLWString& tool_tip, const LLWString& delimiter )
:
mType( type ),
mToken( token ),
mColor( color ),
- mToolTip( tool_tip )
+ mToolTip( tool_tip ),
+ mDelimiter( delimiter ) // right delimiter
{
}
- S32 getLength() const { return mToken.size(); }
+ S32 getLengthHead() const { return mToken.size(); }
+ S32 getLengthTail() const { return mDelimiter.size(); }
BOOL isHead(const llwchar* s) const;
+ BOOL isTail(const llwchar* s) const;
const LLWString& getToken() const { return mToken; }
const LLColor3& getColor() const { return mColor; }
TOKEN_TYPE getType() const { return mType; }
const LLWString& getToolTip() const { return mToolTip; }
+ const LLWString& getDelimiter() const { return mDelimiter; }
#ifdef _DEBUG
void dump();
@@ -68,6 +89,7 @@ private:
LLWString mToken;
LLColor3 mColor;
LLWString mToolTip;
+ LLWString mDelimiter;
};
class LLKeywords
@@ -85,7 +107,8 @@ public:
void addToken(LLKeywordToken::TOKEN_TYPE type,
const std::string& key,
const LLColor3& color,
- const std::string& tool_tip = LLStringUtil::null);
+ const std::string& tool_tip = LLStringUtil::null,
+ const std::string& delimiter = LLStringUtil::null);
// This class is here as a performance optimization.
// The word token map used to be defined as std::map<LLWString, LLKeywordToken*>.
diff --git a/indra/llui/llsdparam.cpp b/indra/llui/llsdparam.cpp
index 6fa90933a4..0e29873bb0 100644
--- a/indra/llui/llsdparam.cpp
+++ b/indra/llui/llsdparam.cpp
@@ -36,6 +36,8 @@ static LLInitParam::Parser::parser_write_func_map_t sWriteFuncs;
static LLInitParam::Parser::parser_inspect_func_map_t sInspectFuncs;
static const LLSD NO_VALUE_MARKER;
+LLFastTimer::DeclareTimer FTM_SD_PARAM_ADAPTOR("LLSD to LLInitParam conversion");
+
//
// LLParamSDParser
//
diff --git a/indra/llui/llsdparam.h b/indra/llui/llsdparam.h
index c1cfa98399..3dfc6d020e 100644
--- a/indra/llui/llsdparam.h
+++ b/indra/llui/llsdparam.h
@@ -91,6 +91,8 @@ private:
LLSD* mCurWriteSD;
};
+
+extern LLFastTimer::DeclareTimer FTM_SD_PARAM_ADAPTOR;
template<typename T>
class LLSDParamAdapter : public T
{
@@ -98,8 +100,11 @@ public:
LLSDParamAdapter() {}
LLSDParamAdapter(const LLSD& sd)
{
+ LLFastTimer _(FTM_SD_PARAM_ADAPTOR);
LLParamSDParser parser;
- parser.readSD(sd, *this);
+ // don't spam for implicit parsing of LLSD, as we want to allow arbitrary freeform data and ignore most of it
+ bool parse_silently = true;
+ parser.readSD(sd, *this, parse_silently);
}
operator LLSD() const
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index 287e3e2b41..e7642ae190 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -109,6 +109,7 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p)
mPadBetween(p.pad_between),
mMinGirth(p.min_girth),
mPopupMenuHandle(),
+ mRightMouseTargetButton(NULL),
mStartDragItemCallback(NULL),
mHandleDragItemCallback(NULL),
mHandleDropCallback(NULL),
@@ -139,6 +140,7 @@ void LLToolBar::createContextMenu()
LLUICtrl::CommitCallbackRegistry::ScopedRegistrar commit_reg;
commit_reg.add("Toolbars.EnableSetting", boost::bind(&LLToolBar::onSettingEnable, this, _2));
+ commit_reg.add("Toolbars.RemoveSelectedCommand", boost::bind(&LLToolBar::onRemoveSelectedCommand, this));
LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_reg;
enable_reg.add("Toolbars.CheckSetting", boost::bind(&LLToolBar::isSettingChecked, this, _2));
@@ -397,6 +399,20 @@ BOOL LLToolBar::handleRightMouseDown(S32 x, S32 y, MASK mask)
if (handle_it_here)
{
+ // Determine which button the mouse was over during the click in case the context menu action
+ // is intended to affect the button.
+ BOOST_FOREACH(LLToolBarButton* button, mButtons)
+ {
+ LLRect button_rect;
+ button->localRectToOtherView(button->getLocalRect(), &button_rect, this);
+
+ if (button_rect.pointInRect(x, y))
+ {
+ mRightMouseTargetButton = button;
+ break;
+ }
+ }
+
createContextMenu();
LLContextMenu * menu = (LLContextMenu *) mPopupMenuHandle.get();
@@ -446,6 +462,18 @@ void LLToolBar::onSettingEnable(const LLSD& userdata)
}
}
+void LLToolBar::onRemoveSelectedCommand()
+{
+ llassert(!mReadOnly);
+
+ if (mRightMouseTargetButton)
+ {
+ removeCommand(mRightMouseTargetButton->getCommandId());
+
+ mRightMouseTargetButton = NULL;
+ }
+}
+
void LLToolBar::setButtonType(LLToolBarEnums::ButtonType button_type)
{
bool regenerate_buttons = (mButtonType != button_type);
@@ -524,11 +552,11 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y)
S32 mid_point = (button_rect.mRight + button_rect.mLeft) / 2;
if (button_panel_x < mid_point)
{
- mDragx = button_rect.mLeft - mPadLeft;
- mDragy = button_rect.mTop + mPadTop;
- }
- else
- {
+ mDragx = button_rect.mLeft - mPadLeft;
+ mDragy = button_rect.mTop + mPadTop;
+ }
+ else
+ {
rank++;
mDragx = button_rect.mRight + mPadRight - 1;
mDragy = button_rect.mTop + mPadTop;
@@ -555,12 +583,12 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y)
{
// We hit passed the end of the list so put the insertion point at the end
if (orientation == LLLayoutStack::HORIZONTAL)
- {
+ {
mDragx = button_rect.mRight + mPadRight;
mDragy = button_rect.mTop + mPadTop;
- }
- else
- {
+ }
+ else
+ {
mDragx = button_rect.mLeft - mPadLeft;
mDragy = button_rect.mBottom - mPadBottom;
}
@@ -836,6 +864,7 @@ void LLToolBar::createButtons()
}
mButtons.clear();
mButtonMap.clear();
+ mRightMouseTargetButton = NULL;
BOOST_FOREACH(LLCommandId& command_id, mButtonCommands)
{
diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h
index 8c25c43f1a..51fe23ddd1 100644
--- a/indra/llui/lltoolbar.h
+++ b/indra/llui/lltoolbar.h
@@ -63,6 +63,7 @@ public:
BOOL handleMouseDown(S32 x, S32 y, MASK mask);
BOOL handleHover(S32 x, S32 y, MASK mask);
+
void reshape(S32 width, S32 height, BOOL called_from_parent = true);
void setEnabled(BOOL enabled);
void setCommandId(const LLCommandId& id) { mId = id; }
@@ -233,6 +234,7 @@ private:
void resizeButtonsInRow(std::vector<LLToolBarButton*>& buttons_in_row, S32 max_row_girth);
BOOL isSettingChecked(const LLSD& userdata);
void onSettingEnable(const LLSD& userdata);
+ void onRemoveSelectedCommand();
private:
// static layout state
@@ -270,6 +272,8 @@ private:
LLPanel* mButtonPanel;
LLHandle<class LLContextMenu> mPopupMenuHandle;
+ LLToolBarButton* mRightMouseTargetButton;
+
bool mNeedsLayout;
bool mModified;
diff --git a/indra/llui/llurlaction.cpp b/indra/llui/llurlaction.cpp
index 42b779bd28..fd9b3d9a6d 100644
--- a/indra/llui/llurlaction.cpp
+++ b/indra/llui/llurlaction.cpp
@@ -33,28 +33,28 @@
#include "llurlregistry.h"
// global state for the callback functions
-void (*LLUrlAction::sOpenURLCallback) (const std::string& url) = NULL;
-void (*LLUrlAction::sOpenURLInternalCallback) (const std::string& url) = NULL;
-void (*LLUrlAction::sOpenURLExternalCallback) (const std::string& url) = NULL;
-bool (*LLUrlAction::sExecuteSLURLCallback) (const std::string& url) = NULL;
+LLUrlAction::url_callback_t LLUrlAction::sOpenURLCallback;
+LLUrlAction::url_callback_t LLUrlAction::sOpenURLInternalCallback;
+LLUrlAction::url_callback_t LLUrlAction::sOpenURLExternalCallback;
+LLUrlAction::execute_url_callback_t LLUrlAction::sExecuteSLURLCallback;
-void LLUrlAction::setOpenURLCallback(void (*cb) (const std::string& url))
+void LLUrlAction::setOpenURLCallback(url_callback_t cb)
{
sOpenURLCallback = cb;
}
-void LLUrlAction::setOpenURLInternalCallback(void (*cb) (const std::string& url))
+void LLUrlAction::setOpenURLInternalCallback(url_callback_t cb)
{
sOpenURLInternalCallback = cb;
}
-void LLUrlAction::setOpenURLExternalCallback(void (*cb) (const std::string& url))
+void LLUrlAction::setOpenURLExternalCallback(url_callback_t cb)
{
sOpenURLExternalCallback = cb;
}
-void LLUrlAction::setExecuteSLURLCallback(bool (*cb) (const std::string& url))
+void LLUrlAction::setExecuteSLURLCallback(execute_url_callback_t cb)
{
sExecuteSLURLCallback = cb;
}
@@ -63,7 +63,7 @@ void LLUrlAction::openURL(std::string url)
{
if (sOpenURLCallback)
{
- (*sOpenURLCallback)(url);
+ sOpenURLCallback(url);
}
}
@@ -71,7 +71,7 @@ void LLUrlAction::openURLInternal(std::string url)
{
if (sOpenURLInternalCallback)
{
- (*sOpenURLInternalCallback)(url);
+ sOpenURLInternalCallback(url);
}
}
@@ -79,7 +79,7 @@ void LLUrlAction::openURLExternal(std::string url)
{
if (sOpenURLExternalCallback)
{
- (*sOpenURLExternalCallback)(url);
+ sOpenURLExternalCallback(url);
}
}
@@ -87,18 +87,18 @@ void LLUrlAction::executeSLURL(std::string url)
{
if (sExecuteSLURLCallback)
{
- (*sExecuteSLURLCallback)(url);
+ sExecuteSLURLCallback(url);
}
}
void LLUrlAction::clickAction(std::string url)
{
// Try to handle as SLURL first, then http Url
- if ( (sExecuteSLURLCallback) && !(*sExecuteSLURLCallback)(url) )
+ if ( (sExecuteSLURLCallback) && !sExecuteSLURLCallback(url) )
{
if (sOpenURLCallback)
{
- (*sOpenURLCallback)(url);
+ sOpenURLCallback(url);
}
}
}
diff --git a/indra/llui/llurlaction.h b/indra/llui/llurlaction.h
index 0132dbaaf0..c34960b826 100644
--- a/indra/llui/llurlaction.h
+++ b/indra/llui/llurlaction.h
@@ -29,6 +29,7 @@
#define LL_LLURLACTION_H
#include <string>
+#include <boost/function.hpp>
///
/// The LLUrlAction class provides a number of static functions that
@@ -77,17 +78,21 @@ public:
static void showProfile(std::string url);
/// specify the callbacks to enable this class's functionality
- static void setOpenURLCallback(void (*cb) (const std::string& url));
- static void setOpenURLInternalCallback(void (*cb) (const std::string& url));
- static void setOpenURLExternalCallback(void (*cb) (const std::string& url));
- static void setExecuteSLURLCallback(bool (*cb) (const std::string& url));
+ typedef boost::function<void (const std::string&)> url_callback_t;
+ typedef boost::function<bool(const std::string& url)> execute_url_callback_t;
+
+ static void setOpenURLCallback(url_callback_t cb);
+ static void setOpenURLInternalCallback(url_callback_t cb);
+ static void setOpenURLExternalCallback(url_callback_t cb);
+ static void setExecuteSLURLCallback(execute_url_callback_t cb);
private:
// callbacks for operations we can perform on Urls
- static void (*sOpenURLCallback) (const std::string& url);
- static void (*sOpenURLInternalCallback) (const std::string& url);
- static void (*sOpenURLExternalCallback) (const std::string& url);
- static bool (*sExecuteSLURLCallback) (const std::string& url);
+ static url_callback_t sOpenURLCallback;
+ static url_callback_t sOpenURLInternalCallback;
+ static url_callback_t sOpenURLExternalCallback;
+
+ static execute_url_callback_t sExecuteSLURLCallback;
};
#endif