From 9ec432034dc3c45d7ce763eb02dae4cc7f6b8da8 Mon Sep 17 00:00:00 2001 From: Steven Bennetts Date: Sun, 21 Jun 2009 08:04:56 +0000 Subject: merge -r 122421-124917 viewer-2.0.0-2 -> viewer-2.0.0-3 ignore-dead-branch --- indra/llui/lltextbox.cpp | 249 +++++++++++++++++++---------------------------- 1 file changed, 100 insertions(+), 149 deletions(-) (limited to 'indra/llui/lltextbox.cpp') diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index 89893bcf8d..464e4be809 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -30,65 +30,66 @@ * $/LicenseInfo$ */ +#define INSTANTIATE_GETCHILD_TEXTBOX + #include "linden_common.h" #include "lltextbox.h" #include "lluictrlfactory.h" #include "llfocusmgr.h" #include "llwindow.h" -static LLRegisterWidget r("text"); - -LLTextBox::LLTextBox(const std::string& name, const LLRect& rect, const std::string& text, - const LLFontGL* font, BOOL mouse_opaque) -: LLUICtrl(name, rect, mouse_opaque, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP ), - mFontGL(font ? font : LLFontGL::getFontSansSerifSmall()) -{ - initDefaults(); - setText( text ); - setTabStop(FALSE); -} - -LLTextBox::LLTextBox(const std::string& name, const std::string& text, F32 max_width, - const LLFontGL* font, BOOL mouse_opaque) : - LLUICtrl(name, LLRect(0, 0, 1, 1), mouse_opaque, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP), - mFontGL(font ? font : LLFontGL::getFontSansSerifSmall()) -{ - initDefaults(); - setWrappedText(text, max_width); - reshapeToFitText(); - setTabStop(FALSE); -} - -LLTextBox::LLTextBox(const std::string& name_and_label, const LLRect& rect) : - LLUICtrl(name_and_label, rect, TRUE, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP), - mFontGL(LLFontGL::getFontSansSerifSmall()) -{ - initDefaults(); - setText( name_and_label ); - setTabStop(FALSE); -} - -void LLTextBox::initDefaults() +template LLTextBox* LLView::getChild( const std::string& name, BOOL recurse, BOOL create_if_missing ) const; + +static LLDefaultWidgetRegistry::Register r("text"); + +LLTextBox::Params::Params() +: text_color("text_color"), + length("length"), + type("type"), + highlight_on_hover("hover", false), + border_visible("border_visible", false), + border_drop_shadow_visible("border_drop_shadow_visible", false), + bg_visible("bg_visible", false), + use_ellipses("use_ellipses"), + word_wrap("word_wrap", false), + drop_shadow_visible("drop_shadow_visible"), + hover_color("hover_color"), + disabled_color("disabled_color"), + background_color("background_color"), + border_color("border_color"), + v_pad("v_pad", 0), + h_pad("h_pad", 0), + line_spacing("line_spacing", 0), + text("text"), + font_shadow("font_shadow", LLFontGL::NO_SHADOW) +{} + +LLTextBox::LLTextBox(const LLTextBox::Params& p) +: LLUICtrl(p), + mFontGL(p.font), + mHoverActive( p.highlight_on_hover ), + mHasHover( FALSE ), + mBackgroundVisible( p.bg_visible ), + mBorderVisible( p.border_visible ), + mShadowType( p.font_shadow ), + mBorderDropShadowVisible( p.border_drop_shadow_visible ), + mUseEllipses( p.use_ellipses ), + mHPad(p.h_pad), + mVPad(p.v_pad), + mVAlign( LLFontGL::TOP ), + mClickedCallback(NULL), + mTextColor(p.text_color()), + mDisabledColor(p.disabled_color()), + mBackgroundColor(p.background_color()), + mBorderColor(p.border_color()), + mHoverColor(p.hover_color()), + mHAlign(p.font_halign), + mLineSpacing(p.line_spacing), + mWordWrap( p.word_wrap ), + mDidWordWrap(FALSE), + mFontStyle(LLFontGL::getStyleFromString(p.font.style)) { - mTextColor = LLUI::sColorsGroup->getColor("LabelTextColor"); - mDisabledColor = LLUI::sColorsGroup->getColor("LabelDisabledColor"); - mBackgroundColor = LLUI::sColorsGroup->getColor("DefaultBackgroundColor"); - mBorderColor = LLUI::sColorsGroup->getColor("DefaultHighlightLight"); - mHoverColor = LLUI::sColorsGroup->getColor( "LabelSelectedColor" ); - mHoverActive = FALSE; - mHasHover = FALSE; - mBackgroundVisible = FALSE; - mBorderVisible = FALSE; - mFontStyle = LLFontGL::DROP_SHADOW_SOFT; - mBorderDropShadowVisible = FALSE; - mUseEllipses = FALSE; - mLineSpacing = 0; - mHPad = 0; - mVPad = 0; - mHAlign = LLFontGL::LEFT; - mVAlign = LLFontGL::TOP; - mClickedCallback = NULL; - mCallbackUserData = NULL; + setText( p.text() ); } BOOL LLTextBox::handleMouseDown(S32 x, S32 y, MASK mask) @@ -113,7 +114,6 @@ BOOL LLTextBox::handleMouseDown(S32 x, S32 y, MASK mask) return handled; } - BOOL LLTextBox::handleMouseUp(S32 x, S32 y, MASK mask) { BOOL handled = FALSE; @@ -139,7 +139,7 @@ BOOL LLTextBox::handleMouseUp(S32 x, S32 y, MASK mask) // If mouseup in the widget, it's been clicked if (mClickedCallback) { - (*mClickedCallback)( mCallbackUserData ); + mClickedCallback(); } } @@ -160,8 +160,15 @@ BOOL LLTextBox::handleHover(S32 x, S32 y, MASK mask) void LLTextBox::setText(const LLStringExplicit& text) { - mText.assign(text); - setLineLengths(); + if(mWordWrap && !mDidWordWrap) + { + setWrappedText(text); + } + else + { + mText.assign(text); + setLineLengths(); + } } void LLTextBox::setLineLengths() @@ -193,7 +200,7 @@ void LLTextBox::setLineLengths() void LLTextBox::setWrappedText(const LLStringExplicit& in_text, F32 max_width) { - if (max_width < 0.0) + if (max_width < 0.0f) { max_width = (F32)getRect().getWidth(); } @@ -203,7 +210,8 @@ void LLTextBox::setWrappedText(const LLStringExplicit& in_text, F32 max_width) LLWString::size_type cur = 0;; LLWString::size_type len = wtext.size(); - + F32 line_height = mFontGL->getLineHeight(); + S32 line_num = 1; while (cur < len) { LLWString::size_type end = wtext.find('\n', cur); @@ -221,6 +229,8 @@ void LLTextBox::setWrappedText(const LLStringExplicit& in_text, F32 max_width) final_wtext.append(wtext, cur, useLen); cur += useLen; + // not enough room to add any more characters + if (useLen == 0) break; } if (cur < len) @@ -229,12 +239,22 @@ void LLTextBox::setWrappedText(const LLStringExplicit& in_text, F32 max_width) { cur += 1; } - final_wtext += '\n'; + line_num +=1; + // Don't wrap the last line if the text is going to spill off + // the bottom of the rectangle. Assume we prefer to run off + // the right edge. + // *TODO: Is this the right behavior? + if((line_num-1)*line_height <= (F32)getRect().getHeight()) + { + final_wtext += '\n'; + } } } - + + mDidWordWrap = TRUE; std::string final_text = wstring_to_utf8str(final_wtext); setText(final_text); + } S32 LLTextBox::getTextPixelWidth() @@ -272,6 +292,11 @@ S32 LLTextBox::getTextPixelHeight() return (S32)(num_lines * mFontGL->getLineHeight()); } +void LLTextBox::setValue(const LLSD& value ) +{ + mDidWordWrap = FALSE; + setText(value.asString()); +} BOOL LLTextBox::setTextArg( const std::string& key, const LLStringExplicit& text ) { @@ -289,8 +314,8 @@ void LLTextBox::draw() if( mBorderDropShadowVisible ) { - static LLColor4 color_drop_shadow = LLUI::sColorsGroup->getColor("ColorDropShadow"); - static S32 drop_shadow_tooltip = LLUI::sConfigGroup->getS32("DropShadowTooltip"); + static LLUICachedControl color_drop_shadow ("ColorDropShadow", *(new LLColor4)); + static LLUICachedControl drop_shadow_tooltip ("DropShadowTooltip", 0); gl_drop_shadow(0, getRect().getHeight(), getRect().getWidth(), 0, color_drop_shadow, drop_shadow_tooltip); } @@ -298,7 +323,7 @@ void LLTextBox::draw() if (mBackgroundVisible) { LLRect r( 0, getRect().getHeight(), getRect().getWidth(), 0 ); - gl_rect_2d( r, mBackgroundColor ); + gl_rect_2d( r, mBackgroundColor.get() ); } S32 text_x = 0; @@ -321,16 +346,16 @@ void LLTextBox::draw() { if(mHasHover) { - drawText( text_x, text_y, mHoverColor ); + drawText( text_x, text_y, mHoverColor.get() ); } else { - drawText( text_x, text_y, mTextColor ); + drawText( text_x, text_y, mTextColor.get() ); } } else { - drawText( text_x, text_y, mDisabledColor ); + drawText( text_x, text_y, mDisabledColor.get() ); } if (sDebugRects) @@ -338,6 +363,13 @@ void LLTextBox::draw() drawDebugRect(); } + //// *HACK: also draw debug rectangles around currently-being-edited LLView, and any elements that are being highlighted by GUI preview code (see LLFloaterUIPreview) + //std::set::iterator iter = std::find(sPreviewHighlightedElements.begin(), sPreviewHighlightedElements.end(), this); + //if ((sEditingUI && this == sEditingUIView) || (iter != sPreviewHighlightedElements.end() && sDrawPreviewHighlights)) + //{ + // drawDebugRect(); + //} + mHasHover = FALSE; // This is reset every frame. } @@ -355,6 +387,7 @@ void LLTextBox::drawText( S32 x, S32 y, const LLColor4& color ) mFontGL->render(mText.getWString(), 0, (F32)x, (F32)y, color, mHAlign, mVAlign, mFontStyle, + mShadowType, S32_MAX, getRect().getWidth(), NULL, TRUE, mUseEllipses); } else @@ -367,6 +400,7 @@ void LLTextBox::drawText( S32 x, S32 y, const LLColor4& color ) mFontGL->render(mText.getWString(), cur_pos, (F32)x, (F32)y, color, mHAlign, mVAlign, mFontStyle, + mShadowType, line_length, getRect().getWidth(), NULL, TRUE, mUseEllipses ); cur_pos += line_length + 1; y -= llfloor(mFontGL->getLineHeight()) + mLineSpacing; @@ -380,86 +414,3 @@ void LLTextBox::reshapeToFitText() S32 height = getTextPixelHeight(); reshape( width + 2 * mHPad, height + 2 * mVPad ); } - -// virtual -LLXMLNodePtr LLTextBox::getXML(bool save_children) const -{ - LLXMLNodePtr node = LLUICtrl::getXML(); - - // Attributes - node->createChild("font", TRUE)->setStringValue(LLFontGL::nameFromFont(mFontGL)); - node->createChild("halign", TRUE)->setStringValue(LLFontGL::nameFromHAlign(mHAlign)); - addColorXML(node, mTextColor, "text_color", "LabelTextColor"); - addColorXML(node, mDisabledColor, "disabled_color", "LabelDisabledColor"); - addColorXML(node, mBackgroundColor, "bg_color", "DefaultBackgroundColor"); - addColorXML(node, mBorderColor, "border_color", "DefaultHighlightLight"); - node->createChild("bg_visible", TRUE)->setBoolValue(mBackgroundVisible); - node->createChild("border_visible", TRUE)->setBoolValue(mBorderVisible); - node->createChild("border_drop_shadow_visible", TRUE)->setBoolValue(mBorderDropShadowVisible); - node->createChild("h_pad", TRUE)->setIntValue(mHPad); - node->createChild("v_pad", TRUE)->setIntValue(mVPad); - - // Contents - node->setStringValue(mText); - - return node; -} - -// static -LLView* LLTextBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) -{ - std::string name("text_box"); - node->getAttributeString("name", name); - LLFontGL* font = LLView::selectFont(node); - - std::string text = node->getTextContents(); - - LLTextBox* text_box = new LLTextBox(name, - LLRect(), - text, - font, - FALSE); - - - LLFontGL::HAlign halign = LLView::selectFontHAlign(node); - text_box->setHAlign(halign); - - text_box->initFromXML(node, parent); - - node->getAttributeS32("line_spacing", text_box->mLineSpacing); - - std::string font_style; - if (node->getAttributeString("font-style", font_style)) - { - text_box->mFontStyle = LLFontGL::getStyleFromString(font_style); - } - - BOOL mouse_opaque = text_box->getMouseOpaque(); - if (node->getAttributeBOOL("mouse_opaque", mouse_opaque)) - { - text_box->setMouseOpaque(mouse_opaque); - } - - if(node->hasAttribute("text_color")) - { - LLColor4 color; - LLUICtrlFactory::getAttributeColor(node, "text_color", color); - text_box->setColor(color); - } - - if(node->hasAttribute("hover_color")) - { - LLColor4 color; - LLUICtrlFactory::getAttributeColor(node, "hover_color", color); - text_box->setHoverColor(color); - text_box->setHoverActive(true); - } - - BOOL hover_active = FALSE; - if(node->getAttributeBOOL("hover", hover_active)) - { - text_box->setHoverActive(hover_active); - } - - return text_box; -} -- cgit v1.2.3 From d6101558a171dbd2390792ac1e78d09fc2c27711 Mon Sep 17 00:00:00 2001 From: James Cook Date: Mon, 6 Jul 2009 21:58:04 +0000 Subject: Merge xui-army-5 to viewer-2, includes layout, art, and color changes, also UI color refactoring and new FreeType font library on Linux. svn merge -r126038:126164 svn+ssh://svn.lindenlab.com/svn/linden/branches/skinning/xui-army-5 --- indra/llui/lltextbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/lltextbox.cpp') diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index 464e4be809..b812e876ef 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -314,7 +314,7 @@ void LLTextBox::draw() if( mBorderDropShadowVisible ) { - static LLUICachedControl color_drop_shadow ("ColorDropShadow", *(new LLColor4)); + static LLUIColor color_drop_shadow = LLUIColorTable::instance().getColor("ColorDropShadow"); static LLUICachedControl drop_shadow_tooltip ("DropShadowTooltip", 0); gl_drop_shadow(0, getRect().getHeight(), getRect().getWidth(), 0, color_drop_shadow, drop_shadow_tooltip); -- cgit v1.2.3 From 52aeaa32841e7d0b37abab0a2a2540c2be2f16b7 Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 7 Jul 2009 00:53:05 +0000 Subject: Merge skinning-14 to viewer-2, including refactoring many floaters to register them with LLFloaterReg, support for introspection of ParamBlock based UI widgets to dump XML schema, splitting llfolderview.cpp into three separate files to unravel dependencies and skeleton for for LLListView widget. Resolved conflicts in these files: lldraghandle.h, lluictrl.h, llchiclet.cpp, llfolderview.h/cpp, lliinventorybridge.cpp, llpanelpicks.cpp, llviewermenu.cpp, floater_mute.xml, floater_preferences.xml, notifications.xml, panel_preferences_audio.xml, panel_preferences_graphics1.xml, panel_region_general.xml svn merge -r124961:126284 svn+ssh://svn.lindenlab.com/svn/linden/branches/skinning/skinning-14 --- indra/llui/lltextbox.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'indra/llui/lltextbox.cpp') diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index b812e876ef..56019171e1 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -30,17 +30,13 @@ * $/LicenseInfo$ */ -#define INSTANTIATE_GETCHILD_TEXTBOX - #include "linden_common.h" #include "lltextbox.h" #include "lluictrlfactory.h" #include "llfocusmgr.h" #include "llwindow.h" -template LLTextBox* LLView::getChild( const std::string& name, BOOL recurse, BOOL create_if_missing ) const; - -static LLDefaultWidgetRegistry::Register r("text"); +static LLDefaultChildRegistry::Register r("text"); LLTextBox::Params::Params() : text_color("text_color"), -- cgit v1.2.3 From 8f7ec64899c54dcee6caa0307510cc4003ba7bdd Mon Sep 17 00:00:00 2001 From: James Cook Date: Mon, 27 Jul 2009 17:56:26 +0000 Subject: Merged skinning-17 into viewer-2 for bug fixes. Commented out new IM window for now, not complete. Merging revisions 127913-128319 of svn+ssh://svn.lindenlab.com/svn/linden/branches/skinning/skinning-17 into D:\viewer-2.0.0-3, respecting ancestry --- indra/llui/lltextbox.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'indra/llui/lltextbox.cpp') diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index 56019171e1..3dd8d21f6b 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -82,8 +82,7 @@ LLTextBox::LLTextBox(const LLTextBox::Params& p) mHAlign(p.font_halign), mLineSpacing(p.line_spacing), mWordWrap( p.word_wrap ), - mDidWordWrap(FALSE), - mFontStyle(LLFontGL::getStyleFromString(p.font.style)) + mDidWordWrap(FALSE) { setText( p.text() ); } @@ -382,7 +381,7 @@ void LLTextBox::drawText( S32 x, S32 y, const LLColor4& color ) { mFontGL->render(mText.getWString(), 0, (F32)x, (F32)y, color, mHAlign, mVAlign, - mFontStyle, + 0, mShadowType, S32_MAX, getRect().getWidth(), NULL, TRUE, mUseEllipses); } @@ -395,7 +394,7 @@ void LLTextBox::drawText( S32 x, S32 y, const LLColor4& color ) S32 line_length = *iter; mFontGL->render(mText.getWString(), cur_pos, (F32)x, (F32)y, color, mHAlign, mVAlign, - mFontStyle, + 0, mShadowType, line_length, getRect().getWidth(), NULL, TRUE, mUseEllipses ); cur_pos += line_length + 1; -- cgit v1.2.3 From 0bf4b5f2222ffb8171be094613363427f3b8470a Mon Sep 17 00:00:00 2001 From: Steven Bennetts Date: Wed, 12 Aug 2009 01:12:27 +0000 Subject: merge https://svn.aws.productengine.com/secondlife/export-from-ll@1277 https://svn.aws.productengine.com/secondlife/pe/stable-1@1297 -> viewer-2-0 Fixes: EXT 208 EXT 366 EXT-211 EXT-245 EXT-246 EXT-278 EXT-279 EXT-280 EXT-298 EXT-301 EXT-304 EXT-311 EXT-317 EXT-318 EXT-319 EXT-339 EXT-343 EXT-344 EXT-346 EXT-349 EXT-350 EXT-351 EXT-354 EXT-355 EXT-358 EXT-360 EXT-362 EXT-369 EXT-372 EXT-374 EXT-381 EXT-382 EXT-383 EXT-395 EXT-396 EXT-412 Other changes: Movement & Caemra controls work Profile and Me panel refactoring Notification refactoring --- indra/llui/lltextbox.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/llui/lltextbox.cpp') diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index 3dd8d21f6b..f9bcb685b8 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -32,12 +32,18 @@ #include "linden_common.h" #include "lltextbox.h" +#include "lllink.h" #include "lluictrlfactory.h" #include "llfocusmgr.h" #include "llwindow.h" static LLDefaultChildRegistry::Register r("text"); +//*NOTE +// LLLink is not used in code for now, therefor Visual Studio doesn't build it. +// "link" is registered here to force Visual Studio to build LLLink class. +static LLDefaultChildRegistry::Register register_link("link"); + LLTextBox::Params::Params() : text_color("text_color"), length("length"), -- cgit v1.2.3 From 138bf1132262c479dbbd5c95195db46b1efd065f Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Mon, 24 Aug 2009 20:04:52 +0000 Subject: merge -r 130399-131510 skinning-21 -> viewer-2.0.0-3 DEV-11254 DEV-11254 DEV-2003: DEV-21567 DEV-37301 EXT-104 EXT-138 EXT-217 EXT-256 EXT-259 EXT-259 EXT-328 EXT-348 EXT-386 EXT-399 EXT-403 EXT-460 EXT-492 EXT-492 EXT-531 EXT-537 EXT-684 improved text editor (handles multiple fonts simultaneously as well as inline widgets) --- indra/llui/lltextbox.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llui/lltextbox.cpp') diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index f9bcb685b8..96e72487b8 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -389,7 +389,7 @@ void LLTextBox::drawText( S32 x, S32 y, const LLColor4& color ) mHAlign, mVAlign, 0, mShadowType, - S32_MAX, getRect().getWidth(), NULL, TRUE, mUseEllipses); + S32_MAX, getRect().getWidth(), NULL, mUseEllipses); } else { @@ -402,7 +402,7 @@ void LLTextBox::drawText( S32 x, S32 y, const LLColor4& color ) mHAlign, mVAlign, 0, mShadowType, - line_length, getRect().getWidth(), NULL, TRUE, mUseEllipses ); + line_length, getRect().getWidth(), NULL, mUseEllipses ); cur_pos += line_length + 1; y -= llfloor(mFontGL->getLineHeight()) + mLineSpacing; } -- cgit v1.2.3