summaryrefslogtreecommitdiff
path: root/indra/llui/lltextbase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/lltextbase.cpp')
-rw-r--r--indra/llui/lltextbase.cpp46
1 files changed, 33 insertions, 13 deletions
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 20be739286..f3a99dcef2 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -1522,6 +1522,7 @@ void LLTextBase::reflow()
}
S32 line_height = 0;
+ S32 seg_line_offset = line_count + 1;
while(seg_iter != mSegments.end())
{
@@ -1534,7 +1535,8 @@ void LLTextBase::reflow()
S32 character_count = segment->getNumChars(getWordWrap() ? llmax(0, remaining_pixels) : S32_MAX,
seg_offset,
cur_index - line_start_index,
- S32_MAX);
+ S32_MAX,
+ line_count - seg_line_offset);
S32 segment_width, segment_height;
bool force_newline = segment->getDimensions(seg_offset, character_count, segment_width, segment_height);
@@ -1597,6 +1599,7 @@ void LLTextBase::reflow()
}
++seg_iter;
seg_offset = 0;
+ seg_line_offset = force_newline ? line_count + 1 : line_count;
}
if (force_newline)
{
@@ -3065,7 +3068,7 @@ LLTextSegment::~LLTextSegment()
bool LLTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const { width = 0; height = 0; return false;}
S32 LLTextSegment::getOffset(S32 segment_local_x_coord, S32 start_offset, S32 num_chars, bool round) const { return 0; }
-S32 LLTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars) const { return 0; }
+S32 LLTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars, S32 line_ind) const { return 0; }
void LLTextSegment::updateLayout(const LLTextBase& editor) {}
F32 LLTextSegment::draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRectf& draw_rect) { return draw_rect.mLeft; }
bool LLTextSegment::canEdit() const { return false; }
@@ -3335,7 +3338,7 @@ S32 LLNormalTextSegment::getOffset(S32 segment_local_x_coord, S32 start_offset,
round);
}
-S32 LLNormalTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars) const
+S32 LLNormalTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars, S32 line_ind) const
{
const LLWString &text = getWText();
@@ -3352,7 +3355,7 @@ S32 LLNormalTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 lin
// if no character yet displayed on this line, don't require word wrapping since
// we can just move to the next line, otherwise insist on it so we make forward progress
- LLFontGL::EWordWrapStyle word_wrap_style = (line_offset == 0)
+ LLFontGL::EWordWrapStyle word_wrap_style = (line_offset == 0)
? LLFontGL::WORD_BOUNDARY_IF_POSSIBLE
: LLFontGL::ONLY_WORD_BOUNDARIES;
@@ -3490,12 +3493,26 @@ LLInlineViewSegment::~LLInlineViewSegment()
bool LLInlineViewSegment::getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const
{
- if (first_char == 0 && num_chars == 0)
+ if (first_char == 0 && num_chars == 0)
{
- // we didn't fit on a line, the widget will fall on the next line
- // so dimensions here are 0
+ // We didn't fit on a line or were forced to new string
+ // the widget will fall on the next line, so width here is 0
width = 0;
- height = 0;
+
+ if (mForceNewLine)
+ {
+ // Chat, string can't be smaller then font height even if it is empty
+ LLStyleSP s(new LLStyle(LLStyle::Params().visible(true)));
+ height = s->getFont()->getLineHeight();
+
+ return true; // new line
+ }
+ else
+ {
+ // height from previous segment in same string will be used, word-wrap
+ height = 0;
+ }
+
}
else
{
@@ -3506,13 +3523,16 @@ bool LLInlineViewSegment::getDimensions(S32 first_char, S32 num_chars, S32& widt
return false;
}
-S32 LLInlineViewSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars) const
+S32 LLInlineViewSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars, S32 line_ind) const
{
// if putting a widget anywhere but at the beginning of a line
// and the widget doesn't fit or mForceNewLine is true
// then return 0 chars for that line, and all characters for the next
- if (line_offset != 0
- && (mForceNewLine || num_pixels < mView->getRect().getWidth()))
+ if (mForceNewLine && line_ind == 0)
+ {
+ return 0;
+ }
+ else if (line_offset != 0 && num_pixels < mView->getRect().getWidth())
{
return 0;
}
@@ -3565,7 +3585,7 @@ bool LLLineBreakTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& w
return true;
}
-S32 LLLineBreakTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars) const
+S32 LLLineBreakTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars, S32 line_ind) const
{
return 1;
}
@@ -3601,7 +3621,7 @@ bool LLImageTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& width
return false;
}
-S32 LLImageTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars) const
+S32 LLImageTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars, S32 line_ind) const
{
LLUIImagePtr image = mStyle->getImage();