summaryrefslogtreecommitdiff
path: root/indra/llui/lltextbase.cpp
diff options
context:
space:
mode:
authorTofu Linden <tofu.linden@lindenlab.com>2010-02-09 16:33:58 +0000
committerTofu Linden <tofu.linden@lindenlab.com>2010-02-09 16:33:58 +0000
commitd1efc0fd52c0e5dc59951f50435e121305fe9b69 (patch)
tree7ac48a54efc4029b44a6743b08d351ecfd947801 /indra/llui/lltextbase.cpp
parent4d9bcc2c8f303464c3664a0a7304a1bc2d658e2e (diff)
parentc9b27bec33d601330afe854d0322d22fce9da76a (diff)
merge from viewer2 trunk.
Diffstat (limited to 'indra/llui/lltextbase.cpp')
-rw-r--r--indra/llui/lltextbase.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index a83cc19d36..b84e6f45fb 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -1575,8 +1575,10 @@ void LLTextBase::appendText(const std::string &new_text, bool prepend_newline, c
{
LLStyle::Params icon;
icon.image = image;
- // HACK: fix spacing of images and remove the fixed char spacing
- appendAndHighlightText(" ", prepend_newline, part, icon);
+ // Text will be replaced during rendering with the icon,
+ // but string cannot be empty or the segment won't be
+ // added (or drawn).
+ appendAndHighlightText(" ", prepend_newline, part, icon);
prepend_newline = false;
}
}
@@ -2297,14 +2299,21 @@ F32 LLNormalTextSegment::draw(S32 start, S32 end, S32 selection_start, S32 selec
{
if ( mStyle->isImage() && (start >= 0) && (end <= mEnd - mStart))
{
+ // ...for images, only render the image, not the underlying text,
+ // which is only a placeholder space
LLColor4 color = LLColor4::white % mEditor.getDrawContext().mAlpha;
LLUIImagePtr image = mStyle->getImage();
S32 style_image_height = image->getHeight();
S32 style_image_width = image->getWidth();
- // Center the image vertically
- S32 image_bottom = draw_rect.getCenterY() - (style_image_height/2);
+ // Text is drawn from the top of the draw_rect downward
+ S32 text_center = draw_rect.mTop - (mFontHeight / 2);
+ // Align image to center of text
+ S32 image_bottom = text_center - (style_image_height / 2);
image->draw(draw_rect.mLeft, image_bottom,
style_image_width, style_image_height, color);
+
+ const S32 IMAGE_HPAD = 3;
+ return draw_rect.mLeft + style_image_width + IMAGE_HPAD;
}
return drawClippedSegment( getStart() + start, getStart() + end, selection_start, selection_end, draw_rect);