UI cleanup.

-Added ui-local transformation matrix.
-Gutted legacy commitcallbacks throughout ui widget ctors.
-Created filter_editor ui widget which issues commit on keypress
   -search_editor commits on focus loss/enter press
   -search_editor and filter_editor now have a built in 'x' button to clear text.
-LLComboBox::setPrearrangeCallback now uses boost::function
-LLComboBox::setTextEntryCallback now uses boost::function
-LLLineEditor::setKeystrokeCallback now uses boost::function
-LLLineEditor::setPrevalidate now uses boost::function
-LLPanel::childSetKeystrokeCallback removed
-LLPanel::childSetPrevalidate removed
-LLPanel::childSetActionTextbox now uses boost::function
-LLTextBox::setClickedCallback now uses boost::function
-LLTextEditor::setKeystrokeCallback added.
-Cleaned up JCFloaterAreaSearch
This commit is contained in:
Shyotl
2013-04-16 00:25:59 -05:00
parent 4cbf8b16b6
commit a5dad6be5c
191 changed files with 3020 additions and 3456 deletions

View File

@@ -219,17 +219,15 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
}
}
gGL.pushMatrix();
gGL.loadIdentity();
gGL.translatef(floorf(sCurOrigin.mX*sScaleX), floorf(sCurOrigin.mY*sScaleY), sCurDepth);
gGL.pushUIMatrix();
// this code snaps the text origin to a pixel grid to start with
F32 pixel_offset_x = llround((F32)sCurOrigin.mX) - (sCurOrigin.mX);
F32 pixel_offset_y = llround((F32)sCurOrigin.mY) - (sCurOrigin.mY);
gGL.translatef(-pixel_offset_x, -pixel_offset_y, 0.f);
gGL.loadUIIdentity();
LLVector2 origin(floorf(sCurOrigin.mX*sScaleX), floorf(sCurOrigin.mY*sScaleY));
gGL.color4fv( color.mV );
// Depth translation, so that floating text appears 'in-world'
// and is correctly occluded.
gGL.translatef(0.f,0.f,sCurDepth);
S32 chars_drawn = 0;
S32 i;
@@ -249,20 +247,21 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
// Not guaranteed to be set correctly
gGL.setSceneBlendType(LLRender::BT_ALPHA);
cur_x = ((F32)x * sScaleX);
cur_y = ((F32)y * sScaleY);
cur_x = ((F32)x * sScaleX) + origin.mV[VX];
cur_y = ((F32)y * sScaleY) + origin.mV[VY];
// Offset y by vertical alignment.
// use unscaled font metrics here
switch (valign)
{
case TOP:
cur_y -= mAscender;
cur_y -= llceil(mAscender);
break;
case BOTTOM:
cur_y += mDescender;
cur_y += llceil(mDescender);
break;
case VCENTER:
cur_y -= ((mAscender - mDescender)/2.f);
cur_y -= llceil((llceil(mAscender) - llceil(mDescender))/2.f);
break;
case BASELINE:
// Baseline, do nothing.
@@ -276,10 +275,10 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
case LEFT:
break;
case RIGHT:
cur_x -= llmin(scaled_max_pixels, llround(getWidthF32(wstr.c_str(), 0, length) * sScaleX));
cur_x -= llmin(scaled_max_pixels, llround(getWidthF32(wstr.c_str(), begin_offset, length) * sScaleX));
break;
case HCENTER:
cur_x -= llmin(scaled_max_pixels, llround(getWidthF32(wstr.c_str(), 0, length) * sScaleX)) / 2;
cur_x -= llmin(scaled_max_pixels, llround(getWidthF32(wstr.c_str(), begin_offset, length) * sScaleX)) / 2;
break;
default:
break;
@@ -288,10 +287,12 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
cur_render_y = cur_y;
cur_render_x = cur_x;
F32 start_x = cur_x;
F32 start_x = (F32)llround(cur_x);
F32 inv_width = 1.f / mFontBitmapCachep->getBitmapWidth();
F32 inv_height = 1.f / mFontBitmapCachep->getBitmapHeight();
const LLFontBitmapCache* font_bitmap_cache = mFontBitmapCachep;
F32 inv_width = 1.f / font_bitmap_cache->getBitmapWidth();
F32 inv_height = 1.f / font_bitmap_cache->getBitmapHeight();
const S32 LAST_CHARACTER = LLFontFreetype::LAST_CHAR_FULL;
@@ -300,7 +301,8 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
if (use_ellipses && halign == LEFT)
{
// check for too long of a string
if (getWidthF32(wstr.c_str(), 0, max_chars) * sScaleX > scaled_max_pixels)
S32 string_width = llround(getWidthF32(wstr.c_str(), begin_offset, max_chars) * sScaleX);
if (string_width > scaled_max_pixels)
{
// use four dots for ellipsis width to generate padding
const LLWString dots(utf8str_to_wstring(std::string("....")));
@@ -358,12 +360,9 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
if (!label.empty())
{
gGL.pushMatrix();
//gGL.loadIdentity();
//gGL.translatef(sCurOrigin.mX, sCurOrigin.mY, 0.0f);
//gGL.scalef(sScaleX, sScaleY, 1.f);
getFontExtChar()->render(label, 0,
/*llfloor*/((ext_x + (F32)ext_image->getWidth() + EXT_X_BEARING) / sScaleX),
/*llfloor*/(cur_y / sScaleY),
/*llfloor*/(ext_x / sScaleX) + ext_image->getWidth() + EXT_X_BEARING - sCurOrigin.mX,
/*llfloor*/(cur_render_y / sScaleY) - sCurOrigin.mY,
color,
halign, BASELINE, NORMAL, NO_SHADOW, S32_MAX, S32_MAX, NULL,
TRUE );
@@ -412,12 +411,12 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
LLRectf uv_rect((fgi->mXBitmapOffset) * inv_width,
(fgi->mYBitmapOffset + fgi->mHeight + PAD_UVY) * inv_height,
(fgi->mXBitmapOffset + fgi->mWidth) * inv_width,
(fgi->mYBitmapOffset - PAD_UVY) * inv_height);
// snap glyph origin to whole screen pixel
LLRectf screen_rect(llround(cur_render_x + (F32)fgi->mXBearing),
llround(cur_render_y + (F32)fgi->mYBearing),
llround(cur_render_x + (F32)fgi->mXBearing) + (F32)fgi->mWidth,
llround(cur_render_y + (F32)fgi->mYBearing) - (F32)fgi->mHeight);
(fgi->mYBitmapOffset - PAD_UVY) * inv_height);
// snap glyph origin to whole screen pixel
LLRectf screen_rect((F32)llround(cur_render_x + (F32)fgi->mXBearing),
(F32)llround(cur_render_y + (F32)fgi->mYBearing),
(F32)llround(cur_render_x + (F32)fgi->mXBearing) + (F32)fgi->mWidth,
(F32)llround(cur_render_y + (F32)fgi->mYBearing) - (F32)fgi->mHeight);
drawGlyph(screen_rect, uv_rect, color, style, shadow, drop_shadow_strength);
@@ -440,8 +439,8 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
// Must do this to cur_x, not just to cur_render_x, otherwise you
// will squish sub-pixel kerned characters too close together.
// For example, "CCCCC" looks bad.
cur_x = (F32)llfloor(cur_x + 0.5f);
//cur_y = (F32)llfloor(cur_y + 0.5f);
cur_x = (F32)llround(cur_x);
//cur_y = (F32)llround(cur_y);
cur_render_x = cur_x;
cur_render_y = cur_y;
@@ -450,41 +449,40 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
if (right_x)
{
*right_x = cur_x / sScaleX;
*right_x = (cur_x - origin.mV[VX]) / sScaleX;
}
if (style & UNDERLINE)
{
F32 descender = (F32)llfloor(mDescender);
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
gGL.begin(LLRender::LINES);
gGL.vertex2f(start_x, cur_y - (mDescender));
gGL.vertex2f(cur_x, cur_y - (mDescender));
gGL.vertex2f(start_x, cur_y - descender);
gGL.vertex2f(cur_x, cur_y - descender);
gGL.end();
}
// *FIX: get this working in all alignment cases, etc.
if (draw_ellipses)
{
// recursively render ellipses at end of string
// we've already reserved enough room
gGL.pushMatrix();
//gGL.loadIdentity();
//gGL.translatef(sCurOrigin.mX, sCurOrigin.mY, 0.0f);
//gGL.scalef(sScaleX, sScaleY, 1.f);
gGL.pushUIMatrix();
renderUTF8(std::string("..."),
0,
cur_x / sScaleX, (F32)y,
(cur_x - origin.mV[VX]) / sScaleX, (F32)y,
color,
LEFT, valign,
style,
LLFontGL::NO_SHADOW,
shadow,
S32_MAX, max_pixels,
right_x,
FALSE);
gGL.popMatrix();
gGL.popUIMatrix();
}
gGL.popMatrix();
gGL.popUIMatrix();
return chars_drawn;
}
@@ -578,7 +576,7 @@ F32 LLFontGL::getWidthF32(const llwchar* wchars, const S32 begin_offset, const S
cur_x += getXAdvance(wch);
llwchar next_char = wchars[i+1];
if (((i + 1) < max_chars)
if (((i + 1) < begin_offset + max_chars)
&& next_char
&& (next_char < LAST_CHARACTER))
{
@@ -587,7 +585,7 @@ F32 LLFontGL::getWidthF32(const llwchar* wchars, const S32 begin_offset, const S
}
}
// Round after kerning.
cur_x = (F32)llfloor(cur_x + 0.5f);
cur_x = (F32)llround(cur_x);
}
return cur_x / sScaleX;
@@ -694,7 +692,7 @@ S32 LLFontGL::maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_ch
}
}
// Round after kerning.
cur_x = (F32)llfloor(cur_x + 0.5f);
cur_x = (F32)llround(cur_x);
drawn_x = cur_x;
}
@@ -871,7 +869,7 @@ S32 LLFontGL::charFromPixelOffset(const llwchar* wchars, const S32 begin_offset,
}
// Round after kerning.
cur_x = (F32)llfloor(cur_x + 0.5f);
cur_x = (F32)llround(cur_x);
}
}

