diff options
Diffstat (limited to 'indra/llui')
57 files changed, 1611 insertions, 704 deletions
diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index 532b6b6524..12df9ccae4 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -52,6 +52,7 @@ set(llui_SOURCE_FILES llkeywords.cpp lllayoutstack.cpp lllineeditor.cpp + llloadingindicator.cpp lllocalcliprect.cpp llmenubutton.cpp llmenugl.cpp @@ -90,6 +91,7 @@ set(llui_SOURCE_FILES lltextbox.cpp lltexteditor.cpp lltextparser.cpp + lltextutil.cpp lltextvalidate.cpp lltransutil.cpp lltoggleablemenu.cpp @@ -144,6 +146,7 @@ set(llui_HEADER_FILES lllayoutstack.h lllazyvalue.h lllineeditor.h + llloadingindicator.h lllocalcliprect.h llmenubutton.h llmenugl.h @@ -183,6 +186,7 @@ set(llui_HEADER_FILES lltextbox.h lltexteditor.h lltextparser.h + lltextutil.h lltextvalidate.h lltoggleablemenu.h lltooltip.h diff --git a/indra/llui/llaccordionctrl.cpp b/indra/llui/llaccordionctrl.cpp index 2ed1082f56..5d1d57cbb2 100644 --- a/indra/llui/llaccordionctrl.cpp +++ b/indra/llui/llaccordionctrl.cpp @@ -329,14 +329,34 @@ void LLAccordionCtrl::addCollapsibleCtrl(LLView* view) LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(view); if(!accordion_tab) return; - if(std::find(getChildList()->begin(),getChildList()->end(),accordion_tab) == getChildList()->end()) + if(std::find(beginChild(), endChild(), accordion_tab) == endChild()) addChild(accordion_tab); mAccordionTabs.push_back(accordion_tab); - + accordion_tab->setDropDownStateChangedCallback( boost::bind(&LLAccordionCtrl::onCollapseCtrlCloseOpen, this, mAccordionTabs.size() - 1) ); } +void LLAccordionCtrl::removeCollapsibleCtrl(LLView* view) +{ + LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(view); + if(!accordion_tab) + return; + + if(std::find(beginChild(), endChild(), accordion_tab) != endChild()) + removeChild(accordion_tab); + + for (std::vector<LLAccordionCtrlTab*>::iterator iter = mAccordionTabs.begin(); + iter != mAccordionTabs.end(); ++iter) + { + if (accordion_tab == (*iter)) + { + mAccordionTabs.erase(iter); + break; + } + } +} + void LLAccordionCtrl::arrangeSinge() { S32 panel_left = BORDER_MARGIN; // Margin from left side of Splitter @@ -372,11 +392,33 @@ void LLAccordionCtrl::arrangeSinge() } else { - panel_height = expanded_height; + if(mFitParent) + { + panel_height = expanded_height; + } + else + { + if(accordion_tab->getAccordionView()) + { + panel_height = accordion_tab->getAccordionView()->getRect().getHeight() + + accordion_tab->getHeaderHeight() + 2*BORDER_MARGIN; + } + else + { + panel_height = accordion_tab->getRect().getHeight(); + } + } } + + // make sure at least header is shown + panel_height = llmax(panel_height, accordion_tab->getHeaderHeight()); + ctrlSetLeftTopAndSize(mAccordionTabs[i], panel_left, panel_top, panel_width, panel_height); panel_top-=mAccordionTabs[i]->getRect().getHeight(); } + + show_hide_scrollbar(getRect().getWidth(), getRect().getHeight()); + updateLayout(getRect().getWidth(), getRect().getHeight()); } void LLAccordionCtrl::arrangeMultiple() @@ -626,15 +668,23 @@ S32 LLAccordionCtrl::notifyParent(const LLSD& info) LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]); if(accordion_tab->hasFocus() && i>0) { + bool prev_visible_tab_found = false; while(i>0) { if(mAccordionTabs[--i]->getVisible()) + { + prev_visible_tab_found = true; break; + } + } + + if (prev_visible_tab_found) + { + accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]); + accordion_tab->notify(LLSD().with("action","select_last")); + return 1; } - - accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]); - accordion_tab->notify(LLSD().with("action","select_last")); - return 1; + break; } } return 0; diff --git a/indra/llui/llaccordionctrl.h b/indra/llui/llaccordionctrl.h index 7c29e545b7..ab7d6548ca 100644 --- a/indra/llui/llaccordionctrl.h +++ b/indra/llui/llaccordionctrl.h @@ -92,6 +92,7 @@ public: virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); void addCollapsibleCtrl(LLView* view); + void removeCollapsibleCtrl(LLView* view); void arrange(); diff --git a/indra/llui/llaccordionctrltab.cpp b/indra/llui/llaccordionctrltab.cpp index 1067c3f1d5..b09c108ec3 100644 --- a/indra/llui/llaccordionctrltab.cpp +++ b/indra/llui/llaccordionctrltab.cpp @@ -32,12 +32,13 @@ #include "linden_common.h" -#include "lluictrl.h" -#include "llscrollbar.h" #include "llaccordionctrltab.h" -#include "lllocalcliprect.h" +#include "lllocalcliprect.h" +#include "llscrollbar.h" #include "lltextbox.h" +#include "lltextutil.h" +#include "lluictrl.h" static const std::string DD_BUTTON_NAME = "dd_button"; static const std::string DD_TEXTBOX_NAME = "dd_textbox"; @@ -72,7 +73,8 @@ public: virtual BOOL postBuild(); - void setTitle(const std::string& title); + std::string getTitle(); + void setTitle(const std::string& title, const std::string& hl); virtual void onMouseEnter(S32 x, S32 y, MASK mask); virtual void onMouseLeave(S32 x, S32 y, MASK mask); @@ -146,10 +148,28 @@ BOOL LLAccordionCtrlTab::LLAccordionCtrlTabHeader::postBuild() return TRUE; } -void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::setTitle(const std::string& title) +std::string LLAccordionCtrlTab::LLAccordionCtrlTabHeader::getTitle() +{ + if(mHeaderTextbox) + { + return mHeaderTextbox->getText(); + } + else + { + return LLStringUtil::null; + } +} + +void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::setTitle(const std::string& title, const std::string& hl) { if(mHeaderTextbox) - mHeaderTextbox->setText(title); + { + LLTextUtil::textboxSetHighlightedVal( + mHeaderTextbox, + LLStyle::Params(), + title, + hl); + } } void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::draw() @@ -425,6 +445,9 @@ bool LLAccordionCtrlTab::addChild(LLView* child, S32 tab_group) setDisplayChildren(getDisplayChildren()); } + if (!mContainerPanel) + mContainerPanel = findContainerView(); + return res; } @@ -433,6 +456,47 @@ void LLAccordionCtrlTab::setAccordionView(LLView* panel) addChild(panel,0); } +std::string LLAccordionCtrlTab::getTitle() +{ + LLAccordionCtrlTabHeader* header = findChild<LLAccordionCtrlTabHeader>(DD_HEADER_NAME); + if (header) + { + return header->getTitle(); + } + else + { + return LLStringUtil::null; + } +} + +void LLAccordionCtrlTab::setTitle(const std::string& title, const std::string& hl) +{ + LLAccordionCtrlTabHeader* header = findChild<LLAccordionCtrlTabHeader>(DD_HEADER_NAME); + if (header) + { + header->setTitle(title, hl); + } +} + +boost::signals2::connection LLAccordionCtrlTab::setFocusReceivedCallback(const focus_signal_t::slot_type& cb) +{ + LLAccordionCtrlTabHeader* header = findChild<LLAccordionCtrlTabHeader>(DD_HEADER_NAME); + if (header) + { + return header->setFocusReceivedCallback(cb); + } + return boost::signals2::connection(); +} + +boost::signals2::connection LLAccordionCtrlTab::setFocusLostCallback(const focus_signal_t::slot_type& cb) +{ + LLAccordionCtrlTabHeader* header = findChild<LLAccordionCtrlTabHeader>(DD_HEADER_NAME); + if (header) + { + return header->setFocusLostCallback(cb); + } + return boost::signals2::connection(); +} LLView* LLAccordionCtrlTab::findContainerView() { @@ -465,10 +529,11 @@ void LLAccordionCtrlTab::setHeaderVisible(bool value) reshape(getRect().getWidth(), getRect().getHeight(), FALSE); }; -//vurtual +//virtual BOOL LLAccordionCtrlTab::postBuild() { - mHeader->setVisible(mHeaderVisible); + if(mHeader) + mHeader->setVisible(mHeaderVisible); static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0); @@ -504,7 +569,8 @@ BOOL LLAccordionCtrlTab::postBuild() mScrollbar->setVisible(false); } - mContainerPanel->setVisible(mDisplayChildren); + if(mContainerPanel) + mContainerPanel->setVisible(mDisplayChildren); return LLUICtrl::postBuild(); } @@ -549,7 +615,8 @@ S32 LLAccordionCtrlTab::notifyParent(const LLSD& info) } //LLAccordionCtrl should rearrange accodion tab if one of accordion change its size - getParent()->notifyParent(info); + if (getParent()) // A parent may not be set if tabs are added dynamically. + getParent()->notifyParent(info); return 1; } else if(str_action == "select_prev") @@ -826,9 +893,6 @@ void LLAccordionCtrlTab::draw() LLLocalClipRect clip(child_rect); drawChild(root_rect,mContainerPanel); } - - - gGL.getTexUnit(0)->disable(); } } @@ -861,5 +925,14 @@ void LLAccordionCtrlTab::ctrlSetLeftTopAndSize(LLView* panel, S32 left, S32 top, panel->reshape( width, height, 1); panel->setRect(panel_rect); } - - +BOOL LLAccordionCtrlTab::handleToolTip(S32 x, S32 y, MASK mask) +{ + //header may be not the first child but we need to process it first + if(y >= (getRect().getHeight() - HEADER_HEIGHT - HEADER_HEIGHT/2) ) + { + //inside tab header + //fix for EXT-6619 + return TRUE; + } + return LLUICtrl::handleToolTip(x, y, mask); +} diff --git a/indra/llui/llaccordionctrltab.h b/indra/llui/llaccordionctrltab.h index 462ccc6d53..f5b7fd0af6 100644 --- a/indra/llui/llaccordionctrltab.h +++ b/indra/llui/llaccordionctrltab.h @@ -35,8 +35,9 @@ #include <string> #include "llrect.h" +#include "lluictrl.h" +#include "lluicolor.h" -class LLUICtrl; class LLUICtrlFactory; class LLUIImage; class LLButton; @@ -112,6 +113,14 @@ public: void setAccordionView(LLView* panel); LLView* getAccordionView() { return mContainerPanel; }; + std::string getTitle(); + + // Set text and highlight substring in LLAccordionCtrlTabHeader + void setTitle(const std::string& title, const std::string& hl = LLStringUtil::null); + + boost::signals2::connection setFocusReceivedCallback(const focus_signal_t::slot_type& cb); + boost::signals2::connection setFocusLostCallback(const focus_signal_t::slot_type& cb); + bool getCollapsible() {return mCollapsible;}; void setCollapsible(bool collapsible) {mCollapsible = collapsible;}; @@ -147,6 +156,8 @@ public: virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); virtual BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent); + virtual BOOL handleToolTip(S32 x, S32 y, MASK mask); + virtual bool addChild(LLView* child, S32 tab_group); bool isExpanded() { return mDisplayChildren; } diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 1d4dc35cee..0255061b12 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -824,7 +824,7 @@ void LLButton::draw() x = text_right; break; case LLFontGL::HCENTER: - x = getRect().getWidth() / 2; + x = text_left + (text_width / 2); break; case LLFontGL::LEFT: default: @@ -1003,6 +1003,11 @@ void LLButton::setImageDisabledSelected(LLPointer<LLUIImage> image) mFadeWhenDisabled = TRUE; } +void LLButton::setImagePressed(LLPointer<LLUIImage> image) +{ + mImagePressed = image; +} + void LLButton::setImageHoverSelected(LLPointer<LLUIImage> image) { mImageHoverSelected = image; diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 59b551a16d..a4d81ed6c3 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -217,7 +217,7 @@ public: void setImageOverlay(const LLUUID& image_id, LLFontGL::HAlign alignment = LLFontGL::HCENTER, const LLColor4& color = LLColor4::white); LLPointer<LLUIImage> getImageOverlay() { return mImageOverlay; } LLFontGL::HAlign getImageOverlayHAlign() const { return mImageOverlayAlignment; } - + void autoResize(); // resize with label of current btn state void resize(LLUIString label); // resize with label input void setLabel( const LLStringExplicit& label); @@ -246,6 +246,7 @@ public: void setImageHoverUnselected(LLPointer<LLUIImage> image); void setImageDisabled(LLPointer<LLUIImage> image); void setImageDisabledSelected(LLPointer<LLUIImage> image); + void setImagePressed(LLPointer<LLUIImage> image); void setCommitOnReturn(BOOL commit) { mCommitOnReturn = commit; } BOOL getCommitOnReturn() const { return mCommitOnReturn; } diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp index c1d512e148..cc107c972d 100644 --- a/indra/llui/llcombobox.cpp +++ b/indra/llui/llcombobox.cpp @@ -495,7 +495,6 @@ void LLComboBox::createLineEditor(const LLComboBox::Params& p) params.max_length_bytes(mMaxChars); params.commit_callback.function(boost::bind(&LLComboBox::onTextCommit, this, _2)); params.keystroke_callback(boost::bind(&LLComboBox::onTextEntry, this, _1)); - params.handle_edit_keys_directly(true); params.commit_on_focus_lost(false); params.follows.flags(FOLLOWS_ALL); params.label(mLabel); @@ -706,14 +705,17 @@ void LLComboBox::onListMouseUp() void LLComboBox::onItemSelected(const LLSD& data) { - setValue(data); - - if (mAllowTextEntry && mLastSelectedIndex != -1) + mLastSelectedIndex = getCurrentIndex(); + if (mLastSelectedIndex != -1) { - gFocusMgr.setKeyboardFocus(mTextEntry); - mTextEntry->selectAll(); - } + setLabel(getSelectedItemLabel()); + if (mAllowTextEntry) + { + gFocusMgr.setKeyboardFocus(mTextEntry); + mTextEntry->selectAll(); + } + } // hiding the list reasserts the old value stored in the text editor/dropdown button hideList(); @@ -1080,24 +1082,6 @@ LLIconsComboBox::LLIconsComboBox(const LLIconsComboBox::Params& p) mLabelColumnIndex(p.label_column) {} -void LLIconsComboBox::setValue(const LLSD& value) -{ - BOOL found = mList->selectByValue(value); - if (found) - { - LLScrollListItem* item = mList->getFirstSelected(); - if (item) - { - setLabel(getSelectedItemLabel()); - } - mLastSelectedIndex = mList->getFirstSelectedIndex(); - } - else - { - mLastSelectedIndex = -1; - } -} - const std::string LLIconsComboBox::getSelectedItemLabel(S32 column) const { mButton->setImageOverlay(LLComboBox::getSelectedItemLabel(mIconColumnIndex), mButton->getImageOverlayHAlign()); diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h index 965061ead2..f0bd432f3a 100644 --- a/indra/llui/llcombobox.h +++ b/indra/llui/llcombobox.h @@ -221,7 +221,6 @@ protected: LLPointer<LLUIImage> mArrowImage; LLUIString mLabel; BOOL mHasAutocompletedText; - S32 mLastSelectedIndex; private: BOOL mAllowTextEntry; @@ -232,6 +231,7 @@ private: commit_callback_t mTextEntryCallback; commit_callback_t mSelectionCallback; boost::signals2::connection mTopLostSignalConnection; + S32 mLastSelectedIndex; }; // A combo box with icons for the list of items. @@ -247,7 +247,6 @@ public: Params(); }; - /*virtual*/ void setValue(const LLSD& value); /*virtual*/ const std::string getSelectedItemLabel(S32 column = 0) const; private: diff --git a/indra/llui/lldraghandle.cpp b/indra/llui/lldraghandle.cpp index 832f148902..9f83fcca35 100644 --- a/indra/llui/lldraghandle.cpp +++ b/indra/llui/lldraghandle.cpp @@ -248,15 +248,14 @@ void LLDragHandleTop::reshapeTitleBox() return; } const LLFontGL* font = LLFontGL::getFontSansSerif(); - S32 title_width = font->getWidth( mTitleBox->getText() ) + TITLE_HPAD; - if (getMaxTitleWidth() > 0) - title_width = llmin(title_width, getMaxTitleWidth()); + S32 title_width = getRect().getWidth(); + title_width -= LEFT_PAD + 2 * BORDER_PAD + getButtonsRect().getWidth(); S32 title_height = llround(font->getLineHeight()); LLRect title_rect; title_rect.setLeftTopAndSize( LEFT_PAD, getRect().getHeight() - title_vpad, - getRect().getWidth() - LEFT_PAD - RIGHT_PAD, + title_width, title_height); // calls reshape on mTitleBox diff --git a/indra/llui/lldraghandle.h b/indra/llui/lldraghandle.h index dc5410787b..825bc9303e 100644 --- a/indra/llui/lldraghandle.h +++ b/indra/llui/lldraghandle.h @@ -71,6 +71,8 @@ public: BOOL getForeground() const { return mForeground; } void setMaxTitleWidth(S32 max_width) {mMaxTitleWidth = llmin(max_width, mMaxTitleWidth); } S32 getMaxTitleWidth() const { return mMaxTitleWidth; } + void setButtonsRect(const LLRect& rect){ mButtonsRect = rect; } + LLRect getButtonsRect() { return mButtonsRect; } void setTitleVisible(BOOL visible); virtual void setTitle( const std::string& title ) = 0; @@ -88,6 +90,7 @@ protected: LLTextBox* mTitleBox; private: + LLRect mButtonsRect; S32 mDragLastScreenX; S32 mDragLastScreenY; S32 mLastMouseScreenX; diff --git a/indra/llui/lleditmenuhandler.cpp b/indra/llui/lleditmenuhandler.cpp index 821afae8fd..245bce76f5 100644 --- a/indra/llui/lleditmenuhandler.cpp +++ b/indra/llui/lleditmenuhandler.cpp @@ -37,3 +37,10 @@ /* static */ LLEditMenuHandler* LLEditMenuHandler::gEditMenuHandler = NULL; +LLEditMenuHandler::~LLEditMenuHandler() +{ + if (gEditMenuHandler == this) + { + gEditMenuHandler = NULL; + } +} diff --git a/indra/llui/lleditmenuhandler.h b/indra/llui/lleditmenuhandler.h index 1de9c56afb..d72283cd99 100644 --- a/indra/llui/lleditmenuhandler.h +++ b/indra/llui/lleditmenuhandler.h @@ -38,7 +38,7 @@ class LLEditMenuHandler { public: // this is needed even though this is just an interface class. - virtual ~LLEditMenuHandler() {}; + virtual ~LLEditMenuHandler(); virtual void undo() {}; virtual BOOL canUndo() const { return FALSE; } diff --git a/indra/llui/llfiltereditor.cpp b/indra/llui/llfiltereditor.cpp index 390504234d..6c80275713 100644 --- a/indra/llui/llfiltereditor.cpp +++ b/indra/llui/llfiltereditor.cpp @@ -39,6 +39,7 @@ LLFilterEditor::LLFilterEditor(const LLFilterEditor::Params& p) : LLSearchEditor(p) { + setCommitOnFocusLost(FALSE); // we'll commit on every keystroke, don't re-commit when we take focus away (i.e. we go to interact with the actual results!) } diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp index 2e5aeec41d..2433c14315 100644 --- a/indra/llui/llflatlistview.cpp +++ b/indra/llui/llflatlistview.cpp @@ -1,10 +1,10 @@ /** * @file llflatlistview.cpp - * @brief LLFlatListView base class + * @brief LLFlatListView base class and extension to support messages for several cases of an empty list. * * $LicenseInfo:firstyear=2009&license=viewergpl$ * - * Copyright (c) 2009, Linden Research, Inc. + * Copyright (c) 2009-2010, Linden Research, Inc. * * Second Life Viewer Source Code * The source code in this file ("Source Code") is provided by Linden Lab @@ -243,7 +243,7 @@ LLUUID LLFlatListView::getSelectedUUID() const } } -void LLFlatListView::getSelectedUUIDs(std::vector<LLUUID>& selected_uuids) const +void LLFlatListView::getSelectedUUIDs(uuid_vec_t& selected_uuids) const { if (mSelectedItemPairs.empty()) return; @@ -297,6 +297,27 @@ void LLFlatListView::setNoItemsCommentText(const std::string& comment_text) mNoItemsCommentTextbox->setValue(comment_text); } +U32 LLFlatListView::size(const bool only_visible_items) const +{ + if (only_visible_items) + { + U32 size = 0; + for (pairs_const_iterator_t + iter = mItemPairs.begin(), + iter_end = mItemPairs.end(); + iter != iter_end; ++iter) + { + if ((*iter)->first->getVisible()) + ++size; + } + return size; + } + else + { + return mItemPairs.size(); + } +} + void LLFlatListView::clear() { // do not use LLView::deleteAllChildren to avoid removing nonvisible items. drag-n-drop for ex. @@ -358,6 +379,7 @@ LLFlatListView::LLFlatListView(const LLFlatListView::Params& p) , mCommitOnSelectionChange(false) , mPrevNotifyParentRect(LLRect()) , mNoItemsCommentTextbox(NULL) + , mIsConsecutiveSelection(false) { mBorderThickness = getBorderWidth(); @@ -426,7 +448,7 @@ void LLFlatListView::rearrangeItems() { static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0); - setNoItemsCommentVisible(mItemPairs.empty()); + setNoItemsCommentVisible(0==size()); if (mItemPairs.empty()) return; @@ -504,7 +526,80 @@ void LLFlatListView::onItemMouseClick(item_pair_t* item_pair, MASK mask) //*TODO find a better place for that enforcing stuff if (mKeepOneItemSelected && numSelected() == 1 && !select_item) return; - + + if ( (mask & MASK_SHIFT) && !(mask & MASK_CONTROL) + && mMultipleSelection && !mSelectedItemPairs.empty() ) + { + item_pair_t* last_selected_pair = mSelectedItemPairs.back(); + + // If item_pair is already selected - do nothing + if (last_selected_pair == item_pair) + return; + + bool grab_items = false; + bool reverse = false; + pairs_list_t pairs_to_select; + + // Pick out items from list between last selected and current clicked item_pair. + for (pairs_iterator_t + iter = mItemPairs.begin(), + iter_end = mItemPairs.end(); + iter != iter_end; ++iter) + { + item_pair_t* cur = *iter; + if (cur == last_selected_pair || cur == item_pair) + { + // We've got reverse selection if last grabed item isn't a new selection. + reverse = grab_items && (cur != item_pair); + grab_items = !grab_items; + // Skip last selected and current clicked item pairs. + continue; + } + if (!cur->first->getVisible()) + { + // Skip invisible item pairs. + continue; + } + if (grab_items) + { + pairs_to_select.push_back(cur); + } + } + + if (reverse) + { + pairs_to_select.reverse(); + } + + pairs_to_select.push_back(item_pair); + + for (pairs_iterator_t + iter = pairs_to_select.begin(), + iter_end = pairs_to_select.end(); + iter != iter_end; ++iter) + { + item_pair_t* pair_to_select = *iter; + if (isSelected(pair_to_select)) + { + // Item was already selected but there is a need to keep order from last selected pair to new selection. + // Do it here to prevent extra mCommitOnSelectionChange in selectItemPair(). + mSelectedItemPairs.remove(pair_to_select); + mSelectedItemPairs.push_back(pair_to_select); + } + else + { + selectItemPair(pair_to_select, true); + } + } + + if (!select_item) + { + // Update last selected item border. + mSelectedItemsBorder->setRect(getLastSelectedItemRect().stretch(-1)); + } + return; + } + if (!(mask & MASK_CONTROL) || !mMultipleSelection) resetSelection(); selectItemPair(item_pair, select_item); } @@ -558,15 +653,6 @@ BOOL LLFlatListView::handleKeyHere(KEY key, MASK mask) } break; } - case 'A': - { - if(MASK_CONTROL & mask) - { - selectAll(); - handled = TRUE; - } - break; - } default: break; } @@ -676,6 +762,8 @@ bool LLFlatListView::selectItemPair(item_pair_t* item_pair, bool select) // Stretch selected item rect to ensure it won't be clipped mSelectedItemsBorder->setRect(getLastSelectedItemRect().stretch(-1)); + // By default mark it as not consecutive selection + mIsConsecutiveSelection = false; return true; } @@ -692,14 +780,44 @@ LLRect LLFlatListView::getLastSelectedItemRect() void LLFlatListView::selectFirstItem () { - selectItemPair(mItemPairs.front(), true); - ensureSelectedVisible(); + // No items - no actions! + if (0 == size()) return; + + // Select first visible item + for (pairs_iterator_t + iter = mItemPairs.begin(), + iter_end = mItemPairs.end(); + iter != iter_end; ++iter) + { + // skip invisible items + if ( (*iter)->first->getVisible() ) + { + selectItemPair(*iter, true); + ensureSelectedVisible(); + break; + } + } } void LLFlatListView::selectLastItem () { - selectItemPair(mItemPairs.back(), true); - ensureSelectedVisible(); + // No items - no actions! + if (0 == size()) return; + + // Select last visible item + for (pairs_list_t::reverse_iterator + r_iter = mItemPairs.rbegin(), + r_iter_end = mItemPairs.rend(); + r_iter != r_iter_end; ++r_iter) + { + // skip invisible items + if ( (*r_iter)->first->getVisible() ) + { + selectItemPair(*r_iter, true); + ensureSelectedVisible(); + break; + } + } } void LLFlatListView::ensureSelectedVisible() @@ -717,14 +835,25 @@ void LLFlatListView::ensureSelectedVisible() bool LLFlatListView::selectNextItemPair(bool is_up_direction, bool reset_selection) { // No items - no actions! - if ( !mItemPairs.size() ) + if ( 0 == size() ) return false; - - item_pair_t* to_sel_pair = NULL; - item_pair_t* cur_sel_pair = NULL; + if (!mIsConsecutiveSelection) + { + // Leave only one item selected if list has not consecutive selection + if (mSelectedItemPairs.size() && !reset_selection) + { + item_pair_t* cur_sel_pair = mSelectedItemPairs.back(); + resetSelection(); + selectItemPair (cur_sel_pair, true); + } + } + if ( mSelectedItemPairs.size() ) { + item_pair_t* to_sel_pair = NULL; + item_pair_t* cur_sel_pair = NULL; + // Take the last selected pair cur_sel_pair = mSelectedItemPairs.back(); // Bases on given direction choose next item to select @@ -758,43 +887,52 @@ bool LLFlatListView::selectNextItemPair(bool is_up_direction, bool reset_selecti } } } + + if ( to_sel_pair ) + { + bool select = true; + if ( reset_selection ) + { + // Reset current selection if we were asked about it + resetSelection(); + } + else + { + // If item already selected and no reset request than we should deselect last selected item. + select = (mSelectedItemPairs.end() == std::find(mSelectedItemPairs.begin(), mSelectedItemPairs.end(), to_sel_pair)); + } + // Select/Deselect next item + selectItemPair(select ? to_sel_pair : cur_sel_pair, select); + // Mark it as consecutive selection + mIsConsecutiveSelection = true; + return true; + } } else { // If there weren't selected items then choose the first one bases on given direction - cur_sel_pair = (is_up_direction) ? mItemPairs.back() : mItemPairs.front(); // Force selection to first item - to_sel_pair = cur_sel_pair; - } - - - if ( to_sel_pair ) - { - bool select = true; - - if ( reset_selection ) - { - // Reset current selection if we were asked about it - resetSelection(); - } + if (is_up_direction) + selectLastItem(); else - { - // If item already selected and no reset request than we should deselect last selected item. - select = (mSelectedItemPairs.end() == std::find(mSelectedItemPairs.begin(), mSelectedItemPairs.end(), to_sel_pair)); - } - - // Select/Deselect next item - selectItemPair(select ? to_sel_pair : cur_sel_pair, select); - + selectFirstItem(); + // Mark it as consecutive selection + mIsConsecutiveSelection = true; return true; } + return false; } -bool LLFlatListView::selectAll() +BOOL LLFlatListView::canSelectAll() const { - if (!mAllowSelection) - return false; + return 0 != size() && mAllowSelection && mMultipleSelection; +} + +void LLFlatListView::selectAll() +{ + if (!mAllowSelection || !mMultipleSelection) + return; mSelectedItemPairs.clear(); @@ -814,8 +952,6 @@ bool LLFlatListView::selectAll() // Stretch selected item rect to ensure it won't be clipped mSelectedItemsBorder->setRect(getLastSelectedItemRect().stretch(-1)); - - return true; } bool LLFlatListView::isSelected(item_pair_t* item_pair) const @@ -953,11 +1089,17 @@ void LLFlatListView::getValues(std::vector<LLSD>& values) const void LLFlatListView::onFocusReceived() { mSelectedItemsBorder->setVisible(TRUE); + gEditMenuHandler = this; } // virtual void LLFlatListView::onFocusLost() { mSelectedItemsBorder->setVisible(FALSE); + // Route menu back to the default + if( gEditMenuHandler == this ) + { + gEditMenuHandler = NULL; + } } //virtual @@ -1061,4 +1203,90 @@ void LLFlatListView::detachItems(std::vector<LLPanel*>& detached_items) } } + +/************************************************************************/ +/* LLFlatListViewEx implementation */ +/************************************************************************/ +LLFlatListViewEx::Params::Params() +: no_items_msg("no_items_msg") +, no_filtered_items_msg("no_filtered_items_msg") +{ + +} + +LLFlatListViewEx::LLFlatListViewEx(const Params& p) +: LLFlatListView(p) +, mNoFilteredItemsMsg(p.no_filtered_items_msg) +, mNoItemsMsg(p.no_items_msg) +{ + +} + +void LLFlatListViewEx::updateNoItemsMessage(const std::string& filter_string) +{ + bool items_filtered = !filter_string.empty(); + if (items_filtered) + { + // items were filtered + LLStringUtil::format_map_t args; + args["[SEARCH_TERM]"] = LLURI::escape(filter_string); + std::string text = mNoFilteredItemsMsg; + LLStringUtil::format(text, args); + setNoItemsCommentText(text); + } + else + { + // list does not contain any items at all + setNoItemsCommentText(mNoItemsMsg); + } + +} + +void LLFlatListViewEx::setFilterSubString(const std::string& filter_str) +{ + if (0 != LLStringUtil::compareInsensitive(filter_str, mFilterSubString)) + { + mFilterSubString = filter_str; + updateNoItemsMessage(mFilterSubString); + filterItems(); + } +} + +void LLFlatListViewEx::filterItems() +{ + typedef std::vector <LLPanel*> item_panel_list_t; + + std::string cur_filter = mFilterSubString; + LLStringUtil::toUpper(cur_filter); + + LLSD action; + action.with("match_filter", cur_filter); + + item_panel_list_t items; + getItems(items); + + for (item_panel_list_t::iterator + iter = items.begin(), + iter_end = items.end(); + iter != iter_end; ++iter) + { + LLPanel* pItem = (*iter); + // 0 signifies that filter is matched, + // i.e. we don't hide items that don't support 'match_filter' action, separators etc. + if (0 == pItem->notify(action)) + { + pItem->setVisible(true); + } + else + { + // TODO: implement (re)storing of current selection. + selectItem(pItem, false); + pItem->setVisible(false); + } + } + + sort(); + notifyParentItemsRectChanged(); +} + //EOF diff --git a/indra/llui/llflatlistview.h b/indra/llui/llflatlistview.h index 92cb40332e..f4e0426f15 100644 --- a/indra/llui/llflatlistview.h +++ b/indra/llui/llflatlistview.h @@ -1,10 +1,10 @@ /** * @file llflatlistview.h - * @brief LLFlatListView base class + * @brief LLFlatListView base class and extension to support messages for several cases of an empty list. * * $LicenseInfo:firstyear=2009&license=viewergpl$ * - * Copyright (c) 2009, Linden Research, Inc. + * Copyright (c) 2009-2010, Linden Research, Inc. * * Second Life Viewer Source Code * The source code in this file ("Source Code") is provided by Linden Lab @@ -58,7 +58,7 @@ * - Order of returned selected items are not guaranteed * - The control assumes that all items being added are unique. */ -class LLFlatListView : public LLScrollContainer +class LLFlatListView : public LLScrollContainer, public LLEditMenuHandler { public: @@ -114,8 +114,6 @@ public: Params(); }; - virtual ~LLFlatListView() { clear(); }; - /** * Connects callback to signal called when Return key is pressed. */ @@ -224,7 +222,7 @@ public: * Get LLUUIDs associated with selected items * @param selected_uuids An std::vector being populated with LLUUIDs associated with selected items */ - virtual void getSelectedUUIDs(std::vector<LLUUID>& selected_uuids) const; + virtual void getSelectedUUIDs(uuid_vec_t& selected_uuids) const; /** Get the top selected item */ virtual LLPanel* getSelectedItem() const; @@ -266,9 +264,8 @@ public: /** Get number of selected items in the list */ U32 numSelected() const {return mSelectedItemPairs.size(); } - /** Get number of items in the list */ - U32 size() const { return mItemPairs.size(); } - + /** Get number of (visible) items in the list */ + U32 size(const bool only_visible_items = true) const; /** Removes all items from the list */ virtual void clear(); @@ -344,7 +341,8 @@ protected: virtual bool selectNextItemPair(bool is_up_direction, bool reset_selection); - virtual bool selectAll(); + virtual BOOL canSelectAll() const; + virtual void selectAll(); virtual bool isSelected(item_pair_t* item_pair) const; @@ -379,11 +377,14 @@ private: void setNoItemsCommentVisible(bool visible) const; -private: +protected: /** Comparator to use when sorting the list. */ const ItemComparator* mItemComparator; + +private: + LLPanel* mItemsPanel; S32 mItemsNoScrollWidth; @@ -409,6 +410,8 @@ private: bool mKeepOneItemSelected; + bool mIsConsecutiveSelection; + /** All pairs of the list */ pairs_list_t mItemPairs; @@ -428,4 +431,66 @@ private: commit_signal_t mOnReturnSignal; }; +/** + * Extends LLFlatListView functionality to show different messages when there are no items in the + * list depend on whether they are filtered or not. + * + * Class provides one message per case of empty list. + * It also provides protected updateNoItemsMessage() method to be called each time when derived list + * is changed to update base mNoItemsCommentTextbox value. + * + * It is implemented to avoid duplication of this functionality in concrete implementations of the + * lists. It is intended to be used as a base class for lists which should support two different + * messages for empty state. Can be improved to support more than two messages via state-to-message map. + */ +class LLFlatListViewEx : public LLFlatListView +{ +public: + struct Params : public LLInitParam::Block<Params, LLFlatListView::Params> + { + /** + * Contains a message for empty list when it does not contain any items at all. + */ + Optional<std::string> no_items_msg; + + /** + * Contains a message for empty list when its items are removed by filtering. + */ + Optional<std::string> no_filtered_items_msg; + Params(); + }; + + // *WORKAROUND: two methods to overload appropriate Params due to localization issue: + // no_items_msg & no_filtered_items_msg attributes are not defined as translatable in VLT. See EXT-5931 + void setNoItemsMsg(const std::string& msg) { mNoItemsMsg = msg; } + void setNoFilteredItemsMsg(const std::string& msg) { mNoFilteredItemsMsg = msg; } + + /** + * Sets up new filter string and filters the list. + */ + void setFilterSubString(const std::string& filter_str); + + /** + * Filters the list, rearranges and notifies parent about shape changes. + * Derived classes may want to overload rearrangeItems() to exclude repeated separators after filtration. + */ + void filterItems(); + +protected: + LLFlatListViewEx(const Params& p); + + /** + * Applies a message for empty list depend on passed argument. + * + * @param filter_string - if is not empty, message for filtered items will be set, otherwise for + * completely empty list. Value of filter string will be passed as search_term in SLURL. + */ + void updateNoItemsMessage(const std::string& filter_string); + +private: + std::string mNoFilteredItemsMsg; + std::string mNoItemsMsg; + std::string mFilterSubString; +}; + #endif diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 33895ac22a..6babaf936b 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -169,6 +169,7 @@ LLFloater::Params::Params() save_rect("save_rect", false), save_visibility("save_visibility", false), can_dock("can_dock", false), + open_centered("open_centered", false), header_height("header_height", 0), legacy_header_height("legacy_header_height", 0), close_image("close_image"), @@ -346,7 +347,7 @@ void LLFloater::layoutDragHandle() rect = getLocalRect(); } mDragHandle->setRect(rect); - updateButtons(); + updateTitleButtons(); applyTitle(); } @@ -563,6 +564,7 @@ void LLFloater::handleVisibilityChange ( BOOL new_visibility ) void LLFloater::openFloater(const LLSD& key) { + llinfos << "Opening floater " << getName() << llendl; mKey = key; // in case we need to open ourselves again if (getSoundFlags() != SILENT @@ -603,6 +605,7 @@ void LLFloater::openFloater(const LLSD& key) void LLFloater::closeFloater(bool app_quitting) { + llinfos << "Closing floater " << getName() << llendl; if (app_quitting) { LLFloater::sQuitting = true; @@ -761,6 +764,13 @@ void LLFloater::applySavedVariables() void LLFloater::applyRectControl() { + // first, center on screen if requested + if (mOpenCentered) + { + center(); + } + + // override center if we have saved rect control if (mRectControl.size() > 1) { const LLRect& rect = LLUI::sSettingGroups["floater"]->getRect(mRectControl); @@ -1061,11 +1071,10 @@ void LLFloater::setMinimized(BOOL minimize) // Reshape *after* setting mMinimized reshape( mExpandedRect.getWidth(), mExpandedRect.getHeight(), TRUE ); } - - applyTitle (); make_ui_sound("UISndWindowClose"); - updateButtons(); + updateTitleButtons(); + applyTitle (); } void LLFloater::setFocus( BOOL b ) @@ -1121,6 +1130,7 @@ void LLFloater::setIsChrome(BOOL is_chrome) setFocus(FALSE); // can't Ctrl-Tab to "chrome" floaters setFocusRoot(FALSE); + mButtons[BUTTON_CLOSE]->setToolTip(LLStringExplicit(getButtonTooltip(Params(), BUTTON_CLOSE, is_chrome))); } // no titles displayed on "chrome" floaters @@ -1190,7 +1200,7 @@ void LLFloater::setHost(LLMultiFloater* host) mButtonScale = 1.f; //mButtonsEnabled[BUTTON_TEAR_OFF] = FALSE; } - updateButtons(); + updateTitleButtons(); if (host) { mHostHandle = host->getHandle(); @@ -1354,7 +1364,6 @@ void LLFloater::bringToFront( S32 x, S32 y ) // virtual void LLFloater::setVisibleAndFrontmost(BOOL take_focus) { - LLUI::clearPopups(); setVisible(TRUE); setFrontmost(take_focus); } @@ -1390,7 +1399,7 @@ void LLFloater::setCanDock(bool b) mButtonsEnabled[BUTTON_DOCK] = FALSE; } } - updateButtons(); + updateTitleButtons(); } void LLFloater::setDocked(bool docked, bool pop_on_undock) @@ -1399,7 +1408,7 @@ void LLFloater::setDocked(bool docked, bool pop_on_undock) { mDocked = docked; mButtonsEnabled[BUTTON_DOCK] = !mDocked; - updateButtons(); + updateTitleButtons(); storeDockStateControl(); } @@ -1452,7 +1461,7 @@ void LLFloater::onClickTearOff(LLFloater* self) } self->setTornOff(false); } - self->updateButtons(); + self->updateTitleButtons(); } // static @@ -1692,7 +1701,7 @@ void LLFloater::setCanMinimize(BOOL can_minimize) mButtonsEnabled[BUTTON_MINIMIZE] = can_minimize && !isMinimized(); mButtonsEnabled[BUTTON_RESTORE] = can_minimize && isMinimized(); - updateButtons(); + updateTitleButtons(); } void LLFloater::setCanClose(BOOL can_close) @@ -1700,7 +1709,7 @@ void LLFloater::setCanClose(BOOL can_close) mCanClose = can_close; mButtonsEnabled[BUTTON_CLOSE] = can_close; - updateButtons(); + updateTitleButtons(); } void LLFloater::setCanTearOff(BOOL can_tear_off) @@ -1708,7 +1717,7 @@ void LLFloater::setCanTearOff(BOOL can_tear_off) mCanTearOff = can_tear_off; mButtonsEnabled[BUTTON_TEAR_OFF] = mCanTearOff && !mHostHandle.isDead(); - updateButtons(); + updateTitleButtons(); } @@ -1732,10 +1741,11 @@ void LLFloater::setCanDrag(BOOL can_drag) } } -void LLFloater::updateButtons() +void LLFloater::updateTitleButtons() { static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0); static LLUICachedControl<S32> close_box_from_top ("UICloseBoxFromTop", 0); + LLRect buttons_rect; S32 button_count = 0; for (S32 i = 0; i < BUTTON_COUNT; i++) { @@ -1786,6 +1796,18 @@ void LLFloater::updateButtons() llround((F32)floater_close_box_size * mButtonScale)); } + // first time here, init 'buttons_rect' + if(1 == button_count) + { + buttons_rect = btn_rect; + } + else + { + // if mDragOnLeft=true then buttons are on top-left side vertically aligned + // title is not displayed in this case, calculating 'buttons_rect' for future use + mDragOnLeft ? buttons_rect.mBottom -= btn_rect.mBottom : + buttons_rect.mLeft = btn_rect.mLeft; + } mButtons[i]->setRect(btn_rect); mButtons[i]->setVisible(TRUE); // the restore button should have a tab stop so that it takes action when you Ctrl-Tab to a minimized floater @@ -1797,7 +1819,10 @@ void LLFloater::updateButtons() } } if (mDragHandle) - mDragHandle->setMaxTitleWidth(getRect().getWidth() - (button_count * (floater_close_box_size + 1))); + { + localRectToOtherView(buttons_rect, &buttons_rect, mDragHandle); + mDragHandle->setButtonsRect(buttons_rect); + } } void LLFloater::buildButtons(const Params& floater_params) @@ -1845,7 +1870,7 @@ void LLFloater::buildButtons(const Params& floater_params) p.click_callback.function(boost::bind(sButtonCallbacks[i], this)); p.tab_stop(false); p.follows.flags(FOLLOWS_TOP|FOLLOWS_RIGHT); - p.tool_tip = getButtonTooltip(floater_params, (EFloaterButton)i); + p.tool_tip = getButtonTooltip(floater_params, (EFloaterButton)i, getIsChrome()); p.scale_image(true); p.chrome(true); @@ -1854,7 +1879,7 @@ void LLFloater::buildButtons(const Params& floater_params) mButtons[i] = buttonp; } - updateButtons(); + updateTitleButtons(); } // static @@ -1900,8 +1925,15 @@ LLUIImage* LLFloater::getButtonPressedImage(const Params& p, EFloaterButton e) } // static -std::string LLFloater::getButtonTooltip(const Params& p, EFloaterButton e) +std::string LLFloater::getButtonTooltip(const Params& p, EFloaterButton e, bool is_chrome) { + // EXT-4081 (Lag Meter: Ctrl+W does not close floater) + // If floater is chrome set 'Close' text for close button's tooltip + if(is_chrome && BUTTON_CLOSE == e) + { + static std::string close_tooltip_chrome = LLTrans::getString("BUTTON_CLOSE_CHROME"); + return close_tooltip_chrome; + } // TODO: per-floater localizable tooltips set in XML return sButtonToolTips[e]; } @@ -2687,6 +2719,7 @@ void LLFloater::initFromParams(const LLFloater::Params& p) mLegacyHeaderHeight = p.legacy_header_height; mSingleInstance = p.single_instance; mAutoTile = p.auto_tile; + mOpenCentered = p.open_centered; if (p.save_rect) { diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 97d2bda594..654164ddc0 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -110,7 +110,8 @@ public: save_rect, save_visibility, save_dock_state, - can_dock; + can_dock, + open_centered; Optional<S32> header_height, legacy_header_height; // HACK see initFromXML() @@ -311,19 +312,26 @@ protected: virtual void onClickCloseBtn(); + virtual void updateTitleButtons(); + private: void setForeground(BOOL b); // called only by floaterview void cleanupHandles(); // remove handles to dead floaters void createMinimizeButton(); - void updateButtons(); void buildButtons(const Params& p); // Images and tooltips are named in the XML, but we want to look them // up by index. static LLUIImage* getButtonImage(const Params& p, EFloaterButton e); static LLUIImage* getButtonPressedImage(const Params& p, EFloaterButton e); - static std::string getButtonTooltip(const Params& p, EFloaterButton e); + /** + * @params is_chrome - if floater is Chrome it means that floater will never get focus. + * Therefore it can't be closed with 'Ctrl+W'. So the tooltip text of close button( X ) + * should be 'Close' not 'Close(Ctrl+W)' as for usual floaters. + */ + static std::string getButtonTooltip(const Params& p, EFloaterButton e, bool is_chrome); + BOOL offerClickToButton(S32 x, S32 y, MASK mask, EFloaterButton index); void addResizeCtrls(); void layoutResizeCtrls(); @@ -366,6 +374,7 @@ private: BOOL mCanClose; BOOL mDragOnLeft; BOOL mResizable; + bool mOpenCentered; S32 mMinWidth; S32 mMinHeight; @@ -425,11 +434,15 @@ private: class LLFloaterView : public LLUICtrl { +public: + struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>{}; + protected: LLFloaterView (const Params& p); friend class LLUICtrlFactory; public: + /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); void reshapeFloater(S32 width, S32 height, BOOL called_from_parent, BOOL adjust_vertical); diff --git a/indra/llui/lliconctrl.h b/indra/llui/lliconctrl.h index 66368f979b..7e37600409 100644 --- a/indra/llui/lliconctrl.h +++ b/indra/llui/lliconctrl.h @@ -73,6 +73,7 @@ public: std::string getImageName() const; void setColor(const LLColor4& color) { mColor = color; } + void setImage(LLPointer<LLUIImage> image) { mImagep = image; } private: void setIconImageDrawSize() ; diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 483a394bbd..45f9de8e8d 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -91,7 +91,6 @@ LLLineEditor::Params::Params() background_image_disabled("background_image_disabled"), background_image_focused("background_image_focused"), select_on_focus("select_on_focus", false), - handle_edit_keys_directly("handle_edit_keys_directly", false), revert_on_esc("revert_on_esc", true), commit_on_focus_lost("commit_on_focus_lost", true), ignore_tab("ignore_tab", true), @@ -136,7 +135,6 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p) mIgnoreArrowKeys( FALSE ), mIgnoreTab( p.ignore_tab ), mDrawAsterixes( FALSE ), - mHandleEditKeysDirectly(p.handle_edit_keys_directly), mSelectAllonFocusReceived( p.select_on_focus ), mPassDelete(FALSE), mReadOnly(FALSE), @@ -192,12 +190,8 @@ LLLineEditor::~LLLineEditor() { mCommitOnFocusLost = FALSE; + // calls onCommit() while LLLineEditor still valid gFocusMgr.releaseFocusIfNeeded( this ); - - if( gEditMenuHandler == this ) - { - gEditMenuHandler = NULL; - } } @@ -497,6 +491,7 @@ void LLLineEditor::selectAll() setCursor(mSelectionEnd); //mScrollHPos = 0; mIsSelecting = TRUE; + updatePrimary(); } @@ -788,7 +783,7 @@ void LLLineEditor::removeChar() } else { - reportBadKeystroke(); + LLUI::reportBadKeystroke(); } } @@ -827,7 +822,7 @@ void LLLineEditor::addChar(const llwchar uni_char) } else { - reportBadKeystroke(); + LLUI::reportBadKeystroke(); } getWindow()->hideCursorUntilMouseMove(); @@ -916,7 +911,7 @@ BOOL LLLineEditor::handleSelectionKey(KEY key, MASK mask) } else { - reportBadKeystroke(); + LLUI::reportBadKeystroke(); } break; @@ -932,7 +927,7 @@ BOOL LLLineEditor::handleSelectionKey(KEY key, MASK mask) } else { - reportBadKeystroke(); + LLUI::reportBadKeystroke(); } break; @@ -958,22 +953,6 @@ BOOL LLLineEditor::handleSelectionKey(KEY key, MASK mask) } } - if (!handled && mHandleEditKeysDirectly) - { - if( (MASK_CONTROL & mask) && ('A' == key) ) - { - if( canSelectAll() ) - { - selectAll(); - } - else - { - reportBadKeystroke(); - } - handled = TRUE; - } - } - if(handled) { // take selection to 'primary' clipboard @@ -1020,7 +999,7 @@ void LLLineEditor::cut() if( need_to_rollback ) { rollback.doRollback( this ); - reportBadKeystroke(); + LLUI::reportBadKeystroke(); } else if( mKeystrokeCallback ) @@ -1129,7 +1108,7 @@ void LLLineEditor::pasteHelper(bool is_primary) } // Truncate the clean string at the limit of what will fit clean_string = clean_string.substr(0, wchars_that_fit); - reportBadKeystroke(); + LLUI::reportBadKeystroke(); } mText.insert(getCursor(), clean_string); @@ -1141,7 +1120,7 @@ void LLLineEditor::pasteHelper(bool is_primary) if( need_to_rollback ) { rollback.doRollback( this ); - reportBadKeystroke(); + LLUI::reportBadKeystroke(); } else if( mKeystrokeCallback ) @@ -1206,7 +1185,7 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask) } else { - reportBadKeystroke(); + LLUI::reportBadKeystroke(); } } handled = TRUE; @@ -1255,7 +1234,7 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask) } else { - reportBadKeystroke(); + LLUI::reportBadKeystroke(); } handled = TRUE; } @@ -1282,7 +1261,7 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask) } else { - reportBadKeystroke(); + LLUI::reportBadKeystroke(); } handled = TRUE; } @@ -1299,7 +1278,7 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask) } else { - reportBadKeystroke(); + LLUI::reportBadKeystroke(); } handled = TRUE; } @@ -1316,7 +1295,7 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask) } else { - reportBadKeystroke(); + LLUI::reportBadKeystroke(); } handled = TRUE; } @@ -1339,64 +1318,6 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask) break; } - if( !handled && mHandleEditKeysDirectly ) - { - // Standard edit keys (Ctrl-X, Delete, etc,) are handled here instead of routed by the menu system. - if( KEY_DELETE == key ) - { - if( canDoDelete() ) - { - doDelete(); - } - else - { - reportBadKeystroke(); - } - handled = TRUE; - } - else - if( MASK_CONTROL & mask ) - { - if( 'C' == key ) - { - if( canCopy() ) - { - copy(); - } - else - { - reportBadKeystroke(); - } - handled = TRUE; - } - else - if( 'V' == key ) - { - if( canPaste() ) - { - paste(); - } - else - { - reportBadKeystroke(); - } - handled = TRUE; - } - else - if( 'X' == key ) - { - if( canCut() ) - { - cut(); - } - else - { - reportBadKeystroke(); - } - handled = TRUE; - } - } - } return handled; } @@ -1451,7 +1372,7 @@ BOOL LLLineEditor::handleKeyHere(KEY key, MASK mask ) { rollback.doRollback(this); - reportBadKeystroke(); + LLUI::reportBadKeystroke(); } // Notify owner if requested @@ -1499,7 +1420,7 @@ BOOL LLLineEditor::handleUnicodeCharHere(llwchar uni_char) { rollback.doRollback( this ); - reportBadKeystroke(); + LLUI::reportBadKeystroke(); } // Notify owner if requested @@ -1519,7 +1440,7 @@ BOOL LLLineEditor::handleUnicodeCharHere(llwchar uni_char) BOOL LLLineEditor::canDoDelete() const { - return ( !mReadOnly && (!mPassDelete || (hasSelection() || (getCursor() < mText.length()))) ); + return ( !mReadOnly && mText.length() > 0 && (!mPassDelete || (hasSelection() || (getCursor() < mText.length()))) ); } void LLLineEditor::doDelete() @@ -1544,7 +1465,7 @@ void LLLineEditor::doDelete() if( need_to_rollback ) { rollback.doRollback( this ); - reportBadKeystroke(); + LLUI::reportBadKeystroke(); } else { @@ -1879,11 +1800,6 @@ S32 LLLineEditor::findPixelNearestPos(const S32 cursor_offset) const return result; } -void LLLineEditor::reportBadKeystroke() -{ - make_ui_sound("UISndBadKeystroke"); -} - //virtual void LLLineEditor::clear() { diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index b62138426b..9489e723e3 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -81,7 +81,6 @@ public: background_image_focused; Optional<bool> select_on_focus, - handle_edit_keys_directly, revert_on_esc, commit_on_focus_lost, ignore_tab; @@ -215,7 +214,6 @@ public: void extendSelection(S32 new_cursor_pos); void deleteSelection(); - void setHandleEditKeysDirectly( BOOL b ) { mHandleEditKeysDirectly = b; } void setSelectAllonFocusReceived(BOOL b); typedef boost::function<void (LLLineEditor* caller, void* user_data)> callback_t; @@ -247,7 +245,6 @@ private: void addChar(const llwchar c); void setCursorAtLocalPos(S32 local_mouse_x); S32 findPixelNearestPos(S32 cursor_offset = 0) const; - void reportBadKeystroke(); BOOL handleSpecialKey(KEY key, MASK mask); BOOL handleSelectionKey(KEY key, MASK mask); BOOL handleControlKey(KEY key, MASK mask); @@ -325,7 +322,6 @@ protected: BOOL mIgnoreTab; BOOL mDrawAsterixes; - BOOL mHandleEditKeysDirectly; // If true, the standard edit keys (Ctrl-X, Delete, etc,) are handled here instead of routed by the menu system BOOL mSelectAllonFocusReceived; BOOL mPassDelete; diff --git a/indra/llui/llloadingindicator.cpp b/indra/llui/llloadingindicator.cpp new file mode 100644 index 0000000000..f8b029e19c --- /dev/null +++ b/indra/llui/llloadingindicator.cpp @@ -0,0 +1,133 @@ +/** + * @file llloadingindicator.cpp + * @brief Perpetual loading indicator + * + * $LicenseInfo:firstyear=2010&license=viewergpl$ + * + * Copyright (c) 2010, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "llloadingindicator.h" + +// Linden library includes +#include "llsingleton.h" + +// Project includes +#include "lluictrlfactory.h" +#include "lluiimage.h" + +static LLDefaultChildRegistry::Register<LLLoadingIndicator> r("loading_indicator"); + +/////////////////////////////////////////////////////////////////////////////// +// LLLoadingIndicator::Data class +/////////////////////////////////////////////////////////////////////////////// + +/** + * Pre-loaded images shared by all instances of the widget + */ +class LLLoadingIndicator::Data: public LLSingleton<LLLoadingIndicator::Data> +{ +public: + /*virtual*/ void initSingleton(); // from LLSingleton + + LLPointer<LLUIImage> getNextImage(S8& idx) const; + U8 getImagesCount() const { return NIMAGES; } +private: + + static const U8 NIMAGES = 12; + LLPointer<LLUIImage> mImages[NIMAGES]; +}; + +// virtual +// Called right after the instance gets constructed. +void LLLoadingIndicator::Data::initSingleton() +{ + // Load images. + for (U8 i = 0; i < NIMAGES; ++i) + { + std::string img_name = llformat("Progress_%d", i+1); + mImages[i] = LLUI::getUIImage(img_name, 0); + llassert(mImages[i]); + } +} + +LLPointer<LLUIImage> LLLoadingIndicator::Data::getNextImage(S8& idx) const +{ + // Calculate next index, performing array bounds checking. + idx = (idx >= NIMAGES || idx < 0) ? 0 : (idx + 1) % NIMAGES; + return mImages[idx]; +} + +/////////////////////////////////////////////////////////////////////////////// +// LLLoadingIndicator class +/////////////////////////////////////////////////////////////////////////////// + +LLLoadingIndicator::LLLoadingIndicator(const Params& p) +: LLUICtrl(p) + , mRotationsPerSec(p.rotations_per_sec > 0 ? p.rotations_per_sec : 1.0f) + , mCurImageIdx(-1) +{ + // Select initial image. + mCurImagep = Data::instance().getNextImage(mCurImageIdx); + + // Start timer for switching images. + start(); +} + +void LLLoadingIndicator::draw() +{ + // Time to switch to the next image? + if (mImageSwitchTimer.getStarted() && mImageSwitchTimer.hasExpired()) + { + // Switch to the next image. + mCurImagep = Data::instance().getNextImage(mCurImageIdx); + + // Restart timer. + start(); + } + + // Draw current image. + if( mCurImagep.notNull() ) + { + mCurImagep->draw(getLocalRect(), LLColor4::white % getDrawContext().mAlpha); + } + + LLUICtrl::draw(); +} + +void LLLoadingIndicator::stop() +{ + mImageSwitchTimer.stop(); +} + +void LLLoadingIndicator::start() +{ + mImageSwitchTimer.start(); + F32 period = 1.0f / (Data::instance().getImagesCount() * mRotationsPerSec); + mImageSwitchTimer.setTimerExpirySec(period); +} diff --git a/indra/llui/llloadingindicator.h b/indra/llui/llloadingindicator.h new file mode 100644 index 0000000000..32dd1fead8 --- /dev/null +++ b/indra/llui/llloadingindicator.h @@ -0,0 +1,93 @@ +/** + * @file llloadingindicator.h + * @brief Perpetual loading indicator + * + * $LicenseInfo:firstyear=2010&license=viewergpl$ + * + * Copyright (c) 2010, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#ifndef LL_LLLOADINGINDICATOR_H +#define LL_LLLOADINGINDICATOR_H + +#include "lluictrl.h" + +/////////////////////////////////////////////////////////////////////////////// +// class LLLoadingIndicator +/////////////////////////////////////////////////////////////////////////////// + +/** + * Perpetual loading indicator (a la MacOSX or YouTube) + * + * Number of rotations per second can be overriden + * with the "roations_per_sec" parameter. + * + * Can start/stop spinning. + * + * @see start() + * @see stop() + */ +class LLLoadingIndicator +: public LLUICtrl +{ + LOG_CLASS(LLLoadingIndicator); +public: + struct Params : public LLInitParam::Block<Params, LLUICtrl::Params> + { + Optional<F32> rotations_per_sec; + Params() + : rotations_per_sec("rotations_per_sec", 1.0f) + {} + }; + + virtual ~LLLoadingIndicator() {} + + // llview overrides + virtual void draw(); + + /** + * Stop spinning. + */ + void stop(); + + /** + * Start spinning. + */ + void start(); + +private: + LLLoadingIndicator(const Params&); + friend class LLUICtrlFactory; + + class Data; + + F32 mRotationsPerSec; + S8 mCurImageIdx; + LLPointer<LLUIImage> mCurImagep; + LLFrameTimer mImageSwitchTimer; +}; + +#endif // LL_LLLOADINGINDICATOR_H diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 0d56c5ed31..b77126996e 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -3345,7 +3345,7 @@ void LLMenuHolderGL::draw() LLView::draw(); // now draw last selected item as overlay LLMenuItemGL* selecteditem = (LLMenuItemGL*)sItemLastSelectedHandle.get(); - if (selecteditem && sItemActivationTimer.getStarted() && sItemActivationTimer.getElapsedTimeF32() < ACTIVATE_HIGHLIGHT_TIME) + if (selecteditem && selecteditem->getVisible() && sItemActivationTimer.getStarted() && sItemActivationTimer.getElapsedTimeF32() < ACTIVATE_HIGHLIGHT_TIME) { // make sure toggle items, for example, show the proper state when fading out selecteditem->buildDrawLabel(); @@ -3420,6 +3420,12 @@ BOOL LLMenuHolderGL::handleKey(KEY key, MASK mask, BOOL called_from_parent) if (pMenu) { + //eat TAB key - EXT-7000 + if (key == KEY_TAB && mask == MASK_NONE) + { + return TRUE; + } + //handle ESCAPE and RETURN key handled = LLPanel::handleKey(key, mask, called_from_parent); if (!handled) @@ -3455,7 +3461,7 @@ LLView* const LLMenuHolderGL::getVisibleMenu() const for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) { LLView* viewp = *child_it; - if (viewp->getVisible() && dynamic_cast<LLMenuBarGL*>(viewp) == NULL) + if (viewp->getVisible() && dynamic_cast<LLMenuGL*>(viewp) != NULL) { return viewp; } @@ -3478,8 +3484,7 @@ BOOL LLMenuHolderGL::hideMenus() for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) { LLView* viewp = *child_it; - // clicks off of menu do not hide menu bar - if (dynamic_cast<LLMenuBarGL*>(viewp) == NULL && viewp->getVisible()) + if (dynamic_cast<LLMenuGL*>(viewp) != NULL && viewp->getVisible()) { viewp->setVisible(FALSE); } @@ -3727,10 +3732,14 @@ void LLContextMenuBranch::buildDrawLabel( void ) void LLContextMenuBranch::showSubMenu() { - S32 center_x; - S32 center_y; - localPointToScreen(getRect().getWidth(), getRect().getHeight() , ¢er_x, ¢er_y); - mBranch->show( center_x, center_y); + LLMenuItemGL* menu_item = mBranch->getParentMenuItem(); + if (menu_item != NULL && menu_item->getVisible()) + { + S32 center_x; + S32 center_y; + localPointToScreen(getRect().getWidth(), getRect().getHeight() , ¢er_x, ¢er_y); + mBranch->show(center_x, center_y); + } } // onCommit() - do the primary funcationality of the menu item. diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index 39d1986461..6f0f83d4b9 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -295,7 +295,7 @@ private: // class, by allowing another method to be specified which determines // if the menu item should consider itself checked as true or not. Be // careful that the provided callback is fast - it needs to be VERY -// FUCKING EFFICIENT, because it may need to be checked a lot. +// EFFICIENT because it may need to be checked a lot. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class LLMenuItemCheckGL diff --git a/indra/llui/llmultifloater.cpp b/indra/llui/llmultifloater.cpp index 33d47a3f0e..3aea648562 100644 --- a/indra/llui/llmultifloater.cpp +++ b/indra/llui/llmultifloater.cpp @@ -345,13 +345,20 @@ void LLMultiFloater::setVisible(BOOL visible) BOOL LLMultiFloater::handleKeyHere(KEY key, MASK mask) { - if (key == 'W' && mask == MASK_CONTROL) + if (key == 'W' && mask == (MASK_CONTROL|MASK_SHIFT)) { LLFloater* floater = getActiveFloater(); // is user closeable and is system closeable if (floater && floater->canClose() && floater->isCloseable()) { floater->closeFloater(); + + // EXT-5695 (Tabbed IM window loses focus if close any tabs by Ctrl+W) + // bring back focus on tab container if there are any tab left + if(mTabContainer->getTabCount() > 0) + { + mTabContainer->setFocus(TRUE); + } } return TRUE; } diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index 5816cef6af..7b8f51ae3c 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -48,122 +48,38 @@ const std::string NOTIFICATION_PERSIST_VERSION = "0.93"; -// local channel for notification history -class LLNotificationHistoryChannel : public LLNotificationChannel +// Local channel for persistent notifications +// Stores only persistent notifications. +// Class users can use connectChanged() to process persistent notifications +// (see LLNotificationStorage for example). +class LLPersistentNotificationChannel : public LLNotificationChannel { - LOG_CLASS(LLNotificationHistoryChannel); + LOG_CLASS(LLPersistentNotificationChannel); public: - LLNotificationHistoryChannel(const std::string& filename) : - LLNotificationChannel("History", "Visible", &historyFilter, LLNotificationComparators::orderByUUID()), - mFileName(filename) + LLPersistentNotificationChannel() : + LLNotificationChannel("Persistent", "Visible", ¬ificationFilter, LLNotificationComparators::orderByUUID()) { - connectChanged(boost::bind(&LLNotificationHistoryChannel::historyHandler, this, _1)); - loadPersistentNotifications(); } private: - bool historyHandler(const LLSD& payload) - { - // we ignore "load" messages, but rewrite the persistence file on any other - std::string sigtype = payload["sigtype"]; - if (sigtype != "load") - { - savePersistentNotifications(); - } - return false; - } - // The history channel gets all notifications except those that have been cancelled - static bool historyFilter(LLNotificationPtr pNotification) + // The channel gets all persistent notifications except those that have been canceled + static bool notificationFilter(LLNotificationPtr pNotification) { - return !pNotification->isCancelled(); - } - - void savePersistentNotifications() - { - /* NOTE: As of 2009-11-09 the reload of notifications on startup does not - work, and has not worked for months. Skip saving notifications until the - read can be fixed, because this hits the disk once per notification and - causes log spam. James - - llinfos << "Saving open notifications to " << mFileName << llendl; + bool handle_notification = false; - llofstream notify_file(mFileName.c_str()); - if (!notify_file.is_open()) - { - llwarns << "Failed to open " << mFileName << llendl; - return; - } - - LLSD output; - output["version"] = NOTIFICATION_PERSIST_VERSION; - LLSD& data = output["data"]; - - for (LLNotificationSet::iterator it = mItems.begin(); it != mItems.end(); ++it) - { - if (!LLNotifications::instance().templateExists((*it)->getName())) continue; + handle_notification = pNotification->isPersistent() + && !pNotification->isCancelled(); - // only store notifications flagged as persisting - LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate((*it)->getName()); - if (!templatep->mPersist) continue; - - data.append((*it)->asLLSD()); - } - - LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter(); - formatter->format(output, notify_file, LLSDFormatter::OPTIONS_PRETTY); - */ + return handle_notification; } - void loadPersistentNotifications() - { - llinfos << "Loading open notifications from " << mFileName << llendl; - - llifstream notify_file(mFileName.c_str()); - if (!notify_file.is_open()) - { - llwarns << "Failed to open " << mFileName << llendl; - return; - } - - LLSD input; - LLPointer<LLSDParser> parser = new LLSDXMLParser(); - if (parser->parse(notify_file, input, LLSDSerialize::SIZE_UNLIMITED) < 0) - { - llwarns << "Failed to parse open notifications" << llendl; - return; - } - - if (input.isUndefined()) return; - std::string version = input["version"]; - if (version != NOTIFICATION_PERSIST_VERSION) - { - llwarns << "Bad open notifications version: " << version << llendl; - return; - } - LLSD& data = input["data"]; - if (data.isUndefined()) return; - - LLNotifications& instance = LLNotifications::instance(); - for (LLSD::array_const_iterator notification_it = data.beginArray(); - notification_it != data.endArray(); - ++notification_it) - { - instance.add(LLNotificationPtr(new LLNotification(*notification_it))); - } - } - - //virtual void onDelete(LLNotificationPtr pNotification) { - // we want to keep deleted notifications in our log + // we want to keep deleted notifications in our log, otherwise some + // notifications will be lost on exit. mItems.insert(pNotification); - - return; } - -private: - std::string mFileName; }; bool filterIgnoredNotifications(LLNotificationPtr notification) @@ -402,7 +318,9 @@ LLNotification::LLNotification(const LLNotification::Params& p) : mRespondedTo(false), mPriority(p.priority), mCancelled(false), - mIgnored(false) + mIgnored(false), + mResponderObj(NULL), + mIsReusable(false) { if (p.functor.name.isChosen()) { @@ -415,6 +333,15 @@ LLNotification::LLNotification(const LLNotification::Params& p) : mTemporaryResponder = true; } + else if(p.functor.responder.isChosen()) + { + mResponder = p.functor.responder; + } + + if(p.responder.isProvided()) + { + mResponderObj = p.responder; + } mId.generate(); init(p.name, p.form_elements); @@ -425,7 +352,9 @@ LLNotification::LLNotification(const LLSD& sd) : mTemporaryResponder(false), mRespondedTo(false), mCancelled(false), - mIgnored(false) + mIgnored(false), + mResponderObj(NULL), + mIsReusable(false) { mId.generate(); mSubstitutions = sd["substitutions"]; @@ -452,6 +381,13 @@ LLSD LLNotification::asLLSD() output["expiry"] = mExpiresAt; output["priority"] = (S32)mPriority; output["responseFunctor"] = mResponseFunctorName; + output["reusable"] = mIsReusable; + + if(mResponder) + { + output["responder"] = mResponder->asLLSD(); + } + return output; } @@ -479,7 +415,9 @@ void LLNotification::updateFrom(LLNotificationPtr other) mForm = other->mForm; mResponseFunctorName = other->mResponseFunctorName; mRespondedTo = other->mRespondedTo; + mResponse = other->mResponse; mTemporaryResponder = other->mTemporaryResponder; + mIsReusable = other->isReusable(); update(); } @@ -556,14 +494,24 @@ std::string LLNotification::getSelectedOptionName(const LLSD& response) void LLNotification::respond(const LLSD& response) { + // *TODO may remove mRespondedTo and use mResponce.isDefined() in isRespondedTo() mRespondedTo = true; - // look up the functor - LLNotificationFunctorRegistry::ResponseFunctor functor = - LLNotificationFunctorRegistry::instance().getFunctor(mResponseFunctorName); - // and then call it - functor(asLLSD(), response); - - if (mTemporaryResponder) + mResponse = response; + + if(mResponder) + { + mResponder->handleRespond(asLLSD(), response); + } + else + { + // look up the functor + LLNotificationFunctorRegistry::ResponseFunctor functor = + LLNotificationFunctorRegistry::instance().getFunctor(mResponseFunctorName); + // and then call it + functor(asLLSD(), response); + } + + if (mTemporaryResponder && !isReusable()) { LLNotificationFunctorRegistry::instance().unregisterFunctor(mResponseFunctorName); mResponseFunctorName = ""; @@ -597,6 +545,21 @@ void LLNotification::setResponseFunctor(std::string const &responseFunctorName) mTemporaryResponder = false; } +void LLNotification::setResponseFunctor(const LLNotificationFunctorRegistry::ResponseFunctor& cb) +{ + if(mTemporaryResponder) + { + LLNotificationFunctorRegistry::instance().unregisterFunctor(mResponseFunctorName); + } + + LLNotificationFunctorRegistry::instance().registerFunctor(mResponseFunctorName, cb); +} + +void LLNotification::setResponseFunctor(const LLNotificationResponderPtr& responder) +{ + mResponder = responder; +} + bool LLNotification::payloadContainsAll(const std::vector<std::string>& required_fields) const { for(std::vector<std::string>::const_iterator required_fields_it = required_fields.begin(); @@ -856,8 +819,12 @@ bool LLNotificationChannelBase::updateItem(const LLSD& payload, LLNotificationPt if (wasFound) { abortProcessing = mChanged(payload); - mItems.erase(pNotification); - onDelete(pNotification); + // do not delete the notification to make LLChatHistory::appendMessage add notification panel to IM window + if( ! pNotification->isReusable() ) + { + mItems.erase(pNotification); + onDelete(pNotification); + } } } return abortProcessing; @@ -1088,12 +1055,9 @@ void LLNotifications::createDefaultChannels() LLNotificationChannel::buildChannel("Visible", "Ignore", &LLNotificationFilters::includeEverything); - // create special history channel - //std::string notifications_log_file = gDirUtilp->getExpandedFilename ( LL_PATH_PER_SL_ACCOUNT, "open_notifications.xml" ); - // use ^^^ when done debugging notifications serialization - std::string notifications_log_file = gDirUtilp->getExpandedFilename ( LL_PATH_USER_SETTINGS, "open_notifications.xml" ); + // create special persistent notification channel // this isn't a leak, don't worry about the empty "new" - new LLNotificationHistoryChannel(notifications_log_file); + new LLPersistentNotificationChannel(); // connect action methods to these channels LLNotifications::instance().getChannel("Expiration")-> @@ -1524,3 +1488,11 @@ std::ostream& operator<<(std::ostream& s, const LLNotification& notification) return s; } +void LLPostponedNotification::onCachedNameReceived(const LLUUID& id, const std::string& first, + const std::string& last, bool is_group) +{ + gCacheName->getFullName(id, mName); + modifyNotificationParams(); + LLNotifications::instance().add(mParams); + cleanup(); +} diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index 8d993b71d7..c942a32512 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -104,6 +104,7 @@ #include "llinitparam.h" #include "llnotificationslistener.h" #include "llnotificationptr.h" +#include "llcachename.h" typedef enum e_notification_priority @@ -115,8 +116,23 @@ typedef enum e_notification_priority NOTIFICATION_PRIORITY_CRITICAL } ENotificationPriority; +class LLNotificationResponderInterface +{ +public: + LLNotificationResponderInterface(){}; + virtual ~LLNotificationResponderInterface(){}; + + virtual void handleRespond(const LLSD& notification, const LLSD& response) = 0; + + virtual LLSD asLLSD() = 0; + + virtual void fromLLSD(const LLSD& params) = 0; +}; + typedef boost::function<void (const LLSD&, const LLSD&)> LLNotificationResponder; +typedef boost::shared_ptr<LLNotificationResponderInterface> LLNotificationResponderPtr; + typedef LLFunctorRegistry<LLNotificationResponder> LLNotificationFunctorRegistry; typedef LLFunctorRegistration<LLNotificationResponder> LLNotificationFunctorRegistration; @@ -296,15 +312,18 @@ public: Optional<LLSD> form_elements; Optional<LLDate> time_stamp; Optional<LLNotificationContext*> context; + Optional<void*> responder; struct Functor : public LLInitParam::Choice<Functor> { Alternative<std::string> name; Alternative<LLNotificationFunctorRegistry::ResponseFunctor> function; + Alternative<LLNotificationResponderPtr> responder; Functor() : name("functor_name"), - function("functor") + function("functor"), + responder("responder") {} }; Optional<Functor> functor; @@ -317,6 +336,7 @@ public: form_elements("form_elements") { time_stamp = LLDate::now(); + responder = NULL; } Params(const std::string& _name) @@ -329,6 +349,7 @@ public: functor.name = _name; name = _name; time_stamp = LLDate::now(); + responder = NULL; } }; @@ -341,13 +362,17 @@ private: LLDate mExpiresAt; bool mCancelled; bool mRespondedTo; // once the notification has been responded to, this becomes true + LLSD mResponse; bool mIgnored; ENotificationPriority mPriority; LLNotificationFormPtr mForm; - + void* mResponderObj; // TODO - refactor/remove this field + bool mIsReusable; + LLNotificationResponderPtr mResponder; + // a reference to the template LLNotificationTemplatePtr mTemplatep; - + /* We want to be able to store and reload notifications so that they can survive a shutdown/restart of the client. So we can't simply pass in callbacks; @@ -384,6 +409,10 @@ public: void setResponseFunctor(std::string const &responseFunctorName); + void setResponseFunctor(const LLNotificationFunctorRegistry::ResponseFunctor& cb); + + void setResponseFunctor(const LLNotificationResponderPtr& responder); + typedef enum e_response_template_type { WITHOUT_DEFAULT_BUTTON, @@ -423,6 +452,10 @@ public: void respond(const LLSD& sd); + void* getResponder() { return mResponderObj; } + + void setResponder(void* responder) { mResponderObj = responder; } + void setIgnored(bool ignore); bool isCancelled() const @@ -435,6 +468,8 @@ public: return mRespondedTo; } + const LLSD& getResponse() { return mResponse; } + bool isIgnored() const { return mIgnored; @@ -444,7 +479,12 @@ public: { return mTemplatep->mName; } - + + bool isPersistent() const + { + return mTemplatep->mPersist; + } + const LLUUID& id() const { return mId; @@ -504,6 +544,10 @@ public: { return mId; } + + bool isReusable() { return mIsReusable; } + + void setReusable(bool reusable) { mIsReusable = reusable; } // comparing two notifications normally means comparing them by UUID (so we can look them // up quickly this way) @@ -931,6 +975,62 @@ private: boost::scoped_ptr<LLNotificationsListener> mListener; }; +/** + * Abstract class for postponed notifications. + * Provides possibility to add notification after specified by id avatar or group will be + * received from cache name. The object of this type automatically well be deleted + * by cleanup method after respond will be received from cache name. + * + * To add custom postponed notification to the notification system client should: + * 1 create class derived from LLPostponedNotification; + * 2 call LLPostponedNotification::add method; + */ +class LLPostponedNotification +{ +public: + /** + * Performs hooking cache name callback which will add notification to notifications system. + * Type of added notification should be specified by template parameter T + * and non-private derived from LLPostponedNotification class, + * otherwise compilation error will occur. + */ + template<class T> + static void add(const LLNotification::Params& params, + const LLUUID& id, bool is_group) + { + // upcast T to the base type to restrict T derivation from LLPostponedNotification + LLPostponedNotification* thiz = new T(); + + thiz->mParams = params; + + gCacheName->get(id, is_group, boost::bind( + &LLPostponedNotification::onCachedNameReceived, thiz, _1, _2, + _3, _4)); + } + +private: + void onCachedNameReceived(const LLUUID& id, const std::string& first, + const std::string& last, bool is_group); + + void cleanup() + { + delete this; + } + +protected: + LLPostponedNotification() {} + virtual ~LLPostponedNotification() {} + + /** + * Abstract method provides possibility to modify notification parameters and + * will be called after cache name retrieve information about avatar or group + * and before notification will be added to the notification system. + */ + virtual void modifyNotificationParams() = 0; + + LLNotification::Params mParams; + std::string mName; +}; #endif//LL_LLNOTIFICATIONS_H diff --git a/indra/llui/llradiogroup.cpp b/indra/llui/llradiogroup.cpp index 4087b484aa..e27792dc1d 100644 --- a/indra/llui/llradiogroup.cpp +++ b/indra/llui/llradiogroup.cpp @@ -106,7 +106,6 @@ LLRadioGroup::LLRadioGroup(const LLRadioGroup::Params& p) void LLRadioGroup::initFromParams(const Params& p) { - LLUICtrl::initFromParams(p); for (LLInitParam::ParamIterator<ItemParams>::const_iterator it = p.items().begin(); it != p.items().end(); ++it) @@ -124,6 +123,9 @@ void LLRadioGroup::initFromParams(const Params& p) LLRadioCtrl* item = LLUICtrlFactory::create<LLRadioCtrl>(item_params, this); mRadioButtons.push_back(item); } + + // call this *after* setting up mRadioButtons so we can handle setValue() calls + LLUICtrl::initFromParams(p); } @@ -138,10 +140,6 @@ BOOL LLRadioGroup::postBuild() { mRadioButtons[0]->setTabStop(true); } - if (mControlVariable) - { - setSelectedIndex(mControlVariable->getValue().asInteger()); - } return TRUE; } diff --git a/indra/llui/llresizebar.cpp b/indra/llui/llresizebar.cpp index 0c46edf300..5d26b904b5 100644 --- a/indra/llui/llresizebar.cpp +++ b/indra/llui/llresizebar.cpp @@ -182,6 +182,11 @@ BOOL LLResizeBar::handleHover(S32 x, S32 y, MASK mask) break; } + notifyParent(LLSD().with("action", "resize") + .with("view_name", mResizingView->getName()) + .with("new_height", new_height) + .with("new_width", new_width)); + scaled_rect.mTop = scaled_rect.mBottom + new_height; scaled_rect.mRight = scaled_rect.mLeft + new_width; mResizingView->setRect(scaled_rect); diff --git a/indra/llui/llscrollingpanellist.cpp b/indra/llui/llscrollingpanellist.cpp index 4f55c0507c..b7840d1b59 100644 --- a/indra/llui/llscrollingpanellist.cpp +++ b/indra/llui/llscrollingpanellist.cpp @@ -47,7 +47,12 @@ void LLScrollingPanelList::clearPanels() { deleteAllChildren(); mPanelList.clear(); - reshape( 1, 1, FALSE ); + + LLRect rc = getRect(); + rc.setLeftTopAndSize(rc.mLeft, rc.mTop, 1, 1); + setRect(rc); + + notifySizeChanged(rc.getHeight()); } S32 LLScrollingPanelList::addPanel( LLScrollingPanel* panel ) @@ -67,7 +72,11 @@ S32 LLScrollingPanelList::addPanel( LLScrollingPanel* panel ) max_width = llmax( max_width, childp->getRect().getWidth() ); cur_gap = GAP_BETWEEN_PANELS; } - reshape( max_width, total_height, FALSE ); + LLRect rc = getRect(); + rc.setLeftTopAndSize(rc.mLeft, rc.mTop, max_width, total_height); + setRect(rc); + + notifySizeChanged(rc.getHeight()); // Reposition each of the child views S32 cur_y = total_height; @@ -131,7 +140,11 @@ void LLScrollingPanelList::removePanel( U32 panel_index ) max_width = llmax( max_width, childp->getRect().getWidth() ); cur_gap = GAP_BETWEEN_PANELS; } - reshape( max_width, total_height, FALSE ); + LLRect rc = getRect(); + rc.setLeftTopAndSize(rc.mLeft, rc.mTop, max_width, total_height); + setRect(rc); + + notifySizeChanged(rc.getHeight()); // Reposition each of the child views S32 cur_y = total_height; @@ -200,3 +213,12 @@ void LLScrollingPanelList::draw() LLUICtrl::draw(); } +void LLScrollingPanelList::notifySizeChanged(S32 height) +{ + LLSD info; + info["action"] = "size_changes"; + info["height"] = height; + notifyParent(info); +} + +// EOF diff --git a/indra/llui/llscrollingpanellist.h b/indra/llui/llscrollingpanellist.h index 3abfbcbbe7..5f1996159b 100644 --- a/indra/llui/llscrollingpanellist.h +++ b/indra/llui/llscrollingpanellist.h @@ -61,7 +61,6 @@ public: Params() { name = "scrolling_panel_list"; - follows.flags = FOLLOWS_LEFT | FOLLOWS_BOTTOM; } }; LLScrollingPanelList(const Params& p) @@ -86,6 +85,11 @@ public: private: void updatePanelVisiblilty(); + /** + * Notify parent about size change, makes sense when used inside accordion + */ + void notifySizeChanged(S32 height); + panel_list_t mPanelList; }; diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 18ec5b51dd..94eade06ad 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -282,6 +282,8 @@ LLScrollListCtrl::LLScrollListCtrl(const LLScrollListCtrl::Params& p) text_p.border_visible(false); text_p.rect(mItemListRect); text_p.follows.flags(FOLLOWS_ALL); + // word wrap was added accroding to the EXT-6841 + text_p.wrap(true); addChild(LLUICtrlFactory::create<LLTextBox>(text_p)); } @@ -324,11 +326,6 @@ LLScrollListCtrl::~LLScrollListCtrl() delete mSortCallback; std::for_each(mItemList.begin(), mItemList.end(), DeletePointer()); - - if( gEditMenuHandler == this ) - { - gEditMenuHandler = NULL; - } } @@ -630,9 +627,7 @@ void LLScrollListCtrl::calcColumnWidths() LLScrollListCell* cellp = (*iter)->getColumn(column->mIndex); if (!cellp) continue; - // get text value width only for text cells - column->mMaxContentWidth = cellp->isText() ? - llmax(LLFontGL::getFontSansSerifSmall()->getWidth(cellp->getValue().asString()) + mColumnPadding + COLUMN_TEXT_PADDING, column->mMaxContentWidth) : column->mMaxContentWidth; + column->mMaxContentWidth = llmax(LLFontGL::getFontSansSerifSmall()->getWidth(cellp->getValue().asString()) + mColumnPadding + COLUMN_TEXT_PADDING, column->mMaxContentWidth); } max_item_width += column->mMaxContentWidth; @@ -959,14 +954,14 @@ void LLScrollListCtrl::mouseOverHighlightNthItem(S32 target_index) } } -S32 LLScrollListCtrl::selectMultiple( std::vector<LLUUID> ids ) +S32 LLScrollListCtrl::selectMultiple( uuid_vec_t ids ) { item_list::iterator iter; S32 count = 0; for (iter = mItemList.begin(); iter != mItemList.end(); iter++) { LLScrollListItem* item = *iter; - std::vector<LLUUID>::iterator iditr; + uuid_vec_t::iterator iditr; for(iditr = ids.begin(); iditr != ids.end(); ++iditr) { if (item->getEnabled() && (item->getUUID() == (*iditr))) diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h index ebdc82115f..1f0ef585db 100644 --- a/indra/llui/llscrolllistctrl.h +++ b/indra/llui/llscrolllistctrl.h @@ -379,7 +379,7 @@ public: BOOL getSortAscending() { return mSortColumns.empty() ? TRUE : mSortColumns.back().second; } BOOL hasSortOrder() const; - S32 selectMultiple( std::vector<LLUUID> ids ); + S32 selectMultiple( uuid_vec_t ids ); // conceptually const, but mutates mItemList void updateSort() const; // sorts a list without affecting the permanent sort order (so further list insertions can be unsorted, for example) diff --git a/indra/llui/llsearcheditor.h b/indra/llui/llsearcheditor.h index 714aca9337..785d0633dc 100644 --- a/indra/llui/llsearcheditor.h +++ b/indra/llui/llsearcheditor.h @@ -66,6 +66,8 @@ public: } }; + void setCommitOnFocusLost(BOOL b) { if (mSearchEditor) mSearchEditor->setCommitOnFocusLost(b); } + protected: LLSearchEditor(const Params&); friend class LLUICtrlFactory; diff --git a/indra/llui/llsliderctrl.cpp b/indra/llui/llsliderctrl.cpp index 80ee5d0984..04958075db 100644 --- a/indra/llui/llsliderctrl.cpp +++ b/indra/llui/llsliderctrl.cpp @@ -63,7 +63,8 @@ LLSliderCtrl::LLSliderCtrl(const LLSliderCtrl::Params& p) mCanEditText(p.can_edit_text), mPrecision(p.decimal_digits), mTextEnabledColor(p.text_color()), - mTextDisabledColor(p.text_disabled_color()) + mTextDisabledColor(p.text_disabled_color()), + mLabelWidth(p.label_width) { S32 top = getRect().getHeight(); S32 bottom = 0; @@ -86,6 +87,7 @@ LLSliderCtrl::LLSliderCtrl(const LLSliderCtrl::Params& p) params.initial_value(p.label()); mLabelBox = LLUICtrlFactory::create<LLTextBox> (params); addChild(mLabelBox); + mLabelFont = params.font(); } if (p.show_text && !p.text_width.isProvided()) @@ -186,9 +188,9 @@ BOOL LLSliderCtrl::setLabelArg( const std::string& key, const LLStringExplicit& if (mLabelBox) { res = mLabelBox->setTextArg(key, text); - if (res && mLabelWidth == 0) + if (res && mLabelFont && mLabelWidth == 0) { - S32 label_width = mFont->getWidth(mLabelBox->getText()); + S32 label_width = mLabelFont->getWidth(mLabelBox->getText()); LLRect rect = mLabelBox->getRect(); S32 prev_right = rect.mRight; rect.mRight = rect.mLeft + label_width; diff --git a/indra/llui/llsliderctrl.h b/indra/llui/llsliderctrl.h index c425849782..482c81a0f4 100644 --- a/indra/llui/llsliderctrl.h +++ b/indra/llui/llsliderctrl.h @@ -141,6 +141,7 @@ private: void reportInvalidData(); const LLFontGL* mFont; + const LLFontGL* mLabelFont; BOOL mShowText; BOOL mCanEditText; @@ -158,3 +159,4 @@ private: }; #endif // LL_LLSLIDERCTRL_H + diff --git a/indra/llui/llspinctrl.cpp b/indra/llui/llspinctrl.cpp index 491cd7b6f3..b47f21ed8a 100644 --- a/indra/llui/llspinctrl.cpp +++ b/indra/llui/llspinctrl.cpp @@ -457,3 +457,8 @@ BOOL LLSpinCtrl::handleKeyHere(KEY key, MASK mask) return FALSE; } +BOOL LLSpinCtrl::handleDoubleClick(S32 x, S32 y, MASK mask) +{ + // just treat a double click as a second click + return handleMouseDown(x, y, mask); +} diff --git a/indra/llui/llspinctrl.h b/indra/llui/llspinctrl.h index 00d6f86f83..06201255d2 100644 --- a/indra/llui/llspinctrl.h +++ b/indra/llui/llspinctrl.h @@ -94,6 +94,7 @@ public: virtual BOOL handleScrollWheel(S32 x,S32 y,S32 clicks); virtual BOOL handleKeyHere(KEY key, MASK mask); + virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask); void onEditorCommit(const LLSD& data); static void onEditorGainFocus(LLFocusableElement* caller, void *userdata); diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 851fb966ec..0e542ad05c 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -246,7 +246,7 @@ LLTextBase::~LLTextBase() { // Menu, like any other LLUICtrl, is deleted by its parent - gMenuHolder - clearSegments(); + mSegments.clear(); } void LLTextBase::initFromParams(const LLTextBase::Params& p) @@ -350,6 +350,8 @@ void LLTextBase::drawSelectionBackground() S32 segment_line_start = segmentp->getStart() + segment_offset; S32 segment_line_end = llmin(segmentp->getEnd(), line_iter->mDocIndexEnd); + if (segment_line_start > segment_line_end) break; + S32 segment_width = 0; S32 segment_height = 0; @@ -361,8 +363,11 @@ void LLTextBase::drawSelectionBackground() selection_rect.mLeft += segment_width; } - // if selection spans end of current segment... - if (selection_right > segment_line_end) + // if selection_right == segment_line_end then that means we are the first character of the next segment + // or first character of the next line, in either case we want to add the length of the current segment + // to the selection rectangle and continue. + // if selection right > segment_line_end then selection spans end of current segment... + if (selection_right >= segment_line_end) { // extend selection slightly beyond end of line // to indicate selection of newline character (use "n" character to determine width) @@ -958,7 +963,7 @@ void LLTextBase::reshape(S32 width, S32 height, BOOL called_from_parent) if (width != getRect().getWidth() || height != getRect().getHeight()) { LLUICtrl::reshape( width, height, called_from_parent ); - + // do this first after reshape, because other things depend on // up-to-date mVisibleTextRect updateRects(); @@ -1043,6 +1048,13 @@ void LLTextBase::setValue(const LLSD& value ) } //virtual +BOOL LLTextBase::canDeselect() const +{ + return hasSelection(); +} + + +//virtual void LLTextBase::deselect() { mSelectionStart = 0; @@ -1093,8 +1105,19 @@ void LLTextBase::reflow() updateSegments(); + S32 reflow_count = 0; while(mReflowIndex < S32_MAX) { + // we can get into an infinite loop if the document height does not monotonically increase + // with decreasing width (embedded ui elements with alternate layouts). In that case, + // we want to stop reflowing after 2 iterations. We use 2, since we need to handle the case + // of introducing a vertical scrollbar causing a reflow with less width. We should also always + // use an even number of iterations to avoid user visible oscillation of the layout + if(++reflow_count > 2) + { + lldebugs << "Breaking out of reflow due to possible infinite loop in " << getName() << llendl; + break; + } S32 start_index = mReflowIndex; mReflowIndex = S32_MAX; @@ -1484,6 +1507,7 @@ void LLTextBase::createUrlContextMenu(S32 x, S32 y, const std::string &in_url) registrar.add("Url.OpenExternal", boost::bind(&LLUrlAction::openURLExternal, url)); registrar.add("Url.Execute", boost::bind(&LLUrlAction::executeSLURL, url)); registrar.add("Url.Teleport", boost::bind(&LLUrlAction::teleportToLocation, url)); + registrar.add("Url.ShowProfile", boost::bind(&LLUrlAction::showProfile, url)); registrar.add("Url.ShowOnMap", boost::bind(&LLUrlAction::showLocationOnMap, url)); registrar.add("Url.CopyLabel", boost::bind(&LLUrlAction::copyLabelToClipboard, url)); registrar.add("Url.CopyUrl", boost::bind(&LLUrlAction::copyURLToClipboard, url)); @@ -1813,11 +1837,18 @@ S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, BOOL round, const LLTextSegmentPtr segmentp = *line_seg_iter; S32 segment_line_start = segmentp->getStart() + line_seg_offset; - S32 segment_line_length = llmin(segmentp->getEnd(), line_iter->mDocIndexEnd - 1) - segment_line_start; + S32 segment_line_length = llmin(segmentp->getEnd(), line_iter->mDocIndexEnd) - segment_line_start; S32 text_width, text_height; - segmentp->getDimensions(line_seg_offset, segment_line_length, text_width, text_height); + bool newline = segmentp->getDimensions(line_seg_offset, segment_line_length, text_width, text_height); + + // if we've reached a line of text *below* the mouse cursor, doc index is first character on that line + if (hit_past_end_of_line && local_y - mVisibleTextRect.mBottom + visible_region.mBottom > line_iter->mRect.mTop) + { + pos = segment_line_start; + break; + } if (local_x < start_x + text_width // cursor to left of right edge of text - || (hit_past_end_of_line && (segmentp->getEnd() >= line_iter->mDocIndexEnd - 1))) // or this segment wraps to next line + || newline) // or this line ends with a newline, set doc pos to newline char { // Figure out which character we're nearest to. S32 offset; @@ -1841,6 +1872,13 @@ S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, BOOL round, pos = segment_line_start + offset; break; } + else if (hit_past_end_of_line && segmentp->getEnd() >= line_iter->mDocIndexEnd - 1) + { + // segment wraps to next line, so just set doc pos to start of next line (represented by mDocIndexEnd) + pos = llmin(getLength(), line_iter->mDocIndexEnd); + break; + } + start_x += text_width; } diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index 5b24c63557..8ed0680df9 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -132,6 +132,7 @@ public: /*virtual*/ LLTextViewModel* getViewModel() const; // LLEditMenuHandler interface + /*virtual*/ BOOL canDeselect() const; /*virtual*/ void deselect(); // used by LLTextSegment layout code diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 7d230f7d42..4fd62045e8 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -240,7 +240,6 @@ LLTextEditor::Params::Params() prevalidate_callback("prevalidate_callback"), embedded_items("embedded_items", false), ignore_tab("ignore_tab", true), - handle_edit_keys_directly("handle_edit_keys_directly", false), show_line_numbers("show_line_numbers", false), default_color("default_color"), commit_on_focus_lost("commit_on_focus_lost", false), @@ -258,7 +257,6 @@ LLTextEditor::LLTextEditor(const LLTextEditor::Params& p) : mShowLineNumbers ( p.show_line_numbers ), mCommitOnFocusLost( p.commit_on_focus_lost), mAllowEmbeddedItems( p.embedded_items ), - mHandleEditKeysDirectly( p.handle_edit_keys_directly ), mMouseDownX(0), mMouseDownY(0), mTabsToNextField(p.ignore_tab), @@ -305,12 +303,6 @@ LLTextEditor::~LLTextEditor() { gFocusMgr.releaseFocusIfNeeded( this ); // calls onCommit() while LLTextEditor still valid - // Route menu back to the default - if( gEditMenuHandler == this ) - { - gEditMenuHandler = NULL; - } - // Scrollbar is deleted by LLView std::for_each(mUndoStack.begin(), mUndoStack.end(), DeletePointer()); @@ -507,21 +499,6 @@ void LLTextEditor::getSegmentsInRange(LLTextEditor::segment_vec_t& segments_out, } } -// virtual -BOOL LLTextEditor::canDeselect() const -{ - return hasSelection(); -} - - -void LLTextEditor::deselect() -{ - mSelectionStart = 0; - mSelectionEnd = 0; - mIsSelecting = FALSE; -} - - BOOL LLTextEditor::selectionContainsLineBreaks() { if (hasSelection()) @@ -668,6 +645,7 @@ void LLTextEditor::selectAll() mSelectionStart = getLength(); mSelectionEnd = 0; setCursorPos(mSelectionEnd); + updatePrimary(); } BOOL LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask) @@ -735,7 +713,8 @@ BOOL LLTextEditor::handleRightMouseDown(S32 x, S32 y, MASK mask) { setFocus(TRUE); } - if (!LLTextBase::handleRightMouseDown(x, y, mask)) + // Prefer editor menu if it has selection. See EXT-6806. + if (hasSelection() || !LLTextBase::handleRightMouseDown(x, y, mask)) { if(getShowContextMenu()) { @@ -1025,7 +1004,7 @@ void LLTextEditor::removeCharOrTab() } else { - reportBadKeystroke(); + LLUI::reportBadKeystroke(); } } @@ -1048,7 +1027,7 @@ void LLTextEditor::removeChar() } else { - reportBadKeystroke(); + LLUI::reportBadKeystroke(); } } @@ -1198,22 +1177,6 @@ BOOL LLTextEditor::handleSelectionKey(const KEY key, const MASK mask) } } - if( !handled && mHandleEditKeysDirectly ) - { - if( (MASK_CONTROL & mask) && ('A' == key) ) - { - if( canSelectAll() ) - { - selectAll(); - } - else - { - reportBadKeystroke(); - } - handled = TRUE; - } - } - if( handled ) { // take selection to 'primary' clipboard @@ -1247,6 +1210,7 @@ BOOL LLTextEditor::handleNavigationKey(const KEY key, const MASK mask) case KEY_DOWN: changeLine( 1 ); + deselect(); break; case KEY_PAGE_DOWN: @@ -1260,7 +1224,7 @@ BOOL LLTextEditor::handleNavigationKey(const KEY key, const MASK mask) case KEY_LEFT: if( hasSelection() ) { - setCursorPos(llmin( mCursorPos - 1, mSelectionStart, mSelectionEnd )); + setCursorPos(llmin( mSelectionStart, mSelectionEnd )); } else { @@ -1270,7 +1234,7 @@ BOOL LLTextEditor::handleNavigationKey(const KEY key, const MASK mask) } else { - reportBadKeystroke(); + LLUI::reportBadKeystroke(); } } break; @@ -1278,7 +1242,7 @@ BOOL LLTextEditor::handleNavigationKey(const KEY key, const MASK mask) case KEY_RIGHT: if( hasSelection() ) { - setCursorPos(llmax( mCursorPos + 1, mSelectionStart, mSelectionEnd )); + setCursorPos(llmax( mSelectionStart, mSelectionEnd )); } else { @@ -1288,7 +1252,7 @@ BOOL LLTextEditor::handleNavigationKey(const KEY key, const MASK mask) } else { - reportBadKeystroke(); + LLUI::reportBadKeystroke(); } } break; @@ -1299,6 +1263,11 @@ BOOL LLTextEditor::handleNavigationKey(const KEY key, const MASK mask) } } + if (handled) + { + deselect(); + } + return handled; } @@ -1551,75 +1520,13 @@ BOOL LLTextEditor::handleControlKey(const KEY key, const MASK mask) return handled; } -BOOL LLTextEditor::handleEditKey(const KEY key, const MASK mask) -{ - BOOL handled = FALSE; - // Standard edit keys (Ctrl-X, Delete, etc,) are handled here instead of routed by the menu system. - if( KEY_DELETE == key ) - { - if( canDoDelete() ) - { - doDelete(); - } - else - { - reportBadKeystroke(); - } - handled = TRUE; - } - else - if( MASK_CONTROL & mask ) +BOOL LLTextEditor::handleSpecialKey(const KEY key, const MASK mask) { - if( 'C' == key ) - { - if( canCopy() ) - { - copy(); - } - else - { - reportBadKeystroke(); - } - handled = TRUE; - } - else - if( 'V' == key ) - { - if( canPaste() ) - { - paste(); - } - else - { - reportBadKeystroke(); - } - handled = TRUE; - } - else - if( 'X' == key ) - { - if( canCut() ) - { - cut(); - } - else - { - reportBadKeystroke(); - } - handled = TRUE; - } - } - - return handled; -} - - -BOOL LLTextEditor::handleSpecialKey(const KEY key, const MASK mask, BOOL* return_key_hit) -{ - *return_key_hit = FALSE; BOOL handled = TRUE; + if (mReadOnly) return FALSE; + switch( key ) { case KEY_INSERT: @@ -1641,7 +1548,7 @@ BOOL LLTextEditor::handleSpecialKey(const KEY key, const MASK mask, BOOL* return } else { - reportBadKeystroke(); + LLUI::reportBadKeystroke(); } break; @@ -1694,6 +1601,10 @@ BOOL LLTextEditor::handleSpecialKey(const KEY key, const MASK mask, BOOL* return break; } + if (handled) + { + onKeyStroke(); + } return handled; } @@ -1714,9 +1625,6 @@ void LLTextEditor::unindentLineBeforeCloseBrace() BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask ) { BOOL handled = FALSE; - BOOL selection_modified = FALSE; - BOOL return_key_hit = FALSE; - BOOL text_may_have_changed = TRUE; // Special case for TAB. If want to move to next field, report // not handled and let the parent take care of field movement. @@ -1724,116 +1632,24 @@ BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask ) { return FALSE; } - /* - if (KEY_F10 == key) - { - LLComboBox::Params cp; - cp.name = "combo box"; - cp.label = "my combo"; - cp.rect.width = 100; - cp.rect.height = 20; - cp.items.add().label = "item 1"; - cp.items.add().label = "item 2"; - cp.items.add().label = "item 3"; - appendWidget(LLUICtrlFactory::create<LLComboBox>(cp), "combo", true, false); - } - if (KEY_F11 == key) - { - LLButton::Params bp; - bp.name = "text button"; - bp.label = "Click me"; - bp.rect.width = 100; - bp.rect.height = 20; - - appendWidget(LLUICtrlFactory::create<LLButton>(bp), "button", true, false); - } - */ - if (mReadOnly) + if (mReadOnly && mScroller) { - if(mScroller) - { - handled = mScroller->handleKeyHere( key, mask ); + handled = (mScroller && mScroller->handleKeyHere( key, mask )) + || handleSelectionKey(key, mask) + || handleControlKey(key, mask); } else { - handled = handleNavigationKey( key, mask ); - } - - } - else - { - // handle navigation keys ourself - handled = handleNavigationKey( key, mask ); - } - - - if( handled ) - { - text_may_have_changed = FALSE; - } - - if( !handled ) - { - handled = handleSelectionKey( key, mask ); - if( handled ) - { - selection_modified = TRUE; - } - } - - if( !handled ) - { - handled = handleControlKey( key, mask ); - if( handled ) - { - selection_modified = TRUE; - } - } - - if( !handled && mHandleEditKeysDirectly ) - { - handled = handleEditKey( key, mask ); - if( handled ) - { - selection_modified = TRUE; - text_may_have_changed = TRUE; - } - } - - // Handle most keys only if the text editor is writeable. - if( !mReadOnly ) - { - if( !handled ) - { - handled = handleSpecialKey( key, mask, &return_key_hit ); - if( handled ) - { - selection_modified = TRUE; - text_may_have_changed = TRUE; - } - } - + handled = handleNavigationKey( key, mask ) + || handleSelectionKey(key, mask) + || handleControlKey(key, mask) + || handleSpecialKey(key, mask); } if( handled ) { resetCursorBlink(); - - // Most keystrokes will make the selection box go away, but not all will. - if( !selection_modified && - KEY_SHIFT != key && - KEY_CONTROL != key && - KEY_ALT != key && - KEY_CAPSLOCK ) - { - deselect(); - } - - if(text_may_have_changed) - { - onKeyStroke(); - } needsScroll(); } @@ -2334,7 +2150,7 @@ void LLTextEditor::getCurrentLineAndColumn( S32* line, S32* col, BOOL include_wo void LLTextEditor::autoIndent() { // Count the number of spaces in the current line - S32 line = getLineNumFromDocIndex(mCursorPos); + S32 line = getLineNumFromDocIndex(mCursorPos, false); S32 line_start = getLineStart(line); S32 space_count = 0; S32 i; diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index 71d937b2c4..9b3ab9414c 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -68,7 +68,6 @@ public: Optional<bool> embedded_items, ignore_tab, - handle_edit_keys_directly, show_line_numbers, commit_on_focus_lost, show_context_menu; @@ -146,8 +145,6 @@ public: virtual BOOL canDoDelete() const; virtual void selectAll(); virtual BOOL canSelectAll() const; - virtual void deselect(); - virtual BOOL canDeselect() const; void selectNext(const std::string& search_text_in, BOOL case_insensitive, BOOL wrap = TRUE); BOOL replaceText(const std::string& search_text, const std::string& replace_text, BOOL case_insensitive, BOOL wrap = TRUE); @@ -218,13 +215,10 @@ protected: S32 indentLine( S32 pos, S32 spaces ); void unindentLineBeforeCloseBrace(); - void reportBadKeystroke() { make_ui_sound("UISndBadKeystroke"); } - BOOL handleNavigationKey(const KEY key, const MASK mask); - BOOL handleSpecialKey(const KEY key, const MASK mask, BOOL* return_key_hit); + BOOL handleSpecialKey(const KEY key, const MASK mask); BOOL handleSelectionKey(const KEY key, const MASK mask); BOOL handleControlKey(const KEY key, const MASK mask); - BOOL handleEditKey(const KEY key, const MASK mask); BOOL selectionContainsLineBreaks(); void deleteSelection(BOOL transient_operation); @@ -329,10 +323,6 @@ private: LLUUID mSourceID; - // If true, the standard edit keys (Ctrl-X, Delete, etc,) are handled here - //instead of routed by the menu system - BOOL mHandleEditKeysDirectly; - LLCoordGL mLastIMEPosition; // Last position of the IME editor keystroke_signal_t mKeystrokeSignal; diff --git a/indra/llui/lltextutil.cpp b/indra/llui/lltextutil.cpp new file mode 100644 index 0000000000..c5f3929fb1 --- /dev/null +++ b/indra/llui/lltextutil.cpp @@ -0,0 +1,79 @@ +/** + * @file lltextutil.cpp + * @brief Misc text-related auxiliary methods + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * + * Copyright (c) 2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "lltextutil.h" + +#include "lluicolor.h" +#include "lltextbox.h" + + +void LLTextUtil::textboxSetHighlightedVal(LLTextBox *txtbox, const LLStyle::Params& normal_style, const std::string& text, const std::string& hl) +{ + static LLUIColor sFilterTextColor = LLUIColorTable::instance().getColor("FilterTextColor", LLColor4::green); + + std::string text_uc = text; + LLStringUtil::toUpper(text_uc); + + size_t hl_begin = 0, hl_len = hl.size(); + + if (hl_len == 0 || (hl_begin = text_uc.find(hl)) == std::string::npos) + { + txtbox->setText(text, normal_style); + return; + } + + LLStyle::Params hl_style = normal_style; + hl_style.color = sFilterTextColor; + + txtbox->setText(LLStringUtil::null); // clear text + txtbox->appendText(text.substr(0, hl_begin), false, normal_style); + txtbox->appendText(text.substr(hl_begin, hl_len), false, hl_style); + txtbox->appendText(text.substr(hl_begin + hl_len), false, normal_style); +} + +const std::string& LLTextUtil::formatPhoneNumber(const std::string& phone_str) +{ + static const std::string PHONE_SEPARATOR = LLUI::sSettingGroups["config"]->getString("AvalinePhoneSeparator"); + static const S32 PHONE_PART_LEN = 2; + + static std::string formatted_phone_str; + formatted_phone_str = phone_str; + S32 separator_pos = (S32)(formatted_phone_str.size()) - PHONE_PART_LEN; + for (; separator_pos >= PHONE_PART_LEN; separator_pos -= PHONE_PART_LEN) + { + formatted_phone_str.insert(separator_pos, PHONE_SEPARATOR); + } + + return formatted_phone_str; +} + +// EOF diff --git a/indra/llui/lltextutil.h b/indra/llui/lltextutil.h new file mode 100644 index 0000000000..325c3c5b7c --- /dev/null +++ b/indra/llui/lltextutil.h @@ -0,0 +1,72 @@ +/** + * @file lltextutil.h + * @brief Misc text-related auxiliary methods + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * + * Copyright (c) 2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#ifndef LL_LLTEXTUTIL_H +#define LL_LLTEXTUTIL_H + +#include "llstyle.h" + +class LLTextBox; + +namespace LLTextUtil +{ + + /** + * Set value for text box, highlighting substring hl_uc. + * + * Used to highlight filter matches. + * + * @param txtbox Text box to set value for + * @param normal_style Style to use for non-highlighted text + * @param text Text to set + * @param hl Upper-cased string to highlight + */ + void textboxSetHighlightedVal( + LLTextBox *txtbox, + const LLStyle::Params& normal_style, + const std::string& text, + const std::string& hl); + + /** + * Formats passed phone number to be more human readable. + * + * It just divides the number on parts by two digits from right to left. The first left part + * can have 2 or 3 digits, i.e. +44-33-33-44-55-66 or 12-34-56-78-90. Separator is set in + * application settings (AvalinePhoneSeparator) + * + * @param[in] phone_str string with original phone number + * @return reference to string with formatted phone number + */ + const std::string& formatPhoneNumber(const std::string& phone_str); +} + +#endif // LL_LLTEXTUTIL_H diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 5121ef5351..bf12384a28 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -56,6 +56,7 @@ #include "llfloaterreg.h" #include "llmenugl.h" #include "llmenubutton.h" +#include "llloadingindicator.h" #include "llwindow.h" // for registration @@ -94,7 +95,10 @@ std::list<std::string> gUntranslated; static LLDefaultChildRegistry::Register<LLFilterEditor> register_filter_editor("filter_editor"); static LLDefaultChildRegistry::Register<LLFlyoutButton> register_flyout_button("flyout_button"); static LLDefaultChildRegistry::Register<LLSearchEditor> register_search_editor("search_editor"); + +// register other widgets which otherwise may not be linked in static LLDefaultChildRegistry::Register<LLMenuButton> register_menu_button("menu_button"); +static LLDefaultChildRegistry::Register<LLLoadingIndicator> register_loading_indicator("loading_indicator"); // @@ -207,7 +211,7 @@ void gl_rect_2d(S32 left, S32 top, S32 right, S32 bottom, BOOL filled ) // Counterclockwise quad will face the viewer if( filled ) - { + { gGL.begin( LLRender::QUADS ); gGL.vertex2i(left, top); gGL.vertex2i(left, bottom); @@ -1914,7 +1918,12 @@ void LLUI::clearPopups() } } - +//static +void LLUI::reportBadKeystroke() +{ + make_ui_sound("UISndBadKeystroke"); +} + //static // spawn_x and spawn_y are top left corner of view in screen GL coordinates void LLUI::positionViewNearMouse(LLView* view, S32 spawn_x, S32 spawn_y) diff --git a/indra/llui/llui.h b/indra/llui/llui.h index 30f3623ded..c18262ef76 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -217,6 +217,8 @@ public: static void removePopup(LLView*); static void clearPopups(); + static void reportBadKeystroke(); + // Ensures view does not overlap mouse cursor, but is inside // the view's parent rectangle. Used for tooltips, inspectors. // Optionally override the view's default X/Y, which are relative to the diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp index 27237800d4..930dadc377 100644 --- a/indra/llui/lluictrlfactory.cpp +++ b/indra/llui/lluictrlfactory.cpp @@ -435,7 +435,10 @@ void LLUICtrlFactory::registerWidget(const std::type_info* widget_type, const st std::string* existing_tag = LLWidgetNameRegistry::instance().getValue(param_block_type); if (existing_tag != NULL && *existing_tag != tag) { - llerrs << "Duplicate entry for T::Params, try creating empty param block in derived classes that inherit T::Params" << llendl; + std::cerr << "Duplicate entry for T::Params, try creating empty param block in derived classes that inherit T::Params" << std::endl; + // forcing crash here + char* foo = 0; + *foo = 1; } LLWidgetNameRegistry ::instance().defaultRegistrar().add(param_block_type, tag); // associate widget type with factory function diff --git a/indra/llui/lluifwd.h b/indra/llui/lluifwd.h index f99bb39fdd..d6047b943c 100644 --- a/indra/llui/lluifwd.h +++ b/indra/llui/lluifwd.h @@ -39,6 +39,7 @@ class LLComboBox; class LLDragHandle; class LLFloater; class LLIconCtrl; +class LLLoadingIndicator; class LLLineEditor; class LLMenuGL; class LLPanel; diff --git a/indra/llui/llurlaction.cpp b/indra/llui/llurlaction.cpp index 679db5e39b..2f13a56b42 100644 --- a/indra/llui/llurlaction.cpp +++ b/indra/llui/llurlaction.cpp @@ -146,3 +146,20 @@ void LLUrlAction::copyLabelToClipboard(std::string url) LLView::getWindow()->copyTextToClipboard(utf8str_to_wstring(match.getLabel())); } } + +void LLUrlAction::showProfile(std::string url) +{ + // Get id from 'secondlife:///app/{cmd}/{id}/{action}' + // and show its profile + LLURI uri(url); + LLSD path_array = uri.pathArray(); + if (path_array.size() == 4) + { + std::string id_str = path_array.get(2).asString(); + if (LLUUID::validate(id_str)) + { + std::string cmd_str = path_array.get(1).asString(); + executeSLURL("secondlife:///app/" + cmd_str + "/" + id_str + "/about"); + } + } +} diff --git a/indra/llui/llurlaction.h b/indra/llui/llurlaction.h index 4830cf27ef..b96faf1b3f 100644 --- a/indra/llui/llurlaction.h +++ b/indra/llui/llurlaction.h @@ -79,6 +79,9 @@ public: /// copy a Url to the clipboard static void copyURLToClipboard(std::string url); + /// if the Url specifies an SL command in the form like 'app/{cmd}/{id}/*', show its profile + 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)); diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index 35428e4227..fd56a87345 100644 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -41,6 +41,9 @@ #include "lltrans.h" #include "lluicolortable.h" +#define APP_HEADER_REGEX "((x-grid-location-info://[-\\w\\.]+/app)|(secondlife:///app))" + + LLUrlEntryBase::LLUrlEntryBase() : mColor(LLUIColorTable::instance().getColor("HTMLLinkColor")), mDisabledLink(false) @@ -303,14 +306,14 @@ std::string LLUrlEntrySLURL::getLocation(const std::string &url) const // // LLUrlEntryAgent Describes a Second Life agent Url, e.g., // secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about +// x-grid-location-info://lincoln.lindenlab.com/app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about // LLUrlEntryAgent::LLUrlEntryAgent() { - mPattern = boost::regex("secondlife:///app/agent/[\\da-f-]+/\\w+", + mPattern = boost::regex(APP_HEADER_REGEX "/agent/[\\da-f-]+/\\w+", boost::regex::perl|boost::regex::icase); mMenuName = "menu_url_agent.xml"; mIcon = "Generic_Person"; - mTooltip = LLTrans::getString("TooltipAgentUrl"); mColor = LLUIColorTable::instance().getColor("AgentLinkColor"); } @@ -323,6 +326,38 @@ void LLUrlEntryAgent::onAgentNameReceived(const LLUUID& id, callObservers(id.asString(), first + " " + last); } +std::string LLUrlEntryAgent::getTooltip(const std::string &string) const +{ + // return a tooltip corresponding to the URL type instead of the generic one + std::string url = getUrl(string); + + if (LLStringUtil::endsWith(url, "/mute")) + { + return LLTrans::getString("TooltipAgentMute"); + } + if (LLStringUtil::endsWith(url, "/unmute")) + { + return LLTrans::getString("TooltipAgentUnmute"); + } + if (LLStringUtil::endsWith(url, "/im")) + { + return LLTrans::getString("TooltipAgentIM"); + } + if (LLStringUtil::endsWith(url, "/pay")) + { + return LLTrans::getString("TooltipAgentPay"); + } + if (LLStringUtil::endsWith(url, "/offerteleport")) + { + return LLTrans::getString("TooltipAgentOfferTeleport"); + } + if (LLStringUtil::endsWith(url, "/requestfriend")) + { + return LLTrans::getString("TooltipAgentRequestFriend"); + } + return LLTrans::getString("TooltipAgentUrl"); +} + std::string LLUrlEntryAgent::getLabel(const std::string &url, const LLUrlLabelCallback &cb) { if (!gCacheName) @@ -346,6 +381,31 @@ std::string LLUrlEntryAgent::getLabel(const std::string &url, const LLUrlLabelCa } else if (gCacheName->getFullName(agent_id, full_name)) { + // customize label string based on agent SLapp suffix + if (LLStringUtil::endsWith(url, "/mute")) + { + return LLTrans::getString("SLappAgentMute") + " " + full_name; + } + if (LLStringUtil::endsWith(url, "/unmute")) + { + return LLTrans::getString("SLappAgentUnmute") + " " + full_name; + } + if (LLStringUtil::endsWith(url, "/im")) + { + return LLTrans::getString("SLappAgentIM") + " " + full_name; + } + if (LLStringUtil::endsWith(url, "/pay")) + { + return LLTrans::getString("SLappAgentPay") + " " + full_name; + } + if (LLStringUtil::endsWith(url, "/offerteleport")) + { + return LLTrans::getString("SLappAgentOfferTeleport") + " " + full_name; + } + if (LLStringUtil::endsWith(url, "/requestfriend")) + { + return LLTrans::getString("SLappAgentRequestFriend") + " " + full_name; + } return full_name; } else @@ -362,10 +422,11 @@ std::string LLUrlEntryAgent::getLabel(const std::string &url, const LLUrlLabelCa // LLUrlEntryGroup Describes a Second Life group Url, e.g., // secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about // secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/inspect +// x-grid-location-info://lincoln.lindenlab.com/app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/inspect // LLUrlEntryGroup::LLUrlEntryGroup() { - mPattern = boost::regex("secondlife:///app/group/[\\da-f-]+/\\w+", + mPattern = boost::regex(APP_HEADER_REGEX "/group/[\\da-f-]+/\\w+", boost::regex::perl|boost::regex::icase); mMenuName = "menu_url_group.xml"; mIcon = "Generic_Group"; @@ -426,7 +487,8 @@ LLUrlEntryInventory::LLUrlEntryInventory() //*TODO: add supporting of inventory item names with whitespaces //this pattern cann't parse for example //secondlife:///app/inventory/0e346d8b-4433-4d66-a6b0-fd37083abc4c/select?name=name with spaces¶m2=value - mPattern = boost::regex("secondlife:///app/inventory/[\\da-f-]+/\\w+\\S*", + //x-grid-location-info://lincoln.lindenlab.com/app/inventory/0e346d8b-4433-4d66-a6b0-fd37083abc4c/select?name=name with spaces¶m2=value + mPattern = boost::regex(APP_HEADER_REGEX "/inventory/[\\da-f-]+/\\w+\\S*", boost::regex::perl|boost::regex::icase); mMenuName = "menu_url_inventory.xml"; } @@ -437,13 +499,43 @@ std::string LLUrlEntryInventory::getLabel(const std::string &url, const LLUrlLab return LLURI::unescape(label.empty() ? url : label); } +// +// LLUrlEntryObjectIM Describes a Second Life inspector for the object Url, e.g., +// secondlife:///app/objectim/7bcd7864-da6b-e43f-4486-91d28a28d95b?name=Object&owner=3de548e1-57be-cfea-2b78-83ae3ad95998&slurl=Danger!%20Danger!/200/200/30/&groupowned=1 +// +LLUrlEntryObjectIM::LLUrlEntryObjectIM() +{ + mPattern = boost::regex("secondlife:///app/objectim/[\\da-f-]+\?.*", + boost::regex::perl|boost::regex::icase); + mMenuName = "menu_url_objectim.xml"; +} + +std::string LLUrlEntryObjectIM::getLabel(const std::string &url, const LLUrlLabelCallback &cb) +{ + LLURI uri(url); + LLSD query_map = uri.queryMap(); + if (query_map.has("name")) + return query_map["name"]; + return unescapeUrl(url); +} + +std::string LLUrlEntryObjectIM::getLocation(const std::string &url) const +{ + LLURI uri(url); + LLSD query_map = uri.queryMap(); + if (query_map.has("slurl")) + return query_map["slurl"]; + return LLUrlEntryBase::getLocation(url); +} + /// /// LLUrlEntryParcel Describes a Second Life parcel Url, e.g., /// secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about +/// x-grid-location-info://lincoln.lindenlab.com/app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about /// LLUrlEntryParcel::LLUrlEntryParcel() { - mPattern = boost::regex("secondlife:///app/parcel/[\\da-f-]+/about", + mPattern = boost::regex(APP_HEADER_REGEX "/parcel/[\\da-f-]+/about", boost::regex::perl|boost::regex::icase); mMenuName = "menu_url_parcel.xml"; mTooltip = LLTrans::getString("TooltipParcelUrl"); @@ -459,7 +551,7 @@ std::string LLUrlEntryParcel::getLabel(const std::string &url, const LLUrlLabelC // LLUrlEntryPlace::LLUrlEntryPlace() { - mPattern = boost::regex("secondlife://\\S+/?(\\d+/\\d+/\\d+|\\d+/\\d+)/?", + mPattern = boost::regex("((x-grid-location-info://[-\\w\\.]+/region/)|(secondlife://))\\S+/?(\\d+/\\d+/\\d+|\\d+/\\d+)/?", boost::regex::perl|boost::regex::icase); mMenuName = "menu_url_slurl.xml"; mTooltip = LLTrans::getString("TooltipSLURL"); @@ -504,10 +596,11 @@ std::string LLUrlEntryPlace::getLocation(const std::string &url) const // // LLUrlEntryTeleport Describes a Second Life teleport Url, e.g., // secondlife:///app/teleport/Ahern/50/50/50/ +// x-grid-location-info://lincoln.lindenlab.com/app/teleport/Ahern/50/50/50/ // LLUrlEntryTeleport::LLUrlEntryTeleport() { - mPattern = boost::regex("secondlife:///app/teleport/\\S+(/\\d+)?(/\\d+)?(/\\d+)?/?\\S*", + mPattern = boost::regex(APP_HEADER_REGEX "/teleport/\\S+(/\\d+)?(/\\d+)?(/\\d+)?/?\\S*", boost::regex::perl|boost::regex::icase); mMenuName = "menu_url_teleport.xml"; mTooltip = LLTrans::getString("TooltipTeleportUrl"); @@ -525,7 +618,12 @@ std::string LLUrlEntryTeleport::getLabel(const std::string &url, const LLUrlLabe LLURI uri(url); LLSD path_array = uri.pathArray(); S32 path_parts = path_array.size(); - const std::string label = LLTrans::getString("SLurlLabelTeleport"); + std::string host = uri.hostName(); + std::string label = LLTrans::getString("SLurlLabelTeleport"); + if (!host.empty()) + { + label += " " + host; + } if (path_parts == 6) { // handle teleport url with (X,Y,Z) coordinates @@ -624,7 +722,7 @@ std::string LLUrlEntrySLLabel::getTooltip(const std::string &string) const // LLUrlEntryWorldMap::LLUrlEntryWorldMap() { - mPattern = boost::regex("secondlife:///app/worldmap/\\S+/?(\\d+)?/?(\\d+)?/?(\\d+)?/?\\S*", + mPattern = boost::regex(APP_HEADER_REGEX "/worldmap/\\S+/?(\\d+)?/?(\\d+)?/?(\\d+)?/?\\S*", boost::regex::perl|boost::regex::icase); mMenuName = "menu_url_map.xml"; mTooltip = LLTrans::getString("TooltipMapUrl"); @@ -647,7 +745,7 @@ std::string LLUrlEntryWorldMap::getLabel(const std::string &url, const LLUrlLabe } const std::string label = LLTrans::getString("SLurlLabelShowOnMap"); - std::string location = path_array[2]; + std::string location = unescapeUrl(path_array[2]); std::string x = (path_parts > 3) ? path_array[3] : "128"; std::string y = (path_parts > 4) ? path_array[4] : "128"; std::string z = (path_parts > 5) ? path_array[5] : "0"; @@ -680,3 +778,35 @@ std::string LLUrlEntryNoLink::getLabel(const std::string &url, const LLUrlLabelC { return getUrl(url); } + +// +// LLUrlEntryIcon describes an icon with <icon>...</icon> tags +// +LLUrlEntryIcon::LLUrlEntryIcon() +{ + mPattern = boost::regex("<icon\\s*>\\s*([^<]*)?\\s*</icon\\s*>", + boost::regex::perl|boost::regex::icase); + mDisabledLink = true; +} + +std::string LLUrlEntryIcon::getUrl(const std::string &url) const +{ + return LLStringUtil::null; +} + +std::string LLUrlEntryIcon::getLabel(const std::string &url, const LLUrlLabelCallback &cb) +{ + return LLStringUtil::null; +} + +std::string LLUrlEntryIcon::getIcon(const std::string &url) +{ + // Grep icon info between <icon>...</icon> tags + // matches[1] contains the icon name/path + boost::match_results<std::string::const_iterator> matches; + mIcon = (boost::regex_match(url, matches, mPattern) && matches[1].matched) + ? matches[1] + : LLStringUtil::null; + LLStringUtil::trim(mIcon); + return mIcon; +} diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h index c947ef7259..71f030677a 100644 --- a/indra/llui/llurlentry.h +++ b/indra/llui/llurlentry.h @@ -77,7 +77,7 @@ public: virtual std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb) { return url; } /// Return an icon that can be displayed next to Urls of this type - std::string getIcon() const { return mIcon; } + virtual std::string getIcon(const std::string &url) { return mIcon; } /// Return the color to render the displayed text LLUIColor getColor() const { return mColor; } @@ -169,6 +169,7 @@ class LLUrlEntryAgent : public LLUrlEntryBase public: LLUrlEntryAgent(); /*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb); + /*virtual*/ std::string getTooltip(const std::string &string) const; private: void onAgentNameReceived(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group); @@ -200,6 +201,18 @@ public: private: }; +/// +/// LLUrlEntryObjectIM Describes a Second Life inspector for the object Url, e.g., +/// secondlife:///app/objectim/7bcd7864-da6b-e43f-4486-91d28a28d95b?name=Object&owner=3de548e1-57be-cfea-2b78-83ae3ad95998&slurl=Danger!%20Danger!/200/200/30/&groupowned=1 +/// +class LLUrlEntryObjectIM : public LLUrlEntryBase +{ +public: + LLUrlEntryObjectIM(); + /*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb); + /*virtual*/ std::string getLocation(const std::string &url) const; +private: +}; /// /// LLUrlEntryParcel Describes a Second Life parcel Url, e.g., @@ -283,4 +296,17 @@ public: /*virtual*/ std::string getUrl(const std::string &string) const; }; +/// +/// LLUrlEntryIcon describes an icon with <icon>...</icon> tags +/// +class LLUrlEntryIcon : public LLUrlEntryBase +{ +public: + LLUrlEntryIcon(); + /*virtual*/ std::string getUrl(const std::string &string) const; + /*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb); + /*virtual*/ std::string getIcon(const std::string &url); +}; + + #endif diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp index faa02e1904..4341286eb4 100644 --- a/indra/llui/llurlregistry.cpp +++ b/indra/llui/llurlregistry.cpp @@ -45,6 +45,7 @@ LLUrlRegistry::LLUrlRegistry() { // Urls are matched in the order that they were registered registerUrl(new LLUrlEntryNoLink()); + registerUrl(new LLUrlEntryIcon()); registerUrl(new LLUrlEntrySLURL()); registerUrl(new LLUrlEntryHTTP()); registerUrl(new LLUrlEntryHTTPLabel()); @@ -53,8 +54,10 @@ LLUrlRegistry::LLUrlRegistry() registerUrl(new LLUrlEntryParcel()); registerUrl(new LLUrlEntryTeleport()); registerUrl(new LLUrlEntryWorldMap()); + registerUrl(new LLUrlEntryObjectIM()); registerUrl(new LLUrlEntryPlace()); registerUrl(new LLUrlEntryInventory()); + registerUrl(new LLUrlEntryObjectIM()); //LLUrlEntrySL and LLUrlEntrySLLabel have more common pattern, //so it should be registered in the end of list registerUrl(new LLUrlEntrySL()); @@ -133,7 +136,8 @@ static bool stringHasUrl(const std::string &text) text.find(".net") != std::string::npos || text.find(".edu") != std::string::npos || text.find(".org") != std::string::npos || - text.find("<nolink>") != std::string::npos); + text.find("<nolink>") != std::string::npos || + text.find("<icon") != std::string::npos); } bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LLUrlLabelCallback &cb) @@ -175,7 +179,7 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL match_entry->getUrl(url), match_entry->getLabel(url, cb), match_entry->getTooltip(url), - match_entry->getIcon(), + match_entry->getIcon(url), match_entry->getColor(), match_entry->getMenuName(), match_entry->getLocation(url), diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index d34083a384..bd56da9121 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -107,8 +107,6 @@ LLView::Params::Params() top_delta("top_delta", S32_MAX), left_pad("left_pad"), left_delta("left_delta", S32_MAX), - center_horiz("center_horiz", false), - center_vert("center_vert", false), from_xui("from_xui", false), user_resize("user_resize"), auto_resize("auto_resize"), @@ -152,7 +150,7 @@ LLView::~LLView() //llinfos << "Deleting view " << mName << ":" << (void*) this << llendl; if (LLView::sIsDrawing) { - llwarns << "Deleting view " << mName << " during UI draw() phase" << llendl; + lldebugs << "Deleting view " << mName << " during UI draw() phase" << llendl; } // llassert(LLView::sIsDrawing == FALSE); @@ -1325,7 +1323,6 @@ void LLView::drawChildren() localRectToScreen(viewp->getRect(),&screenRect); if ( rootRect.overlaps(screenRect) && LLUI::sDirtyRect.overlaps(screenRect)) { - glMatrixMode(GL_MODELVIEW); LLUI::pushMatrix(); { LLUI::translate((F32)viewp->getRect().mLeft, (F32)viewp->getRect().mBottom, 0.f); @@ -1349,8 +1346,6 @@ void LLView::drawChildren() } --sDepth; } - - gGL.getTexUnit(0)->disable(); } void LLView::dirtyRect() @@ -2502,7 +2497,6 @@ void LLView::applyXUILayout(LLView::Params& p, LLView* parent) p.layout = parent->getLayout(); } - if (parent) { LLRect parent_rect = parent->getLocalRect(); @@ -2510,60 +2504,21 @@ void LLView::applyXUILayout(LLView::Params& p, LLView* parent) LLRect last_rect = parent->getLocalRect(); bool layout_topleft = (p.layout() == "topleft"); - if (layout_topleft) - { - //invert top to bottom - if (p.rect.top.isProvided()) p.rect.top = parent_rect.getHeight() - p.rect.top; - if (p.rect.bottom.isProvided()) p.rect.bottom = parent_rect.getHeight() - p.rect.bottom; - } // convert negative or centered coordinates to parent relative values // Note: some of this logic matches the logic in TypedParam<LLRect>::setValueFromBlock() + if (p.rect.left.isProvided() && p.rect.left < 0) p.rect.left = p.rect.left + parent_rect.getWidth(); + if (p.rect.right.isProvided() && p.rect.right < 0) p.rect.right = p.rect.right + parent_rect.getWidth(); + if (p.rect.bottom.isProvided() && p.rect.bottom < 0) p.rect.bottom = p.rect.bottom + parent_rect.getHeight(); + if (p.rect.top.isProvided() && p.rect.top < 0) p.rect.top = p.rect.top + parent_rect.getHeight(); - if (p.center_horiz) - { - if (p.rect.left.isProvided() && p.rect.right.isProvided()) - { - S32 width = p.rect.right - p.rect.left; - width = llmax(width, 0); - S32 offset = parent_rect.getWidth()/2 - width/2; - p.rect.left = p.rect.left + offset; - p.rect.right = p.rect.right + offset; - } - else - { - p.rect.left = p.rect.left + parent_rect.getWidth()/2 - p.rect.width/2; - p.rect.right.setProvided(false); // recalculate the right - } - } - else - { - if (p.rect.left.isProvided() && p.rect.left < 0) p.rect.left = p.rect.left + parent_rect.getWidth(); - if (p.rect.right.isProvided() && p.rect.right < 0) p.rect.right = p.rect.right + parent_rect.getWidth(); - } - if (p.center_vert) - { - if (p.rect.bottom.isProvided() && p.rect.top.isProvided()) - { - S32 height = p.rect.top - p.rect.bottom; - height = llmax(height, 0); - S32 offset = parent_rect.getHeight()/2 - height/2; - p.rect.bottom = p.rect.bottom + offset; - p.rect.top = p.rect.top + offset; - } - else - { - p.rect.bottom = p.rect.bottom + parent_rect.getHeight()/2 - p.rect.height/2; - p.rect.top.setProvided(false); // recalculate the top - } - } - else + if (layout_topleft) { - if (p.rect.bottom.isProvided() && p.rect.bottom < 0) p.rect.bottom = p.rect.bottom + parent_rect.getHeight(); - if (p.rect.top.isProvided() && p.rect.top < 0) p.rect.top = p.rect.top + parent_rect.getHeight(); + //invert top to bottom + if (p.rect.top.isProvided()) p.rect.top = parent_rect.getHeight() - p.rect.top; + if (p.rect.bottom.isProvided()) p.rect.bottom = parent_rect.getHeight() - p.rect.bottom; } - // DEPRECATE: automatically fall back to height of MIN_WIDGET_HEIGHT pixels if (!p.rect.height.isProvided() && !p.rect.top.isProvided() && p.rect.height == 0) { diff --git a/indra/llui/llview.h b/indra/llui/llview.h index efae00f0e5..3779fedf34 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -143,9 +143,6 @@ public: left_pad, // from last right to my left left_delta; // from last left to my left - Optional<bool> center_horiz, - center_vert; - // these are nested attributes for LLLayoutPanel //FIXME: get parent context involved in parsing traversal Ignored user_resize, diff --git a/indra/llui/tests/llurlentry_test.cpp b/indra/llui/tests/llurlentry_test.cpp index cbb303a059..4463b6cc6f 100644 --- a/indra/llui/tests/llurlentry_test.cpp +++ b/indra/llui/tests/llurlentry_test.cpp @@ -286,6 +286,13 @@ namespace tut "XXX secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/foobar", "secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/foobar"); + testRegex("Standalone Agent Url ", url, + "x-grid-location-info://lincoln.lindenlab.com/app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about", + "x-grid-location-info://lincoln.lindenlab.com/app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about"); + + testRegex("Standalone Agent Url Multicase with Text", url, + "M x-grid-location-info://lincoln.lindenlab.com/app/AGENT/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about M", + "x-grid-location-info://lincoln.lindenlab.com/app/AGENT/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about"); } template<> template<> @@ -315,6 +322,15 @@ namespace tut testRegex("Group Url multicase", url, "XXX secondlife:///APP/Group/00005FF3-4044-c79f-9de8-fb28ae0df991/About XXX", "secondlife:///APP/Group/00005FF3-4044-c79f-9de8-fb28ae0df991/About"); + + testRegex("Standalone Group Url ", url, + "x-grid-location-info://lincoln.lindenlab.com/app/group/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about", + "x-grid-location-info://lincoln.lindenlab.com/app/group/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about"); + + testRegex("Standalone Group Url Multicase ith Text", url, + "M x-grid-location-info://lincoln.lindenlab.com/app/GROUP/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about M", + "x-grid-location-info://lincoln.lindenlab.com/app/GROUP/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about"); + } template<> template<> @@ -361,7 +377,11 @@ namespace tut // DEV-35459: SLURLs and teleport Links not parsed properly testRegex("SLURL with quote", url, "XXX secondlife://A'ksha%20Oasis/41/166/701 XXX", - "secondlife://A%27ksha%20Oasis/41/166/701"); + "secondlife://A%27ksha%20Oasis/41/166/701"); + + testRegex("Standalone All Hands (50,50) [2] with text", url, + "XXX x-grid-location-info://lincoln.lindenlab.com/region/All%20Hands/50/50/50 XXX", + "x-grid-location-info://lincoln.lindenlab.com/region/All%20Hands/50/50/50"); } template<> template<> @@ -461,6 +481,10 @@ namespace tut testRegex("Teleport url with quote", url, "XXX secondlife:///app/teleport/A'ksha%20Oasis/41/166/701 XXX", "secondlife:///app/teleport/A%27ksha%20Oasis/41/166/701"); + + testRegex("Standalone All Hands", url, + "XXX x-grid-location-info://lincoln.lindenlab.com/app/teleport/All%20Hands/50/50/50 XXX", + "x-grid-location-info://lincoln.lindenlab.com/app/teleport/All%20Hands/50/50/50"); } template<> template<> |