diff options
author | James Cook <james@lindenlab.com> | 2008-04-30 23:30:09 +0000 |
---|---|---|
committer | James Cook <james@lindenlab.com> | 2008-04-30 23:30:09 +0000 |
commit | 36fccc3888c5dc318a8a235da8a5cae4faeb637d (patch) | |
tree | 021e439fe9fa3a285062d70bf0b8c0f799471681 /indra/llui | |
parent | cf2a96375f62316b98c2dddd57f812f7565584be (diff) |
svn merge -r 86190:86191 maint-ui-11-merge (EFFECTIVE MERGE: -r 84579:85724 maint-ui-11-qa).
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llcombobox.cpp | 2 | ||||
-rw-r--r-- | indra/llui/lllineeditor.cpp | 9 | ||||
-rw-r--r-- | indra/llui/lllineeditor.h | 4 | ||||
-rw-r--r-- | indra/llui/llresizebar.cpp | 11 | ||||
-rw-r--r-- | indra/llui/llresizebar.h | 2 | ||||
-rw-r--r-- | indra/llui/llstyle.h | 9 | ||||
-rw-r--r-- | indra/llui/lltexteditor.cpp | 90 | ||||
-rw-r--r-- | indra/llui/lltexteditor.h | 18 |
8 files changed, 84 insertions, 61 deletions
diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp index 3dd99a4636..538641d060 100644 --- a/indra/llui/llcombobox.cpp +++ b/indra/llui/llcombobox.cpp @@ -565,6 +565,8 @@ void LLComboBox::showList() S32 min_width = getRect().getWidth(); S32 max_width = llmax(min_width, MAX_COMBO_WIDTH); + // make sure we have up to date content width metrics + mList->calcColumnWidths(); S32 list_width = llclamp(mList->getMaxContentWidth(), min_width, max_width); if (mListPosition == BELOW) diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index b54470d44a..90e0552861 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -132,7 +132,8 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect, mSelectAllonFocusReceived( FALSE ), mPassDelete(FALSE), mReadOnly(FALSE), - mImage( sImage ) + mImage( sImage ), + mReplaceNewlinesWithSpaces( TRUE ) { llassert( max_length_bytes > 0 ); @@ -961,7 +962,7 @@ void LLLineEditor::paste() LLWString clean_string(paste); LLWString::replaceTabsWithSpaces(clean_string, 1); //clean_string = wstring_detabify(paste, 1); - LLWString::replaceChar(clean_string, '\n', ' '); + LLWString::replaceChar(clean_string, '\n', mReplaceNewlinesWithSpaces ? ' ' : 182); // 182 == paragraph character // Insert the string @@ -2547,6 +2548,10 @@ S32 LLLineEditor::getPreeditFontSize() const return llround(mGLFont->getLineHeight() * LLUI::sGLScaleFactor.mV[VY]); } +void LLLineEditor::setReplaceNewlinesWithSpaces(BOOL replace) +{ + mReplaceNewlinesWithSpaces = replace; +} static LLRegisterWidget<LLSearchEditor> r2("search_editor"); diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index f5d7ecd4c4..8b41dd1d87 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -211,6 +211,8 @@ public: void setEnableLineHistory( BOOL enabled ) { mHaveHistory = enabled; } // switches line history on or off void updateHistory(); // stores current line in history + void setReplaceNewlinesWithSpaces(BOOL replace); + private: // private helper methods void removeChar(); @@ -311,6 +313,8 @@ private: // Instances that by default point to the statics but can be overidden in XML. LLPointer<LLUIImage> mImage; + BOOL mReplaceNewlinesWithSpaces; // if false, will replace pasted newlines with paragraph symbol. + // private helper class class LLLineEditorRollback { diff --git a/indra/llui/llresizebar.cpp b/indra/llui/llresizebar.cpp index e82e93a7ba..82be9672b6 100644 --- a/indra/llui/llresizebar.cpp +++ b/indra/llui/llresizebar.cpp @@ -50,6 +50,7 @@ LLResizeBar::LLResizeBar( const LLString& name, LLView* resizing_view, const LLR mMaxSize( max_size ), mSide( side ), mSnappingEnabled(TRUE), + mAllowDoubleClickSnapping(TRUE), mResizingView(resizing_view) { // set up some generically good follow code. @@ -260,27 +261,31 @@ BOOL LLResizeBar::handleDoubleClick(S32 x, S32 y, MASK mask) LLRect orig_rect = mResizingView->getRect(); LLRect scaled_rect = orig_rect; - if (mSnappingEnabled) + if (mSnappingEnabled && mAllowDoubleClickSnapping) { switch( mSide ) { case LEFT: mResizingView->findSnapEdge(scaled_rect.mLeft, LLCoordGL(0, 0), SNAP_LEFT, SNAP_PARENT_AND_SIBLINGS, S32_MAX); + scaled_rect.mLeft = scaled_rect.mRight - llclamp(scaled_rect.getWidth(), mMinSize, mMaxSize); break; case TOP: mResizingView->findSnapEdge(scaled_rect.mTop, LLCoordGL(0, 0), SNAP_TOP, SNAP_PARENT_AND_SIBLINGS, S32_MAX); + scaled_rect.mTop = scaled_rect.mBottom + llclamp(scaled_rect.getHeight(), mMinSize, mMaxSize); break; case RIGHT: mResizingView->findSnapEdge(scaled_rect.mRight, LLCoordGL(0, 0), SNAP_RIGHT, SNAP_PARENT_AND_SIBLINGS, S32_MAX); + scaled_rect.mRight = scaled_rect.mLeft + llclamp(scaled_rect.getWidth(), mMinSize, mMaxSize); break; case BOTTOM: mResizingView->findSnapEdge(scaled_rect.mBottom, LLCoordGL(0, 0), SNAP_BOTTOM, SNAP_PARENT_AND_SIBLINGS, S32_MAX); + scaled_rect.mBottom = scaled_rect.mTop - llclamp(scaled_rect.getHeight(), mMinSize, mMaxSize); break; } + + mResizingView->userSetShape(scaled_rect); } - mResizingView->reshape(scaled_rect.getWidth(), scaled_rect.getHeight()); - mResizingView->setOrigin(scaled_rect.mLeft, scaled_rect.mBottom); return TRUE; } diff --git a/indra/llui/llresizebar.h b/indra/llui/llresizebar.h index f45653cbad..b760abf13d 100644 --- a/indra/llui/llresizebar.h +++ b/indra/llui/llresizebar.h @@ -50,6 +50,7 @@ public: void setResizeLimits( S32 min_size, S32 max_size ) { mMinSize = min_size; mMaxSize = max_size; } void setEnableSnapping(BOOL enable) { mSnappingEnabled = enable; } + void setAllowDoubleClickSnapping(BOOL allow) { mAllowDoubleClickSnapping = allow; } private: S32 mDragLastScreenX; @@ -61,6 +62,7 @@ private: S32 mMaxSize; const Side mSide; BOOL mSnappingEnabled; + BOOL mAllowDoubleClickSnapping; LLView* mResizingView; }; diff --git a/indra/llui/llstyle.h b/indra/llui/llstyle.h index 8b82a84b46..6896ee288f 100644 --- a/indra/llui/llstyle.h +++ b/indra/llui/llstyle.h @@ -37,7 +37,7 @@ #include "llfont.h" #include "llui.h" -class LLStyle +class LLStyle : public LLRefCount { public: LLStyle(); @@ -46,8 +46,6 @@ public: LLStyle &operator=(const LLStyle &rhs); - virtual ~LLStyle() { } - virtual void init (BOOL is_visible, const LLColor4 &color, const LLString& font_name); virtual const LLColor4& getColor() const { return mColor; } @@ -101,6 +99,9 @@ public: S32 mImageWidth; S32 mImageHeight; +protected: + virtual ~LLStyle() { } + private: BOOL mVisible; LLColor4 mColor; @@ -111,4 +112,6 @@ private: BOOL mIsEmbeddedItem; }; +typedef LLPointer<LLStyle> LLStyleSP; + #endif // LL_LLSTYLE_H diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 7c8c0fe81c..5617eb4873 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -1244,14 +1244,14 @@ BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask) const LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y ); if( cur_segment ) { - if(cur_segment->getStyle().isLink()) + if(cur_segment->getStyle()->isLink()) { lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (over link, inactive)" << llendl; getWindow()->setCursor(UI_CURSOR_HAND); handled = TRUE; } else - if(cur_segment->getStyle().getIsEmbeddedItem()) + if(cur_segment->getStyle()->getIsEmbeddedItem()) { lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (over embedded item, inactive)" << llendl; getWindow()->setCursor(UI_CURSOR_HAND); @@ -2928,23 +2928,26 @@ void LLTextEditor::drawText() S32 clipped_len = clipped_end - seg_start; if( clipped_len > 0 ) { - LLStyle style = cur_segment->getStyle(); - if ( style.isImage() && (cur_segment->getStart() >= seg_start) && (cur_segment->getStart() <= clipped_end)) + LLStyleSP style = cur_segment->getStyle(); + if ( style->isImage() && (cur_segment->getStart() >= seg_start) && (cur_segment->getStart() <= clipped_end)) { - LLUIImagePtr image = style.getImage(); - image->draw(llround(text_x), llround(text_y)+line_height-style.mImageHeight, style.mImageWidth, style.mImageHeight); + S32 style_image_height = style->mImageHeight; + S32 style_image_width = style->mImageWidth; + LLUIImagePtr image = style->getImage(); + image->draw(llround(text_x), llround(text_y)+line_height-style_image_height, + style_image_width, style_image_height); } - if (cur_segment == mHoverSegment && style.getIsEmbeddedItem()) + if (cur_segment == mHoverSegment && style->getIsEmbeddedItem()) { - style.mUnderline = TRUE; + style->mUnderline = TRUE; } S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); if ( (mParseHTML) && (left_pos > seg_start) && (left_pos < clipped_end) && mIsSelecting && (mSelectionStart == mSelectionEnd) ) { - mHTML = style.getLinkHREF(); + mHTML = style->getLinkHREF(); } drawClippedSegment( text, seg_start, clipped_end, text_x, text_y, selection_left, selection_right, style, &text_x ); @@ -2963,38 +2966,38 @@ void LLTextEditor::drawText() } // Draws a single text segment, reversing the color for selection if needed. -void LLTextEditor::drawClippedSegment(const LLWString &text, S32 seg_start, S32 seg_end, F32 x, F32 y, S32 selection_left, S32 selection_right, const LLStyle& style, F32* right_x ) +void LLTextEditor::drawClippedSegment(const LLWString &text, S32 seg_start, S32 seg_end, F32 x, F32 y, S32 selection_left, S32 selection_right, const LLStyleSP& style, F32* right_x ) { - if (!style.isVisible()) + if (!style->isVisible()) { return; } const LLFontGL* font = mGLFont; - LLColor4 color = style.getColor(); + LLColor4 color = style->getColor(); - if ( style.getFontString()[0] ) + if ( style->getFontString()[0] ) { - font = LLResMgr::getInstance()->getRes(style.getFontID()); + font = LLResMgr::getInstance()->getRes(style->getFontID()); } U8 font_flags = LLFontGL::NORMAL; - if (style.mBold) + if (style->mBold) { font_flags |= LLFontGL::BOLD; } - if (style.mItalic) + if (style->mItalic) { font_flags |= LLFontGL::ITALIC; } - if (style.mUnderline) + if (style->mUnderline) { font_flags |= LLFontGL::UNDERLINE; } - if (style.getIsEmbeddedItem()) + if (style->getIsEmbeddedItem()) { if (mReadOnly) { @@ -3434,17 +3437,17 @@ void LLTextEditor::appendColoredText(const LLString &new_text, const LLColor4 &color, const LLString& font_name) { - LLStyle style; - style.setVisible(true); - style.setColor(color); - style.setFontName(font_name); + LLStyleSP style(new LLStyle); + style->setVisible(true); + style->setColor(color); + style->setFontName(font_name); appendStyledText(new_text, allow_undo, prepend_newline, &style); } void LLTextEditor::appendStyledText(const LLString &new_text, bool allow_undo, bool prepend_newline, - const LLStyle* style) + const LLStyleSP *stylep) { if(mParseHTML) { @@ -3453,17 +3456,17 @@ void LLTextEditor::appendStyledText(const LLString &new_text, LLString text = new_text; while ( findHTML(text, &start, &end) ) { - LLStyle html; - html.setVisible(true); - html.setColor(mLinkColor); - if (style) + LLStyleSP html(new LLStyle); + html->setVisible(true); + html->setColor(mLinkColor); + if (stylep) { - html.setFontName(style->getFontString()); + html->setFontName((*stylep)->getFontString()); } - html.mUnderline = TRUE; + html->mUnderline = TRUE; - if (start > 0) appendText(text.substr(0,start),allow_undo, prepend_newline, style); - html.setLinkHREF(text.substr(start,end-start)); + if (start > 0) appendText(text.substr(0,start),allow_undo, prepend_newline, stylep); + html->setLinkHREF(text.substr(start,end-start)); appendText(text.substr(start, end-start),allow_undo, prepend_newline, &html); if (end < (S32)text.length()) { @@ -3475,17 +3478,17 @@ void LLTextEditor::appendStyledText(const LLString &new_text, break; } } - if (end < (S32)text.length()) appendText(text,allow_undo, prepend_newline, style); + if (end < (S32)text.length()) appendText(text,allow_undo, prepend_newline, stylep); } else { - appendText(new_text, allow_undo, prepend_newline, style); + appendText(new_text, allow_undo, prepend_newline, stylep); } } // Appends new text to end of document void LLTextEditor::appendText(const LLString &new_text, bool allow_undo, bool prepend_newline, - const LLStyle* segment_style) + const LLStyleSP *stylep) { // Save old state BOOL was_scrolled_to_bottom = (mScrollbar->getDocPos() == mScrollbar->getDocPosMax()); @@ -3513,11 +3516,11 @@ void LLTextEditor::appendText(const LLString &new_text, bool allow_undo, bool pr append(utf8str_to_wstring(new_text), TRUE ); } - if (segment_style) + if (stylep) { S32 segment_start = old_length; S32 segment_end = getLength(); - LLTextSegment* segment = new LLTextSegment(*segment_style, segment_start, segment_end ); + LLTextSegment* segment = new LLTextSegment(*stylep, segment_start, segment_end ); mSegments.push_back(segment); } @@ -3803,8 +3806,8 @@ void LLTextEditor::findEmbeddedItemSegments() in_text = TRUE; } - LLStyle embedded_style; - embedded_style.setIsEmbeddedItem( TRUE ); + LLStyleSP embedded_style(new LLStyle); + embedded_style->setIsEmbeddedItem( TRUE ); // Start with i just after the first embedded item while ( text[idx] ) @@ -4003,7 +4006,7 @@ BOOL LLTextEditor::exportBuffer(LLString &buffer ) LLTextSegment::LLTextSegment(S32 start) : mStart(start) { } -LLTextSegment::LLTextSegment( const LLStyle& style, S32 start, S32 end ) : +LLTextSegment::LLTextSegment( const LLStyleSP& style, S32 start, S32 end ) : mStyle( style ), mStart( start), mEnd( end ), @@ -4011,9 +4014,8 @@ LLTextSegment::LLTextSegment( const LLStyle& style, S32 start, S32 end ) : mIsDefault(FALSE) { } -LLTextSegment::LLTextSegment( - const LLColor4& color, S32 start, S32 end, BOOL is_visible) : - mStyle( is_visible, color,"" ), +LLTextSegment::LLTextSegment( const LLColor4& color, S32 start, S32 end, BOOL is_visible) : + mStyle(new LLStyle(is_visible,color,"")), mStart( start), mEnd( end ), mToken(NULL), @@ -4021,7 +4023,7 @@ LLTextSegment::LLTextSegment( { } LLTextSegment::LLTextSegment( const LLColor4& color, S32 start, S32 end ) : - mStyle( TRUE, color,"" ), + mStyle(new LLStyle(TRUE, color,"" )), mStart( start), mEnd( end ), mToken(NULL), @@ -4029,7 +4031,7 @@ LLTextSegment::LLTextSegment( const LLColor4& color, S32 start, S32 end ) : { } LLTextSegment::LLTextSegment( const LLColor3& color, S32 start, S32 end ) : - mStyle( TRUE, color,"" ), + mStyle(new LLStyle(TRUE, color,"" )), mStart( start), mEnd( end ), mToken(NULL), diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index 00dc70ba92..af2dbcfd5f 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -139,7 +139,7 @@ public: void insertText(const LLString &text); // appends text at end void appendText(const LLString &wtext, bool allow_undo, bool prepend_newline, - const LLStyle* segment_style = NULL); + const LLStyleSP *stylep = NULL); void appendColoredText(const LLString &wtext, bool allow_undo, bool prepend_newline, @@ -148,7 +148,7 @@ public: // if styled text starts a line, you need to prepend a newline. void appendStyledText(const LLString &new_text, bool allow_undo, bool prepend_newline, - const LLStyle* style); + const LLStyleSP *stylep = NULL); // Removes text from the end of document // Does not change highlight or cursor position. @@ -429,7 +429,7 @@ private: void drawSelectionBackground(); void drawCursor(); void drawText(); - void drawClippedSegment(const LLWString &wtext, S32 seg_start, S32 seg_end, F32 x, F32 y, S32 selection_left, S32 selection_right, const LLStyle& color, F32* right_x); + void drawClippedSegment(const LLWString &wtext, S32 seg_start, S32 seg_end, F32 x, F32 y, S32 selection_left, S32 selection_right, const LLStyleSP& color, F32* right_x); // // Data @@ -528,7 +528,7 @@ class LLTextSegment public: // for creating a compare value LLTextSegment(S32 start); - LLTextSegment( const LLStyle& style, S32 start, S32 end ); + LLTextSegment( const LLStyleSP& style, S32 start, S32 end ); LLTextSegment( const LLColor4& color, S32 start, S32 end, BOOL is_visible); LLTextSegment( const LLColor4& color, S32 start, S32 end ); LLTextSegment( const LLColor3& color, S32 start, S32 end ); @@ -536,10 +536,10 @@ public: S32 getStart() const { return mStart; } S32 getEnd() const { return mEnd; } void setEnd( S32 end ) { mEnd = end; } - const LLColor4& getColor() const { return mStyle.getColor(); } - void setColor(const LLColor4 &color) { mStyle.setColor(color); } - const LLStyle& getStyle() const { return mStyle; } - void setStyle(const LLStyle &style) { mStyle = style; } + const LLColor4& getColor() const { return mStyle->getColor(); } + void setColor(const LLColor4 &color) { mStyle->setColor(color); } + const LLStyleSP& getStyle() const { return mStyle; } + void setStyle(const LLStyleSP &style) { mStyle = style; } void setIsDefault(BOOL b) { mIsDefault = b; } BOOL getIsDefault() const { return mIsDefault; } void setToken( LLKeywordToken* token ) { mToken = token; } @@ -557,7 +557,7 @@ public: }; private: - LLStyle mStyle; + LLStyleSP mStyle; S32 mStart; S32 mEnd; LLKeywordToken* mToken; |