View File

@@ -100,22 +100,21 @@ void gl_rect_2d_offset_local( S32 left, S32 top, S32 right, S32 bottom, const LL
void gl_rect_2d_offset_local( S32 left, S32 top, S32 right, S32 bottom, S32 pixel_offset, BOOL filled)
{
gGL.pushMatrix();
gGL.pushUIMatrix();
left += LLFontGL::sCurOrigin.mX;
right += LLFontGL::sCurOrigin.mX;
bottom += LLFontGL::sCurOrigin.mY;
top += LLFontGL::sCurOrigin.mY;
gGL.loadIdentity();
gGL.loadUIIdentity();
gl_rect_2d(llfloor((F32)left * LLRender2D::sGLScaleFactor.mV[VX]) - pixel_offset,
llfloor((F32)top * LLRender2D::sGLScaleFactor.mV[VY]) + pixel_offset,
llfloor((F32)right * LLRender2D::sGLScaleFactor.mV[VX]) + pixel_offset,
llfloor((F32)bottom * LLRender2D::sGLScaleFactor.mV[VY]) - pixel_offset,
filled);
gGL.popMatrix();
gGL.popUIMatrix();
}
void gl_rect_2d(S32 left, S32 top, S32 right, S32 bottom, BOOL filled )
{
stop_glerror();
@@ -386,8 +385,8 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex
}
// add in offset of current image to current UI translation
const LLVector3 ui_scale = LLVector3(1.f,1.f,1.f);//gGL.getUIScale();
const LLVector3 ui_translation = LLVector3(x,y,0.f);//(gGL.getUITranslation() + LLVector3(x, y, 0.f)).scaledVec(ui_scale);
const LLVector3 ui_scale = gGL.getUIScale();
const LLVector3 ui_translation = (gGL.getUITranslation() + LLVector3(x, y, 0.f)).scaledVec(ui_scale);
F32 uv_width = uv_outer_rect.getWidth();
F32 uv_height = uv_outer_rect.getHeight();
@@ -658,8 +657,8 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre
gGL.begin(LLRender::QUADS);
{
LLVector3 ui_scale = LLVector3(1.f,1.f,1.f);//gGL.getUIScale();
LLVector3 ui_translation = LLVector3(0.f,0.f,0.f); //gGL.getUITranslation();
LLVector3 ui_scale = gGL.getUIScale();
LLVector3 ui_translation = gGL.getUITranslation();
ui_translation.mV[VX] += x;
ui_translation.mV[VY] += y;
ui_translation.scaleVec(ui_scale);
@@ -689,13 +688,13 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre
}
else
{
gGL.pushMatrix();
gGL.translatef((F32)x, (F32)y, 0.f);
gGL.pushUIMatrix();
gGL.translateUI((F32)x, (F32)y, 0.f);
F32 offset_x = F32(width/2);
F32 offset_y = F32(height/2);
gGL.translatef(offset_x, offset_y, 0.f);
gGL.translateUI(offset_x, offset_y, 0.f);
LLMatrix3 quat(0.f, 0.f, degrees*DEG_TO_RAD);
@@ -724,7 +723,7 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre
gGL.vertex2f(v.mV[0], v.mV[1] );
}
gGL.end();
gGL.popMatrix();
gGL.popUIMatrix();
}
}
@@ -765,9 +764,9 @@ void gl_arc_2d(F32 center_x, F32 center_y, F32 radius, S32 steps, BOOL filled, F
end_angle += F_TWO_PI;
}
gGL.pushMatrix();
gGL.pushUIMatrix();
{
gGL.translatef(center_x, center_y, 0.f);
gGL.translateUI(center_x, center_y, 0.f);
// Inexact, but reasonably fast.
F32 delta = (end_angle - start_angle) / steps;
@@ -798,15 +797,15 @@ void gl_arc_2d(F32 center_x, F32 center_y, F32 radius, S32 steps, BOOL filled, F
}
gGL.end();
}
gGL.popMatrix();
gGL.popUIMatrix();
}
void gl_circle_2d(F32 center_x, F32 center_y, F32 radius, S32 steps, BOOL filled)
{
gGL.pushMatrix();
gGL.pushUIMatrix();
{
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
gGL.translatef(center_x, center_y, 0.f);
gGL.translateUI(center_x, center_y, 0.f);
// Inexact, but reasonably fast.
F32 delta = F_TWO_PI / steps;
@@ -837,7 +836,7 @@ void gl_circle_2d(F32 center_x, F32 center_y, F32 radius, S32 steps, BOOL filled
}
gGL.end();
}
gGL.popMatrix();
gGL.popUIMatrix();
}
// Renders a ring with sides (tube shape)
@@ -864,9 +863,9 @@ void gl_deep_circle( F32 radius, F32 depth, S32 steps )
void gl_ring( F32 radius, F32 width, const LLColor4& center_color, const LLColor4& side_color, S32 steps, BOOL render_center )
{
gGL.pushMatrix();
gGL.pushUIMatrix();
{
gGL.translatef(0.f, 0.f, -width / 2);
gGL.translateUI(0.f, 0.f, -width / 2);
if( render_center )
{
gGL.color4fv(center_color.mV);
@@ -877,11 +876,11 @@ void gl_ring( F32 radius, F32 width, const LLColor4& center_color, const LLColor
{
gGL.diffuseColor4fv(side_color.mV);
gl_washer_2d(radius, radius - width, steps, side_color, side_color);
gGL.translatef(0.f, 0.f, width);
gGL.translateUI(0.f, 0.f, width);
gl_washer_2d(radius - width, radius, steps, side_color, side_color);
}
}
gGL.popMatrix();
gGL.popUIMatrix();
}
// Draw gray and white checkerboard with black border
@@ -1056,9 +1055,9 @@ void gl_segmented_rect_2d_tex(const S32 left,
S32 width = llabs(right - left);
S32 height = llabs(top - bottom);
gGL.pushMatrix();
gGL.pushUIMatrix();
gGL.translatef((F32)left, (F32)bottom, 0.f);
gGL.translateUI((F32)left, (F32)bottom, 0.f);
LLVector2 border_uv_scale((F32)border_size / (F32)texture_width, (F32)border_size / (F32)texture_height);
if (border_uv_scale.mV[VX] > 0.5f)
@@ -1199,7 +1198,7 @@ void gl_segmented_rect_2d_tex(const S32 left,
}
gGL.end();
gGL.popMatrix();
gGL.popUIMatrix();
}
//FIXME: rewrite to use scissor?
@@ -1217,9 +1216,9 @@ void gl_segmented_rect_2d_fragment_tex(const S32 left,
S32 width = llabs(right - left);
S32 height = llabs(top - bottom);
gGL.pushMatrix();
gGL.pushUIMatrix();
gGL.translatef((F32)left, (F32)bottom, 0.f);
gGL.translateUI((F32)left, (F32)bottom, 0.f);
LLVector2 border_uv_scale((F32)border_size / (F32)texture_width, (F32)border_size / (F32)texture_height);
if (border_uv_scale.mV[VX] > 0.5f)
@@ -1390,7 +1389,7 @@ void gl_segmented_rect_2d_fragment_tex(const S32 left,
}
gGL.end();
gGL.popMatrix();
gGL.popUIMatrix();
}
void gl_segmented_rect_3d_tex(const LLVector2& border_scale, const LLVector3& border_width,
@@ -1553,7 +1552,7 @@ void LLRender2D::cleanupClass()
//static
void LLRender2D::translate(F32 x, F32 y, F32 z)
{
gGL.translatef(x,y,z);
gGL.translateUI(x,y,z);
LLFontGL::sCurOrigin.mX += (S32) x;
LLFontGL::sCurOrigin.mY += (S32) y;
LLFontGL::sCurDepth += z;
@@ -1562,14 +1561,14 @@ void LLRender2D::translate(F32 x, F32 y, F32 z)
//static
void LLRender2D::pushMatrix()
{
gGL.pushMatrix();
gGL.pushUIMatrix();
LLFontGL::sOriginStack.push_back(std::make_pair(LLFontGL::sCurOrigin, LLFontGL::sCurDepth));
}
//static
void LLRender2D::popMatrix()
{
gGL.popMatrix();
gGL.popUIMatrix();
LLFontGL::sCurOrigin = LLFontGL::sOriginStack.back().first;
LLFontGL::sCurDepth = LLFontGL::sOriginStack.back().second;
LLFontGL::sOriginStack.pop_back();
@@ -1578,7 +1577,7 @@ void LLRender2D::popMatrix()
//static
void LLRender2D::loadIdentity()
{
gGL.loadIdentity();
gGL.loadUIIdentity();
LLFontGL::sCurOrigin.mX = 0;
LLFontGL::sCurOrigin.mY = 0;
LLFontGL::sCurDepth = 0.f;