Skip to content

Instantly share code, notes, and snippets.

@esetomo
Created August 16, 2013 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esetomo/6251333 to your computer and use it in GitHub Desktop.
Save esetomo/6251333 to your computer and use it in GitHub Desktop.
diff -r 5c4dc17956b9 indra/llui/lltexteditor.cpp
--- a/indra/llui/lltexteditor.cpp Fri Aug 16 13:05:38 2013 +0100
+++ b/indra/llui/lltexteditor.cpp Fri Aug 16 17:18:26 2013 +0100
@@ -2782,6 +2782,9 @@
BOOL LLTextEditor::getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect *bounds, LLRect *control) const
{
+ static LLUICachedControl<S32> preedit_marker_thickness ("UIPreeditMarkerThickness", 0);
+ static LLUICachedControl<S32> preedit_standout_thickness ("UIPreeditStandoutThickness", 0);
+
if (control)
{
LLRect control_rect_screen;
@@ -2812,32 +2815,31 @@
return FALSE;
}
- S32 current_line = first_visible_line;
- S32 current_line_start, current_line_end;
- for (;;)
+ S32 current_line;
+ S32 num_lines = getLineCount();
+ S32 current_line_start = 0;
+ S32 current_line_end = 0;
+ for (current_line = first_visible_line; current_line < num_lines; current_line++)
{
current_line_start = getLineStart(current_line);
- current_line_end = getLineStart(current_line + 1);
+ current_line_end = getLineEnd(current_line);
if (query >= current_line_start && query < current_line_end)
{
break;
}
- if (current_line_start == current_line_end)
- {
- // We have reached on the last line. The query position must be here.
- break;
- }
- current_line++;
}
+ if(current_line >= num_lines)
+ return FALSE;
const LLWString textString(getWText());
const llwchar * const text = textString.c_str();
- const S32 line_height = mFont->getLineHeight();
+ const line_info& line = mLineInfoList[current_line];
+ LLRect text_rect(line.mRect);
if (coord)
{
- const S32 query_x = mVisibleTextRect.mLeft + mFont->getWidth(text, current_line_start, query - current_line_start);
- const S32 query_y = mVisibleTextRect.mTop - (current_line - first_visible_line) * line_height - line_height / 2;
+ const S32 query_x = text_rect.mLeft + mFont->getWidth(text, current_line_start, query - current_line_start);
+ const S32 query_y = (text_rect.mTop + text_rect.mBottom) / 2;
S32 query_screen_x, query_screen_y;
localPointToScreen(query_x, query_y, &query_screen_x, &query_screen_y);
LLUI::screenPointToGL(query_screen_x, query_screen_y, &coord->mX, &coord->mY);
@@ -2845,13 +2847,13 @@
if (bounds)
{
- S32 preedit_left = mVisibleTextRect.mLeft;
+ S32 preedit_left = text_rect.mLeft;
if (preedit_left_position > current_line_start)
{
preedit_left += mFont->getWidth(text, current_line_start, preedit_left_position - current_line_start);
}
- S32 preedit_right = mVisibleTextRect.mLeft;
+ S32 preedit_right = text_rect.mLeft;
if (preedit_right_position < current_line_end)
{
preedit_right += mFont->getWidth(text, current_line_start, preedit_right_position - current_line_start);
@@ -2861,8 +2863,8 @@
preedit_right += mFont->getWidth(text, current_line_start, current_line_end - current_line_start);
}
- const S32 preedit_top = mVisibleTextRect.mTop - (current_line - first_visible_line) * line_height;
- const S32 preedit_bottom = preedit_top - line_height;
+ const S32 preedit_top = text_rect.mTop + 2;
+ const S32 preedit_bottom = text_rect.mBottom - max(preedit_marker_thickness, preedit_standout_thickness) - 2;
const LLRect preedit_rect_local(preedit_left, preedit_top, preedit_right, preedit_bottom);
LLRect preedit_rect_screen;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment