diff options
author | Leslie Linden <leslie@lindenlab.com> | 2011-11-14 14:44:13 -0800 |
---|---|---|
committer | Leslie Linden <leslie@lindenlab.com> | 2011-11-14 14:44:13 -0800 |
commit | 76caf0238cb98c1abf69d56e122c71a1208b0d72 (patch) | |
tree | 4f4a77ff8f11e7cc0a0f7af437b8699f0d035727 /indra/llui | |
parent | b403a9da23a2df73a657bfa835a3706a261af2fb (diff) | |
parent | c24645f7b51ea27e1686bbe72470a9f3c09fc676 (diff) |
Merge
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llbutton.cpp | 1 | ||||
-rw-r--r-- | indra/llui/llkeywords.cpp | 81 | ||||
-rw-r--r-- | indra/llui/llkeywords.h | 33 | ||||
-rw-r--r-- | indra/llui/llmenugl.cpp | 5 | ||||
-rw-r--r-- | indra/llui/llmenugl.h | 4 | ||||
-rw-r--r-- | indra/llui/llsdparam.cpp | 2 | ||||
-rw-r--r-- | indra/llui/llsdparam.h | 7 | ||||
-rw-r--r-- | indra/llui/lltabcontainer.cpp | 185 | ||||
-rw-r--r-- | indra/llui/lltabcontainer.h | 6 | ||||
-rw-r--r-- | indra/llui/lltoolbar.cpp | 47 | ||||
-rw-r--r-- | indra/llui/lltoolbar.h | 89 | ||||
-rw-r--r-- | indra/llui/llurlaction.cpp | 28 | ||||
-rw-r--r-- | indra/llui/llurlaction.h | 21 |
13 files changed, 308 insertions, 201 deletions
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 74b8885e1f..f9e2ad8554 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -1234,7 +1234,6 @@ void LLButton::resetMouseDownTimer() mMouseDownTimer.reset(); } - BOOL LLButton::handleDoubleClick(S32 x, S32 y, MASK mask) { // just treat a double click as a second click 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/llmenugl.cpp b/indra/llui/llmenugl.cpp index 3ef8d8ff35..cb237fca7c 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -1686,7 +1686,8 @@ LLMenuGL::LLMenuGL(const LLMenuGL::Params& p) mSpilloverMenu(NULL), mJumpKey(p.jump_key), mCreateJumpKeys(p.create_jump_keys), - mNeedsArrange(FALSE), + mNeedsArrange(FALSE), + mResetScrollPositionOnShow(true), mShortcutPad(p.shortcut_pad) { typedef boost::tokenizer<boost::char_separator<char> > tokenizer; @@ -3043,7 +3044,7 @@ void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y) S32 mouse_x, mouse_y; // Resetting scrolling position - if (menu->isScrollable()) + if (menu->isScrollable() && menu->isScrollPositionOnShowReset()) { menu->mFirstVisibleItem = NULL; } diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index 77db588390..bdae899933 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -516,6 +516,9 @@ public: static class LLMenuHolderGL* sMenuContainer; + void resetScrollPositionOnShow(bool reset_scroll_pos) { mResetScrollPositionOnShow = reset_scroll_pos; } + bool isScrollPositionOnShowReset() { return mResetScrollPositionOnShow; } + protected: void createSpilloverBranch(); void cleanupSpilloverBranch(); @@ -565,6 +568,7 @@ private: KEY mJumpKey; BOOL mCreateJumpKeys; S32 mShortcutPad; + bool mResetScrollPositionOnShow; }; // end class LLMenuGL 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/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index ad1f3c504d..d5f8707381 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -214,6 +214,7 @@ LLTabContainer::Params::Params() middle_tab("middle_tab"), last_tab("last_tab"), use_custom_icon_ctrl("use_custom_icon_ctrl", false), + open_tabs_on_drag_and_drop("open_tabs_on_drag_and_drop", false), tab_icon_ctrl_pad("tab_icon_ctrl_pad", 0), use_ellipses("use_ellipses"), font_halign("halign") @@ -250,6 +251,7 @@ LLTabContainer::LLTabContainer(const LLTabContainer::Params& p) mMiddleTabParams(p.middle_tab), mLastTabParams(p.last_tab), mCustomIconCtrlUsed(p.use_custom_icon_ctrl), + mOpenTabsOnDragAndDrop(p.open_tabs_on_drag_and_drop), mTabIconCtrlPad(p.tab_icon_ctrl_pad), mUseTabEllipses(p.use_ellipses) { @@ -812,50 +814,62 @@ BOOL LLTabContainer::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDrag { BOOL has_scroll_arrows = (getMaxScrollPos() > 0); - if( !getTabsHidden() - && mDragAndDropDelayTimer.getStarted() - && mDragAndDropDelayTimer.getElapsedTimeF32() > SCROLL_DELAY_TIME ) + if(mOpenTabsOnDragAndDrop && !getTabsHidden()) { - if (has_scroll_arrows) + // In that case, we'll open the hovered tab while dragging and dropping items. + // This allows for drilling through tabs. + if (mDragAndDropDelayTimer.getStarted()) { - if (mJumpPrevArrowBtn && mJumpPrevArrowBtn->getRect().pointInRect(x, y)) + if (mDragAndDropDelayTimer.getElapsedTimeF32() > SCROLL_DELAY_TIME) { - S32 local_x = x - mJumpPrevArrowBtn->getRect().mLeft; - S32 local_y = y - mJumpPrevArrowBtn->getRect().mBottom; - mJumpPrevArrowBtn->handleHover(local_x, local_y, mask); - } - if (mJumpNextArrowBtn && mJumpNextArrowBtn->getRect().pointInRect(x, y)) - { - S32 local_x = x - mJumpNextArrowBtn->getRect().mLeft; - S32 local_y = y - mJumpNextArrowBtn->getRect().mBottom; - mJumpNextArrowBtn->handleHover(local_x, local_y, mask); - } - if (mPrevArrowBtn->getRect().pointInRect(x, y)) - { - S32 local_x = x - mPrevArrowBtn->getRect().mLeft; - S32 local_y = y - mPrevArrowBtn->getRect().mBottom; - mPrevArrowBtn->handleHover(local_x, local_y, mask); - } - else if (mNextArrowBtn->getRect().pointInRect(x, y)) - { - S32 local_x = x - mNextArrowBtn->getRect().mLeft; - S32 local_y = y - mNextArrowBtn->getRect().mBottom; - mNextArrowBtn->handleHover(local_x, local_y, mask); - } - } + if (has_scroll_arrows) + { + if (mJumpPrevArrowBtn && mJumpPrevArrowBtn->getRect().pointInRect(x, y)) + { + S32 local_x = x - mJumpPrevArrowBtn->getRect().mLeft; + S32 local_y = y - mJumpPrevArrowBtn->getRect().mBottom; + mJumpPrevArrowBtn->handleHover(local_x, local_y, mask); + } + if (mJumpNextArrowBtn && mJumpNextArrowBtn->getRect().pointInRect(x, y)) + { + S32 local_x = x - mJumpNextArrowBtn->getRect().mLeft; + S32 local_y = y - mJumpNextArrowBtn->getRect().mBottom; + mJumpNextArrowBtn->handleHover(local_x, local_y, mask); + } + if (mPrevArrowBtn->getRect().pointInRect(x, y)) + { + S32 local_x = x - mPrevArrowBtn->getRect().mLeft; + S32 local_y = y - mPrevArrowBtn->getRect().mBottom; + mPrevArrowBtn->handleHover(local_x, local_y, mask); + } + else if (mNextArrowBtn->getRect().pointInRect(x, y)) + { + S32 local_x = x - mNextArrowBtn->getRect().mLeft; + S32 local_y = y - mNextArrowBtn->getRect().mBottom; + mNextArrowBtn->handleHover(local_x, local_y, mask); + } + } - for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter) - { - LLTabTuple* tuple = *iter; - tuple->mButton->setVisible( TRUE ); - S32 local_x = x - tuple->mButton->getRect().mLeft; - S32 local_y = y - tuple->mButton->getRect().mBottom; - if (tuple->mButton->pointInView(local_x, local_y) && tuple->mButton->getEnabled() && !tuple->mTabPanel->getVisible()) - { - tuple->mButton->onCommit(); + for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter) + { + LLTabTuple* tuple = *iter; + tuple->mButton->setVisible( TRUE ); + S32 local_x = x - tuple->mButton->getRect().mLeft; + S32 local_y = y - tuple->mButton->getRect().mBottom; + if (tuple->mButton->pointInView(local_x, local_y) && tuple->mButton->getEnabled() && !tuple->mTabPanel->getVisible()) + { + tuple->mButton->onCommit(); + } + } + // Stop the timer whether successful or not. Don't let it run forever. mDragAndDropDelayTimer.stop(); } } + else + { + // Start a timer so we don't open tabs as soon as we hover on them + mDragAndDropDelayTimer.start(); + } } return LLView::handleDragAndDrop(x, y, mask, drop, type, cargo_data, accept, tooltip); @@ -1025,85 +1039,50 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel) } else { + LLButton::Params& p = (mCustomIconCtrlUsed ? custom_btn_params : normal_btn_params); + + p.rect(btn_rect); + p.font(mFont); + p.font_halign = mFontHalign; + p.label(trimmed_label); + p.click_callback.function(boost::bind(&LLTabContainer::onTabBtn, this, _2, child)); + if (indent) + { + p.pad_left(indent); + } + p.pad_bottom( mLabelPadBottom ); + p.scale_image(true); + p.tab_stop(false); + p.label_shadow(false); + p.follows.flags = FOLLOWS_LEFT; + if (mIsVertical) { - LLButton::Params& p = (mCustomIconCtrlUsed)? - custom_btn_params:normal_btn_params; - p.name(std::string("vert tab button")); - p.rect(btn_rect); - p.follows.flags(FOLLOWS_TOP | FOLLOWS_LEFT); - p.click_callback.function(boost::bind(&LLTabContainer::onTabBtn, this, _2, child)); - p.font(mFont); - p.label(trimmed_label); p.image_unselected(mMiddleTabParams.tab_left_image_unselected); p.image_selected(mMiddleTabParams.tab_left_image_selected); - p.scale_image(true); - p.font_halign = mFontHalign; - p.pad_bottom( mLabelPadBottom ); - p.tab_stop(false); - p.label_shadow(false); - if (indent) - { - p.pad_left(indent); - } - - - if(mCustomIconCtrlUsed) - { - btn = LLUICtrlFactory::create<LLCustomButtonIconCtrl>(custom_btn_params); - - } - else - { - btn = LLUICtrlFactory::create<LLButton>(p); - } + p.follows.flags = p.follows.flags() | FOLLOWS_TOP; } else { - LLButton::Params& p = (mCustomIconCtrlUsed)? - custom_btn_params:normal_btn_params; p.name(std::string(child->getName()) + " tab"); - p.rect(btn_rect); - p.click_callback.function(boost::bind(&LLTabContainer::onTabBtn, this, _2, child)); - p.font(mFont); - p.label(trimmed_label); p.visible(false); - p.scale_image(true); p.image_unselected(tab_img); p.image_selected(tab_selected_img); - p.tab_stop(false); - p.label_shadow(false); + p.follows.flags = p.follows.flags() | (getTabPosition() == TOP ? FOLLOWS_TOP : FOLLOWS_BOTTOM); // Try to squeeze in a bit more text p.pad_left( mLabelPadLeft ); p.pad_right(2); - p.pad_bottom( mLabelPadBottom ); - p.font_halign = mFontHalign; - p.follows.flags = FOLLOWS_LEFT; - p.follows.flags = FOLLOWS_LEFT; - - if (indent) - { - p.pad_left(indent); - } - - if( getTabPosition() == TOP ) - { - p.follows.flags = p.follows.flags() | FOLLOWS_TOP; - } - else - { - p.follows.flags = p.follows.flags() | FOLLOWS_BOTTOM; - } - - if(mCustomIconCtrlUsed) - { - btn = LLUICtrlFactory::create<LLCustomButtonIconCtrl>(custom_btn_params); - } - else - { - btn = LLUICtrlFactory::create<LLButton>(p); - } + } + + // *TODO : It seems wrong not to use p in both cases considering the way p is initialized + if (mCustomIconCtrlUsed) + { + btn = LLUICtrlFactory::create<LLCustomButtonIconCtrl>(custom_btn_params); + } + else + { + btn = LLUICtrlFactory::create<LLButton>(p); } } @@ -1280,6 +1259,10 @@ void LLTabContainer::enableTabButton(S32 which, BOOL enable) { mTabList[which]->mButton->setEnabled(enable); } + // Stop the DaD timer as it might run forever + // enableTabButton() is typically called on refresh and draw when anything changed + // in the tab container so it's a good time to reset that. + mDragAndDropDelayTimer.stop(); } void LLTabContainer::deleteAllTabs() diff --git a/indra/llui/lltabcontainer.h b/indra/llui/lltabcontainer.h index eaa2fd54e0..cebace2ceb 100644 --- a/indra/llui/lltabcontainer.h +++ b/indra/llui/lltabcontainer.h @@ -105,6 +105,11 @@ public: Optional<bool> use_custom_icon_ctrl; /** + * Open tabs on hover in drag and drop situations + */ + Optional<bool> open_tabs_on_drag_and_drop; + + /** * Paddings for LLIconCtrl in case of LLCustomButtonIconCtrl usage(use_custom_icon_ctrl = true) */ Optional<S32> tab_icon_ctrl_pad; @@ -300,6 +305,7 @@ private: TabParams mLastTabParams; bool mCustomIconCtrlUsed; + bool mOpenTabsOnDragAndDrop; S32 mTabIconCtrlPad; bool mUseTabEllipses; }; 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 f10f39adc3..51fe23ddd1 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -63,9 +63,11 @@ 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; } + LLCommandId getCommandId() { return mId; } void setStartDragCallback(tool_startdrag_callback_t cb) { mStartDragItemCallback = cb; } void setHandleDragCallback(tool_handledrag_callback_t cb) { mHandleDragItemCallback = cb; } @@ -164,7 +166,8 @@ public: pad_bottom, pad_between, min_girth; - // get rid of this + + // default command set Multiple<LLCommandId::Params> commands; Optional<LLPanel::Params> button_panel; @@ -175,8 +178,6 @@ public: // virtuals void draw(); void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); - int getRankFromPosition(S32 x, S32 y); - int getRankFromPosition(const LLCommandId& id); BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, @@ -185,15 +186,14 @@ public: std::string& tooltip_msg); static const int RANK_NONE = -1; - bool addCommand(const LLCommandId& commandId, int rank = RANK_NONE); int removeCommand(const LLCommandId& commandId); // Returns the rank the removed command was at, RANK_NONE if not found - bool hasCommand(const LLCommandId& commandId) const; - bool enableCommand(const LLCommandId& commandId, bool enabled); - bool stopCommandInProgress(const LLCommandId& commandId); - bool flashCommand(const LLCommandId& commandId, bool flash); + bool hasCommand(const LLCommandId& commandId) const; // is this command bound to a button in this toolbar + bool enableCommand(const LLCommandId& commandId, bool enabled); // enable/disable button bound to the specified command, if it exists in this toolbar + bool stopCommandInProgress(const LLCommandId& commandId); // stop command if it is currently active + bool flashCommand(const LLCommandId& commandId, bool flash); // flash button associated with given command, if in this toolbar - void setStartDragCallback(tool_startdrag_callback_t cb) { mStartDragItemCallback = cb; } + void setStartDragCallback(tool_startdrag_callback_t cb) { mStartDragItemCallback = cb; } // connects drag and drop behavior to external logic void setHandleDragCallback(tool_handledrag_callback_t cb) { mHandleDragItemCallback = cb; } void setHandleDropCallback(tool_handledrop_callback_t cb) { mHandleDropCallback = cb; } bool isReadOnly() const { return mReadOnly; } @@ -206,69 +206,76 @@ public: boost::signals2::connection setButtonLeaveCallback(const button_signal_t::slot_type& cb); boost::signals2::connection setButtonRemoveCallback(const button_signal_t::slot_type& cb); - void setTooltipButtonSuffix(const std::string& suffix) { mButtonTooltipSuffix = suffix; } + // append the specified string to end of tooltip + void setTooltipButtonSuffix(const std::string& suffix) { mButtonTooltipSuffix = suffix; } LLToolBarEnums::SideType getSideType() const { return mSideType; } bool hasButtons() const { return !mButtons.empty(); } bool isModified() const { return mModified; } -protected: - friend class LLUICtrlFactory; - LLToolBar(const Params&); - ~LLToolBar(); - - void initFromParams(const Params&); - tool_startdrag_callback_t mStartDragItemCallback; - tool_handledrag_callback_t mHandleDragItemCallback; - tool_handledrop_callback_t mHandleDropCallback; - bool mDragAndDropTarget; - int mDragRank; - S32 mDragx, - mDragy, - mDragGirth; + int getRankFromPosition(S32 x, S32 y); + int getRankFromPosition(const LLCommandId& id); -public: // Methods used in loading and saving toolbar settings void setButtonType(LLToolBarEnums::ButtonType button_type); LLToolBarEnums::ButtonType getButtonType() { return mButtonType; } command_id_list_t& getCommandsList() { return mButtonCommands; } void clearCommandsList(); - + private: + friend class LLUICtrlFactory; + LLToolBar(const Params&); + ~LLToolBar(); + + void initFromParams(const Params&); void createContextMenu(); void updateLayoutAsNeeded(); void createButtons(); 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 const bool mReadOnly; + const LLToolBarEnums::SideType mSideType; + const bool mWrap; + const S32 mPadLeft, + mPadRight, + mPadTop, + mPadBottom, + mPadBetween, + mMinGirth; + + // drag and drop state + tool_startdrag_callback_t mStartDragItemCallback; + tool_handledrag_callback_t mHandleDragItemCallback; + tool_handledrop_callback_t mHandleDropCallback; + bool mDragAndDropTarget; + int mDragRank; + S32 mDragx, + mDragy, + mDragGirth; typedef std::list<LLToolBarButton*> toolbar_button_list; + typedef std::map<LLUUID, LLToolBarButton*> command_id_map; toolbar_button_list mButtons; command_id_list_t mButtonCommands; - typedef std::map<LLUUID, LLToolBarButton*> command_id_map; command_id_map mButtonMap; LLToolBarEnums::ButtonType mButtonType; + LLToolBarButton::Params mButtonParams[LLToolBarEnums::BTNTYPE_COUNT]; + + // related widgets LLLayoutStack* mCenteringStack; - LLLayoutStack* mWrapStack; LLPanel* mButtonPanel; - LLToolBarEnums::SideType mSideType; - - bool mWrap; - bool mNeedsLayout; - bool mModified; - S32 mPadLeft, - mPadRight, - mPadTop, - mPadBottom, - mPadBetween, - mMinGirth; + LLHandle<class LLContextMenu> mPopupMenuHandle; - LLToolBarButton::Params mButtonParams[LLToolBarEnums::BTNTYPE_COUNT]; + LLToolBarButton* mRightMouseTargetButton; - LLHandle<class LLContextMenu> mPopupMenuHandle; + bool mNeedsLayout; + bool mModified; button_signal_t* mButtonAddSignal; button_signal_t* mButtonEnterSignal; 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 |