diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llfloater.cpp | 87 | ||||
-rw-r--r-- | indra/llui/llfloater.h | 7 | ||||
-rw-r--r-- | indra/llui/llmenugl.cpp | 4 | ||||
-rw-r--r-- | indra/llui/llmenugl.h | 11 | ||||
-rw-r--r-- | indra/llui/llnotifications.cpp | 5 | ||||
-rw-r--r-- | indra/llui/llnotifications.h | 1 | ||||
-rw-r--r-- | indra/llui/llresizebar.cpp | 55 | ||||
-rw-r--r-- | indra/llui/llresizehandle.cpp | 58 | ||||
-rw-r--r-- | indra/llui/lltexteditor.cpp | 78 | ||||
-rw-r--r-- | indra/llui/lltexteditor.h | 4 | ||||
-rw-r--r-- | indra/llui/lltoggleablemenu.h | 2 | ||||
-rw-r--r-- | indra/llui/lltoolbar.cpp | 10 | ||||
-rw-r--r-- | indra/llui/lltoolbar.h | 3 | ||||
-rw-r--r-- | indra/llui/lltooltip.cpp | 18 | ||||
-rw-r--r-- | indra/llui/lltooltip.h | 4 |
15 files changed, 248 insertions, 99 deletions
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index d2aae11191..05b2a1b7c6 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -1129,17 +1129,26 @@ void LLFloater::handleReshape(const LLRect& new_rect, bool by_user) const LLRect old_rect = getRect(); LLView::handleReshape(new_rect, by_user); - if (by_user && !isMinimized()) + if (by_user && !getHost()) { - storeRectControl(); - mPositioning = LLFloaterEnums::POSITIONING_RELATIVE; - LLRect screen_rect = calcScreenRect(); - mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert(); + static_cast<LLFloaterView*>(getParent())->adjustToFitScreen(this, !isMinimized()); } // if not minimized, adjust all snapped dependents to new shape if (!isMinimized()) { + if (by_user) + { + if (isDocked()) + { + setDocked( false, false); + } + storeRectControl(); + mPositioning = LLFloaterEnums::POSITIONING_RELATIVE; + LLRect screen_rect = calcScreenRect(); + mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert(); + } + // gather all snapped dependents for(handle_set_iter_t dependent_it = mDependents.begin(); dependent_it != mDependents.end(); ++dependent_it) @@ -1752,56 +1761,10 @@ void LLFloater::initRectControl() } } -// static -LLFloater* LLFloater::getClosableFloaterFromFocus() -{ - LLFloater* focused_floater = NULL; - LLInstanceTracker<LLFloater>::instance_iter it = beginInstances(); - LLInstanceTracker<LLFloater>::instance_iter end_it = endInstances(); - for (; it != end_it; ++it) - { - if (it->hasFocus()) - { - LLFloater& floater = *it; - focused_floater = &floater; - break; - } - } - - if (it == endInstances()) - { - // nothing found, return - return NULL; - } - - // The focused floater may not be closable, - // Find and close a parental floater that is closeable, if any. - LLFloater* prev_floater = NULL; - for(LLFloater* floater_to_close = focused_floater; - NULL != floater_to_close; - floater_to_close = gFloaterView->getParentFloater(floater_to_close)) - { - if(floater_to_close->isCloseable()) - { - return floater_to_close; - } - - // If floater has as parent root view - // gFloaterView->getParentFloater(floater_to_close) returns - // the same floater_to_close, so we need to check this. - if (prev_floater == floater_to_close) { - break; - } - prev_floater = floater_to_close; - } - - return NULL; -} - // static -void LLFloater::closeFocusedFloater() +void LLFloater::closeFrontmostFloater() { - LLFloater* floater_to_close = LLFloater::getClosableFloaterFromFocus(); + LLFloater* floater_to_close = gFloaterView->getFrontmostClosableFloater(); if(floater_to_close) { floater_to_close->closeFloater(); @@ -2532,6 +2495,24 @@ void LLFloaterView::highlightFocusedFloater() } } +LLFloater* LLFloaterView::getFrontmostClosableFloater() +{ + child_list_const_iter_t child_it; + LLFloater* frontmost_floater = NULL; + + for ( child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) + { + frontmost_floater = (LLFloater *)(*child_it); + + if (frontmost_floater->isInVisibleChain() && frontmost_floater->isCloseable()) + { + return frontmost_floater; + } + } + + return NULL; +} + void LLFloaterView::unhighlightFocusedFloater() { for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 9ad566a1a1..a6a85fc7d1 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -329,12 +329,10 @@ public: bool isTornOff() {return mTornOff;} void setOpenPositioning(LLFloaterEnums::EOpenPositioning pos) {mPositioning = pos;} - // Return a closeable floater, if any, given the current focus. - static LLFloater* getClosableFloaterFromFocus(); - // Close the floater returned by getClosableFloaterFromFocus() and + // Close the floater returned by getFrontmostClosableFloater() and // handle refocusing. - static void closeFocusedFloater(); + static void closeFrontmostFloater(); // LLNotification::Params contextualNotification(const std::string& name) // { @@ -564,6 +562,7 @@ public: S32 getZOrder(LLFloater* child); void setFloaterSnapView(LLHandle<LLView> snap_view) {mSnapView = snap_view; } + LLFloater* getFrontmostClosableFloater(); private: void hiddenFloaterClosed(LLFloater* floater); diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 27f6ac5b80..b7148bb91b 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -2587,9 +2587,7 @@ BOOL LLMenuGL::appendMenu( LLMenuGL* menu ) } // add a context menu branch - BOOL LLMenuGL::appendContextSubMenu(LLMenuGL *menu) - { if (menu == this) { @@ -2598,7 +2596,6 @@ BOOL LLMenuGL::appendContextSubMenu(LLMenuGL *menu) LLContextMenuBranch *item; LLContextMenuBranch::Params p; - p.name = menu->getName(); p.label = menu->getLabel(); p.branch = (LLContextMenu *)menu; @@ -2606,6 +2603,7 @@ BOOL LLMenuGL::appendContextSubMenu(LLMenuGL *menu) p.disabled_color=LLUIColorTable::instance().getColor("MenuItemDisabledColor"); p.highlight_bg_color=LLUIColorTable::instance().getColor("MenuItemHighlightBgColor"); p.highlight_fg_color=LLUIColorTable::instance().getColor("MenuItemHighlightFgColor"); + item = LLUICtrlFactory::create<LLContextMenuBranch>(p); LLMenuGL::sMenuContainer->addChild(item->getBranch()); diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index c57e0f0267..51df5df1f8 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -716,20 +716,25 @@ public: LLContextMenuBranch(const Params&); - // Called to rebuild strings for this item + virtual ~LLContextMenuBranch() + {} + + // called to rebuild the draw label virtual void buildDrawLabel( void ); - // Performed when menu item clicked + // onCommit() - do the primary funcationality of the menu item. virtual void onCommit( void ); LLContextMenu* getBranch() { return mBranch.get(); } void setHighlight( BOOL highlight ); protected: - void showSubMenu(); + void showSubMenu(); + LLHandle<LLContextMenu> mBranch; }; + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLMenuBarGL // diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index ea52bee184..1789f003b9 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -1147,6 +1147,11 @@ bool LLNotificationChannel::isEmpty() const return mItems.empty(); } +S32 LLNotificationChannel::size() const +{ + return mItems.size(); +} + LLNotificationChannel::Iterator LLNotificationChannel::begin() { return mItems.begin(); diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index e02c58de44..87573c2a56 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -840,6 +840,7 @@ public: void connectToChannel(const std::string& channel_name); bool isEmpty() const; + S32 size() const; Iterator begin(); Iterator end(); diff --git a/indra/llui/llresizebar.cpp b/indra/llui/llresizebar.cpp index 4b9add820f..15e56cbfe5 100644 --- a/indra/llui/llresizebar.cpp +++ b/indra/llui/llresizebar.cpp @@ -140,13 +140,6 @@ BOOL LLResizeBar::handleHover(S32 x, S32 y, MASK mask) if( valid_rect.localPointInRect( screen_x, screen_y ) && mResizingView ) { - // undock floater when user resize it - LLFloater* parent = dynamic_cast<LLFloater*>( getParent()); - if (parent && parent->isDocked()) - { - parent->setDocked( false, false); - } - // Resize the parent LLRect orig_rect = mResizingView->getRect(); LLRect scaled_rect = orig_rect; @@ -220,20 +213,66 @@ BOOL LLResizeBar::handleHover(S32 x, S32 y, MASK mask) // update last valid mouse cursor position based on resized view's actual size LLRect new_rect = mResizingView->getRect(); + switch(mSide) { case LEFT: - mDragLastScreenX += new_rect.mLeft - orig_rect.mLeft; + { + S32 actual_delta_x = new_rect.mLeft - orig_rect.mLeft; + if (actual_delta_x != delta_x) + { + // restore everything by left + new_rect.mBottom = orig_rect.mBottom; + new_rect.mTop = orig_rect.mTop; + new_rect.mRight = orig_rect.mRight; + mResizingView->setShape(new_rect, true); + } + mDragLastScreenX += actual_delta_x; + break; + } case RIGHT: + { + S32 actual_delta_x = new_rect.mRight - orig_rect.mRight; + if (actual_delta_x != delta_x) + { + // restore everything by left + new_rect.mBottom = orig_rect.mBottom; + new_rect.mTop = orig_rect.mTop; + new_rect.mLeft = orig_rect.mLeft; + mResizingView->setShape(new_rect, true); + } mDragLastScreenX += new_rect.mRight - orig_rect.mRight; break; + } case TOP: + { + S32 actual_delta_y = new_rect.mTop - orig_rect.mTop; + if (actual_delta_y != delta_y) + { + // restore everything by left + new_rect.mBottom = orig_rect.mBottom; + new_rect.mLeft = orig_rect.mLeft; + new_rect.mRight = orig_rect.mRight; + mResizingView->setShape(new_rect, true); + } mDragLastScreenY += new_rect.mTop - orig_rect.mTop; break; + } case BOTTOM: + { + S32 actual_delta_y = new_rect.mBottom - orig_rect.mBottom; + if (actual_delta_y != delta_y) + { + // restore everything by left + new_rect.mTop = orig_rect.mTop; + new_rect.mLeft = orig_rect.mLeft; + new_rect.mRight = orig_rect.mRight; + mResizingView->setShape(new_rect, true); + } mDragLastScreenY += new_rect.mBottom- orig_rect.mBottom; break; + } default: break; } diff --git a/indra/llui/llresizehandle.cpp b/indra/llui/llresizehandle.cpp index c3a51c36c9..24794305ac 100644 --- a/indra/llui/llresizehandle.cpp +++ b/indra/llui/llresizehandle.cpp @@ -257,23 +257,65 @@ BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask) // update last valid mouse cursor position based on resized view's actual size LLRect new_rect = resizing_view->getRect(); + S32 actual_delta_x = 0; + S32 actual_delta_y = 0; switch(mCorner) { case LEFT_TOP: - mDragLastScreenX += new_rect.mLeft - orig_rect.mLeft; - mDragLastScreenY += new_rect.mTop - orig_rect.mTop; + actual_delta_x = new_rect.mLeft - orig_rect.mLeft; + actual_delta_y = new_rect.mTop - orig_rect.mTop; + if (actual_delta_x != delta_x + || actual_delta_y != delta_y) + { + new_rect.mRight = orig_rect.mRight; + new_rect.mBottom = orig_rect.mBottom; + resizing_view->setShape(new_rect, true); + } + + mDragLastScreenX += actual_delta_x; + mDragLastScreenY += actual_delta_y; break; case LEFT_BOTTOM: - mDragLastScreenX += new_rect.mLeft - orig_rect.mLeft; - mDragLastScreenY += new_rect.mBottom- orig_rect.mBottom; + actual_delta_x = new_rect.mLeft - orig_rect.mLeft; + actual_delta_y = new_rect.mBottom - orig_rect.mBottom; + if (actual_delta_x != delta_x + || actual_delta_y != delta_y) + { + new_rect.mRight = orig_rect.mRight; + new_rect.mTop = orig_rect.mTop; + resizing_view->setShape(new_rect, true); + } + + mDragLastScreenX += actual_delta_x; + mDragLastScreenY += actual_delta_y; break; case RIGHT_TOP: - mDragLastScreenX += new_rect.mRight - orig_rect.mRight; - mDragLastScreenY += new_rect.mTop - orig_rect.mTop; + actual_delta_x = new_rect.mRight - orig_rect.mRight; + actual_delta_y = new_rect.mTop - orig_rect.mTop; + if (actual_delta_x != delta_x + || actual_delta_y != delta_y) + { + new_rect.mLeft = orig_rect.mLeft; + new_rect.mBottom = orig_rect.mBottom; + resizing_view->setShape(new_rect, true); + } + + mDragLastScreenX += actual_delta_x; + mDragLastScreenY += actual_delta_y; break; case RIGHT_BOTTOM: - mDragLastScreenX += new_rect.mRight - orig_rect.mRight; - mDragLastScreenY += new_rect.mBottom- orig_rect.mBottom; + actual_delta_x = new_rect.mRight - orig_rect.mRight; + actual_delta_y = new_rect.mBottom - orig_rect.mBottom; + if (actual_delta_x != delta_x + || actual_delta_y != delta_y) + { + new_rect.mLeft = orig_rect.mLeft; + new_rect.mTop = orig_rect.mTop; + resizing_view->setShape(new_rect, true); + } + + mDragLastScreenX += actual_delta_x; + mDragLastScreenY += actual_delta_y; break; default: break; diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 562bbc7100..2f120479d9 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -240,7 +240,8 @@ LLTextEditor::Params::Params() auto_indent("auto_indent", true), default_color("default_color"), commit_on_focus_lost("commit_on_focus_lost", false), - show_context_menu("show_context_menu") + show_context_menu("show_context_menu"), + enable_tooltip_paste("enable_tooltip_paste") { addSynonym(prevalidate_callback, "text_type"); } @@ -262,6 +263,7 @@ LLTextEditor::LLTextEditor(const LLTextEditor::Params& p) : mPrevalidateFunc(p.prevalidate_callback()), mContextMenu(NULL), mShowContextMenu(p.show_context_menu), + mEnableTooltipPaste(p.enable_tooltip_paste), mPassDelete(FALSE) { mSourceID.generate(); @@ -1433,6 +1435,23 @@ void LLTextEditor::pasteHelper(bool is_primary) // Clean up string (replace tabs and remove characters that our fonts don't support). LLWString clean_string(paste); + cleanStringForPaste(clean_string); + + // Insert the new text into the existing text. + + //paste text with linebreaks. + pasteTextWithLinebreaks(clean_string); + + deselect(); + + onKeyStroke(); + mParseOnTheFly = TRUE; +} + + +// Clean up string (replace tabs and remove characters that our fonts don't support). +void LLTextEditor::cleanStringForPaste(LLWString & clean_string) +{ LLWStringUtil::replaceTabsWithSpaces(clean_string, SPACES_PER_TAB); if( mAllowEmbeddedItems ) { @@ -1451,10 +1470,11 @@ void LLTextEditor::pasteHelper(bool is_primary) } } } +} - // Insert the new text into the existing text. - //paste text with linebreaks. +void LLTextEditor::pasteTextWithLinebreaks(LLWString & clean_string) +{ std::basic_string<llwchar>::size_type start = 0; std::basic_string<llwchar>::size_type pos = clean_string.find('\n',start); @@ -1473,15 +1493,8 @@ void LLTextEditor::pasteHelper(bool is_primary) std::basic_string<llwchar> str = std::basic_string<llwchar>(clean_string,start,clean_string.length()-start); setCursorPos(mCursorPos + insert(mCursorPos, str, FALSE, LLTextSegmentPtr())); - - deselect(); - - onKeyStroke(); - mParseOnTheFly = TRUE; } - - // copy selection to primary void LLTextEditor::copyPrimary() { @@ -1705,19 +1718,50 @@ BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask ) { return FALSE; } - + if (mReadOnly && mScroller) { handled = (mScroller && mScroller->handleKeyHere( key, mask )) || handleSelectionKey(key, mask) || handleControlKey(key, mask); + } + else + { + if (mEnableTooltipPaste && + LLToolTipMgr::instance().toolTipVisible() && + KEY_TAB == key) + { // Paste the first line of a tooltip into the editor + std::string message; + LLToolTipMgr::instance().getToolTipMessage(message); + LLWString tool_tip_text(utf8str_to_wstring(message)); + + if (tool_tip_text.size() > 0) + { + // Delete any selected characters (the tooltip text replaces them) + if(hasSelection()) + { + deleteSelection(TRUE); + } + + std::basic_string<llwchar>::size_type pos = tool_tip_text.find('\n',0); + if (pos != -1) + { // Extract the first line of the tooltip + tool_tip_text = std::basic_string<llwchar>(tool_tip_text, 0, pos); + } + + // Add the text + cleanStringForPaste(tool_tip_text); + pasteTextWithLinebreaks(tool_tip_text); + handled = TRUE; + } + } + else + { // Normal key handling + handled = handleNavigationKey( key, mask ) + || handleSelectionKey(key, mask) + || handleControlKey(key, mask) + || handleSpecialKey(key, mask); } - else - { - handled = handleNavigationKey( key, mask ) - || handleSelectionKey(key, mask) - || handleControlKey(key, mask) - || handleSpecialKey(key, mask); } if( handled ) diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index 5e189070fa..969e072704 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -65,6 +65,7 @@ public: show_line_numbers, commit_on_focus_lost, show_context_menu, + enable_tooltip_paste, auto_indent; //colors @@ -297,6 +298,8 @@ private: // Methods // void pasteHelper(bool is_primary); + void cleanStringForPaste(LLWString & clean_string); + void pasteTextWithLinebreaks(LLWString & clean_string); void drawLineNumbers(); @@ -330,6 +333,7 @@ private: BOOL mAllowEmbeddedItems; bool mShowContextMenu; bool mParseOnTheFly; + bool mEnableTooltipPaste; bool mPassDelete; LLUUID mSourceID; diff --git a/indra/llui/lltoggleablemenu.h b/indra/llui/lltoggleablemenu.h index 57b8f62eb6..dfe70cbf54 100644 --- a/indra/llui/lltoggleablemenu.h +++ b/indra/llui/lltoggleablemenu.h @@ -48,7 +48,7 @@ public: virtual void handleVisibilityChange (BOOL curVisibilityIn); virtual bool addChild (LLView* view, S32 tab_group = 0); - + const LLRect& getButtonRect() const { return mButtonRect; } // Converts the given local button rect to a screen rect diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 1aa46806c3..071046fe6d 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -117,7 +117,8 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) mButtonEnterSignal(NULL), mButtonLeaveSignal(NULL), mButtonRemoveSignal(NULL), - mDragAndDropTarget(false) + mDragAndDropTarget(false), + mCaretIcon(NULL) { mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT] = p.button_icon_and_text; mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_ONLY] = p.button_icon; @@ -830,7 +831,12 @@ void LLToolBar::draw() LLUI::translate((F32)getRect().mLeft, (F32)getRect().mBottom); // Position the caret - LLIconCtrl* caret = getChild<LLIconCtrl>("caret"); + if (!mCaretIcon) + { + mCaretIcon = getChild<LLIconCtrl>("caret"); + } + + LLIconCtrl* caret = mCaretIcon; caret->setVisible(FALSE); if (mDragAndDropTarget && !mButtonCommands.empty()) { diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index a50c60282c..31424a36d4 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -37,6 +37,7 @@ class LLToolBar; class LLToolBarButton; +class LLIconCtrl; typedef boost::function<void (S32 x, S32 y, LLToolBarButton* button)> tool_startdrag_callback_t; typedef boost::function<BOOL (S32 x, S32 y, const LLUUID& uuid, LLAssetType::EType type)> tool_handledrag_callback_t; @@ -284,6 +285,8 @@ private: button_signal_t* mButtonRemoveSignal; std::string mButtonTooltipSuffix; + + LLIconCtrl* mCaretIcon; }; diff --git a/indra/llui/lltooltip.cpp b/indra/llui/lltooltip.cpp index d4670efedf..f52a3b3323 100644 --- a/indra/llui/lltooltip.cpp +++ b/indra/llui/lltooltip.cpp @@ -390,6 +390,15 @@ bool LLToolTip::hasClickCallback() return mHasClickCallback; } +void LLToolTip::getToolTipMessage(std::string & message) +{ + if (mTextBox) + { + message = mTextBox->getText(); + } +} + + // // LLToolTipMgr @@ -594,5 +603,14 @@ void LLToolTipMgr::updateToolTipVisibility() } +// Return the current tooltip text +void LLToolTipMgr::getToolTipMessage(std::string & message) +{ + if (toolTipVisible()) + { + mToolTip->getToolTipMessage(message); + } +} + // EOF diff --git a/indra/llui/lltooltip.h b/indra/llui/lltooltip.h index d71a944c3d..fad127fc4c 100644 --- a/indra/llui/lltooltip.h +++ b/indra/llui/lltooltip.h @@ -105,6 +105,8 @@ public: LLToolTip(const Params& p); void initFromParams(const LLToolTip::Params& params); + void getToolTipMessage(std::string & message); + private: class LLTextBox* mTextBox; class LLButton* mInfoButton; @@ -142,6 +144,8 @@ public: LLRect getMouseNearRect(); void updateToolTipVisibility(); + void getToolTipMessage(std::string & message); + private: void createToolTip(const LLToolTip::Params& params); |