summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llbutton.cpp571
-rw-r--r--indra/llui/llbutton.h8
-rw-r--r--indra/llui/llcheckboxctrl.cpp3
-rw-r--r--indra/llui/llcheckboxctrl.h3
-rw-r--r--indra/llui/llcombobox.cpp67
-rw-r--r--indra/llui/llcombobox.h13
-rw-r--r--indra/llui/lldraghandle.cpp26
-rw-r--r--indra/llui/lldraghandle.h6
-rw-r--r--indra/llui/llfloater.cpp215
-rw-r--r--indra/llui/llfloater.h11
-rw-r--r--indra/llui/llfocusmgr.cpp5
-rw-r--r--indra/llui/llfocusmgr.h7
-rw-r--r--indra/llui/lliconctrl.cpp59
-rw-r--r--indra/llui/lliconctrl.h6
-rw-r--r--indra/llui/lllineeditor.cpp216
-rw-r--r--indra/llui/lllineeditor.h40
-rw-r--r--indra/llui/llmenugl.cpp178
-rw-r--r--indra/llui/llmenugl.h42
-rw-r--r--indra/llui/llmodaldialog.cpp49
-rw-r--r--indra/llui/llmodaldialog.h2
-rw-r--r--indra/llui/llmultislider.cpp308
-rw-r--r--indra/llui/llmultislider.h4
-rw-r--r--indra/llui/llmultisliderctrl.cpp2
-rw-r--r--indra/llui/llmultisliderctrl.h2
-rw-r--r--indra/llui/llpanel.cpp318
-rw-r--r--indra/llui/llpanel.h40
-rw-r--r--indra/llui/llradiogroup.cpp5
-rw-r--r--indra/llui/llradiogroup.h4
-rw-r--r--indra/llui/llresizebar.cpp15
-rw-r--r--indra/llui/llresizebar.h3
-rw-r--r--indra/llui/llresizehandle.cpp27
-rw-r--r--indra/llui/llresizehandle.h5
-rw-r--r--indra/llui/llresmgr.cpp2
-rw-r--r--indra/llui/llresmgr.h66
-rw-r--r--indra/llui/llscrollbar.cpp191
-rw-r--r--indra/llui/llscrollbar.h5
-rw-r--r--indra/llui/llscrollcontainer.cpp176
-rw-r--r--indra/llui/llscrollcontainer.h4
-rw-r--r--indra/llui/llscrollingpanellist.cpp9
-rw-r--r--indra/llui/llscrollingpanellist.h2
-rw-r--r--indra/llui/llscrolllistctrl.cpp259
-rw-r--r--indra/llui/llscrolllistctrl.h35
-rw-r--r--indra/llui/llslider.cpp134
-rw-r--r--indra/llui/llslider.h10
-rw-r--r--indra/llui/llsliderctrl.cpp1
-rw-r--r--indra/llui/llsliderctrl.h3
-rw-r--r--indra/llui/llspinctrl.cpp22
-rw-r--r--indra/llui/llspinctrl.h5
-rw-r--r--indra/llui/llstyle.cpp32
-rw-r--r--indra/llui/llstyle.h17
-rw-r--r--indra/llui/lltabcontainer.cpp213
-rw-r--r--indra/llui/lltabcontainer.h10
-rw-r--r--indra/llui/lltextbox.cpp95
-rw-r--r--indra/llui/lltextbox.h3
-rw-r--r--indra/llui/lltexteditor.cpp166
-rw-r--r--indra/llui/lltexteditor.h7
-rw-r--r--indra/llui/llui.cpp160
-rw-r--r--indra/llui/llui.h127
-rw-r--r--indra/llui/lluictrl.cpp22
-rw-r--r--indra/llui/lluictrl.h4
-rw-r--r--indra/llui/lluictrlfactory.cpp301
-rw-r--r--indra/llui/lluictrlfactory.h64
-rw-r--r--indra/llui/llview.cpp150
-rw-r--r--indra/llui/llview.h159
-rw-r--r--indra/llui/llviewborder.cpp81
-rw-r--r--indra/llui/llviewborder.h4
-rw-r--r--indra/llui/llviewquery.cpp5
-rw-r--r--indra/llui/llviewquery.h10
68 files changed, 2127 insertions, 2687 deletions
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp
index 8ae6dd2ea5..e0ac3cebd7 100644
--- a/indra/llui/llbutton.cpp
+++ b/indra/llui/llbutton.cpp
@@ -50,6 +50,8 @@
#include "llwindow.h"
#include "llglimmediate.h"
+static LLRegisterWidget<LLButton> r("button");
+
// globals loaded from settings.xml
S32 LLBUTTON_ORIG_H_PAD = 6; // Pre-zoomable UI
S32 LLBUTTON_H_PAD = 0;
@@ -222,18 +224,6 @@ LLButton::~LLButton()
}
}
-// virtual
-EWidgetType LLButton::getWidgetType() const
-{
- return WIDGET_TYPE_BUTTON;
-}
-
-// virtual
-LLString LLButton::getWidgetTag() const
-{
- return LL_BUTTON_TAG;
-}
-
// HACK: Committing a button is the same as instantly clicking it.
// virtual
void LLButton::onCommit()
@@ -277,10 +267,11 @@ void LLButton::onCommit()
-BOOL LLButton::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent)
+BOOL LLButton::handleUnicodeCharHere(llwchar uni_char)
{
BOOL handled = FALSE;
- if( getVisible() && getEnabled() && !called_from_parent && ' ' == uni_char && !gKeyboard->getKeyRepeated(' '))
+ if(' ' == uni_char
+ && !gKeyboard->getKeyRepeated(' '))
{
if (mIsToggle)
{
@@ -296,24 +287,21 @@ BOOL LLButton::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent)
return handled;
}
-BOOL LLButton::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent )
+BOOL LLButton::handleKeyHere(KEY key, MASK mask )
{
BOOL handled = FALSE;
- if( getVisible() && getEnabled() && !called_from_parent )
+ if( mCommitOnReturn && KEY_RETURN == key && mask == MASK_NONE && !gKeyboard->getKeyRepeated(key))
{
- if( mCommitOnReturn && KEY_RETURN == key && mask == MASK_NONE && !gKeyboard->getKeyRepeated(key))
+ if (mIsToggle)
{
- if (mIsToggle)
- {
- toggleState();
- }
+ toggleState();
+ }
- handled = TRUE;
+ handled = TRUE;
- if (mClickedCallback)
- {
- (*mClickedCallback)( mCallbackUserData );
- }
+ if (mClickedCallback)
+ {
+ (*mClickedCallback)( mCallbackUserData );
}
}
return handled;
@@ -391,8 +379,6 @@ BOOL LLButton::handleMouseUp(S32 x, S32 y, MASK mask)
BOOL LLButton::handleHover(S32 x, S32 y, MASK mask)
{
- BOOL handled = FALSE;
-
LLMouseHandler* other_captor = gFocusMgr.getMouseCapture();
mNeedsHighlight = other_captor == NULL ||
other_captor == this ||
@@ -409,358 +395,333 @@ BOOL LLButton::handleHover(S32 x, S32 y, MASK mask)
}
// We only handle the click if the click both started and ended within us
- if( hasMouseCapture() )
- {
- handled = TRUE;
- }
- else if( getVisible() )
- {
- // Opaque
- handled = TRUE;
- }
+ getWindow()->setCursor(UI_CURSOR_ARROW);
+ lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << llendl;
- if( handled )
- {
- getWindow()->setCursor(UI_CURSOR_ARROW);
- lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << llendl;
- }
-
- return handled;
+ return TRUE;
}
// virtual
void LLButton::draw()
{
- if( getVisible() )
+ BOOL flash = FALSE;
+ if( mFlashing )
{
- BOOL flash = FALSE;
- if( mFlashing )
- {
- F32 elapsed = mFlashingTimer.getElapsedTimeF32();
- S32 flash_count = S32(elapsed * LLUI::sConfigGroup->getF32("ButtonFlashRate") * 2.f);
- // flash on or off?
- flash = (flash_count % 2 == 0) || flash_count > (F32)LLUI::sConfigGroup->getS32("ButtonFlashCount");
- }
+ F32 elapsed = mFlashingTimer.getElapsedTimeF32();
+ S32 flash_count = S32(elapsed * LLUI::sConfigGroup->getF32("ButtonFlashRate") * 2.f);
+ // flash on or off?
+ flash = (flash_count % 2 == 0) || flash_count > S32((F32)LLUI::sConfigGroup->getS32("ButtonFlashCount") * 2.f);
+ }
- BOOL pressed_by_keyboard = FALSE;
- if (hasFocus())
- {
- pressed_by_keyboard = gKeyboard->getKeyDown(' ') || (mCommitOnReturn && gKeyboard->getKeyDown(KEY_RETURN));
- }
+ BOOL pressed_by_keyboard = FALSE;
+ if (hasFocus())
+ {
+ pressed_by_keyboard = gKeyboard->getKeyDown(' ') || (mCommitOnReturn && gKeyboard->getKeyDown(KEY_RETURN));
+ }
- // Unselected image assignments
- S32 local_mouse_x;
- S32 local_mouse_y;
- LLCoordWindow cursor_pos_window;
- getWindow()->getCursorPosition(&cursor_pos_window);
- LLCoordGL cursor_pos_gl;
- getWindow()->convertCoords(cursor_pos_window, &cursor_pos_gl);
- cursor_pos_gl.mX = llround((F32)cursor_pos_gl.mX / LLUI::sGLScaleFactor.mV[VX]);
- cursor_pos_gl.mY = llround((F32)cursor_pos_gl.mY / LLUI::sGLScaleFactor.mV[VY]);
- screenPointToLocal(cursor_pos_gl.mX, cursor_pos_gl.mY, &local_mouse_x, &local_mouse_y);
-
- BOOL pressed = pressed_by_keyboard
- || (hasMouseCapture() && pointInView(local_mouse_x, local_mouse_y))
- || mToggleState;
-
- BOOL use_glow_effect = FALSE;
- if ( mNeedsHighlight || flash )
+ // Unselected image assignments
+ S32 local_mouse_x;
+ S32 local_mouse_y;
+ LLCoordWindow cursor_pos_window;
+ getWindow()->getCursorPosition(&cursor_pos_window);
+ LLCoordGL cursor_pos_gl;
+ getWindow()->convertCoords(cursor_pos_window, &cursor_pos_gl);
+ cursor_pos_gl.mX = llround((F32)cursor_pos_gl.mX / LLUI::sGLScaleFactor.mV[VX]);
+ cursor_pos_gl.mY = llround((F32)cursor_pos_gl.mY / LLUI::sGLScaleFactor.mV[VY]);
+ screenPointToLocal(cursor_pos_gl.mX, cursor_pos_gl.mY, &local_mouse_x, &local_mouse_y);
+
+ BOOL pressed = pressed_by_keyboard
+ || (hasMouseCapture() && pointInView(local_mouse_x, local_mouse_y))
+ || mToggleState;
+
+ BOOL use_glow_effect = FALSE;
+ if ( mNeedsHighlight || flash )
+ {
+ if (pressed)
{
- if (pressed)
+ if (mImageHoverSelected)
{
- if (mImageHoverSelected)
- {
- mImagep = mImageHoverSelected;
- }
- else
- {
- mImagep = mImageSelected;
- use_glow_effect = TRUE;
- }
+ mImagep = mImageHoverSelected;
}
else
{
- if (mImageHoverUnselected)
- {
- mImagep = mImageHoverUnselected;
- }
- else
- {
- mImagep = mImageUnselected;
- use_glow_effect = TRUE;
- }
+ mImagep = mImageSelected;
+ use_glow_effect = TRUE;
}
}
- else if ( pressed )
- {
- mImagep = mImageSelected;
- }
else
{
- mImagep = mImageUnselected;
+ if (mImageHoverUnselected)
+ {
+ mImagep = mImageHoverUnselected;
+ }
+ else
+ {
+ mImagep = mImageUnselected;
+ use_glow_effect = TRUE;
+ }
}
+ }
+ else if ( pressed )
+ {
+ mImagep = mImageSelected;
+ }
+ else
+ {
+ mImagep = mImageUnselected;
+ }
- // Override if more data is available
- // HACK: Use gray checked state to mean either:
- // enabled and tentative
- // or
- // disabled but checked
- if (!mImageDisabledSelected.isNull() && ( (getEnabled() && getTentative()) || (!getEnabled() && pressed ) ) )
- {
- mImagep = mImageDisabledSelected;
- }
- else if (!mImageDisabled.isNull() && !getEnabled() && !pressed)
- {
- mImagep = mImageDisabled;
- }
+ // Override if more data is available
+ // HACK: Use gray checked state to mean either:
+ // enabled and tentative
+ // or
+ // disabled but checked
+ if (!mImageDisabledSelected.isNull()
+ &&
+ ( (getEnabled() && getTentative())
+ || (!getEnabled() && pressed ) ) )
+ {
+ mImagep = mImageDisabledSelected;
+ }
+ else if (!mImageDisabled.isNull()
+ && !getEnabled()
+ && !pressed)
+ {
+ mImagep = mImageDisabled;
+ }
- if (mNeedsHighlight && !mImagep)
- {
- use_glow_effect = TRUE;
- }
+ if (mNeedsHighlight && !mImagep)
+ {
+ use_glow_effect = TRUE;
+ }
- // Figure out appropriate color for the text
- LLColor4 label_color;
+ // Figure out appropriate color for the text
+ LLColor4 label_color;
- // label changes when button state changes, not when pressed
- if ( getEnabled() )
+ // label changes when button state changes, not when pressed
+ if ( getEnabled() )
+ {
+ if ( mToggleState )
{
- if ( mToggleState )
- {
- label_color = mSelectedLabelColor;
- }
- else
- {
- label_color = mUnselectedLabelColor;
- }
+ label_color = mSelectedLabelColor;
}
else
{
- if ( mToggleState )
- {
- label_color = mDisabledSelectedLabelColor;
- }
- else
- {
- label_color = mDisabledLabelColor;
- }
+ label_color = mUnselectedLabelColor;
}
-
- // Unselected label assignments
- LLWString label;
-
- if( mToggleState )
+ }
+ else
+ {
+ if ( mToggleState )
{
- if( getEnabled() || mDisabledSelectedLabel.empty() )
- {
- label = mSelectedLabel;
- }
- else
- {
- label = mDisabledSelectedLabel;
- }
+ label_color = mDisabledSelectedLabelColor;
}
else
{
- if( getEnabled() || mDisabledLabel.empty() )
- {
- label = mUnselectedLabel;
- }
- else
- {
- label = mDisabledLabel;
- }
+ label_color = mDisabledLabelColor;
}
-
- // draw default button border
- if (getEnabled() && mBorderEnabled && gFocusMgr.getAppHasFocus()) // because we're the default button in a panel
+ }
+
+ // Unselected label assignments
+ LLWString label;
+
+ if( mToggleState )
+ {
+ if( getEnabled() || mDisabledSelectedLabel.empty() )
{
- drawBorder(LLUI::sColorsGroup->getColor( "ButtonBorderColor" ), BORDER_SIZE);
+ label = mSelectedLabel;
}
-
- // overlay with keyboard focus border
- if (hasFocus())
+ else
{
- F32 lerp_amt = gFocusMgr.getFocusFlashAmt();
- drawBorder(gFocusMgr.getFocusColor(), llround(lerp(1.f, 3.f, lerp_amt)));
+ label = mDisabledSelectedLabel;
}
-
- if (use_glow_effect)
+ }
+ else
+ {
+ if( getEnabled() || mDisabledLabel.empty() )
{
- mCurGlowStrength = lerp(mCurGlowStrength, mHoverGlowStrength, LLCriticalDamp::getInterpolant(0.05f));
+ label = mUnselectedLabel;
}
else
{
- mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLCriticalDamp::getInterpolant(0.05f));
+ label = mDisabledLabel;
}
+ }
- // Draw button image, if available.
- // Otherwise draw basic rectangular button.
- if( mImagep.notNull() && !mScaleImage)
+ // overlay with keyboard focus border
+ if (hasFocus())
+ {
+ F32 lerp_amt = gFocusMgr.getFocusFlashAmt();
+ drawBorder(gFocusMgr.getFocusColor(), llround(lerp(1.f, 3.f, lerp_amt)));
+ }
+
+ if (use_glow_effect)
+ {
+ mCurGlowStrength = lerp(mCurGlowStrength, mHoverGlowStrength, LLCriticalDamp::getInterpolant(0.05f));
+ }
+ else
+ {
+ mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLCriticalDamp::getInterpolant(0.05f));
+ }
+
+ // Draw button image, if available.
+ // Otherwise draw basic rectangular button.
+ if (mImagep.notNull())
+ {
+ if ( mScaleImage)
{
- mImagep->draw(0, 0, getEnabled() ? mImageColor : mDisabledImageColor );
+ mImagep->draw(getLocalRect(), getEnabled() ? mImageColor : mDisabledImageColor );
if (mCurGlowStrength > 0.01f)
{
- gGL.blendFunc(GL_SRC_ALPHA, GL_ONE);
- mImagep->drawSolid(0, 0, LLColor4(1.f, 1.f, 1.f, mCurGlowStrength));
- gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ mImagep->drawSolid(0, 0, getRect().getWidth(), getRect().getHeight(), LLColor4(1.f, 1.f, 1.f, mCurGlowStrength));
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
}
else
- if ( mImagep.notNull() && mScaleImage)
{
- mImagep->draw(0, 0, getRect().getWidth(), getRect().getHeight(), getEnabled() ? mImageColor : mDisabledImageColor );
+ mImagep->draw(0, 0, getEnabled() ? mImageColor : mDisabledImageColor );
if (mCurGlowStrength > 0.01f)
{
- gGL.blendFunc(GL_SRC_ALPHA, GL_ONE);
- mImagep->drawSolid(0, 0, getRect().getWidth(), getRect().getHeight(), LLColor4(1.f, 1.f, 1.f, mCurGlowStrength));
- gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ mImagep->drawSolid(0, 0, LLColor4(1.f, 1.f, 1.f, mCurGlowStrength));
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
}
- else
- {
- // no image
- llwarns << "No image for button " << getName() << llendl;
- // draw it in pink so we can find it
- gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4::pink1, FALSE);
- }
-
- // let overlay image and text play well together
- S32 text_left = mLeftHPad;
- S32 text_right = getRect().getWidth() - mRightHPad;
- S32 text_width = getRect().getWidth() - mLeftHPad - mRightHPad;
-
- // draw overlay image
- if (mImageOverlay.notNull())
- {
- // get max width and height (discard level 0)
- S32 overlay_width = mImageOverlay->getWidth();
- S32 overlay_height = mImageOverlay->getHeight();
+ }
+ else
+ {
+ // no image
+ llwarns << "No image for button " << getName() << llendl;
+ // draw it in pink so we can find it
+ gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4::pink1, FALSE);
+ }
- F32 scale_factor = llmin((F32)getRect().getWidth() / (F32)overlay_width, (F32)getRect().getHeight() / (F32)overlay_height, 1.f);
- overlay_width = llround((F32)overlay_width * scale_factor);
- overlay_height = llround((F32)overlay_height * scale_factor);
+ // let overlay image and text play well together
+ S32 text_left = mLeftHPad;
+ S32 text_right = getRect().getWidth() - mRightHPad;
+ S32 text_width = getRect().getWidth() - mLeftHPad - mRightHPad;
- S32 center_x = getLocalRect().getCenterX();
- S32 center_y = getLocalRect().getCenterY();
+ // draw overlay image
+ if (mImageOverlay.notNull())
+ {
+ // get max width and height (discard level 0)
+ S32 overlay_width = mImageOverlay->getWidth();
+ S32 overlay_height = mImageOverlay->getHeight();
- //FUGLY HACK FOR "DEPRESSED" BUTTONS
- if (pressed)
- {
- center_y--;
- center_x++;
- }
+ F32 scale_factor = llmin((F32)getRect().getWidth() / (F32)overlay_width, (F32)getRect().getHeight() / (F32)overlay_height, 1.f);
+ overlay_width = llround((F32)overlay_width * scale_factor);
+ overlay_height = llround((F32)overlay_height * scale_factor);
- // fade out overlay images on disabled buttons
- LLColor4 overlay_color = mImageOverlayColor;
- if (!getEnabled())
- {
- overlay_color.mV[VALPHA] = 0.5f;
- }
+ S32 center_x = getLocalRect().getCenterX();
+ S32 center_y = getLocalRect().getCenterY();
- switch(mImageOverlayAlignment)
- {
- case LLFontGL::LEFT:
- text_left += overlay_width + 1;
- text_width -= overlay_width + 1;
- mImageOverlay->draw(
- mLeftHPad,
- center_y - (overlay_height / 2),
- overlay_width,
- overlay_height,
- overlay_color);
- break;
- case LLFontGL::HCENTER:
- mImageOverlay->draw(
- center_x - (overlay_width / 2),
- center_y - (overlay_height / 2),
- overlay_width,
- overlay_height,
- overlay_color);
- break;
- case LLFontGL::RIGHT:
- text_right -= overlay_width + 1;
- text_width -= overlay_width + 1;
- mImageOverlay->draw(
- getRect().getWidth() - mRightHPad - overlay_width,
- center_y - (overlay_height / 2),
- overlay_width,
- overlay_height,
- overlay_color);
- break;
- default:
- // draw nothing
- break;
- }
+ //FUGLY HACK FOR "DEPRESSED" BUTTONS
+ if (pressed)
+ {
+ center_y--;
+ center_x++;
}
- // Draw label
- if( !label.empty() )
+ // fade out overlay images on disabled buttons
+ LLColor4 overlay_color = mImageOverlayColor;
+ if (!getEnabled())
{
- LLWString::trim(label);
+ overlay_color.mV[VALPHA] = 0.5f;
+ }
- S32 x;
- switch( mHAlign )
- {
- case LLFontGL::RIGHT:
- x = text_right;
- break;
- case LLFontGL::HCENTER:
- x = getRect().getWidth() / 2;
- break;
- case LLFontGL::LEFT:
- default:
- x = text_left;
- break;
- }
+ switch(mImageOverlayAlignment)
+ {
+ case LLFontGL::LEFT:
+ text_left += overlay_width + 1;
+ text_width -= overlay_width + 1;
+ mImageOverlay->draw(
+ mLeftHPad,
+ center_y - (overlay_height / 2),
+ overlay_width,
+ overlay_height,
+ overlay_color);
+ break;
+ case LLFontGL::HCENTER:
+ mImageOverlay->draw(
+ center_x - (overlay_width / 2),
+ center_y - (overlay_height / 2),
+ overlay_width,
+ overlay_height,
+ overlay_color);
+ break;
+ case LLFontGL::RIGHT:
+ text_right -= overlay_width + 1;
+ text_width -= overlay_width + 1;
+ mImageOverlay->draw(
+ getRect().getWidth() - mRightHPad - overlay_width,
+ center_y - (overlay_height / 2),
+ overlay_width,
+ overlay_height,
+ overlay_color);
+ break;
+ default:
+ // draw nothing
+ break;
+ }
+ }
- S32 y_offset = 2 + (getRect().getHeight() - 20)/2;
-
- if (pressed)
- {
- y_offset--;
- x++;
- }
+ // Draw label
+ if( !label.empty() )
+ {
+ LLWString::trim(label);
- mGLFont->render(label, 0, (F32)x, (F32)(LLBUTTON_V_PAD + y_offset),
- label_color,
- mHAlign, LLFontGL::BOTTOM,
- mDropShadowedText ? LLFontGL::DROP_SHADOW_SOFT : LLFontGL::NORMAL,
- U32_MAX, text_width,
- NULL, FALSE, FALSE);
+ S32 x;
+ switch( mHAlign )
+ {
+ case LLFontGL::RIGHT:
+ x = text_right;
+ break;
+ case LLFontGL::HCENTER:
+ x = getRect().getWidth() / 2;
+ break;
+ case LLFontGL::LEFT:
+ default:
+ x = text_left;
+ break;
}
- if (sDebugRects
- || (LLView::sEditingUI && this == LLView::sEditingUIView))
+ S32 y_offset = 2 + (getRect().getHeight() - 20)/2;
+
+ if (pressed)
{
- drawDebugRect();
+ y_offset--;
+ x++;
}
+
+ mGLFont->render(label, 0, (F32)x, (F32)(LLBUTTON_V_PAD + y_offset),
+ label_color,
+ mHAlign, LLFontGL::BOTTOM,
+ mDropShadowedText ? LLFontGL::DROP_SHADOW_SOFT : LLFontGL::NORMAL,
+ U32_MAX, text_width,
+ NULL, FALSE, FALSE);
}
+
+ if (sDebugRects
+ || (LLView::sEditingUI && this == LLView::sEditingUIView))
+ {
+ drawDebugRect();
+ }
+
// reset hover status for next frame
mNeedsHighlight = FALSE;
}
void LLButton::drawBorder(const LLColor4& color, S32 size)
{
- S32 left = -size;
- S32 top = getRect().getHeight() + size;
- S32 right = getRect().getWidth() + size;
- S32 bottom = -size;
-
- if (mImagep.isNull())
- {
- gl_rect_2d(left, top, right, bottom, color, FALSE);
- return;
- }
-
if (mScaleImage)
{
- mImagep->drawSolid(left, bottom, right-left, top-bottom, color);
+ mImagep->drawBorder(getLocalRect(), color, size);
}
else
{
- mImagep->drawSolid(left, bottom, mImagep->getWidth() + size * 2, mImagep->getHeight() + size * 2, color);
+ mImagep->drawBorder(0, 0, color, size);
}
}
@@ -923,7 +884,7 @@ void LLButton::setImageOverlay(const LLString &image_name, LLFontGL::HAlign alig
}
else
{
- mImageOverlay = LLUI::getUIImageByName(image_name);
+ mImageOverlay = LLUI::getUIImage(image_name);
mImageOverlayAlignment = alignment;
mImageOverlayColor = color;
}
@@ -956,37 +917,37 @@ S32 round_up(S32 grid, S32 value)
void LLButton::setImageUnselected(const LLString &image_name)
{
- setImageUnselected(image_name.empty() ? NULL : LLUI::getUIImageByName(image_name));
+ setImageUnselected(LLUI::getUIImage(image_name));
mImageUnselectedName = image_name;
}
void LLButton::setImageSelected(const LLString &image_name)
{
- setImageSelected(image_name.empty() ? NULL : LLUI::getUIImageByName(image_name));
+ setImageSelected(LLUI::getUIImage(image_name));
mImageSelectedName = image_name;
}
void LLButton::setImageHoverSelected(const LLString &image_name)
{
- setImageHoverSelected(image_name.empty() ? NULL : LLUI::getUIImageByName(image_name));
+ setImageHoverSelected(LLUI::getUIImage(image_name));
mImageHoverSelectedName = image_name;
}
void LLButton::setImageHoverUnselected(const LLString &image_name)
{
- setImageHoverUnselected(image_name.empty() ? NULL : LLUI::getUIImageByName(image_name));
+ setImageHoverUnselected(LLUI::getUIImage(image_name));
mImageHoverUnselectedName = image_name;
}
void LLButton::setImageDisabled(const LLString &image_name)
{
- setImageDisabled(image_name.empty() ? NULL : LLUI::getUIImageByName(image_name));
+ setImageDisabled(LLUI::getUIImage(image_name));
mImageDisabledName = image_name;
}
void LLButton::setImageDisabledSelected(const LLString &image_name)
{
- setImageDisabledSelected(image_name.empty() ? NULL : LLUI::getUIImageByName(image_name));
+ setImageDisabledSelected(LLUI::getUIImage(image_name));
mImageDisabledSelectedName = image_name;
}
diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h
index a181fbbf56..6357e27bb7 100644
--- a/indra/llui/llbutton.h
+++ b/indra/llui/llbutton.h
@@ -87,16 +87,15 @@ public:
virtual ~LLButton();
void init(void (*click_callback)(void*), void *callback_data, const LLFontGL* font, const LLString& control_name);
- virtual EWidgetType getWidgetType() const;
- virtual LLString getWidgetTag() const;
+
void addImageAttributeToXML(LLXMLNodePtr node, const LLString& imageName,
const LLUUID& imageID,const LLString& xmlTagName) const;
virtual LLXMLNodePtr getXML(bool save_children = true) const;
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
- virtual BOOL handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent);
- virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
+ virtual BOOL handleUnicodeCharHere(llwchar uni_char);
+ virtual BOOL handleKeyHere(KEY key, MASK mask);
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
virtual BOOL handleHover(S32 x, S32 y, MASK mask);
@@ -104,7 +103,6 @@ public:
virtual void onMouseCaptureLost();
- // HACK: "committing" a button is the same as clicking on it.
virtual void onCommit();
void setUnselectedLabelColor( const LLColor4& c ) { mUnselectedLabelColor = c; }
diff --git a/indra/llui/llcheckboxctrl.cpp b/indra/llui/llcheckboxctrl.cpp
index 0b3156fa1e..4d65047c36 100644
--- a/indra/llui/llcheckboxctrl.cpp
+++ b/indra/llui/llcheckboxctrl.cpp
@@ -45,10 +45,11 @@
#include "llfontgl.h"
#include "lltextbox.h"
#include "llkeyboard.h"
-#include "llviewborder.h"
const U32 MAX_STRING_LENGTH = 10;
+static LLRegisterWidget<LLCheckBoxCtrl> r("check_box");
+
LLCheckBoxCtrl::LLCheckBoxCtrl(const LLString& name, const LLRect& rect,
const LLString& label,
diff --git a/indra/llui/llcheckboxctrl.h b/indra/llui/llcheckboxctrl.h
index 513b2930e1..2921e837c4 100644
--- a/indra/llui/llcheckboxctrl.h
+++ b/indra/llui/llcheckboxctrl.h
@@ -75,8 +75,7 @@ public:
virtual ~LLCheckBoxCtrl();
// LLView interface
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_CHECKBOX; }
- virtual LLString getWidgetTag() const { return LL_CHECK_BOX_CTRL_TAG; }
+
virtual LLXMLNodePtr getXML(bool save_children = true) const;
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp
index ca02305f32..62f2a6d319 100644
--- a/indra/llui/llcombobox.cpp
+++ b/indra/llui/llcombobox.cpp
@@ -57,6 +57,8 @@ S32 LLCOMBOBOX_HEIGHT = 0;
S32 LLCOMBOBOX_WIDTH = 0;
S32 MAX_COMBO_WIDTH = 500;
+static LLRegisterWidget<LLComboBox> r1("combo_box");
+
LLComboBox::LLComboBox( const LLString& name, const LLRect &rect, const LLString& label,
void (*commit_callback)(LLUICtrl*,void*),
void *callback_userdata
@@ -74,9 +76,10 @@ LLComboBox::LLComboBox( const LLString& name, const LLRect &rect, const LLString
{
// Always use text box
// Text label button
- mButton = new LLButton("comboxbox button",
- LLRect(), label, NULL, LLString::null,
- NULL, this);
+ mButton = new LLButton(label,
+ LLRect(),
+ LLString::null,
+ NULL, this);
mButton->setImageUnselected("square_btn_32x128.tga");
mButton->setImageSelected("square_btn_selected_32x128.tga");
mButton->setImageDisabled("square_btn_32x128.tga");
@@ -99,13 +102,7 @@ LLComboBox::LLComboBox( const LLString& name, const LLRect &rect, const LLString
mList->setCommitOnKeyboardMovement(FALSE);
addChild(mList);
- LLRect border_rect(0, getRect().getHeight(), getRect().getWidth(), 0);
- mBorder = new LLViewBorder( "combo border", border_rect );
- addChild( mBorder );
- mBorder->setFollowsAll();
-
- LLUUID arrow_image_id( LLUI::sAssetsGroup->getString("combobox_arrow.tga") );
- mArrowImage = LLUI::sImageProvider->getImageByID(arrow_image_id);
+ mArrowImage = LLUI::sImageProvider->getUIImage("combobox_arrow.tga");
mButton->setImageOverlay("combobox_arrow.tga", LLFontGL::RIGHT);
updateLayout();
@@ -447,7 +444,7 @@ void LLComboBox::setButtonVisible(BOOL visible)
LLRect text_entry_rect(0, getRect().getHeight(), getRect().getWidth(), 0);
if (visible)
{
- text_entry_rect.mRight -= llmax(8,mArrowImage->getWidth(0)) + 2 * LLUI::sConfigGroup->getS32("DropShadowButton");
+ text_entry_rect.mRight -= llmax(8,mArrowImage->getWidth()) + 2 * LLUI::sConfigGroup->getS32("DropShadowButton");
}
//mTextEntry->setRect(text_entry_rect);
mTextEntry->reshape(text_entry_rect.getWidth(), text_entry_rect.getHeight(), TRUE);
@@ -456,15 +453,10 @@ void LLComboBox::setButtonVisible(BOOL visible)
void LLComboBox::draw()
{
- if( getVisible() )
- {
- mBorder->setKeyboardFocusHighlight(hasFocus());
-
- mButton->setEnabled(getEnabled() /*&& !mList->isEmpty()*/);
+ mButton->setEnabled(getEnabled() /*&& !mList->isEmpty()*/);
- // Draw children normally
- LLUICtrl::draw();
- }
+ // Draw children normally
+ LLUICtrl::draw();
}
BOOL LLComboBox::setCurrentByIndex( S32 index )
@@ -494,14 +486,14 @@ void LLComboBox::updateLayout()
if (mAllowTextEntry)
{
S32 shadow_size = LLUI::sConfigGroup->getS32("DropShadowButton");
- mButton->setRect(LLRect( getRect().getWidth() - llmax(8,mArrowImage->getWidth(0)) - 2 * shadow_size,
+ mButton->setRect(LLRect( getRect().getWidth() - llmax(8,mArrowImage->getWidth()) - 2 * shadow_size,
rect.mTop, rect.mRight, rect.mBottom));
mButton->setTabStop(FALSE);
if (!mTextEntry)
{
LLRect text_entry_rect(0, getRect().getHeight(), getRect().getWidth(), 0);
- text_entry_rect.mRight -= llmax(8,mArrowImage->getWidth(0)) + 2 * LLUI::sConfigGroup->getS32("DropShadowButton");
+ text_entry_rect.mRight -= llmax(8,mArrowImage->getWidth()) + 2 * LLUI::sConfigGroup->getS32("DropShadowButton");
// clear label on button
LLString cur_label = mButton->getLabelSelected();
mTextEntry = new LLLineEditor("combo_text_entry",
@@ -512,11 +504,7 @@ void LLComboBox::updateLayout()
onTextCommit,
onTextEntry,
NULL,
- this,
- NULL, // prevalidate func
- LLViewBorder::BEVEL_NONE,
- LLViewBorder::STYLE_LINE,
- 0); // no border
+ this);
mTextEntry->setSelectAllonFocusReceived(TRUE);
mTextEntry->setHandleEditKeysDirectly(TRUE);
mTextEntry->setCommitOnFocusLost(FALSE);
@@ -780,10 +768,10 @@ BOOL LLComboBox::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_
return TRUE;
}
-BOOL LLComboBox::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
+BOOL LLComboBox::handleKeyHere(KEY key, MASK mask)
{
BOOL result = FALSE;
- if (gFocusMgr.childHasKeyboardFocus(this))
+ if (hasFocus())
{
//give list a chance to pop up and handle key
LLScrollListItem* last_selected_item = mList->getLastSelectedItem();
@@ -792,7 +780,7 @@ BOOL LLComboBox::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
// highlight the original selection before potentially selecting a new item
mList->highlightNthItem(mList->getItemIndex(last_selected_item));
}
- result = mList->handleKeyHere(key, mask, FALSE);
+ result = mList->handleKeyHere(key, mask);
// if selection has changed, pop open list
if (mList->getLastSelectedItem() != last_selected_item)
{
@@ -802,7 +790,7 @@ BOOL LLComboBox::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
return result;
}
-BOOL LLComboBox::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent)
+BOOL LLComboBox::handleUnicodeCharHere(llwchar uni_char)
{
BOOL result = FALSE;
if (gFocusMgr.childHasKeyboardFocus(this))
@@ -816,7 +804,7 @@ BOOL LLComboBox::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent
// highlight the original selection before potentially selecting a new item
mList->highlightNthItem(mList->getItemIndex(last_selected_item));
}
- result = mList->handleUnicodeCharHere(uni_char, called_from_parent);
+ result = mList->handleUnicodeCharHere(uni_char);
if (mList->getLastSelectedItem() != last_selected_item)
{
showList();
@@ -1095,6 +1083,8 @@ BOOL LLComboBox::selectItemRange( S32 first, S32 last )
// LLFlyoutButton
//
+static LLRegisterWidget<LLFlyoutButton> r2("flyout_button");
+
const S32 FLYOUT_BUTTON_ARROW_WIDTH = 24;
LLFlyoutButton::LLFlyoutButton(
@@ -1109,9 +1099,8 @@ LLFlyoutButton::LLFlyoutButton(
{
// Always use text box
// Text label button
- mActionButton = new LLButton("flyout_button_main",
- LLRect(), label, NULL, LLString::null,
- NULL, this);
+ mActionButton = new LLButton(label,
+ LLRect(), LLString::null, NULL, this);
mActionButton->setScaleImage(TRUE);
mActionButton->setClickedCallback(onActionButtonClick);
@@ -1120,10 +1109,10 @@ LLFlyoutButton::LLFlyoutButton(
mActionButton->setLabel(label);
addChild(mActionButton);
- mActionButtonImage = LLUI::getUIImageByName("flyout_btn_left.tga");
- mExpanderButtonImage = LLUI::getUIImageByName("flyout_btn_right.tga");
- mActionButtonImageSelected = LLUI::getUIImageByName("flyout_btn_left_selected.tga");
- mExpanderButtonImageSelected = LLUI::getUIImageByName("flyout_btn_right_selected.tga");
+ mActionButtonImage = LLUI::getUIImage("flyout_btn_left.tga");
+ mExpanderButtonImage = LLUI::getUIImage("flyout_btn_right.tga");
+ mActionButtonImageSelected = LLUI::getUIImage("flyout_btn_left_selected.tga");
+ mExpanderButtonImageSelected = LLUI::getUIImage("flyout_btn_right_selected.tga");
mActionButton->setImageSelected(mActionButtonImageSelected);
mActionButton->setImageUnselected(mActionButtonImage);
@@ -1136,8 +1125,6 @@ LLFlyoutButton::LLFlyoutButton(
mButton->setImageDisabledSelected(LLPointer<LLUIImage>(NULL));
mButton->setRightHPad(6);
- mBorder->setVisible(FALSE);
-
updateLayout();
}
diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h
index 0d6c3aef2e..c4db52cc97 100644
--- a/indra/llui/llcombobox.h
+++ b/indra/llui/llcombobox.h
@@ -73,8 +73,7 @@ public:
virtual ~LLComboBox();
// LLView interface
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_COMBO_BOX; }
- virtual LLString getWidgetTag() const { return LL_COMBO_BOX_TAG; }
+
virtual LLXMLNodePtr getXML(bool save_children = true) const;
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
@@ -85,8 +84,8 @@ public:
virtual void setEnabled(BOOL enabled);
virtual BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect);
- virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
- virtual BOOL handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent);
+ virtual BOOL handleKeyHere(KEY key, MASK mask);
+ virtual BOOL handleUnicodeCharHere(llwchar uni_char);
// LLUICtrl interface
virtual void clear(); // select nothing
@@ -187,9 +186,8 @@ public:
protected:
LLButton* mButton;
LLScrollListCtrl* mList;
- LLViewBorder* mBorder;
EPreferredPosition mListPosition;
- LLPointer<LLImageGL> mArrowImage;
+ LLPointer<LLUIImage> mArrowImage;
private:
S32 mButtonPadding;
@@ -211,9 +209,6 @@ public:
void (*commit_callback)(LLUICtrl*, void*) = NULL,
void *callback_userdata = NULL);
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_FLYOUT_BUTTON; }
- virtual LLString getWidgetTag() const { return LL_FLYOUT_BUTTON_TAG; }
-
virtual void updateLayout();
virtual void draw();
virtual void setEnabled(BOOL enabled);
diff --git a/indra/llui/lldraghandle.cpp b/indra/llui/lldraghandle.cpp
index a4e92e11d0..75e4ad5c08 100644
--- a/indra/llui/lldraghandle.cpp
+++ b/indra/llui/lldraghandle.cpp
@@ -101,16 +101,6 @@ LLDragHandleTop::LLDragHandleTop(const LLString& name, const LLRect &rect, const
setTitle( title );
}
-EWidgetType LLDragHandleTop::getWidgetType() const
-{
- return WIDGET_TYPE_DRAG_HANDLE_TOP;
-}
-
-LLString LLDragHandleTop::getWidgetTag() const
-{
- return LL_DRAG_HANDLE_TOP_TAG;
-}
-
LLDragHandleLeft::LLDragHandleLeft(const LLString& name, const LLRect &rect, const LLString& title)
: LLDragHandle(name, rect, title)
{
@@ -118,22 +108,12 @@ LLDragHandleLeft::LLDragHandleLeft(const LLString& name, const LLRect &rect, con
setTitle( title );
}
-EWidgetType LLDragHandleLeft::getWidgetType() const
-{
- return WIDGET_TYPE_DRAG_HANDLE_LEFT;
-}
-
-LLString LLDragHandleLeft::getWidgetTag() const
-{
- return LL_DRAG_HANDLE_LEFT_TAG;
-}
-
void LLDragHandleTop::setTitle(const LLString& title)
{
LLString trimmed_title = title;
LLString::trim(trimmed_title);
- const LLFontGL* font = gResMgr->getRes( LLFONT_SANSSERIF );
+ const LLFontGL* font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF );
LLTextBox* titlebox = new LLTextBox( "Drag Handle Title", getRect(), trimmed_title, font );
titlebox->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT | FOLLOWS_RIGHT);
titlebox->setFontStyle(LLFontGL::DROP_SHADOW_SOFT);
@@ -262,7 +242,7 @@ void LLDragHandleTop::reshapeTitleBox()
{
return;
}
- const LLFontGL* font = gResMgr->getRes( LLFONT_SANSSERIF );
+ const LLFontGL* font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF );
S32 title_width = font->getWidth( getTitleBox()->getText() ) + TITLE_PAD;
if (getMaxTitleWidth() > 0)
title_width = llmin(title_width, getMaxTitleWidth());
@@ -372,7 +352,7 @@ BOOL LLDragHandle::handleHover(S32 x, S32 y, MASK mask)
lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" <<llendl;
handled = TRUE;
}
- else if( getVisible() )
+ else
{
getWindow()->setCursor(UI_CURSOR_ARROW);
lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive)" << llendl;
diff --git a/indra/llui/lldraghandle.h b/indra/llui/lldraghandle.h
index 940eb21e66..6215142e6f 100644
--- a/indra/llui/lldraghandle.h
+++ b/indra/llui/lldraghandle.h
@@ -91,9 +91,6 @@ class LLDragHandleTop
public:
LLDragHandleTop(const LLString& name, const LLRect& rect, const LLString& title );
- virtual EWidgetType getWidgetType() const;
- virtual LLString getWidgetTag() const;
-
virtual void setTitle( const LLString& title );
virtual const LLString& getTitle() const;
virtual void draw();
@@ -111,9 +108,6 @@ class LLDragHandleLeft
public:
LLDragHandleLeft(const LLString& name, const LLRect& rect, const LLString& title );
- virtual EWidgetType getWidgetType() const;
- virtual LLString getWidgetTag() const;
-
virtual void setTitle( const LLString& title );
virtual const LLString& getTitle() const;
virtual void draw();
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index fed39b7917..f8882c5ebf 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -50,7 +50,6 @@
#include "lltextbox.h"
#include "llresmgr.h"
#include "llui.h"
-#include "llviewborder.h"
#include "llwindow.h"
#include "llstl.h"
#include "llcontrol.h"
@@ -799,24 +798,10 @@ void LLFloater::setMinimized(BOOL minimize)
mButtonsEnabled[BUTTON_RESTORE] = TRUE;
}
- mMinimizedHiddenChildren.clear();
- // hide all children
- for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
- {
- LLView* viewp = *child_it;
- if (!viewp->getVisible())
- {
- mMinimizedHiddenChildren.push_back(viewp->getHandle());
- }
- viewp->setVisible(FALSE);
- }
-
- // except the special controls
if (mDragHandle)
{
mDragHandle->setVisible(TRUE);
}
-
setBorderVisible(TRUE);
for(handle_set_iter_t dependent_it = mDependents.begin();
@@ -840,6 +825,12 @@ void LLFloater::setMinimized(BOOL minimize)
// Lose keyboard focus when minimized
releaseFocus();
+ for (S32 i = 0; i < 4; i++)
+ {
+ mResizeBar[i]->setEnabled(FALSE);
+ mResizeHandle[i]->setEnabled(FALSE);
+ }
+
mMinimized = TRUE;
}
else
@@ -862,24 +853,6 @@ void LLFloater::setMinimized(BOOL minimize)
mButtonsEnabled[BUTTON_RESTORE] = FALSE;
}
- // show all children
- for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
- {
- LLView* viewp = *child_it;
- viewp->setVisible(TRUE);
- }
-
- std::vector<LLHandle<LLView> >::iterator itor = mMinimizedHiddenChildren.begin();
- for ( ; itor != mMinimizedHiddenChildren.end(); ++itor)
- {
- LLView* viewp = itor->get();
- if(viewp)
- {
- viewp->setVisible(FALSE);
- }
- }
- mMinimizedHiddenChildren.clear();
-
// show dependent floater
for(handle_set_iter_t dependent_it = mDependents.begin();
dependent_it != mDependents.end();
@@ -893,6 +866,12 @@ void LLFloater::setMinimized(BOOL minimize)
}
}
+ for (S32 i = 0; i < 4; i++)
+ {
+ mResizeBar[i]->setEnabled(isResizable());
+ mResizeHandle[i]->setEnabled(isResizable());
+ }
+
mMinimized = FALSE;
}
make_ui_sound("UISndWindowClose");
@@ -1302,49 +1281,72 @@ void LLFloater::onClickClose( void* userdata )
// virtual
void LLFloater::draw()
{
- if( getVisible() )
+ // draw background
+ if( isBackgroundVisible() )
{
- // draw background
- if( isBackgroundVisible() )
- {
- S32 left = LLPANEL_BORDER_WIDTH;
- S32 top = getRect().getHeight() - LLPANEL_BORDER_WIDTH;
- S32 right = getRect().getWidth() - LLPANEL_BORDER_WIDTH;
- S32 bottom = LLPANEL_BORDER_WIDTH;
+ S32 left = LLPANEL_BORDER_WIDTH;
+ S32 top = getRect().getHeight() - LLPANEL_BORDER_WIDTH;
+ S32 right = getRect().getWidth() - LLPANEL_BORDER_WIDTH;
+ S32 bottom = LLPANEL_BORDER_WIDTH;
- LLColor4 shadow_color = LLUI::sColorsGroup->getColor("ColorDropShadow");
- F32 shadow_offset = (F32)LLUI::sConfigGroup->getS32("DropShadowFloater");
- if (!isBackgroundOpaque())
- {
- shadow_offset *= 0.2f;
- shadow_color.mV[VALPHA] *= 0.5f;
- }
- gl_drop_shadow(left, top, right, bottom,
- shadow_color,
- llround(shadow_offset));
+ LLColor4 shadow_color = LLUI::sColorsGroup->getColor("ColorDropShadow");
+ F32 shadow_offset = (F32)LLUI::sConfigGroup->getS32("DropShadowFloater");
+ if (!isBackgroundOpaque())
+ {
+ shadow_offset *= 0.2f;
+ shadow_color.mV[VALPHA] *= 0.5f;
+ }
+ gl_drop_shadow(left, top, right, bottom,
+ shadow_color,
+ llround(shadow_offset));
- // No transparent windows in simple UI
- if (isBackgroundOpaque())
- {
- gl_rect_2d( left, top, right, bottom, getBackgroundColor() );
- }
- else
- {
- gl_rect_2d( left, top, right, bottom, getTransparentColor() );
- }
+ // No transparent windows in simple UI
+ if (isBackgroundOpaque())
+ {
+ gl_rect_2d( left, top, right, bottom, getBackgroundColor() );
+ }
+ else
+ {
+ gl_rect_2d( left, top, right, bottom, getTransparentColor() );
+ }
- if(gFocusMgr.childHasKeyboardFocus(this) && !getIsChrome() && !getTitle().empty())
- {
- // draw highlight on title bar to indicate focus. RDW
- const LLFontGL* font = gResMgr->getRes( LLFONT_SANSSERIF );
- LLRect r = getRect();
- gl_rect_2d_offset_local(0, r.getHeight(), r.getWidth(), r.getHeight() - (S32)font->getLineHeight() - 1,
- LLUI::sColorsGroup->getColor("TitleBarFocusColor"), 0, TRUE);
- }
+ if(gFocusMgr.childHasKeyboardFocus(this) && !getIsChrome() && !getTitle().empty())
+ {
+ // draw highlight on title bar to indicate focus. RDW
+ const LLFontGL* font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF );
+ LLRect r = getRect();
+ gl_rect_2d_offset_local(0, r.getHeight(), r.getWidth(), r.getHeight() - (S32)font->getLineHeight() - 1,
+ LLUI::sColorsGroup->getColor("TitleBarFocusColor"), 0, TRUE);
}
+ }
- LLPanel::updateDefaultBtn();
+ LLPanel::updateDefaultBtn();
+ if( getDefaultButton() )
+ {
+ if (hasFocus() && getDefaultButton()->getEnabled())
+ {
+ LLUICtrl* focus_ctrl = gFocusMgr.getKeyboardFocus();
+ // is this button a direct descendent and not a nested widget (e.g. checkbox)?
+ BOOL focus_is_child_button = dynamic_cast<LLButton*>(focus_ctrl) != NULL && focus_ctrl->getParent() == this;
+ // only enable default button when current focus is not a button
+ getDefaultButton()->setBorderEnabled(!focus_is_child_button);
+ }
+ else
+ {
+ getDefaultButton()->setBorderEnabled(FALSE);
+ }
+ }
+ if (isMinimized())
+ {
+ for (S32 i = 0; i < BUTTON_COUNT; i++)
+ {
+ drawChild(mButtons[i]);
+ }
+ drawChild(mDragHandle);
+ }
+ else
+ {
// draw children
LLView* focused_child = gFocusMgr.getKeyboardFocus();
BOOL focused_child_visible = FALSE;
@@ -1357,36 +1359,35 @@ void LLFloater::draw()
// don't call LLPanel::draw() since we've implemented custom background rendering
LLView::draw();
- if( isBackgroundVisible() )
- {
- // add in a border to improve spacialized visual aclarity ;)
- // use lines instead of gl_rect_2d so we can round the edges as per james' recommendation
- LLUI::setLineWidth(1.5f);
- LLColor4 outlineColor = gFocusMgr.childHasKeyboardFocus(this) ? LLUI::sColorsGroup->getColor("FloaterFocusBorderColor") : LLUI::sColorsGroup->getColor("FloaterUnfocusBorderColor");
- gl_rect_2d_offset_local(0, getRect().getHeight() + 1, getRect().getWidth() + 1, 0, outlineColor, -LLPANEL_BORDER_WIDTH, FALSE);
- LLUI::setLineWidth(1.f);
- }
-
if (focused_child_visible)
{
focused_child->setVisible(TRUE);
}
drawChild(focused_child);
+ }
+
+ if( isBackgroundVisible() )
+ {
+ // add in a border to improve spacialized visual aclarity ;)
+ // use lines instead of gl_rect_2d so we can round the edges as per james' recommendation
+ LLUI::setLineWidth(1.5f);
+ LLColor4 outlineColor = gFocusMgr.childHasKeyboardFocus(this) ? LLUI::sColorsGroup->getColor("FloaterFocusBorderColor") : LLUI::sColorsGroup->getColor("FloaterUnfocusBorderColor");
+ gl_rect_2d_offset_local(0, getRect().getHeight() + 1, getRect().getWidth() + 1, 0, outlineColor, -LLPANEL_BORDER_WIDTH, FALSE);
+ LLUI::setLineWidth(1.f);
+ }
- // update tearoff button for torn off floaters
- // when last host goes away
- if (mCanTearOff && !getHost())
+ // update tearoff button for torn off floaters
+ // when last host goes away
+ if (mCanTearOff && !getHost())
+ {
+ LLFloater* old_host = mLastHostHandle.get();
+ if (!old_host)
{
- LLFloater* old_host = mLastHostHandle.get();
- if (!old_host)
- {
- setCanTearOff(FALSE);
- }
+ setCanTearOff(FALSE);
}
}
}
-
void LLFloater::setCanMinimize(BOOL can_minimize)
{
// removing minimize/restore button programmatically,
@@ -1532,7 +1533,13 @@ void LLFloater::updateButtons()
S32 button_count = 0;
for (S32 i = 0; i < BUTTON_COUNT; i++)
{
- if (mButtonsEnabled[i])
+ mButtons[i]->setEnabled(mButtonsEnabled[i]);
+
+ if (mButtonsEnabled[i]
+ //*HACK: always render close button for hosted floaters
+ // so that users don't accidentally hit the button when closing multiple windows
+ // in the chatterbox
+ || (i == BUTTON_CLOSE && mButtonScale != 1.f))
{
button_count++;
@@ -1556,14 +1563,12 @@ void LLFloater::updateButtons()
mButtons[i]->setRect(btn_rect);
mButtons[i]->setVisible(TRUE);
- mButtons[i]->setEnabled(TRUE);
// the restore button should have a tab stop so that it takes action when you Ctrl-Tab to a minimized floater
mButtons[i]->setTabStop(i == BUTTON_RESTORE);
}
else if (mButtons[i])
{
mButtons[i]->setVisible(FALSE);
- mButtons[i]->setEnabled(FALSE);
}
}
@@ -2068,7 +2073,7 @@ void LLFloaterView::closeAllChildren(bool app_quitting)
// Attempt to close floater. This will cause the "do you want to save"
// dialogs to appear.
- if (floaterp->canClose())
+ if (floaterp->canClose() && !floaterp->isDead())
{
floaterp->close(app_quitting);
}
@@ -2085,7 +2090,7 @@ BOOL LLFloaterView::allChildrenClosed()
LLView* viewp = *it;
LLFloater* floaterp = (LLFloater*)viewp;
- if (floaterp->getVisible() && floaterp->canClose())
+ if (floaterp->getVisible() && !floaterp->isDead() && floaterp->canClose())
{
return false;
}
@@ -2670,24 +2675,20 @@ void LLMultiFloater::setVisible(BOOL visible)
}
}
-BOOL LLMultiFloater::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
+BOOL LLMultiFloater::handleKeyHere(KEY key, MASK mask)
{
- if (getEnabled()
- && mask == MASK_CONTROL)
+ if (key == 'W' && mask == MASK_CONTROL)
{
- if (key == 'W')
+ LLFloater* floater = getActiveFloater();
+ // is user closeable and is system closeable
+ if (floater && floater->canClose() && floater->isCloseable())
{
- LLFloater* floater = getActiveFloater();
- // is user closeable and is system closeable
- if (floater && floater->canClose() && floater->isCloseable())
- {
- floater->close();
- }
- return TRUE;
+ floater->close();
}
+ return TRUE;
}
- return LLFloater::handleKeyHere(key, mask, called_from_parent);
+ return LLFloater::handleKeyHere(key, mask);
}
LLFloater* LLMultiFloater::getActiveFloater()
@@ -2760,10 +2761,10 @@ BOOL LLMultiFloater::postBuild()
return TRUE;
}
- requires("Preview Tabs", WIDGET_TYPE_TAB_CONTAINER);
+ requires<LLTabContainer>("Preview Tabs");
if (checkRequirements())
{
- mTabContainer = LLUICtrlFactory::getTabContainerByName(this, "Preview Tabs");
+ mTabContainer = getChild<LLTabContainer>("Preview Tabs");
return TRUE;
}
diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h
index 6597ef46da..360d8093e5 100644
--- a/indra/llui/llfloater.h
+++ b/indra/llui/llfloater.h
@@ -50,7 +50,7 @@ class LLMultiFloater;
const S32 LLFLOATER_VPAD = 6;
const S32 LLFLOATER_HPAD = 6;
const S32 LLFLOATER_CLOSE_BOX_SIZE = 16;
-const S32 LLFLOATER_HEADER_SIZE = 16;
+const S32 LLFLOATER_HEADER_SIZE = 18;
const BOOL RESIZE_YES = TRUE;
const BOOL RESIZE_NO = FALSE;
@@ -122,8 +122,6 @@ public:
virtual void init(const LLString& title, BOOL resizable,
S32 min_width, S32 min_height, BOOL drag_on_left,
BOOL minimizable, BOOL close_btn);
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_FLOATER; }
- virtual LLString getWidgetTag() const { return LL_FLOATER_TAG; };
virtual void open(); /* Flawfinder: ignore */
@@ -302,9 +300,6 @@ class LLFloaterView : public LLUICtrl
public:
LLFloaterView( const LLString& name, const LLRect& rect );
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_FLOATER_VIEW; }
- virtual LLString getWidgetTag() const { return LL_FLOATER_VIEW_TAG; }
-
/*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent);
void reshape(S32 width, S32 height, BOOL called_from_parent, BOOL adjust_vertical);
@@ -373,9 +368,7 @@ public:
/*virtual*/ void onClose(bool app_quitting);
/*virtual*/ void draw();
/*virtual*/ void setVisible(BOOL visible);
- /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
- /*virtual*/ EWidgetType getWidgetType() const { return WIDGET_TYPE_MULTI_FLOATER; }
- /*virtual*/ LLString getWidgetTag() const { return LL_MULTI_FLOATER_TAG; };
+ /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask);
virtual void setCanResize(BOOL can_resize);
virtual void growToFit(S32 content_width, S32 content_height);
diff --git a/indra/llui/llfocusmgr.cpp b/indra/llui/llfocusmgr.cpp
index 29c6aa3c30..621b01ad82 100644
--- a/indra/llui/llfocusmgr.cpp
+++ b/indra/llui/llfocusmgr.cpp
@@ -46,6 +46,7 @@ LLFocusMgr::LLFocusMgr()
mKeyboardFocus( NULL ),
mLastKeyboardFocus( NULL ),
mDefaultKeyboardFocus( NULL ),
+ mKeystrokesOnly(FALSE),
mTopCtrl( NULL ),
mFocusWeight(0.f),
mAppHasFocus(TRUE) // Macs don't seem to notify us that we've gotten focus, so default to true
@@ -85,7 +86,7 @@ void LLFocusMgr::releaseFocusIfNeeded( const LLView* view )
}
-void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock)
+void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock, BOOL keystrokes_only)
{
if (mLockedView &&
(new_focus == NULL ||
@@ -98,6 +99,8 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock)
//llinfos << "Keyboard focus handled by " << (new_focus ? new_focus->getName() : "nothing") << llendl;
+ mKeystrokesOnly = keystrokes_only;
+
if( new_focus != mKeyboardFocus )
{
mLastKeyboardFocus = mKeyboardFocus;
diff --git a/indra/llui/llfocusmgr.h b/indra/llui/llfocusmgr.h
index a3ca8bee26..34651160f1 100644
--- a/indra/llui/llfocusmgr.h
+++ b/indra/llui/llfocusmgr.h
@@ -54,13 +54,17 @@ public:
BOOL childHasMouseCapture( const LLView* parent ) const;
// Keyboard Focus
- void setKeyboardFocus(LLUICtrl* new_focus, BOOL lock = FALSE); // new_focus = NULL to release the focus.
+ void setKeyboardFocus(LLUICtrl* new_focus, BOOL lock = FALSE, BOOL keystrokes_only = FALSE); // new_focus = NULL to release the focus.
LLUICtrl* getKeyboardFocus() const { return mKeyboardFocus; }
LLUICtrl* getLastKeyboardFocus() const { return mLastKeyboardFocus; }
BOOL childHasKeyboardFocus( const LLView* parent ) const;
void removeKeyboardFocusWithoutCallback( const LLView* focus );
+ BOOL getKeystrokesOnly() { return mKeystrokesOnly; }
+ void setKeystrokesOnly(BOOL keystrokes_only) { mKeystrokesOnly = keystrokes_only; }
+
F32 getFocusTime() const { return mFocusTimer.getElapsedTimeF32(); }
F32 getFocusFlashAmt() const;
+ S32 getFocusFlashWidth() const { return llround(lerp(1.f, 3.f, getFocusFlashAmt())); }
LLColor4 getFocusColor() const;
void triggerFocusFlash();
BOOL getAppHasFocus() const { return mAppHasFocus; }
@@ -96,6 +100,7 @@ private:
LLUICtrl* mKeyboardFocus; // Keyboard events are preemptively routed to this object
LLUICtrl* mLastKeyboardFocus; // who last had focus
LLUICtrl* mDefaultKeyboardFocus;
+ BOOL mKeystrokesOnly;
// Top View
LLUICtrl* mTopCtrl;
diff --git a/indra/llui/lliconctrl.cpp b/indra/llui/lliconctrl.cpp
index f47f166c45..df37532d60 100644
--- a/indra/llui/lliconctrl.cpp
+++ b/indra/llui/lliconctrl.cpp
@@ -42,14 +42,15 @@
const F32 RESOLUTION_BUMP = 1.f;
+static LLRegisterWidget<LLIconCtrl> r("icon");
+
LLIconCtrl::LLIconCtrl(const LLString& name, const LLRect &rect, const LLUUID &image_id)
: LLUICtrl(name,
rect,
FALSE, // mouse opaque
NULL, NULL,
FOLLOWS_LEFT | FOLLOWS_TOP),
- mColor( LLColor4::white ),
- mImageName("")
+ mColor( LLColor4::white )
{
setImage( image_id );
setTabStop(FALSE);
@@ -64,9 +65,7 @@ LLIconCtrl::LLIconCtrl(const LLString& name, const LLRect &rect, const LLString
mColor( LLColor4::white ),
mImageName(image_name)
{
- LLUUID image_id;
- image_id.set(LLUI::sAssetsGroup->getString( image_name ));
- setImage( image_id );
+ setImage( image_name );
setTabStop(FALSE);
}
@@ -77,32 +76,52 @@ LLIconCtrl::~LLIconCtrl()
}
-void LLIconCtrl::setImage(const LLUUID &image_id)
+void LLIconCtrl::setImage(const LLString& image_name)
{
- mImageID = image_id;
+ //RN: support UUIDs masquerading as strings
+ if (LLUUID::validate(image_name))
+ {
+ mImageID = LLUUID(image_name);
+
+ setImage(mImageID);
+ }
+ else
+ {
+ mImageName = image_name;
+ mImagep = LLUI::sImageProvider->getUIImage(image_name);
+ mImageID.setNull();
+ }
+}
+
+void LLIconCtrl::setImage(const LLUUID& image_id)
+{
+ mImageName.clear();
mImagep = LLUI::sImageProvider->getUIImageByID(image_id);
+ mImageID = image_id;
}
void LLIconCtrl::draw()
{
- if( getVisible() )
+ if( mImagep.notNull() )
{
- if( mImagep.notNull() )
- {
- mImagep->draw(0, 0,
- getRect().getWidth(), getRect().getHeight(),
- mColor );
- }
-
- LLUICtrl::draw();
+ mImagep->draw(getLocalRect(), mColor );
}
+
+ LLUICtrl::draw();
}
// virtual
void LLIconCtrl::setValue(const LLSD& value )
{
- setImage(value.asUUID());
+ if (value.isUUID())
+ {
+ setImage(value.asUUID());
+ }
+ else
+ {
+ setImage(value.asString());
+ }
}
// virtual
@@ -135,18 +154,16 @@ LLView* LLIconCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *
LLRect rect;
createRect(node, rect, parent, LLRect());
- LLUUID image_id;
+ LLString image_name;
if (node->hasAttribute("image_name"))
{
- LLString image_name;
node->getAttributeString("image_name", image_name);
- image_id.set(LLUI::sAssetsGroup->getString( image_name ));
}
LLColor4 color(LLColor4::white);
LLUICtrlFactory::getAttributeColor(node,"color", color);
- LLIconCtrl* icon = new LLIconCtrl(name, rect, image_id);
+ LLIconCtrl* icon = new LLIconCtrl(name, rect, image_name);
icon->setColor(color);
diff --git a/indra/llui/lliconctrl.h b/indra/llui/lliconctrl.h
index 6535c0bb0b..33429c580e 100644
--- a/indra/llui/lliconctrl.h
+++ b/indra/llui/lliconctrl.h
@@ -51,14 +51,14 @@ public:
LLIconCtrl(const LLString& name, const LLRect &rect, const LLUUID &image_id);
LLIconCtrl(const LLString& name, const LLRect &rect, const LLString &image_name);
virtual ~LLIconCtrl();
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_ICON; }
- virtual LLString getWidgetTag() const { return LL_ICON_CTRL_TAG; }
// llview overrides
virtual void draw();
- void setImage(const LLUUID &image_id);
+ void setImage(const LLString& image_name);
+ void setImage(const LLUUID& image_name);
const LLUUID &getImage() const { return mImageID; }
+ LLString getImageName() const { return mImageName; }
// Takes a UUID, wraps get/setImage
virtual void setValue(const LLSD& value );
diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp
index 6d5e589b04..b54470d44a 100644
--- a/indra/llui/lllineeditor.cpp
+++ b/indra/llui/lllineeditor.cpp
@@ -70,7 +70,6 @@ const F32 CURSOR_FLASH_DELAY = 1.0f; // in seconds
const S32 SCROLL_INCREMENT_ADD = 0; // make space for typing
const S32 SCROLL_INCREMENT_DEL = 4; // make space for baskspacing
const F32 AUTO_SCROLL_TIME = 0.05f;
-const F32 LABEL_HPAD = 5.f;
const F32 PREEDIT_MARKER_BRIGHTNESS = 0.4f;
const S32 PREEDIT_MARKER_GAP = 1;
@@ -81,6 +80,10 @@ const S32 PREEDIT_STANDOUT_GAP = 1;
const S32 PREEDIT_STANDOUT_POSITION = 2;
const S32 PREEDIT_STANDOUT_THICKNESS = 2;
+static LLRegisterWidget<LLLineEditor> r1("line_editor");
+
+/* static */ LLPointer<LLUIImage> LLLineEditor::sImage;
+
//
// Member functions
//
@@ -101,8 +104,8 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect,
mMaxLengthBytes(max_length_bytes),
mCursorPos( 0 ),
mScrollHPos( 0 ),
- mBorderLeft(0),
- mBorderRight(0),
+ mTextPadLeft(0),
+ mTextPadRight(0),
mCommitOnFocusLost( TRUE ),
mRevertOnEsc( TRUE ),
mKeystrokeCallback( keystroke_callback ),
@@ -128,7 +131,8 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect,
mHandleEditKeysDirectly( FALSE ),
mSelectAllonFocusReceived( FALSE ),
mPassDelete(FALSE),
- mReadOnly(FALSE)
+ mReadOnly(FALSE),
+ mImage( sImage )
{
llassert( max_length_bytes > 0 );
@@ -151,8 +155,7 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect,
setFocusLostCallback(focus_lost_callback);
- mMinHPixels = mBorderThickness + UI_LINEEDITOR_H_PAD + mBorderLeft;
- mMaxHPixels = getRect().getWidth() - mMinHPixels - mBorderThickness - mBorderRight;
+ setTextPadding(0, 0);
mScrollTimer.reset();
@@ -166,6 +169,12 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect,
mBorder = new LLViewBorder( "line ed border", border_rect, border_bevel, border_style, mBorderThickness );
addChild( mBorder );
mBorder->setFollows(FOLLOWS_LEFT|FOLLOWS_RIGHT|FOLLOWS_TOP|FOLLOWS_BOTTOM);
+
+ if( ! sImage)
+ {
+ sImage = LLUI::getUIImage("sm_rounded_corners_simple.tga");
+ }
+ mImage = sImage;
}
@@ -243,9 +252,9 @@ void LLLineEditor::updateHistory()
void LLLineEditor::reshape(S32 width, S32 height, BOOL called_from_parent)
{
- LLUICtrl::reshape(width, height, called_from_parent );
-
- mMaxHPixels = getRect().getWidth() - 2 * (mBorderThickness + UI_LINEEDITOR_H_PAD) + 1 - mBorderRight;
+ LLUICtrl::reshape(width, height, called_from_parent);
+ setTextPadding(mTextPadLeft, mTextPadRight); // For clamping side-effect.
+ setCursor(mCursorPos); // For clamping side-effect.
}
void LLLineEditor::setEnabled(BOOL enabled)
@@ -262,12 +271,12 @@ void LLLineEditor::setMaxTextLength(S32 max_text_length)
mMaxLengthBytes = max_len;
}
-void LLLineEditor::setBorderWidth(S32 left, S32 right)
+void LLLineEditor::setTextPadding(S32 left, S32 right)
{
- mBorderLeft = llclamp(left, 0, getRect().getWidth());
- mBorderRight = llclamp(right, 0, getRect().getWidth());
- mMinHPixels = mBorderThickness + UI_LINEEDITOR_H_PAD + mBorderLeft;
- mMaxHPixels = getRect().getWidth() - mMinHPixels - mBorderThickness - mBorderRight;
+ mTextPadLeft = llclamp(left, 0, getRect().getWidth());
+ mTextPadRight = llclamp(right, 0, getRect().getWidth());
+ mMinHPixels = UI_LINEEDITOR_H_PAD + mTextPadLeft;
+ mMaxHPixels = getRect().getWidth() - mMinHPixels - mTextPadRight;
}
@@ -483,9 +492,10 @@ BOOL LLLineEditor::handleDoubleClick(S32 x, S32 y, MASK mask)
BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask)
{
- if (x < mBorderLeft || x > (getRect().getWidth() - mBorderRight))
+ // Check first whether the "clear search" button wants to deal with this.
+ if(childrenHandleMouseDown(x, y, mask) != NULL)
{
- return LLUICtrl::handleMouseDown(x, y, mask);
+ return TRUE;
}
if (mSelectAllonFocusReceived
&& gFocusMgr.getKeyboardFocus() != this)
@@ -563,61 +573,62 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask)
BOOL LLLineEditor::handleHover(S32 x, S32 y, MASK mask)
{
BOOL handled = FALSE;
- if (!hasMouseCapture() && (x < mBorderLeft || x > (getRect().getWidth() - mBorderRight)))
+ // Check first whether the "clear search" button wants to deal with this.
+ if(!hasMouseCapture())
{
- return LLUICtrl::handleHover(x, y, mask);
+ if(childrenHandleHover(x, y, mask) != NULL)
+ {
+ return TRUE;
+ }
}
- if( getVisible() )
+ if( (hasMouseCapture()) && mIsSelecting )
{
- if( (hasMouseCapture()) && mIsSelecting )
+ if (x != mLastSelectionX || y != mLastSelectionY)
{
- if (x != mLastSelectionX || y != mLastSelectionY)
+ mLastSelectionX = x;
+ mLastSelectionY = y;
+ }
+ // Scroll if mouse cursor outside of bounds
+ if (mScrollTimer.hasExpired())
+ {
+ S32 increment = llround(mScrollTimer.getElapsedTimeF32() / AUTO_SCROLL_TIME);
+ mScrollTimer.reset();
+ mScrollTimer.setTimerExpirySec(AUTO_SCROLL_TIME);
+ if( (x < mMinHPixels) && (mScrollHPos > 0 ) )
{
- mLastSelectionX = x;
- mLastSelectionY = y;
+ // Scroll to the left
+ mScrollHPos = llclamp(mScrollHPos - increment, 0, mText.length());
}
- // Scroll if mouse cursor outside of bounds
- if (mScrollTimer.hasExpired())
+ else
+ if( (x > mMaxHPixels) && (mCursorPos < (S32)mText.length()) )
{
- S32 increment = llround(mScrollTimer.getElapsedTimeF32() / AUTO_SCROLL_TIME);
- mScrollTimer.reset();
- mScrollTimer.setTimerExpirySec(AUTO_SCROLL_TIME);
- if( (x < mMinHPixels) && (mScrollHPos > 0 ) )
- {
- // Scroll to the left
- mScrollHPos = llclamp(mScrollHPos - increment, 0, mText.length());
- }
- else
- if( (x > mMaxHPixels) && (mCursorPos < (S32)mText.length()) )
+ // If scrolling one pixel would make a difference...
+ S32 pixels_after_scrolling_one_char = findPixelNearestPos(1);
+ if( pixels_after_scrolling_one_char >= mMaxHPixels )
{
- // If scrolling one pixel would make a difference...
- S32 pixels_after_scrolling_one_char = findPixelNearestPos(1);
- if( pixels_after_scrolling_one_char >= mMaxHPixels )
- {
- // ...scroll to the right
- mScrollHPos = llclamp(mScrollHPos + increment, 0, mText.length());
- }
+ // ...scroll to the right
+ mScrollHPos = llclamp(mScrollHPos + increment, 0, mText.length());
}
}
+ }
- setCursorAtLocalPos( x );
- mSelectionEnd = getCursor();
+ setCursorAtLocalPos( x );
+ mSelectionEnd = getCursor();
- // delay cursor flashing
- mKeystrokeTimer.reset();
+ // delay cursor flashing
+ mKeystrokeTimer.reset();
- getWindow()->setCursor(UI_CURSOR_IBEAM);
- lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl;
- handled = TRUE;
- }
+ getWindow()->setCursor(UI_CURSOR_IBEAM);
+ lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl;
+ handled = TRUE;
+ }
- if( !handled )
- {
- getWindow()->setCursor(UI_CURSOR_IBEAM);
- lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive)" << llendl;
- handled = TRUE;
- }
+ if( !handled )
+ {
+ getWindow()->setCursor(UI_CURSOR_IBEAM);
+ lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive)" << llendl;
+ handled = TRUE;
}
return handled;
@@ -634,9 +645,10 @@ BOOL LLLineEditor::handleMouseUp(S32 x, S32 y, MASK mask)
handled = TRUE;
}
- if (!handled && (x < mBorderLeft || x > (getRect().getWidth() - mBorderRight)))
+ // Check first whether the "clear search" button wants to deal with this.
+ if(!handled && childrenHandleMouseUp(x, y, mask) != NULL)
{
- return LLUICtrl::handleMouseUp(x, y, mask);
+ return TRUE;
}
if( mIsSelecting )
@@ -1223,12 +1235,12 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask)
}
-BOOL LLLineEditor::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent )
+BOOL LLLineEditor::handleKeyHere(KEY key, MASK mask )
{
BOOL handled = FALSE;
BOOL selection_modified = FALSE;
- if ( (gFocusMgr.getKeyboardFocus() == this) && getVisible())
+ if ( gFocusMgr.getKeyboardFocus() == this )
{
LLLineEditorRollback rollback( this );
@@ -1291,7 +1303,7 @@ BOOL LLLineEditor::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent )
}
-BOOL LLLineEditor::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent)
+BOOL LLLineEditor::handleUnicodeCharHere(llwchar uni_char)
{
if ((uni_char < 0x20) || (uni_char == 0x7F)) // Control character or DEL
{
@@ -1381,11 +1393,6 @@ void LLLineEditor::doDelete()
void LLLineEditor::draw()
{
- if( !getVisible() )
- {
- return;
- }
-
S32 text_len = mText.length();
LLString saved_text;
@@ -1406,6 +1413,13 @@ void LLLineEditor::draw()
LLColor4 bg_color = mReadOnlyBgColor;
+#if 0 // for when we're ready for image art.
+ if( hasFocus())
+ {
+ mImage->drawBorder(0, 0, getRect().getWidth(), getRect().getHeight(), gFocusMgr.getFocusColor(), gFocusMgr.getFocusFlashWidth());
+ }
+ mImage->draw(getLocalRect(), mReadOnly ? mReadOnlyBgColor : mWriteableBgColor );
+#else // the old programmer art.
// drawing solids requires texturing be disabled
{
LLGLSNoTexture no_texture;
@@ -1423,6 +1437,7 @@ void LLLineEditor::draw()
}
gl_rect_2d(background, bg_color);
}
+#endif
// draw text
@@ -1560,10 +1575,14 @@ void LLLineEditor::draw()
mMaxHPixels - llround(rendered_pixels_right),
&rendered_pixels_right);
}
+#if 0 // for when we're ready for image art.
+ mBorder->setVisible(FALSE); // no more programmatic art.
+#endif
// If we're editing...
if( gFocusMgr.getKeyboardFocus() == this)
{
+ //mBorder->setVisible(TRUE); // ok, programmer art just this once.
// (Flash the cursor every half second)
if (gShowTextEditCursor && !mReadOnly)
{
@@ -1616,7 +1635,7 @@ void LLLineEditor::draw()
if (0 == mText.length())
{
mGLFont->render(mLabel.getWString(), 0,
- LABEL_HPAD, (F32)text_bottom,
+ mMinHPixels, (F32)text_bottom,
label_color,
LLFontGL::LEFT, LLFontGL::BOTTOM,
LLFontGL::NORMAL,
@@ -1757,7 +1776,7 @@ BOOL LLLineEditor::prevalidateFloat(const LLWString &str)
if( 0 < len )
{
// May be a comma or period, depending on the locale
- llwchar decimal_point = (llwchar)gResMgr->getDecimalPoint();
+ llwchar decimal_point = (llwchar)LLResMgr::getInstance()->getDecimalPoint();
S32 i = 0;
@@ -1806,7 +1825,7 @@ BOOL LLLineEditor::postvalidateFloat(const LLString &str)
}
// May be a comma or period, depending on the locale
- llwchar decimal_point = (llwchar)gResMgr->getDecimalPoint();
+ llwchar decimal_point = (llwchar)LLResMgr::getInstance()->getDecimalPoint();
for( ; i < len; i++ )
{
@@ -2244,8 +2263,27 @@ LLView* LLLineEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory
return line_editor;
}
+//static
+void LLLineEditor::cleanupClass()
+{
+ sImage = NULL;
+}
+
+/* static */
+LLPointer<LLUIImage> LLLineEditor::parseImage(LLString name, LLXMLNodePtr from, LLPointer<LLUIImage> def)
+{
+ LLString xml_name;
+ if (from->hasAttribute(name)) from->getAttributeString(name, xml_name);
+ if (xml_name == LLString::null) return def;
+ LLPointer<LLUIImage> image = LLUI::getUIImage(xml_name);
+ return image.isNull() ? def : image;
+}
+
void LLLineEditor::setColorParameters(LLXMLNodePtr node)
{
+ // overrides default image if supplied.
+ mImage = parseImage("image", node, mImage);
+
LLColor4 color;
if (LLUICtrlFactory::getAttributeColor(node,"cursor_color", color))
{
@@ -2510,6 +2548,9 @@ S32 LLLineEditor::getPreeditFontSize() const
}
+static LLRegisterWidget<LLSearchEditor> r2("search_editor");
+
+
LLSearchEditor::LLSearchEditor(const LLString& name,
const LLRect& rect,
S32 max_length_bytes,
@@ -2539,7 +2580,7 @@ LLSearchEditor::LLSearchEditor(const LLString& name,
LLRect clear_btn_rect(rect.getWidth() - btn_width, rect.getHeight(), rect.getWidth(), 0);
mClearSearchButton = new LLButton("clear search",
clear_btn_rect,
- "closebox.tga",
+ "icn_clear_lineeditor.tga",
"UIImgBtnCloseInactiveUUID",
LLString::null,
onClearSearch,
@@ -2552,9 +2593,42 @@ LLSearchEditor::LLSearchEditor(const LLString& name,
mClearSearchButton->setTabStop(FALSE);
mSearchEdit->addChild(mClearSearchButton);
- mSearchEdit->setBorderWidth(0, btn_width);
+ mSearchEdit->setTextPadding(0, btn_width);
+}
+
+
+//virtual
+void LLSearchEditor::setValue(const LLSD& value )
+{
+ mSearchEdit->setValue(value);
+}
+
+//virtual
+LLSD LLSearchEditor::getValue() const
+{
+ return mSearchEdit->getValue();
}
+//virtual
+BOOL LLSearchEditor::setTextArg( const LLString& key, const LLStringExplicit& text )
+{
+ return mSearchEdit->setTextArg(key, text);
+}
+
+//virtual
+BOOL LLSearchEditor::setLabelArg( const LLString& key, const LLStringExplicit& text )
+{
+ return mSearchEdit->setLabelArg(key, text);
+}
+
+//virtual
+void LLSearchEditor::clear()
+{
+ if (mSearchEdit)
+ {
+ mSearchEdit->clear();
+ }
+}
void LLSearchEditor::draw()
{
diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h
index 6210c37ef3..687e98e377 100644
--- a/indra/llui/lllineeditor.h
+++ b/indra/llui/lllineeditor.h
@@ -78,19 +78,19 @@ public:
S32 border_thickness = 1);
virtual ~LLLineEditor();
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_LINE_EDITOR; }
- virtual LLString getWidgetTag() const { return LL_LINE_EDITOR_TAG; };
+
virtual LLXMLNodePtr getXML(bool save_children = true) const;
void setColorParameters(LLXMLNodePtr node);
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
+ static void cleanupClass();
// mousehandler overrides
/*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
/*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
/*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
/*virtual*/ BOOL handleDoubleClick(S32 x,S32 y,MASK mask);
- /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent );
- /*virtual*/ BOOL handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent);
+ /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask );
+ /*virtual*/ BOOL handleUnicodeCharHere(llwchar uni_char);
/*virtual*/ void onMouseCaptureLost();
// LLEditMenuHandler overrides
@@ -189,8 +189,8 @@ public:
void setKeystrokeCallback(void (*keystroke_callback)(LLLineEditor* caller, void* user_data));
- void setMaxTextLength(S32 max_text_length);
- void setBorderWidth(S32 left, S32 right);
+ void setMaxTextLength(S32 max_text_length);
+ void setTextPadding(S32 left, S32 right); // Used to specify room for children before or after text.
static BOOL isPartOfWord(llwchar c);
// Prevalidation controls which keystrokes can affect the editor
@@ -212,7 +212,7 @@ public:
void updateHistory(); // stores current line in history
private:
- // private helper classes
+ // private helper methods
void removeChar();
void addChar(const llwchar c);
void setCursorAtLocalPos(S32 local_mouse_x);
@@ -254,10 +254,10 @@ protected:
S32 mCursorPos; // I-beam is just after the mCursorPos-th character.
S32 mScrollHPos; // Horizontal offset from the start of mText. Used for scrolling.
LLFrameTimer mScrollTimer;
+ S32 mTextPadLeft; // Used to reserve space before the beginning of the text for children.
+ S32 mTextPadRight; // Used to reserve space after the end of the text for children.
S32 mMinHPixels;
S32 mMaxHPixels;
- S32 mBorderLeft;
- S32 mBorderRight;
BOOL mCommitOnFocusLost;
BOOL mRevertOnEsc;
@@ -302,6 +302,15 @@ protected:
std::vector<S32> mPreeditPositions;
LLPreeditor::standouts_t mPreeditStandouts;
+private:
+ // Utility on top of LLUI::getUIImage, looks up a named image in a given XML node and returns it if possible
+ // or returns a given default image if anything in the process fails.
+ static LLPointer<LLUIImage> LLLineEditor::parseImage(LLString name, LLXMLNodePtr from, LLPointer<LLUIImage> def);
+ // Global instance used as default for member instance below.
+ static LLPointer<LLUIImage> sImage;
+ // Instances that by default point to the statics but can be overidden in XML.
+ LLPointer<LLUIImage> mImage;
+
// private helper class
class LLLineEditorRollback
{
@@ -359,8 +368,6 @@ public:
/*virtual*/ void draw();
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_SEARCH_EDITOR; }
- virtual LLString getWidgetTag() const { return LL_SEARCH_EDITOR_TAG; }
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
void setText(const LLStringExplicit &new_text) { mSearchEdit->setText(new_text); }
@@ -368,12 +375,11 @@ public:
void setSearchCallback(void (*search_callback)(const LLString& search_string, void* user_data), void* data) { mSearchCallback = search_callback; mCallbackUserData = data; }
// LLUICtrl interface
- virtual void setValue(const LLSD& value ) { mSearchEdit->setValue(value); }
- virtual LLSD getValue() const { return mSearchEdit->getValue(); }
- virtual BOOL setTextArg( const LLString& key, const LLStringExplicit& text ) { return mSearchEdit->setTextArg( key, text); }
- virtual BOOL setLabelArg( const LLString& key, const LLStringExplicit& text ) { return mSearchEdit->setLabelArg(key, text); }
- virtual void clear() { if (mSearchEdit) mSearchEdit->clear(); }
-
+ virtual void setValue(const LLSD& value );
+ virtual LLSD getValue() const;
+ virtual BOOL setTextArg( const LLString& key, const LLStringExplicit& text );
+ virtual BOOL setLabelArg( const LLString& key, const LLStringExplicit& text );
+ virtual void clear();
private:
static void onSearchEdit(LLLineEditor* caller, void* user_data );
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index 8c62a10f2b..b52de24bb5 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -188,31 +188,6 @@ LLXMLNodePtr LLMenuItemGL::getXML(bool save_children) const
return node;
}
-BOOL LLMenuItemGL::handleKey(KEY key, MASK mask, BOOL called_from_parent)
-{
- // modified from LLView::handleKey
- // ignore visibility, as keyboard accelerators should still trigger menu items
- // even when they are not visible
- // also, ignore enabled flag for self, as that can change based on menu callbacks
- BOOL handled = FALSE;
-
- if( called_from_parent )
- {
- // Downward traversal
- if (getEnabled())
- {
- handled = childrenHandleKey( key, mask ) != NULL;
- }
- }
-
- if( !handled )
- {
- handled = handleKeyHere( key, mask, called_from_parent );
- }
-
- return handled;
-}
-
BOOL LLMenuItemGL::handleAcceleratorKey(KEY key, MASK mask)
{
if( getEnabled() && (!gKeyboard->getKeyRepeated(key) || mAllowKeyRepeat) && (key == mAcceleratorKey) && (mask == (mAcceleratorMask & MASK_NORMALKEYS)) )
@@ -400,7 +375,7 @@ void LLMenuItemGL::doIt( void )
}
-BOOL LLMenuItemGL::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent )
+BOOL LLMenuItemGL::handleKeyHere( KEY key, MASK mask )
{
if (getHighlight() &&
getMenu()->isOpen())
@@ -436,29 +411,21 @@ BOOL LLMenuItemGL::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent )
BOOL LLMenuItemGL::handleMouseUp( S32 x, S32 y, MASK )
{
- if (getEnabled())
- {
- // switch to mouse navigation mode
- LLMenuGL::setKeyboardMode(FALSE);
+ // switch to mouse navigation mode
+ LLMenuGL::setKeyboardMode(FALSE);
- doIt();
- make_ui_sound("UISndClickRelease");
- return TRUE;
- }
- return FALSE;
+ doIt();
+ make_ui_sound("UISndClickRelease");
+ return TRUE;
}
BOOL LLMenuItemGL::handleMouseDown( S32 x, S32 y, MASK )
{
- if (getEnabled())
- {
- // switch to mouse navigation mode
- LLMenuGL::setKeyboardMode(FALSE);
+ // switch to mouse navigation mode
+ LLMenuGL::setKeyboardMode(FALSE);
- setHighlight(TRUE);
- return TRUE;
- }
- return FALSE;
+ setHighlight(TRUE);
+ return TRUE;
}
@@ -560,9 +527,6 @@ public:
virtual LLString getType() const { return "separator"; }
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_ITEM_SEPARATOR; }
- virtual LLString getWidgetTag() const { return LL_MENU_ITEM_SEPARATOR_GL_TAG; }
-
// doIt() - do the primary funcationality of the menu item.
virtual void doIt( void ) {}
@@ -641,9 +605,6 @@ class LLMenuItemVerticalSeparatorGL
public:
LLMenuItemVerticalSeparatorGL( void );
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_SEPARATOR_VERTICAL; }
- virtual LLString getWidgetTag() const { return LL_MENU_ITEM_VERTICAL_SEPARATOR_GL_TAG; }
-
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask) { return FALSE; }
};
@@ -739,8 +700,6 @@ public:
{
setEnabled(FALSE);
}
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_ITEM_BLANK; }
- virtual LLString getWidgetTag() const { return LL_MENU_ITEM_BLANK_GL_TAG; }
virtual void doIt( void ) {}
virtual void draw( void ) {}
};
@@ -1086,29 +1045,31 @@ LLMenuItemBranchGL::LLMenuItemBranchGL( const LLString& name, const LLString& la
}
// virtual
-LLView* LLMenuItemBranchGL::getChildByName(const LLString& name, BOOL recurse) const
+LLView* LLMenuItemBranchGL::getChildView(const LLString& name, BOOL recurse, BOOL create_if_missing) const
{
+ // richard: this is redundant with parent, remove
if (mBranch->getName() == name)
{
return mBranch;
}
// Always recurse on branches
- return mBranch->getChild<LLView>(name, recurse);
+ LLView* child = mBranch->getChildView(name, recurse, FALSE);
+ if (!child)
+ {
+ child = LLView::getChildView(name, recurse, create_if_missing);
+ }
+ return child;
}
// virtual
BOOL LLMenuItemBranchGL::handleMouseUp(S32 x, S32 y, MASK mask)
{
- if (getEnabled())
- {
- // switch to mouse navigation mode
- LLMenuGL::setKeyboardMode(FALSE);
+ // switch to mouse navigation mode
+ LLMenuGL::setKeyboardMode(FALSE);
- doIt();
- make_ui_sound("UISndClickRelease");
- return TRUE;
- }
- return FALSE;
+ doIt();
+ make_ui_sound("UISndClickRelease");
+ return TRUE;
}
BOOL LLMenuItemBranchGL::handleAcceleratorKey(KEY key, MASK mask)
@@ -1266,7 +1227,7 @@ void LLMenuItemBranchGL::onVisibilityChange( BOOL new_visibility )
LLMenuItemGL::onVisibilityChange(new_visibility);
}
-BOOL LLMenuItemBranchGL::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent )
+BOOL LLMenuItemBranchGL::handleKeyHere( KEY key, MASK mask )
{
if (getMenu()->getVisible() && mBranch->getVisible() && key == KEY_LEFT)
{
@@ -1285,8 +1246,7 @@ BOOL LLMenuItemBranchGL::handleKeyHere( KEY key, MASK mask, BOOL called_from_par
return handled;
}
- if (getEnabled() &&
- getHighlight() &&
+ if (getHighlight() &&
getMenu()->isOpen() &&
key == KEY_RIGHT && !mBranch->getHighlightedItem())
{
@@ -1300,7 +1260,7 @@ BOOL LLMenuItemBranchGL::handleKeyHere( KEY key, MASK mask, BOOL called_from_par
}
}
- return LLMenuItemGL::handleKeyHere(key, mask, called_from_parent);
+ return LLMenuItemGL::handleKeyHere(key, mask);
}
void LLMenuItemBranchGL::openMenu()
@@ -1370,9 +1330,6 @@ public:
LLMenuItemBranchDownGL( const LLString& name, const LLString& label, LLMenuGL* branch,
KEY key = KEY_NONE, MASK mask = MASK_NONE );
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_ITEM_BRANCH_DOWN; }
- virtual LLString getWidgetTag() const { return LL_MENU_ITEM_BRANCH_DOWN_GL_TAG; }
-
virtual LLString getType() const { return "menu"; }
// returns the normal width of this control in pixels - this is
@@ -1396,7 +1353,7 @@ public:
virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
virtual BOOL handleMouseUp( S32 x, S32 y, MASK mask );
virtual void draw( void );
- virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
+ virtual BOOL handleKeyHere(KEY key, MASK mask);
virtual BOOL handleAcceleratorKey(KEY key, MASK mask);
};
@@ -1533,7 +1490,7 @@ BOOL LLMenuItemBranchDownGL::handleAcceleratorKey(KEY key, MASK mask)
return handled;
}
-BOOL LLMenuItemBranchDownGL::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
+BOOL LLMenuItemBranchDownGL::handleKeyHere(KEY key, MASK mask)
{
BOOL menu_open = getBranch()->getVisible();
// don't do keyboard navigation of top-level menus unless in keyboard mode, or menu expanded
@@ -1572,7 +1529,7 @@ BOOL LLMenuItemBranchDownGL::handleKeyHere(KEY key, MASK mask, BOOL called_from_
// switch to keyboard navigation mode
LLMenuGL::setKeyboardMode(TRUE);
- if (getEnabled() && !isActive())
+ if (!isActive())
{
doIt();
}
@@ -1584,7 +1541,7 @@ BOOL LLMenuItemBranchDownGL::handleKeyHere(KEY key, MASK mask, BOOL called_from_
// switch to keyboard navigation mode
LLMenuGL::setKeyboardMode(TRUE);
- if (getEnabled() && !isActive())
+ if (!isActive())
{
doIt();
}
@@ -1657,6 +1614,8 @@ void LLMenuItemBranchDownGL::draw( void )
/// Class LLMenuGL
///============================================================================
+static LLRegisterWidget<LLMenuGL> r1("menu");
+
// Default constructor
LLMenuGL::LLMenuGL( const LLString& name, const LLString& label, LLHandle<LLFloater> parent_floater_handle )
: LLUICtrl( name, LLRect(), FALSE, NULL, NULL ),
@@ -2652,8 +2611,8 @@ LLMenuItemGL* LLMenuGL::highlightNextItem(LLMenuItemGL* cur_item, BOOL skip_disa
while(1)
{
- // skip separators and disabled items
- if ((*next_item_iter)->getEnabled() && (*next_item_iter)->getType() != SEPARATOR_NAME)
+ // skip separators and disabled/invisible items
+ if ((*next_item_iter)->getEnabled() && (*next_item_iter)->getVisible() && (*next_item_iter)->getType() != SEPARATOR_NAME)
{
if (cur_item)
{
@@ -2718,8 +2677,8 @@ LLMenuItemGL* LLMenuGL::highlightPrevItem(LLMenuItemGL* cur_item, BOOL skip_disa
while(1)
{
- // skip separators and disabled items
- if ((*prev_item_iter)->getEnabled() && (*prev_item_iter)->getName() != SEPARATOR_NAME)
+ // skip separators and disabled/invisible items
+ if ((*prev_item_iter)->getEnabled() && (*prev_item_iter)->getVisible() && (*prev_item_iter)->getName() != SEPARATOR_NAME)
{
(*prev_item_iter)->setHighlight(TRUE);
return (*prev_item_iter);
@@ -2768,37 +2727,6 @@ void LLMenuGL::updateParent(LLView* parentp)
}
}
-// LLView functionality
-BOOL LLMenuGL::handleKey( KEY key, MASK mask, BOOL called_from_parent )
-{
- BOOL handled = FALSE;
-
- // Pass down even if not visible
- if( getEnabled() && called_from_parent )
- {
- for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
- {
- LLView* viewp = *child_it;
- if (viewp->handleKey(key, mask, TRUE))
- {
- handled = TRUE;
- break;
- }
- }
- }
-
- if( !handled )
- {
- handled = handleKeyHere( key, mask, called_from_parent );
- if (handled && LLView::sDebugKeys)
- {
- llinfos << "Key handled by " << getName() << llendl;
- }
- }
-
- return handled;
-}
-
BOOL LLMenuGL::handleAcceleratorKey(KEY key, MASK mask)
{
// don't handle if not enabled
@@ -2821,7 +2749,7 @@ BOOL LLMenuGL::handleAcceleratorKey(KEY key, MASK mask)
return FALSE;
}
-BOOL LLMenuGL::handleUnicodeCharHere( llwchar uni_char, BOOL called_from_parent )
+BOOL LLMenuGL::handleUnicodeCharHere( llwchar uni_char )
{
if (jumpKeysActive())
{
@@ -2947,17 +2875,19 @@ void LLMenuGL::setVisible(BOOL visible)
LLMenuGL* LLMenuGL::getChildMenuByName(const LLString& name, BOOL recurse) const
{
- LLView* view = getChildByName(name, recurse);
+ LLView* view = getChildView(name, recurse, FALSE);
if (view)
{
- if (view->getWidgetType() == WIDGET_TYPE_MENU_ITEM_BRANCH)
+ LLMenuItemBranchGL* branch = dynamic_cast<LLMenuItemBranchGL*>(view);
+ if (branch)
{
- LLMenuItemBranchGL *branch = (LLMenuItemBranchGL *)view;
return branch->getBranch();
}
- if (view->getWidgetType() == WIDGET_TYPE_MENU || view->getWidgetType() == WIDGET_TYPE_PIE_MENU)
+
+ LLMenuGL* menup = dynamic_cast<LLMenuGL*>(view);
+ if (menup)
{
- return (LLMenuGL*)view;
+ return menup;
}
}
llwarns << "Child Menu " << name << " not found in menu " << getName() << llendl;
@@ -3038,9 +2968,6 @@ public:
LLPieMenuBranch(const LLString& name, const LLString& label, LLPieMenu* branch,
enabled_callback ecb, void* user_data);
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_PIE_MENU_BRANCH; }
- virtual LLString getWidgetTag() const { return LL_PIE_MENU_BRANCH_TAG; }
-
// called to rebuild the draw label
virtual void buildDrawLabel( void );
@@ -3825,6 +3752,8 @@ void LLPieMenu::hide(BOOL item_selected)
/// Class LLMenuBarGL
///============================================================================
+static LLRegisterWidget<LLMenuBarGL> r2("menu_bar");
+
// Default constructor
LLMenuBarGL::LLMenuBarGL( const LLString& name ) : LLMenuGL ( name, name )
{
@@ -3880,9 +3809,10 @@ LLView* LLMenuBarGL::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory
LLMenuBarGL *menubar = new LLMenuBarGL(name);
LLHandle<LLFloater> parent_handle;
- if (parent->getWidgetType() == WIDGET_TYPE_FLOATER)
+ LLFloater* parent_floater = dynamic_cast<LLFloater*>(parent);
+ if (parent_floater)
{
- parent_handle = ((LLFloater*)parent)->getHandle();
+ parent_handle = parent_floater->getHandle();
}
// We need to have the rect early so that it's around when building
@@ -3974,7 +3904,7 @@ BOOL LLMenuBarGL::handleAcceleratorKey(KEY key, MASK mask)
return result;
}
-BOOL LLMenuBarGL::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
+BOOL LLMenuBarGL::handleKeyHere(KEY key, MASK mask)
{
if(key == KEY_ALT && !gKeyboard->getKeyRepeated(key) && LLUI::sConfigGroup->getBOOL("UseAltKeyForMenus"))
{
@@ -3988,7 +3918,7 @@ BOOL LLMenuBarGL::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
// before processing any other key, check to see if ALT key has triggered menu access
checkMenuTrigger();
- return LLMenuGL::handleKeyHere(key, mask, called_from_parent);
+ return LLMenuGL::handleKeyHere(key, mask);
}
BOOL LLMenuBarGL::handleJumpKey(KEY key)
@@ -4278,7 +4208,7 @@ BOOL LLMenuHolderGL::hasVisibleMenu() const
for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
{
LLView* viewp = *child_it;
- if (viewp->getVisible() && viewp->getWidgetType() != WIDGET_TYPE_MENU_BAR)
+ if (viewp->getVisible() && dynamic_cast<LLMenuBarGL*>(viewp) == NULL)
{
return TRUE;
}
@@ -4302,7 +4232,7 @@ BOOL LLMenuHolderGL::hideMenus()
{
LLView* viewp = *child_it;
// clicks off of menu do not hide menu bar
- if (viewp->getWidgetType() != WIDGET_TYPE_MENU_BAR && viewp->getVisible())
+ if (dynamic_cast<LLMenuBarGL*>(viewp) == NULL && viewp->getVisible())
{
viewp->setVisible(FALSE);
}
@@ -4412,7 +4342,7 @@ BOOL LLTearOffMenu::handleUnicodeChar(llwchar uni_char, BOOL called_from_parent)
return mMenu->handleUnicodeChar(uni_char, TRUE);
}
-BOOL LLTearOffMenu::handleKey(KEY key, MASK mask, BOOL called_from_parent)
+BOOL LLTearOffMenu::handleKeyHere(KEY key, MASK mask)
{
if (!mMenu->getHighlightedItem())
{
diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h
index 33b226fd99..3166290307 100644
--- a/indra/llui/llmenugl.h
+++ b/indra/llui/llmenugl.h
@@ -91,14 +91,11 @@ public:
LLMenuItemGL( const LLString& name, const LLString& label, KEY key = KEY_NONE, MASK = MASK_NONE );
virtual void setValue(const LLSD& value) { setLabel(value.asString()); }
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_ITEM; }
- virtual LLString getWidgetTag() const { return LL_MENU_ITEM_TAG; }
virtual LLXMLNodePtr getXML(bool save_children = true) const;
virtual LLString getType() const { return "item"; }
- virtual BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent);
virtual BOOL handleHover(S32 x, S32 y, MASK mask);
virtual BOOL handleAcceleratorKey(KEY key, MASK mask);
@@ -165,7 +162,7 @@ public:
virtual void setEnabledSubMenus(BOOL enable){};
// LLView Functionality
- virtual BOOL handleKeyHere( KEY key, MASK mask, BOOL called_from_parent );
+ virtual BOOL handleKeyHere( KEY key, MASK mask );
virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
virtual BOOL handleMouseUp( S32 x, S32 y, MASK mask );
virtual void draw( void );
@@ -267,8 +264,6 @@ public:
virtual LLString getType() const { return "call"; }
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_ITEM_CALL; }
- virtual LLString getWidgetTag() const { return LL_MENU_ITEM_CALL_GL_TAG; }
void setEnabledControl(LLString enabled_control, LLView *context);
void setVisibleControl(LLString enabled_control, LLView *context);
@@ -341,8 +336,6 @@ public:
void setCheckedControl(LLString checked_control, LLView *context);
virtual void setValue(const LLSD& value);
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_ITEM_CHECK; }
- virtual LLString getWidgetTag() const { return LL_MENU_ITEM_CHECK_GL_TAG; }
virtual LLString getType() const { return "check"; }
@@ -405,6 +398,8 @@ class LLMenuGL
// TODO: The menu and menu item classes share a great deal of functionality and perhaps should be united.
// I think it may make the most sense to make LLMenuGL be a subclass of LLMenuItemGL. -MG
{
+ // let branching menu items use my protected traversal methods
+ friend class LLMenuItemBranchGL;
public:
LLMenuGL( const LLString& name, const LLString& label, LLHandle<LLFloater> parent_floater = LLHandle<LLFloater>());
LLMenuGL( const LLString& label, LLHandle<LLFloater> parent_floater = LLHandle<LLFloater>() );
@@ -414,13 +409,9 @@ public:
void parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory *factory);
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU; }
- virtual LLString getWidgetTag() const { return LL_MENU_GL_TAG; }
// LLView Functionality
- virtual BOOL handleKey( KEY key, MASK mask, BOOL called_from_parent );
- //virtual BOOL handleKeyHere( KEY key, MASK mask, BOOL called_from_parent );
- virtual BOOL handleUnicodeCharHere( llwchar uni_char, BOOL called_from_parent );
+ virtual BOOL handleUnicodeCharHere( llwchar uni_char );
virtual BOOL handleHover( S32 x, S32 y, MASK mask );
virtual void draw( void );
virtual void drawBackground(LLMenuItemGL* itemp, LLColor4& color);
@@ -578,9 +569,6 @@ public:
virtual LLString getType() const { return "menu"; }
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_ITEM_BRANCH; }
- virtual LLString getWidgetTag() const { return LL_MENU_ITEM_BRANCH_GL_TAG; }
-
virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
virtual BOOL handleAcceleratorKey(KEY key, MASK mask);
@@ -601,7 +589,7 @@ public:
// active. This is used for behavior transfer.
virtual void setHighlight( BOOL highlight );
- virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
+ virtual BOOL handleKeyHere(KEY key, MASK mask);
virtual BOOL isActive() const { return isOpen() && mBranch->getHighlightedItem(); }
@@ -620,8 +608,7 @@ public:
virtual void openMenu();
-protected:
- virtual LLView* getChildByName(const LLString& name, BOOL recurse) const;
+ virtual LLView* getChildView(const LLString& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const;
private:
LLMenuGL* mBranch;
@@ -642,16 +629,12 @@ public:
LLPieMenu(const LLString& name);
virtual ~LLPieMenu() {}
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_PIE_MENU; }
- virtual LLString getWidgetTag() const { return LL_PIE_MENU_TAG; }
-
void initXML(LLXMLNodePtr node, LLView *context, LLUICtrlFactory *factory);
// LLView Functionality
// can't set visibility directly, must call show or hide
virtual void setVisible(BOOL visible);
- //virtual BOOL handleKey( KEY key, MASK mask, BOOL called_from_parent );
virtual BOOL handleHover( S32 x, S32 y, MASK mask );
virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
@@ -710,11 +693,8 @@ public:
virtual LLXMLNodePtr getXML(bool save_children = true) const;
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_BAR; }
- virtual LLString getWidgetTag() const { return LL_MENU_BAR_GL_TAG; }
-
virtual BOOL handleAcceleratorKey(KEY key, MASK mask);
- virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
+ virtual BOOL handleKeyHere(KEY key, MASK mask);
virtual BOOL handleJumpKey(KEY key);
// rearrange the child rects so they fit the shape of the menu
@@ -756,9 +736,6 @@ public:
LLMenuHolderGL(const LLString& name, const LLRect& rect, BOOL mouse_opaque, U32 follows = FOLLOWS_NONE);
virtual ~LLMenuHolderGL() {}
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_HOLDER; }
- virtual LLString getWidgetTag() const { return LL_MENU_HOLDER_GL_TAG; }
-
virtual BOOL hideMenus();
void reshape(S32 width, S32 height, BOOL called_from_parent);
void setCanHide(BOOL can_hide) { mCanHide = can_hide; }
@@ -796,7 +773,7 @@ public:
virtual void onFocusReceived();
virtual void onFocusLost();
virtual BOOL handleUnicodeChar(llwchar uni_char, BOOL called_from_parent);
- virtual BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent);
+ virtual BOOL handleKeyHere(KEY key, MASK mask);
virtual void translate(S32 x, S32 y);
private:
@@ -818,9 +795,6 @@ class LLMenuItemTearOffGL : public LLMenuItemGL
public:
LLMenuItemTearOffGL( LLHandle<LLFloater> parent_floater_handle = LLHandle<LLFloater>());
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_TEAROFF_MENU; }
- virtual LLString getWidgetTag() const { return LL_MENU_ITEM_TEAR_OFF_GL_TAG; }
-
virtual LLString getType() const { return "tearoff_menu"; }
virtual void doIt(void);
diff --git a/indra/llui/llmodaldialog.cpp b/indra/llui/llmodaldialog.cpp
index a150d295e5..878c57b8b3 100644
--- a/indra/llui/llmodaldialog.cpp
+++ b/indra/llui/llmodaldialog.cpp
@@ -211,11 +211,9 @@ BOOL LLModalDialog::handleRightMouseDown(S32 x, S32 y, MASK mask)
}
-BOOL LLModalDialog::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent )
+BOOL LLModalDialog::handleKeyHere(KEY key, MASK mask )
{
- childrenHandleKey(key, mask);
-
- LLFloater::handleKeyHere(key, mask, called_from_parent );
+ LLFloater::handleKeyHere(key, mask );
if (mModal)
{
@@ -246,33 +244,30 @@ void LLModalDialog::onClose(bool app_quitting)
// virtual
void LLModalDialog::draw()
{
- if (getVisible())
- {
- LLColor4 shadow_color = LLUI::sColorsGroup->getColor("ColorDropShadow");
- S32 shadow_lines = LLUI::sConfigGroup->getS32("DropShadowFloater");
+ LLColor4 shadow_color = LLUI::sColorsGroup->getColor("ColorDropShadow");
+ S32 shadow_lines = LLUI::sConfigGroup->getS32("DropShadowFloater");
+
+ gl_drop_shadow( 0, getRect().getHeight(), getRect().getWidth(), 0,
+ shadow_color, shadow_lines);
- gl_drop_shadow( 0, getRect().getHeight(), getRect().getWidth(), 0,
- shadow_color, shadow_lines);
+ LLFloater::draw();
+
+ if (mModal)
+ {
+ // If we've lost focus to a non-child, get it back ASAP.
+ if( gFocusMgr.getTopCtrl() != this )
+ {
+ gFocusMgr.setTopCtrl( this );
+ }
- LLFloater::draw();
+ if( !gFocusMgr.childHasKeyboardFocus( this ) )
+ {
+ setFocus(TRUE);
+ }
- if (mModal)
+ if( !gFocusMgr.childHasMouseCapture( this ) )
{
- // If we've lost focus to a non-child, get it back ASAP.
- if( gFocusMgr.getTopCtrl() != this )
- {
- gFocusMgr.setTopCtrl( this );
- }
-
- if( !gFocusMgr.childHasKeyboardFocus( this ) )
- {
- setFocus(TRUE);
- }
-
- if( !gFocusMgr.childHasMouseCapture( this ) )
- {
- gFocusMgr.setMouseCapture( this );
- }
+ gFocusMgr.setMouseCapture( this );
}
}
}
diff --git a/indra/llui/llmodaldialog.h b/indra/llui/llmodaldialog.h
index f13e5c37b7..a5e6e9a490 100644
--- a/indra/llui/llmodaldialog.h
+++ b/indra/llui/llmodaldialog.h
@@ -60,7 +60,7 @@ public:
/*virtual*/ BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
/*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
/*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
- /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent );
+ /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask );
/*virtual*/ void onClose(bool app_quitting);
diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp
index b4bf3a92d5..c5c0e1c8b1 100644
--- a/indra/llui/llmultislider.cpp
+++ b/indra/llui/llmultislider.cpp
@@ -43,6 +43,8 @@
#include <sstream>
+static LLRegisterWidget<LLMultiSlider> r("multi_slider_bar");
+
const S32 MULTI_THUMB_WIDTH = 8;
const S32 MULTI_TRACK_HEIGHT = 6;
const F32 FLOAT_THRESHOLD = 0.00001f;
@@ -98,16 +100,6 @@ LLMultiSlider::LLMultiSlider(
setValue(getValue());
}
-EWidgetType LLMultiSlider::getWidgetType() const
-{
- return WIDGET_TYPE_MULTI_SLIDER_BAR;
-}
-
-LLString LLMultiSlider::getWidgetTag() const
-{
- return LL_MULTI_SLIDER_TAG;
-}
-
void LLMultiSlider::setSliderValue(const LLString& name, F32 value, BOOL from_event)
{
// exit if not there
@@ -403,31 +395,28 @@ BOOL LLMultiSlider::handleMouseDown(S32 x, S32 y, MASK mask)
return TRUE;
}
-BOOL LLMultiSlider::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
+BOOL LLMultiSlider::handleKeyHere(KEY key, MASK mask)
{
BOOL handled = FALSE;
- if( getVisible() && getEnabled() && !called_from_parent )
+ switch(key)
{
- switch(key)
- {
- case KEY_UP:
- case KEY_DOWN:
- // eat up and down keys to be consistent
- handled = TRUE;
- break;
- case KEY_LEFT:
- setCurSliderValue(getCurSliderValue() - getIncrement());
- onCommit();
- handled = TRUE;
- break;
- case KEY_RIGHT:
- setCurSliderValue(getCurSliderValue() + getIncrement());
- onCommit();
- handled = TRUE;
- break;
- default:
- break;
- }
+ case KEY_UP:
+ case KEY_DOWN:
+ // eat up and down keys to be consistent
+ handled = TRUE;
+ break;
+ case KEY_LEFT:
+ setCurSliderValue(getCurSliderValue() - getIncrement());
+ onCommit();
+ handled = TRUE;
+ break;
+ case KEY_RIGHT:
+ setCurSliderValue(getCurSliderValue() + getIncrement());
+ onCommit();
+ handled = TRUE;
+ break;
+ default:
+ break;
}
return handled;
}
@@ -438,177 +427,142 @@ void LLMultiSlider::draw()
std::map<LLString, LLRect>::iterator mIt;
std::map<LLString, LLRect>::iterator curSldrIt;
- if( getVisible() )
- {
- // Draw background and thumb.
- // drawing solids requires texturing be disabled
- LLGLSNoTexture no_texture;
+ // Draw background and thumb.
- LLRect rect(mDragStartThumbRect);
+ // drawing solids requires texturing be disabled
+ LLGLSNoTexture no_texture;
- F32 opacity = getEnabled() ? 1.f : 0.3f;
+ LLRect rect(mDragStartThumbRect);
- // Track
- LLUUID thumb_image_id;
- thumb_image_id.set(LLUI::sAssetsGroup->getString("rounded_square.tga"));
- LLPointer<LLImageGL> thumb_imagep(LLUI::sImageProvider->getUIImageByID(thumb_image_id)->getImage());
+ F32 opacity = getEnabled() ? 1.f : 0.3f;
- S32 height_offset = (getRect().getHeight() - MULTI_TRACK_HEIGHT) / 2;
- LLRect track_rect(0, getRect().getHeight() - height_offset, getRect().getWidth(), height_offset );
+ // Track
+ LLUIImagePtr thumb_imagep = LLUI::sImageProvider->getUIImage("rounded_square.tga");
+ S32 height_offset = (getRect().getHeight() - MULTI_TRACK_HEIGHT) / 2;
+ LLRect track_rect(0, getRect().getHeight() - height_offset, getRect().getWidth(), height_offset );
- if(mDrawTrack)
- {
- track_rect.stretch(-1);
- gl_draw_scaled_image_with_border(track_rect.mLeft, track_rect.mBottom, 16, 16, track_rect.getWidth(), track_rect.getHeight(),
- thumb_imagep, mTrackColor % opacity);
- }
- // if we're supposed to use a drawn triangle
- // simple gl call for the triangle
- if(mUseTriangle) {
+ if(mDrawTrack)
+ {
+ track_rect.stretch(-1);
+ thumb_imagep->draw(track_rect, mTrackColor % opacity);
+ }
- for(mIt = mThumbRects.begin(); mIt != mThumbRects.end(); mIt++) {
+ // if we're supposed to use a drawn triangle
+ // simple gl call for the triangle
+ if(mUseTriangle) {
- gl_triangle_2d(
- mIt->second.mLeft - EXTRA_TRIANGLE_WIDTH,
- mIt->second.mTop + EXTRA_TRIANGLE_HEIGHT,
- mIt->second.mRight + EXTRA_TRIANGLE_WIDTH,
- mIt->second.mTop + EXTRA_TRIANGLE_HEIGHT,
- mIt->second.mLeft + mIt->second.getWidth() / 2,
- mIt->second.mBottom - EXTRA_TRIANGLE_HEIGHT,
- mTriangleColor, TRUE);
- }
+ for(mIt = mThumbRects.begin(); mIt != mThumbRects.end(); mIt++) {
+
+ gl_triangle_2d(
+ mIt->second.mLeft - EXTRA_TRIANGLE_WIDTH,
+ mIt->second.mTop + EXTRA_TRIANGLE_HEIGHT,
+ mIt->second.mRight + EXTRA_TRIANGLE_WIDTH,
+ mIt->second.mTop + EXTRA_TRIANGLE_HEIGHT,
+ mIt->second.mLeft + mIt->second.getWidth() / 2,
+ mIt->second.mBottom - EXTRA_TRIANGLE_HEIGHT,
+ mTriangleColor, TRUE);
}
- else if (!thumb_imagep)
- {
- // draw all the thumbs
- curSldrIt = mThumbRects.end();
- for(mIt = mThumbRects.begin(); mIt != mThumbRects.end(); mIt++) {
+ }
+ else if (!thumb_imagep)
+ {
+ // draw all the thumbs
+ curSldrIt = mThumbRects.end();
+ for(mIt = mThumbRects.begin(); mIt != mThumbRects.end(); mIt++) {
+
+ // choose the color
+ curThumbColor = mThumbCenterColor;
+ if(mIt->first == mCurSlider) {
- // choose the color
- curThumbColor = mThumbCenterColor;
- if(mIt->first == mCurSlider) {
-
- curSldrIt = mIt;
- continue;
- //curThumbColor = mThumbCenterSelectedColor;
- }
-
- // the draw command
- gl_rect_2d(mIt->second, curThumbColor, TRUE);
+ curSldrIt = mIt;
+ continue;
+ //curThumbColor = mThumbCenterSelectedColor;
}
- // now draw the current slider
- if(curSldrIt != mThumbRects.end()) {
- gl_rect_2d(curSldrIt->second, mThumbCenterSelectedColor, TRUE);
- }
+ // the draw command
+ gl_rect_2d(mIt->second, curThumbColor, TRUE);
+ }
- // and draw the drag start
- if (gFocusMgr.getMouseCapture() == this)
- {
- gl_rect_2d(mDragStartThumbRect, mThumbCenterColor % opacity, FALSE);
- }
+ // now draw the current slider
+ if(curSldrIt != mThumbRects.end()) {
+ gl_rect_2d(curSldrIt->second, mThumbCenterSelectedColor, TRUE);
}
- else if( gFocusMgr.getMouseCapture() == this )
+
+ // and draw the drag start
+ if (gFocusMgr.getMouseCapture() == this)
{
- // draw drag start
- gl_draw_scaled_image_with_border(mDragStartThumbRect.mLeft,
- mDragStartThumbRect.mBottom, 16, 16,
- mDragStartThumbRect.getWidth(),
- mDragStartThumbRect.getHeight(),
- thumb_imagep, mThumbCenterColor % 0.3f, TRUE);
-
- // draw the highlight
- if (hasFocus())
+ gl_rect_2d(mDragStartThumbRect, mThumbCenterColor % opacity, FALSE);
+ }
+ }
+ else if( gFocusMgr.getMouseCapture() == this )
+ {
+ // draw drag start
+ thumb_imagep->drawSolid(mDragStartThumbRect, mThumbCenterColor % 0.3f);
+
+ // draw the highlight
+ if (hasFocus())
+ {
+ thumb_imagep->drawBorder(mThumbRects[mCurSlider], gFocusMgr.getFocusColor(), gFocusMgr.getFocusFlashWidth());
+ }
+
+ // draw the thumbs
+ curSldrIt = mThumbRects.end();
+ for(mIt = mThumbRects.begin(); mIt != mThumbRects.end(); mIt++)
+ {
+ // choose the color
+ curThumbColor = mThumbCenterColor;
+ if(mIt->first == mCurSlider)
{
- F32 lerp_amt = gFocusMgr.getFocusFlashAmt();
- LLRect highlight_rect = mThumbRects[mCurSlider];
- highlight_rect.stretch(llround(lerp(1.f, 3.f, lerp_amt)));
- gl_draw_scaled_image_with_border(highlight_rect.mLeft,
- highlight_rect.mBottom, 16, 16, highlight_rect.getWidth(),
- highlight_rect.getHeight(),
- thumb_imagep, gFocusMgr.getFocusColor());
+ // don't draw now, draw last
+ curSldrIt = mIt;
+ continue;
}
+
+ // the draw command
+ thumb_imagep->drawSolid(mIt->second, curThumbColor);
+ }
+
+ // draw cur slider last
+ if(curSldrIt != mThumbRects.end())
+ {
+ thumb_imagep->drawSolid(curSldrIt->second, mThumbCenterSelectedColor);
+ }
+
+ }
+ else
+ {
+ // draw highlight
+ if (hasFocus())
+ {
+ thumb_imagep->drawBorder(mThumbRects[mCurSlider], gFocusMgr.getFocusColor(), gFocusMgr.getFocusFlashWidth());
+ }
- // draw the thumbs
- curSldrIt = mThumbRects.end();
- for(mIt = mThumbRects.begin(); mIt != mThumbRects.end(); mIt++) {
-
- // choose the color
- curThumbColor = mThumbCenterColor;
- if(mIt->first == mCurSlider) {
- // don't draw now, draw last
- curSldrIt = mIt;
- continue;
- }
-
- // the draw command
- gl_draw_scaled_image_with_border(
- mIt->second.mLeft,
- mIt->second.mBottom, 16, 16,
- mIt->second.getWidth(),
- mIt->second.getHeight(), thumb_imagep,
- curThumbColor, TRUE);
- }
+ // draw thumbs
+ curSldrIt = mThumbRects.end();
+ for(mIt = mThumbRects.begin(); mIt != mThumbRects.end(); mIt++)
+ {
- // draw cur slider last
- if(curSldrIt != mThumbRects.end()) {
- gl_draw_scaled_image_with_border(
- curSldrIt->second.mLeft,
- curSldrIt->second.mBottom, 16, 16,
- curSldrIt->second.getWidth(),
- curSldrIt->second.getHeight(), thumb_imagep,
- mThumbCenterSelectedColor, TRUE);
- }
+ // choose the color
+ curThumbColor = mThumbCenterColor;
+ if(mIt->first == mCurSlider)
+ {
+ curSldrIt = mIt;
+ continue;
+ //curThumbColor = mThumbCenterSelectedColor;
+ }
+ thumb_imagep->drawSolid(mIt->second, curThumbColor % opacity);
}
- else
- {
- // draw highlight
- if (hasFocus())
- {
- F32 lerp_amt = gFocusMgr.getFocusFlashAmt();
- LLRect highlight_rect = mThumbRects[mCurSlider];
- highlight_rect.stretch(llround(lerp(1.f, 3.f, lerp_amt)));
- gl_draw_scaled_image_with_border(highlight_rect.mLeft, highlight_rect.mBottom, 16, 16, highlight_rect.getWidth(), highlight_rect.getHeight(),
- thumb_imagep, gFocusMgr.getFocusColor());
- }
- // draw thumbs
- curSldrIt = mThumbRects.end();
- for(mIt = mThumbRects.begin(); mIt != mThumbRects.end(); mIt++) {
-
- // choose the color
- curThumbColor = mThumbCenterColor;
- if(mIt->first == mCurSlider) {
- curSldrIt = mIt;
- continue;
- //curThumbColor = mThumbCenterSelectedColor;
- }
-
- // the draw command
- gl_draw_scaled_image_with_border(
- mIt->second.mLeft,
- mIt->second.mBottom, 16, 16,
- mIt->second.getWidth(),
- mIt->second.getHeight(), thumb_imagep,
- curThumbColor % opacity, TRUE);
- }
-
- if(curSldrIt != mThumbRects.end()) {
- gl_draw_scaled_image_with_border(
- curSldrIt->second.mLeft,
- curSldrIt->second.mBottom, 16, 16,
- curSldrIt->second.getWidth(),
- curSldrIt->second.getHeight(), thumb_imagep,
- mThumbCenterSelectedColor % opacity, TRUE);
- }
+ if(curSldrIt != mThumbRects.end())
+ {
+ thumb_imagep->drawSolid(curSldrIt->second, mThumbCenterSelectedColor % opacity);
}
-
- LLUICtrl::draw();
}
+
+ LLUICtrl::draw();
}
// virtual
diff --git a/indra/llui/llmultislider.h b/indra/llui/llmultislider.h
index 67f627d21c..1eb7764c3c 100644
--- a/indra/llui/llmultislider.h
+++ b/indra/llui/llmultislider.h
@@ -55,8 +55,6 @@ public:
BOOL use_triangle,
const LLString& control_name = LLString::null );
- virtual EWidgetType getWidgetType() const;
- virtual LLString getWidgetTag() const;
virtual LLXMLNodePtr getXML(bool save_children = true) const;
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
@@ -94,7 +92,7 @@ public:
virtual BOOL handleHover(S32 x, S32 y, MASK mask);
virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
- virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
+ virtual BOOL handleKeyHere(KEY key, MASK mask);
virtual void draw();
protected:
diff --git a/indra/llui/llmultisliderctrl.cpp b/indra/llui/llmultisliderctrl.cpp
index 6f921a4e5e..641b88de9a 100644
--- a/indra/llui/llmultisliderctrl.cpp
+++ b/indra/llui/llmultisliderctrl.cpp
@@ -50,6 +50,8 @@
#include "llfocusmgr.h"
#include "llresmgr.h"
+static LLRegisterWidget<LLMultiSliderCtrl> r("multi_slider");
+
const U32 MAX_STRING_LENGTH = 10;
diff --git a/indra/llui/llmultisliderctrl.h b/indra/llui/llmultisliderctrl.h
index 028f54ed5e..a3a602c2b2 100644
--- a/indra/llui/llmultisliderctrl.h
+++ b/indra/llui/llmultisliderctrl.h
@@ -71,8 +71,6 @@ public:
const LLString& control_which = LLString::null );
virtual ~LLMultiSliderCtrl();
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MULTI_SLIDER; }
- virtual LLString getWidgetTag() const { return LL_MULTI_SLIDER_CTRL_TAG; }
virtual LLXMLNodePtr getXML(bool save_children = true) const;
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp
index cb732a17c6..c3afa040f8 100644
--- a/indra/llui/llpanel.cpp
+++ b/indra/llui/llpanel.cpp
@@ -65,6 +65,8 @@ LLPanel::alert_queue_t LLPanel::sAlertQueue;
const S32 RESIZE_BAR_OVERLAP = 1;
const S32 RESIZE_BAR_HEIGHT = 3;
+static LLRegisterWidget<LLPanel> r1("panel");
+
void LLPanel::init()
{
// mRectControl
@@ -126,18 +128,6 @@ LLPanel::~LLPanel()
}
// virtual
-EWidgetType LLPanel::getWidgetType() const
-{
- return WIDGET_TYPE_PANEL;
-}
-
-// virtual
-LLString LLPanel::getWidgetTag() const
-{
- return LL_PANEL_TAG;
-}
-
-// virtual
BOOL LLPanel::isPanel() const
{
return TRUE;
@@ -227,7 +217,8 @@ void LLPanel::updateDefaultBtn()
if (gFocusMgr.childHasKeyboardFocus( this ) && mDefaultBtn->getEnabled())
{
LLUICtrl* focus_ctrl = gFocusMgr.getKeyboardFocus();
- BOOL focus_is_child_button = focus_ctrl->getWidgetType() == WIDGET_TYPE_BUTTON && static_cast<LLButton *>(focus_ctrl)->getCommitOnReturn();
+ LLButton* buttonp = dynamic_cast<LLButton*>(focus_ctrl);
+ BOOL focus_is_child_button = buttonp && buttonp->getCommitOnReturn();
// only enable default button when current focus is not a return-capturing button
mDefaultBtn->setBorderEnabled(!focus_is_child_button);
}
@@ -259,7 +250,7 @@ void LLPanel::setDefaultBtn(LLButton* btn)
void LLPanel::setDefaultBtn(const LLString& id)
{
- LLButton *button = LLUICtrlFactory::getButtonByName(this, id);
+ LLButton *button = getChild<LLButton>(id);
if (button)
{
setDefaultBtn(button);
@@ -270,77 +261,6 @@ void LLPanel::setDefaultBtn(const LLString& id)
}
}
-BOOL LLPanel::handleKey(KEY key, MASK mask, BOOL called_from_parent)
-{
- BOOL handled = FALSE;
- if (getVisible() && getEnabled())
- {
- if( (mask == MASK_SHIFT) && (KEY_TAB == key))
- {
- //SHIFT-TAB
- LLUICtrl* cur_focus = gFocusMgr.getKeyboardFocus();
- if (cur_focus && gFocusMgr.childHasKeyboardFocus(this))
- {
- LLUICtrl* focus_root = cur_focus;
- while(cur_focus->getParentUICtrl())
- {
- cur_focus = cur_focus->getParentUICtrl();
- if (cur_focus->isFocusRoot())
- {
- // this is the root-most focus root found so far
- focus_root = cur_focus;
- }
- }
- handled = focus_root->focusPrevItem(FALSE);
- }
- else if (!cur_focus && isFocusRoot())
- {
- handled = focusLastItem();
- if (!handled)
- {
- setFocus(TRUE);
- handled = TRUE;
- }
- }
- }
- else
- if( (mask == MASK_NONE ) && (KEY_TAB == key))
- {
- //TAB
- LLUICtrl* cur_focus = gFocusMgr.getKeyboardFocus();
- if (cur_focus && gFocusMgr.childHasKeyboardFocus(this))
- {
- LLUICtrl* focus_root = cur_focus;
- while(cur_focus->getParentUICtrl())
- {
- cur_focus = cur_focus->getParentUICtrl();
- if (cur_focus->isFocusRoot())
- {
- focus_root = cur_focus;
- }
- }
- handled = focus_root->focusNextItem(FALSE);
- }
- else if (!cur_focus && isFocusRoot())
- {
- handled = focusFirstItem();
- if (!handled)
- {
- setFocus(TRUE);
- handled = TRUE;
- }
- }
- }
- }
-
- if (!handled)
- {
- handled = LLView::handleKey(key, mask, called_from_parent);
- }
-
- return handled;
-}
-
void LLPanel::addCtrl( LLUICtrl* ctrl, S32 tab_group)
{
mLastTabGroup = tab_group;
@@ -355,83 +275,84 @@ void LLPanel::addCtrlAtEnd( LLUICtrl* ctrl, S32 tab_group)
LLView::addCtrlAtEnd(ctrl, tab_group);
}
-BOOL LLPanel::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent )
+BOOL LLPanel::handleKeyHere( KEY key, MASK mask )
{
BOOL handled = FALSE;
- if( getVisible() && getEnabled() &&
- gFocusMgr.childHasKeyboardFocus(this) && !called_from_parent )
+ LLUICtrl* cur_focus = gFocusMgr.getKeyboardFocus();
+
+ // handle user hitting ESC to defocus
+ if (key == KEY_ESCAPE)
{
- // handle user hitting ESC to defocus
- if (key == KEY_ESCAPE)
+ gFocusMgr.setKeyboardFocus(NULL);
+ return TRUE;
+ }
+ else if( (mask == MASK_SHIFT) && (KEY_TAB == key))
+ {
+ //SHIFT-TAB
+ if (cur_focus)
{
- gFocusMgr.setKeyboardFocus(NULL);
- return TRUE;
+ LLUICtrl* focus_root = cur_focus->findRootMostFocusRoot();
+ handled = focus_root->focusPrevItem(FALSE);
}
-
- LLUICtrl* cur_focus = gFocusMgr.getKeyboardFocus();
- // If we have a default button, click it when
- // return is pressed, unless current focus is a return-capturing button
- // in which case *that* button will handle the return key
- if (cur_focus && !(cur_focus->getWidgetType() == WIDGET_TYPE_BUTTON && static_cast<LLButton *>(cur_focus)->getCommitOnReturn()))
+ }
+ else if( (mask == MASK_NONE ) && (KEY_TAB == key))
+ {
+ //TAB
+ if (cur_focus)
{
- // RETURN key means hit default button in this case
- if (key == KEY_RETURN && mask == MASK_NONE
- && mDefaultBtn != NULL
- && mDefaultBtn->getVisible()
- && mDefaultBtn->getEnabled())
- {
- mDefaultBtn->onCommit();
- handled = TRUE;
- }
+ LLUICtrl* focus_root = cur_focus->findRootMostFocusRoot();
+ handled = focus_root->focusNextItem(FALSE);
}
+ }
- if (key == KEY_RETURN && mask == MASK_NONE)
+ // If we have a default button, click it when
+ // return is pressed, unless current focus is a return-capturing button
+ // in which case *that* button will handle the return key
+ LLButton* focused_button = dynamic_cast<LLButton*>(cur_focus);
+ if (cur_focus && !(focused_button && focused_button->getCommitOnReturn()))
+ {
+ // RETURN key means hit default button in this case
+ if (key == KEY_RETURN && mask == MASK_NONE
+ && mDefaultBtn != NULL
+ && mDefaultBtn->getVisible()
+ && mDefaultBtn->getEnabled())
{
- // set keyboard focus to self to trigger commitOnFocusLost behavior on current ctrl
- if (cur_focus && cur_focus->acceptsTextInput())
- {
- cur_focus->onCommit();
- handled = TRUE;
- }
+ mDefaultBtn->onCommit();
+ handled = TRUE;
}
}
- return handled;
-}
-
-void LLPanel::requires(LLString name, EWidgetType type)
-{
- mRequirements[name] = type;
-}
-
-BOOL LLPanel::checkRequirements() const
-{
- BOOL retval = TRUE;
- LLString message;
-
- for (requirements_map_t::const_iterator i = mRequirements.begin(); i != mRequirements.end(); ++i)
+ if (key == KEY_RETURN && mask == MASK_NONE)
{
- if (!this->getCtrlByNameAndType(i->first, i->second))
+ // set keyboard focus to self to trigger commitOnFocusLost behavior on current ctrl
+ if (cur_focus && cur_focus->acceptsTextInput())
{
- retval = FALSE;
- message += i->first + " " + LLUICtrlFactory::getWidgetType(i->second) + "\n";
+ cur_focus->onCommit();
+ handled = TRUE;
}
}
- if (!retval)
+ return handled;
+}
+
+BOOL LLPanel::checkRequirements()
+{
+ if (!mRequirementsError.empty())
{
LLString::format_map_t args;
- args["[COMPONENTS]"] = message;
+ args["[COMPONENTS]"] = mRequirementsError;
args["[FLOATER]"] = getName();
llwarns << getName() << " failed requirements check on: \n"
- << message << llendl;
+ << mRequirementsError << llendl;
alertXml("FailedRequirementsCheck", args);
+ mRequirementsError.clear();
+ return FALSE;
}
- return retval;
+ return TRUE;
}
//static
@@ -494,30 +415,6 @@ void LLPanel::setBorderVisible(BOOL b)
}
}
-LLUICtrl* LLPanel::getCtrlByNameAndType(const LLString& name, EWidgetType type) const
-{
- LLView* view = getChildByName(name, TRUE);
- if (view && view->isCtrl())
- {
- if (type == WIDGET_TYPE_DONTCARE || view->getWidgetType() == type)
- {
- return (LLUICtrl*)view;
- }
- else
- {
- llwarns << "Widget " << name << " has improper type in panel " << getName() << "\n"
- << "Is: \t\t" << view->getWidgetType() << "\n"
- << "Should be: \t" << type
- << llendl;
- }
- }
- else
- {
- childNotFound(name);
- }
- return NULL;
-}
-
// virtual
LLXMLNodePtr LLPanel::getXML(bool save_children) const
{
@@ -963,7 +860,7 @@ BOOL LLPanel::childSetLabelArg(const LLString& id, const LLString& key, const LL
BOOL LLPanel::childSetToolTipArg(const LLString& id, const LLString& key, const LLStringExplicit& text)
{
- LLView* child = getChildByName(id, true);
+ LLView* child = getChildView(id, true, FALSE);
if (child)
{
return child->setToolTipArg(key, text);
@@ -991,7 +888,7 @@ void LLPanel::childSetMaxValue(const LLString& id, LLSD max_value)
void LLPanel::childShowTab(const LLString& id, const LLString& tabname, bool visible)
{
- LLTabContainer* child = LLUICtrlFactory::getTabContainerByName(this, id);
+ LLTabContainer* child = getChild<LLTabContainer>(id);
if (child)
{
child->selectTabByName(tabname);
@@ -1000,7 +897,7 @@ void LLPanel::childShowTab(const LLString& id, const LLString& tabname, bool vis
LLPanel *LLPanel::childGetVisibleTab(const LLString& id) const
{
- LLTabContainer* child = LLUICtrlFactory::getTabContainerByName(this, id);
+ LLTabContainer* child = getChild<LLTabContainer>(id);
if (child)
{
return child->getCurrentPanel();
@@ -1010,7 +907,7 @@ LLPanel *LLPanel::childGetVisibleTab(const LLString& id) const
void LLPanel::childSetTabChangeCallback(const LLString& id, const LLString& tabname, void (*on_tab_clicked)(void*, bool), void *userdata)
{
- LLTabContainer* child = LLUICtrlFactory::getTabContainerByName(this, id);
+ LLTabContainer* child = getChild<LLTabContainer>(id);
if (child)
{
LLPanel *panel = child->getPanelByName(tabname);
@@ -1024,7 +921,7 @@ void LLPanel::childSetTabChangeCallback(const LLString& id, const LLString& tabn
void LLPanel::childSetKeystrokeCallback(const LLString& id, void (*keystroke_callback)(LLLineEditor* caller, void* user_data), void *user_data)
{
- LLLineEditor* child = LLUICtrlFactory::getLineEditorByName(this, id);
+ LLLineEditor* child = getChild<LLLineEditor>(id);
if (child)
{
child->setKeystrokeCallback(keystroke_callback);
@@ -1037,7 +934,7 @@ void LLPanel::childSetKeystrokeCallback(const LLString& id, void (*keystroke_cal
void LLPanel::childSetPrevalidate(const LLString& id, BOOL (*func)(const LLWString &) )
{
- LLLineEditor* child = LLUICtrlFactory::getLineEditorByName(this, id);
+ LLLineEditor* child = getChild<LLLineEditor>(id);
if (child)
{
child->setPrevalidate(func);
@@ -1046,7 +943,7 @@ void LLPanel::childSetPrevalidate(const LLString& id, BOOL (*func)(const LLWStri
void LLPanel::childSetWrappedText(const LLString& id, const LLString& text, bool visible)
{
- LLTextBox* child = (LLTextBox*)getCtrlByNameAndType(id, WIDGET_TYPE_TEXT_BOX);
+ LLTextBox* child = getChild<LLTextBox>(id);
if (child)
{
child->setVisible(visible);
@@ -1056,7 +953,7 @@ void LLPanel::childSetWrappedText(const LLString& id, const LLString& text, bool
void LLPanel::childSetAction(const LLString& id, void(*function)(void*), void* value)
{
- LLButton* button = (LLButton*)getCtrlByNameAndType(id, WIDGET_TYPE_BUTTON);
+ LLButton* button = getChild<LLButton>(id);
if (button)
{
button->setClickedCallback(function, value);
@@ -1065,7 +962,7 @@ void LLPanel::childSetAction(const LLString& id, void(*function)(void*), void* v
void LLPanel::childSetActionTextbox(const LLString& id, void(*function)(void*))
{
- LLTextBox* textbox = (LLTextBox*)getCtrlByNameAndType(id, WIDGET_TYPE_TEXT_BOX);
+ LLTextBox* textbox = getChild<LLTextBox>(id);
if (textbox)
{
textbox->setClickedCallback(function);
@@ -1082,13 +979,18 @@ void LLPanel::childSetControlName(const LLString& id, const LLString& control_na
}
//virtual
-LLView* LLPanel::getChildByName(const LLString& name, BOOL recurse) const
+LLView* LLPanel::getChildView(const LLString& name, BOOL recurse, BOOL create_if_missing) const
{
- LLView* view = LLUICtrl::getChildByName(name, recurse);
+ // just get child, don't try to create a dummy one
+ LLView* view = LLUICtrl::getChildView(name, recurse, FALSE);
if (!view && !recurse)
{
childNotFound(name);
}
+ if (!view && create_if_missing)
+ {
+ view = createDummyWidget<LLView>(name);
+ }
return view;
}
@@ -1181,6 +1083,8 @@ struct LLLayoutStack::LLEmbeddedPanel
F32 mVisibleAmt;
};
+static LLRegisterWidget<LLLayoutStack> r2("layout_stack");
+
LLLayoutStack::LLLayoutStack(eLayoutOrientation orientation) :
mOrientation(orientation),
mMinWidth(0),
@@ -1194,19 +1098,6 @@ LLLayoutStack::~LLLayoutStack()
std::for_each(mPanels.begin(), mPanels.end(), DeletePointer());
}
-// virtual
-EWidgetType LLLayoutStack::getWidgetType() const
-{
- return WIDGET_TYPE_LAYOUT_STACK;
-}
-
-// virtual
-LLString LLLayoutStack::getWidgetTag() const
-{
- return LL_LAYOUT_STACK_TAG;
-}
-
-
void LLLayoutStack::draw()
{
updateLayout();
@@ -1294,18 +1185,18 @@ LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactor
LLXMLNodePtr child;
for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling())
{
+ S32 min_width = 0;
+ S32 min_height = 0;
+ BOOL auto_resize = TRUE;
+
+ child->getAttributeS32("min_width", min_width);
+ child->getAttributeS32("min_height", min_height);
+ child->getAttributeBOOL("auto_resize", auto_resize);
+
if (child->hasName("layout_panel"))
{
- S32 min_width = 0;
- S32 min_height = 0;
- BOOL auto_resize = TRUE;
BOOL user_resize = TRUE;
-
- child->getAttributeS32("min_width", min_width);
- child->getAttributeS32("min_height", min_height);
- child->getAttributeBOOL("auto_resize", auto_resize);
child->getAttributeBOOL("user_resize", user_resize);
-
LLPanel* panelp = (LLPanel*)LLPanel::fromXML(child, layout_stackp, factory);
if (panelp)
{
@@ -1313,6 +1204,26 @@ LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactor
layout_stackp->addPanel(panelp, min_width, min_height, auto_resize, user_resize);
}
}
+ else
+ {
+ BOOL user_resize = FALSE;
+ child->getAttributeBOOL("user_resize", user_resize);
+
+ LLPanel* panelp = new LLPanel("auto_panel");
+ LLView* new_child = factory->createWidget(panelp, child);
+ if (new_child)
+ {
+ // put child in new embedded panel
+ layout_stackp->addPanel(panelp, min_width, min_height, auto_resize, user_resize);
+ // resize panel to contain widget and move widget to be contained in panel
+ panelp->setRect(new_child->getRect());
+ new_child->setOrigin(0, 0);
+ }
+ else
+ {
+ panelp->die();
+ }
+ }
}
layout_stackp->updateLayout();
@@ -1401,6 +1312,11 @@ void LLLayoutStack::updateLayout(BOOL force_resize)
if (mOrientation == HORIZONTAL)
{
+ // enforce minimize size constraint by default
+ if (panelp->getRect().getWidth() < (*panel_it)->mMinWidth)
+ {
+ panelp->reshape((*panel_it)->mMinWidth, panelp->getRect().getHeight());
+ }
total_width += llround(panelp->getRect().getWidth() * (*panel_it)->mVisibleAmt);
// want n-1 panel gaps for n panels
if (panel_it != mPanels.begin())
@@ -1410,6 +1326,11 @@ void LLLayoutStack::updateLayout(BOOL force_resize)
}
else //VERTICAL
{
+ // enforce minimize size constraint by default
+ if (panelp->getRect().getHeight() < (*panel_it)->mMinHeight)
+ {
+ panelp->reshape(panelp->getRect().getWidth(), (*panel_it)->mMinHeight);
+ }
total_height += llround(panelp->getRect().getHeight() * (*panel_it)->mVisibleAmt);
if (panel_it != mPanels.begin())
{
@@ -1428,6 +1349,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize)
{
continue;
}
+
// if currently resizing a panel or the panel is flagged as not automatically resizing
// only track total available headroom, but don't use it for automatic resize logic
if ((*panel_it)->mResizeBar->hasMouseCapture()
@@ -1459,6 +1381,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize)
}
}
+ // calculate how many pixels need to be distributed among layout panels
// positive means panels need to grow, negative means shrink
S32 pixels_to_distribute;
if (mOrientation == HORIZONTAL)
@@ -1470,6 +1393,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize)
pixels_to_distribute = getRect().getHeight() - total_height;
}
+ // now we distribute the pixels...
S32 cur_x = 0;
S32 cur_y = getRect().getHeight();
@@ -1495,13 +1419,17 @@ void LLLayoutStack::updateLayout(BOOL force_resize)
if (pixels_to_distribute < 0)
{
// shrink proportionally to amount over minimum
- delta_size = (shrink_headroom_available > 0) ? llround((F32)pixels_to_distribute * (F32)(cur_width - (*panel_it)->mMinWidth) / (F32)shrink_headroom_available) : 0;
+ // so we can do this in one pass
+ delta_size = (shrink_headroom_available > 0) ? llround((F32)pixels_to_distribute * ((F32)(cur_width - (*panel_it)->mMinWidth) / (F32)shrink_headroom_available)) : 0;
+ shrink_headroom_available -= (cur_width - (*panel_it)->mMinWidth);
}
else
{
// grow all elements equally
delta_size = llround((F32)pixels_to_distribute / (F32)num_resizable_panels);
+ num_resizable_panels--;
}
+ pixels_to_distribute -= delta_size;
new_width = llmax((*panel_it)->mMinWidth, cur_width + delta_size);
}
else
@@ -1514,12 +1442,16 @@ void LLLayoutStack::updateLayout(BOOL force_resize)
if (pixels_to_distribute < 0)
{
// shrink proportionally to amount over minimum
- delta_size = (shrink_headroom_available > 0) ? llround((F32)pixels_to_distribute * (F32)(cur_height - (*panel_it)->mMinHeight) / (F32)shrink_headroom_available) : 0;
+ // so we can do this in one pass
+ delta_size = (shrink_headroom_available > 0) ? llround((F32)pixels_to_distribute * ((F32)(cur_height - (*panel_it)->mMinHeight) / (F32)shrink_headroom_available)) : 0;
+ shrink_headroom_available -= (cur_height - (*panel_it)->mMinHeight);
}
else
{
delta_size = llround((F32)pixels_to_distribute / (F32)num_resizable_panels);
+ num_resizable_panels--;
}
+ pixels_to_distribute -= delta_size;
new_height = llmax((*panel_it)->mMinHeight, cur_height + delta_size);
}
else
diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h
index 96417d358b..0485274055 100644
--- a/indra/llui/llpanel.h
+++ b/indra/llui/llpanel.h
@@ -82,13 +82,12 @@ public:
/*virtual*/ ~LLPanel();
// LLView interface
- /*virtual*/ EWidgetType getWidgetType() const;
- /*virtual*/ LLString getWidgetTag() const;
/*virtual*/ BOOL isPanel() const;
/*virtual*/ void draw();
- /*virtual*/ BOOL handleKey( KEY key, MASK mask, BOOL called_from_parent );
- /*virtual*/ BOOL handleKeyHere( KEY key, MASK mask, BOOL called_from_parent );
+ /*virtual*/ BOOL handleKeyHere( KEY key, MASK mask );
/*virtual*/ LLXMLNodePtr getXML(bool save_children = true) const;
+ // Override to set not found list:
+ virtual LLView* getChildView(const LLString& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const;
// From LLFocusableElement
/*virtual*/ void setFocus( BOOL b );
@@ -106,8 +105,21 @@ public:
BOOL hasBorder() const { return mBorder != NULL; }
void setBorderVisible( BOOL b );
- void requires(LLString name, EWidgetType type = WIDGET_TYPE_DONTCARE);
- BOOL checkRequirements() const;
+ template <class T> void requires(LLString name)
+ {
+ // check for widget with matching type and name
+ if (LLView::getChild<T>(name) == NULL)
+ {
+ mRequirementsError += name + "\n";
+ }
+ }
+
+ // requires LLView by default
+ void requires(LLString name)
+ {
+ requires<LLView>(name);
+ }
+ BOOL checkRequirements();
void setBackgroundColor( const LLColor4& color ) { mBgColorOpaque = color; }
const LLColor4& getBackgroundColor() const { return mBgColorOpaque; }
@@ -133,8 +145,6 @@ public:
S32 getLastTabGroup() const { return mLastTabGroup; }
- LLUICtrl* getCtrlByNameAndType(const LLString& name, EWidgetType type) const;
-
const LLCallbackMap::map_t& getFactoryMap() const { return mFactoryMap; }
BOOL initPanelXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
@@ -226,9 +236,6 @@ protected:
LLButton* getDefaultButton() { return mDefaultBtn; }
LLCallbackMap::map_t mFactoryMap;
- // Override to set not found list:
- virtual LLView* getChildByName(const LLString& name, BOOL recurse = FALSE) const;
-
private:
// common construction logic
void init();
@@ -257,8 +264,7 @@ private:
typedef std::map<LLString, LLUIString> ui_string_map_t;
ui_string_map_t mUIStrings;
- typedef std::map<LLString, EWidgetType> requirements_map_t;
- requirements_map_t mRequirements;
+ LLString mRequirementsError;
typedef std::queue<LLAlertInfo> alert_queue_t;
static alert_queue_t sAlertQueue;
@@ -281,9 +287,6 @@ public:
/*virtual*/ LLXMLNodePtr getXML(bool save_children = true) const;
/*virtual*/ void removeCtrl(LLUICtrl* ctrl);
- virtual EWidgetType getWidgetType() const;
- virtual LLString getWidgetTag() const;
-
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
S32 getMinWidth() const { return mMinWidth; }
@@ -291,16 +294,17 @@ public:
void addPanel(LLPanel* panel, S32 min_width, S32 min_height, BOOL auto_resize, BOOL user_resize, S32 index = S32_MAX);
void removePanel(LLPanel* panel);
- void updateLayout(BOOL force_resize = FALSE);
private:
+ struct LLEmbeddedPanel;
+
+ void updateLayout(BOOL force_resize = FALSE);
void calcMinExtents();
S32 getDefaultHeight(S32 cur_height);
S32 getDefaultWidth(S32 cur_width);
const eLayoutOrientation mOrientation;
- struct LLEmbeddedPanel;
typedef std::vector<LLEmbeddedPanel*> e_panel_list_t;
e_panel_list_t mPanels;
LLEmbeddedPanel* findEmbeddedPanel(LLPanel* panelp) const;
diff --git a/indra/llui/llradiogroup.cpp b/indra/llui/llradiogroup.cpp
index 8bda6780a2..6d496b391f 100644
--- a/indra/llui/llradiogroup.cpp
+++ b/indra/llui/llradiogroup.cpp
@@ -42,6 +42,7 @@
#include "llui.h"
#include "llfocusmgr.h"
+static LLRegisterWidget<LLRadioGroup> r("radio_group");
LLRadioGroup::LLRadioGroup(const LLString& name, const LLRect& rect,
const LLString& control_name,
@@ -161,11 +162,11 @@ BOOL LLRadioGroup::setSelectedIndex(S32 index, BOOL from_event)
return TRUE;
}
-BOOL LLRadioGroup::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
+BOOL LLRadioGroup::handleKeyHere(KEY key, MASK mask)
{
BOOL handled = FALSE;
// do any of the tab buttons have keyboard focus?
- if (getEnabled() && !called_from_parent && mask == MASK_NONE)
+ if (mask == MASK_NONE)
{
switch(key)
{
diff --git a/indra/llui/llradiogroup.h b/indra/llui/llradiogroup.h
index 3e01e8223c..b9e2167446 100644
--- a/indra/llui/llradiogroup.h
+++ b/indra/llui/llradiogroup.h
@@ -82,10 +82,8 @@ public:
BOOL border = TRUE);
virtual ~LLRadioGroup();
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_RADIO_GROUP; }
- virtual LLString getWidgetTag() const { return LL_RADIO_GROUP_TAG; }
- virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
+ virtual BOOL handleKeyHere(KEY key, MASK mask);
virtual void setEnabled(BOOL enabled);
virtual LLXMLNodePtr getXML(bool save_children = true) const;
diff --git a/indra/llui/llresizebar.cpp b/indra/llui/llresizebar.cpp
index 40346513cf..e82e93a7ba 100644
--- a/indra/llui/llresizebar.cpp
+++ b/indra/llui/llresizebar.cpp
@@ -85,16 +85,13 @@ LLResizeBar::LLResizeBar( const LLString& name, LLView* resizing_view, const LLR
BOOL LLResizeBar::handleMouseDown(S32 x, S32 y, MASK mask)
{
- if( getEnabled() )
- {
- // Route future Mouse messages here preemptively. (Release on mouse up.)
- // No handler needed for focus lost since this clas has no state that depends on it.
- gFocusMgr.setMouseCapture( this );
+ // Route future Mouse messages here preemptively. (Release on mouse up.)
+ // No handler needed for focus lost since this clas has no state that depends on it.
+ gFocusMgr.setMouseCapture( this );
- localPointToScreen(x, y, &mDragLastScreenX, &mDragLastScreenY);
- mLastMouseScreenX = mDragLastScreenX;
- mLastMouseScreenY = mDragLastScreenY;
- }
+ localPointToScreen(x, y, &mDragLastScreenX, &mDragLastScreenY);
+ mLastMouseScreenX = mDragLastScreenX;
+ mLastMouseScreenY = mDragLastScreenY;
return TRUE;
}
diff --git a/indra/llui/llresizebar.h b/indra/llui/llresizebar.h
index a3fef1a28c..f45653cbad 100644
--- a/indra/llui/llresizebar.h
+++ b/indra/llui/llresizebar.h
@@ -42,9 +42,6 @@ public:
LLResizeBar(const LLString& name, LLView* resizing_view, const LLRect& rect, S32 min_size, S32 max_size, Side side );
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_RESIZE_BAR; }
- virtual LLString getWidgetTag() const { return LL_RESIZE_BAR_TAG; }
-
// virtual void draw(); No appearance
virtual BOOL handleHover(S32 x, S32 y, MASK mask);
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
diff --git a/indra/llui/llresizehandle.cpp b/indra/llui/llresizehandle.cpp
index 36028a4513..4da2d4fca1 100644
--- a/indra/llui/llresizehandle.cpp
+++ b/indra/llui/llresizehandle.cpp
@@ -59,8 +59,7 @@ LLResizeHandle::LLResizeHandle( const LLString& name, const LLRect& rect, S32 mi
if( RIGHT_BOTTOM == mCorner)
{
- LLUUID image_id(LLUI::sConfigGroup->getString("UIImgResizeBottomRightUUID"));
- mImage = LLUI::sImageProvider->getImageByID(image_id);
+ mImage = LLUI::sImageProvider->getUIImage("UIImgResizeBottomRightUUID");
}
switch( mCorner )
@@ -78,19 +77,16 @@ LLResizeHandle::LLResizeHandle( const LLString& name, const LLRect& rect, S32 mi
BOOL LLResizeHandle::handleMouseDown(S32 x, S32 y, MASK mask)
{
BOOL handled = FALSE;
- if( getVisible() && pointInHandle(x, y) )
+ if( pointInHandle(x, y) )
{
handled = TRUE;
- if( getEnabled() )
- {
- // Route future Mouse messages here preemptively. (Release on mouse up.)
- // No handler needed for focus lost since this clas has no state that depends on it.
- gFocusMgr.setMouseCapture( this );
+ // Route future Mouse messages here preemptively. (Release on mouse up.)
+ // No handler needed for focus lost since this clas has no state that depends on it.
+ gFocusMgr.setMouseCapture( this );
- localPointToScreen(x, y, &mDragLastScreenX, &mDragLastScreenY);
- mLastMouseScreenX = mDragLastScreenX;
- mLastMouseScreenY = mDragLastScreenY;
- }
+ localPointToScreen(x, y, &mDragLastScreenX, &mDragLastScreenY);
+ mLastMouseScreenX = mDragLastScreenX;
+ mLastMouseScreenY = mDragLastScreenY;
}
return handled;
@@ -107,8 +103,7 @@ BOOL LLResizeHandle::handleMouseUp(S32 x, S32 y, MASK mask)
gFocusMgr.setMouseCapture( NULL );
handled = TRUE;
}
- else
- if( getVisible() && pointInHandle(x, y) )
+ else if( pointInHandle(x, y) )
{
handled = TRUE;
}
@@ -284,7 +279,7 @@ BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask)
}
else // don't have mouse capture
{
- if( getVisible() && pointInHandle( x, y ) )
+ if( pointInHandle( x, y ) )
{
handled = TRUE;
}
@@ -314,7 +309,7 @@ void LLResizeHandle::draw()
{
if( mImage.notNull() && getVisible() && (RIGHT_BOTTOM == mCorner) )
{
- gl_draw_image( 0, 0, mImage );
+ mImage->draw(0, 0);
}
}
diff --git a/indra/llui/llresizehandle.h b/indra/llui/llresizehandle.h
index 34be319786..15336948e2 100644
--- a/indra/llui/llresizehandle.h
+++ b/indra/llui/llresizehandle.h
@@ -46,9 +46,6 @@ public:
LLResizeHandle(const LLString& name, const LLRect& rect, S32 min_width, S32 min_height, ECorner corner = RIGHT_BOTTOM );
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_RESIZE_HANDLE; }
- virtual LLString getWidgetTag() const { return LL_RESIZE_HANDLE_TAG; }
-
virtual void draw();
virtual BOOL handleHover(S32 x, S32 y, MASK mask);
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
@@ -64,7 +61,7 @@ private:
S32 mLastMouseScreenX;
S32 mLastMouseScreenY;
LLCoordGL mLastMouseDir;
- LLPointer<LLImageGL> mImage;
+ LLPointer<LLUIImage> mImage;
S32 mMinWidth;
S32 mMinHeight;
const ECorner mCorner;
diff --git a/indra/llui/llresmgr.cpp b/indra/llui/llresmgr.cpp
index 0e1b9bfbef..6cfc6a924b 100644
--- a/indra/llui/llresmgr.cpp
+++ b/indra/llui/llresmgr.cpp
@@ -39,8 +39,6 @@
#include "llerror.h"
#include "llstring.h"
-// Global singleton
-LLResMgr* gResMgr = NULL;
LLResMgr::LLResMgr()
{
diff --git a/indra/llui/llresmgr.h b/indra/llui/llresmgr.h
index 1a452f7381..2e39387ae1 100644
--- a/indra/llui/llresmgr.h
+++ b/indra/llui/llresmgr.h
@@ -36,6 +36,7 @@
#include "locale.h"
#include "stdtypes.h"
#include "llstring.h"
+#include "llmemory.h"
enum LLLOCALE_ID
{
@@ -44,67 +45,6 @@ enum LLLOCALE_ID
LLLOCALE_COUNT // Number of values in this enum. Keep at end.
};
-/*
-enum LLSTR_ID
-{
- LLSTR_HELLO,
- LLSTR_GOODBYE,
- LLSTR_CHAT_LABEL,
- LLSTR_STATUS_LABEL,
- LLSTR_X,
- LLSTR_Y,
- LLSTR_Z,
- LLSTR_POSITION,
- LLSTR_SCALE,
- LLSTR_ROTATION,
- LLSTR_HAS_PHYSICS,
- LLSTR_SCRIPT,
- LLSTR_HELP,
- LLSTR_REMOVE,
- LLSTR_CLEAR,
- LLSTR_APPLY,
- LLSTR_CANCEL,
- LLSTR_MATERIAL,
- LLSTR_FACE,
- LLSTR_TEXTURE,
- LLSTR_TEXTURE_SIZE,
- LLSTR_TEXTURE_OFFSET,
- LLSTR_TEXTURE_ROTATION,
- LLSTR_U,
- LLSTR_V,
- LLSTR_OWNERSHIP,
- LLSTR_PUBLIC,
- LLSTR_PRIVATE,
- LLSTR_REVERT,
- LLSTR_INSERT_SAMPLE,
- LLSTR_SET_TEXTURE,
- LLSTR_EDIT_SCRIPT,
- LLSTR_MOUSELOOK_INSTRUCTIONS,
- LLSTR_EDIT_FACE_INSTRUCTIONS,
- LLSTR_CLOSE,
- LLSTR_MOVE,
- LLSTR_ROTATE,
- LLSTR_RESIZE,
- LLSTR_PLACE_BOX,
- LLSTR_PLACE_PRISM,
- LLSTR_PLACE_PYRAMID,
- LLSTR_PLACE_TETRAHEDRON,
- LLSTR_PLACE_CYLINDER,
- LLSTR_PLACE_HALF_CYLINDER,
- LLSTR_PLACE_CONE,
- LLSTR_PLACE_HALF_CONE,
- LLSTR_PLACE_SPHERE,
- LLSTR_PLACE_HALF_SPHERE,
- LLSTR_PLACE_BIRD,
- LLSTR_PLACE_SNAKE,
- LLSTR_PLACE_ROCK,
- LLSTR_PLACE_TREE,
- LLSTR_PLACE_GRASS,
- LLSTR_MODIFY_LAND,
- LLSTR_COUNT // Number of values in this enum. Keep at end.
-};
-*/
-
enum LLFONT_ID
{
LLFONT_OCRA,
@@ -117,7 +57,7 @@ enum LLFONT_ID
class LLFontGL;
-class LLResMgr
+class LLResMgr : public LLSingleton<LLResMgr>
{
public:
LLResMgr();
@@ -162,6 +102,4 @@ private:
LLString mPrevLocaleString;
};
-extern LLResMgr* gResMgr;
-
#endif // LL_RESMGR_
diff --git a/indra/llui/llscrollbar.cpp b/indra/llui/llscrollbar.cpp
index c3afb32570..90659cdc70 100644
--- a/indra/llui/llscrollbar.cpp
+++ b/indra/llui/llscrollbar.cpp
@@ -414,17 +414,8 @@ BOOL LLScrollbar::handleHover(S32 x, S32 y, MASK mask)
BOOL LLScrollbar::handleScrollWheel(S32 x, S32 y, S32 clicks)
{
- BOOL handled = FALSE;
- if( getVisible() && getRect().localPointInRect( x, y ) )
- {
- if( getEnabled() )
- {
- changeLine( clicks * mStepSize, TRUE );
- }
- handled = TRUE;
- }
-
- return handled;
+ changeLine( clicks * mStepSize, TRUE );
+ return TRUE;
}
BOOL LLScrollbar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
@@ -475,85 +466,68 @@ void LLScrollbar::reshape(S32 width, S32 height, BOOL called_from_parent)
void LLScrollbar::draw()
{
- if( getVisible() )
+ S32 local_mouse_x;
+ S32 local_mouse_y;
+ LLCoordWindow cursor_pos_window;
+ getWindow()->getCursorPosition(&cursor_pos_window);
+ LLCoordGL cursor_pos_gl;
+ getWindow()->convertCoords(cursor_pos_window, &cursor_pos_gl);
+
+ screenPointToLocal(cursor_pos_gl.mX, cursor_pos_gl.mY, &local_mouse_x, &local_mouse_y);
+ BOOL other_captor = gFocusMgr.getMouseCapture() && gFocusMgr.getMouseCapture() != this;
+ BOOL hovered = getEnabled() && !other_captor && (hasMouseCapture() || mThumbRect.pointInRect(local_mouse_x, local_mouse_y));
+ if (hovered)
{
- S32 local_mouse_x;
- S32 local_mouse_y;
- LLCoordWindow cursor_pos_window;
- getWindow()->getCursorPosition(&cursor_pos_window);
- LLCoordGL cursor_pos_gl;
- getWindow()->convertCoords(cursor_pos_window, &cursor_pos_gl);
-
- screenPointToLocal(cursor_pos_gl.mX, cursor_pos_gl.mY, &local_mouse_x, &local_mouse_y);
- BOOL other_captor = gFocusMgr.getMouseCapture() && gFocusMgr.getMouseCapture() != this;
- BOOL hovered = getEnabled() && !other_captor && (hasMouseCapture() || mThumbRect.pointInRect(local_mouse_x, local_mouse_y));
- if (hovered)
- {
- mCurGlowStrength = lerp(mCurGlowStrength, mHoverGlowStrength, LLCriticalDamp::getInterpolant(0.05f));
- }
- else
- {
- mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLCriticalDamp::getInterpolant(0.05f));
- }
+ mCurGlowStrength = lerp(mCurGlowStrength, mHoverGlowStrength, LLCriticalDamp::getInterpolant(0.05f));
+ }
+ else
+ {
+ mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLCriticalDamp::getInterpolant(0.05f));
+ }
- // Draw background and thumb.
- LLUUID rounded_rect_image_id;
- rounded_rect_image_id.set(LLUI::sAssetsGroup->getString("rounded_square.tga"));
- LLImageGL* rounded_rect_imagep = LLUI::sImageProvider->getImageByID(rounded_rect_image_id);
+ // Draw background and thumb.
+ LLUIImage* rounded_rect_imagep = LLUI::sImageProvider->getUIImage("rounded_square.tga");
- if (!rounded_rect_imagep)
- {
- gl_rect_2d(mOrientation == HORIZONTAL ? SCROLLBAR_SIZE : 0,
- mOrientation == VERTICAL ? getRect().getHeight() - 2 * SCROLLBAR_SIZE : getRect().getHeight(),
- mOrientation == HORIZONTAL ? getRect().getWidth() - 2 * SCROLLBAR_SIZE : getRect().getWidth(),
- mOrientation == VERTICAL ? SCROLLBAR_SIZE : 0, mTrackColor, TRUE);
+ if (!rounded_rect_imagep)
+ {
+ gl_rect_2d(mOrientation == HORIZONTAL ? SCROLLBAR_SIZE : 0,
+ mOrientation == VERTICAL ? getRect().getHeight() - 2 * SCROLLBAR_SIZE : getRect().getHeight(),
+ mOrientation == HORIZONTAL ? getRect().getWidth() - 2 * SCROLLBAR_SIZE : getRect().getWidth(),
+ mOrientation == VERTICAL ? SCROLLBAR_SIZE : 0, mTrackColor, TRUE);
- gl_rect_2d(mThumbRect, mThumbColor, TRUE);
+ gl_rect_2d(mThumbRect, mThumbColor, TRUE);
- }
- else
- {
- // Background
- gl_draw_scaled_image_with_border(mOrientation == HORIZONTAL ? SCROLLBAR_SIZE : 0,
- mOrientation == VERTICAL ? SCROLLBAR_SIZE : 0,
- 16,
- 16,
- mOrientation == HORIZONTAL ? getRect().getWidth() - 2 * SCROLLBAR_SIZE : getRect().getWidth(),
- mOrientation == VERTICAL ? getRect().getHeight() - 2 * SCROLLBAR_SIZE : getRect().getHeight(),
- rounded_rect_imagep,
- mTrackColor,
- TRUE);
-
- // Thumb
- LLRect outline_rect = mThumbRect;
- outline_rect.stretch(2);
-
- if (gFocusMgr.getKeyboardFocus() == this)
- {
- gl_draw_scaled_image_with_border(outline_rect.mLeft, outline_rect.mBottom, 16, 16, outline_rect.getWidth(), outline_rect.getHeight(),
- rounded_rect_imagep, gFocusMgr.getFocusColor() );
- }
+ }
+ else
+ {
+ // Thumb
+ LLRect outline_rect = mThumbRect;
+ outline_rect.stretch(2);
- gl_draw_scaled_image_with_border(mThumbRect.mLeft, mThumbRect.mBottom, 16, 16, mThumbRect.getWidth(), mThumbRect.getHeight(),
- rounded_rect_imagep, mThumbColor );
- if (mCurGlowStrength > 0.01f)
- {
- gGL.blendFunc(GL_SRC_ALPHA, GL_ONE);
- gl_draw_scaled_image_with_border(mThumbRect.mLeft, mThumbRect.mBottom, 16, 16, mThumbRect.getWidth(), mThumbRect.getHeight(),
- rounded_rect_imagep, LLColor4(1.f, 1.f, 1.f, mCurGlowStrength), TRUE);
- gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- }
+ if (gFocusMgr.getKeyboardFocus() == this)
+ {
+ rounded_rect_imagep->draw(outline_rect, gFocusMgr.getFocusColor());
}
- BOOL was_scrolled_to_bottom = (getDocPos() == getDocPosMax());
- if (mOnScrollEndCallback && was_scrolled_to_bottom)
+ rounded_rect_imagep->draw(mThumbRect, mThumbColor);
+ if (mCurGlowStrength > 0.01f)
{
- mOnScrollEndCallback(mOnScrollEndData);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ rounded_rect_imagep->drawSolid(mThumbRect, LLColor4(1.f, 1.f, 1.f, mCurGlowStrength));
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
- // Draw children
- LLView::draw();
+
}
+
+ BOOL was_scrolled_to_bottom = (getDocPos() == getDocPosMax());
+ if (mOnScrollEndCallback && was_scrolled_to_bottom)
+ {
+ mOnScrollEndCallback(mOnScrollEndData);
+ }
+
+ // Draw children
+ LLView::draw();
} // end draw
@@ -582,42 +556,39 @@ void LLScrollbar::setValue(const LLSD& value)
}
-BOOL LLScrollbar::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
+BOOL LLScrollbar::handleKeyHere(KEY key, MASK mask)
{
BOOL handled = FALSE;
- if( getVisible() && getEnabled() && !called_from_parent )
+ switch( key )
{
- switch( key )
- {
- case KEY_HOME:
- changeLine( -mDocPos, TRUE );
- handled = TRUE;
- break;
-
- case KEY_END:
- changeLine( getDocPosMax() - mDocPos, TRUE );
- handled = TRUE;
- break;
-
- case KEY_DOWN:
- changeLine( mStepSize, TRUE );
- handled = TRUE;
- break;
-
- case KEY_UP:
- changeLine( - mStepSize, TRUE );
- handled = TRUE;
- break;
-
- case KEY_PAGE_DOWN:
- pageDown(1);
- break;
-
- case KEY_PAGE_UP:
- pageUp(1);
- break;
- }
+ case KEY_HOME:
+ changeLine( -mDocPos, TRUE );
+ handled = TRUE;
+ break;
+
+ case KEY_END:
+ changeLine( getDocPosMax() - mDocPos, TRUE );
+ handled = TRUE;
+ break;
+
+ case KEY_DOWN:
+ changeLine( mStepSize, TRUE );
+ handled = TRUE;
+ break;
+
+ case KEY_UP:
+ changeLine( - mStepSize, TRUE );
+ handled = TRUE;
+ break;
+
+ case KEY_PAGE_DOWN:
+ pageDown(1);
+ break;
+
+ case KEY_PAGE_UP:
+ pageUp(1);
+ break;
}
return handled;
diff --git a/indra/llui/llscrollbar.h b/indra/llui/llscrollbar.h
index ac0bd37e3a..4d3b711b1a 100644
--- a/indra/llui/llscrollbar.h
+++ b/indra/llui/llscrollbar.h
@@ -62,11 +62,8 @@ public:
virtual void setValue(const LLSD& value);
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_SCROLLBAR; }
- virtual LLString getWidgetTag() const { return LL_SCROLLBAR_TAG; }
-
// Overrides from LLView
- virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
+ virtual BOOL handleKeyHere(KEY key, MASK mask);
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
virtual BOOL handleHover(S32 x, S32 y, MASK mask);
diff --git a/indra/llui/llscrollcontainer.cpp b/indra/llui/llscrollcontainer.cpp
index 991ba0ed04..d8df636abd 100644
--- a/indra/llui/llscrollcontainer.cpp
+++ b/indra/llui/llscrollcontainer.cpp
@@ -61,6 +61,8 @@ static const F32 AUTO_SCROLL_RATE_ACCEL = 120.f;
/// Class LLScrollableContainerView
///----------------------------------------------------------------------------
+static LLRegisterWidget<LLScrollableContainerView> r("scroll_container");
+
// Default constructor
LLScrollableContainerView::LLScrollableContainerView( const LLString& name,
const LLRect& rect,
@@ -210,63 +212,33 @@ void LLScrollableContainerView::reshape(S32 width, S32 height,
}
}
-BOOL LLScrollableContainerView::handleKey( KEY key, MASK mask, BOOL called_from_parent )
+BOOL LLScrollableContainerView::handleKeyHere(KEY key, MASK mask)
{
- if( getVisible() && getEnabled() )
+ for( S32 i = 0; i < SCROLLBAR_COUNT; i++ )
{
- if( called_from_parent )
- {
- // Downward traversal
-
- // Don't pass keys to scrollbars on downward.
-
- // Handle 'child' view.
- if( mScrolledView && mScrolledView->handleKey(key, mask, TRUE) )
- {
- return TRUE;
- }
- }
- else
+ if( mScrollbar[i]->handleKeyHere(key, mask) )
{
- // Upward traversal
-
- for( S32 i = 0; i < SCROLLBAR_COUNT; i++ )
- {
- // Note: the scrollbar _is_ actually being called from it's parent. Here
- // we're delgating LLScrollableContainerView's upward traversal to the scrollbars
- if( mScrollbar[i]->handleKey(key, mask, TRUE) )
- {
- return TRUE;
- }
- }
-
- if (getParent())
- {
- return getParent()->handleKey( key, mask, FALSE );
- }
+ return TRUE;
}
- }
+ }
return FALSE;
}
BOOL LLScrollableContainerView::handleScrollWheel( S32 x, S32 y, S32 clicks )
{
- if( getEnabled() )
+ for( S32 i = 0; i < SCROLLBAR_COUNT; i++ )
{
- for( S32 i = 0; i < SCROLLBAR_COUNT; i++ )
- {
- // Note: tries vertical and then horizontal
+ // Note: tries vertical and then horizontal
- // Pretend the mouse is over the scrollbar
- if( mScrollbar[i]->handleScrollWheel( 0, 0, clicks ) )
- {
- return TRUE;
- }
+ // Pretend the mouse is over the scrollbar
+ if( mScrollbar[i]->handleScrollWheel( 0, 0, clicks ) )
+ {
+ return TRUE;
}
}
- // Opaque
+ // Eat scroll wheel event (to avoid scrolling nested containers?)
return TRUE;
}
@@ -446,80 +418,78 @@ void LLScrollableContainerView::draw()
// clear this flag to be set on next call to handleDragAndDrop
mAutoScrolling = FALSE;
- if( getVisible() )
+ // auto-focus when scrollbar active
+ // this allows us to capture user intent (i.e. stop automatically scrolling the view/etc)
+ if (!gFocusMgr.childHasKeyboardFocus(this) &&
+ (mScrollbar[VERTICAL]->hasMouseCapture() || mScrollbar[HORIZONTAL]->hasMouseCapture()))
{
- // auto-focus when scrollbar active
- // this allows us to capture user intent (i.e. stop automatically scrolling the view/etc)
- if (!gFocusMgr.childHasKeyboardFocus(this) &&
- (mScrollbar[VERTICAL]->hasMouseCapture() || mScrollbar[HORIZONTAL]->hasMouseCapture()))
- {
- focusFirstItem();
- }
+ focusFirstItem();
+ }
- // Draw background
- if( mIsOpaque )
+ // Draw background
+ if( mIsOpaque )
+ {
+ LLGLSNoTexture no_texture;
+ glColor4fv( mBackgroundColor.mV );
+ gl_rect_2d( mInnerRect );
+ }
+
+ // Draw mScrolledViews and update scroll bars.
+ // get a scissor region ready, and draw the scrolling view. The
+ // scissor region ensures that we don't draw outside of the bounds
+ // of the rectangle.
+ if( mScrolledView )
+ {
+ updateScroll();
+
+ // Draw the scrolled area.
{
- LLGLSNoTexture no_texture;
- gGL.color4fv( mBackgroundColor.mV );
- gl_rect_2d( mInnerRect );
+ S32 visible_width = 0;
+ S32 visible_height = 0;
+ BOOL show_v_scrollbar = FALSE;
+ BOOL show_h_scrollbar = FALSE;
+ calcVisibleSize( mScrolledView->getRect(), &visible_width, &visible_height, &show_h_scrollbar, &show_v_scrollbar );
+
+ LLLocalClipRect clip(LLRect(mInnerRect.mLeft,
+ mInnerRect.mBottom + (show_h_scrollbar ? SCROLLBAR_SIZE : 0) + visible_height,
+ visible_width,
+ mInnerRect.mBottom + (show_h_scrollbar ? SCROLLBAR_SIZE : 0)
+ ));
+ drawChild(mScrolledView);
}
-
- // Draw mScrolledViews and update scroll bars.
- // get a scissor region ready, and draw the scrolling view. The
- // scissor region ensures that we don't draw outside of the bounds
- // of the rectangle.
- if( mScrolledView )
- {
- updateScroll();
+ }
- // Draw the scrolled area.
- {
- S32 visible_width = 0;
- S32 visible_height = 0;
- BOOL show_v_scrollbar = FALSE;
- BOOL show_h_scrollbar = FALSE;
- calcVisibleSize( mScrolledView->getRect(), &visible_width, &visible_height, &show_h_scrollbar, &show_v_scrollbar );
-
- LLLocalClipRect clip(LLRect(mInnerRect.mLeft,
- mInnerRect.mBottom + (show_h_scrollbar ? SCROLLBAR_SIZE : 0) + visible_height,
- visible_width,
- mInnerRect.mBottom + (show_h_scrollbar ? SCROLLBAR_SIZE : 0)
- ));
- drawChild(mScrolledView);
- }
- }
+ // Highlight border if a child of this container has keyboard focus
+ if( mBorder->getVisible() )
+ {
+ mBorder->setKeyboardFocusHighlight( gFocusMgr.childHasKeyboardFocus(this) );
+ }
- // Highlight border if a child of this container has keyboard focus
- if( mBorder->getVisible() )
+ // Draw all children except mScrolledView
+ // Note: scrollbars have been adjusted by above drawing code
+ for (child_list_const_reverse_iter_t child_iter = getChildList()->rbegin();
+ child_iter != getChildList()->rend(); ++child_iter)
+ {
+ LLView *viewp = *child_iter;
+ if( sDebugRects )
{
- mBorder->setKeyboardFocusHighlight( gFocusMgr.childHasKeyboardFocus(this) );
+ sDepth++;
}
-
- // Draw all children except mScrolledView
- // Note: scrollbars have been adjusted by above drawing code
- for (child_list_const_reverse_iter_t child_iter = getChildList()->rbegin();
- child_iter != getChildList()->rend(); ++child_iter)
+ if( (viewp != mScrolledView) && viewp->getVisible() )
{
- LLView *viewp = *child_iter;
- if( sDebugRects )
- {
- sDepth++;
- }
- if( (viewp != mScrolledView) && viewp->getVisible() )
- {
- drawChild(viewp);
- }
- if( sDebugRects )
- {
- sDepth--;
- }
+ drawChild(viewp);
}
-
- if (sDebugRects)
+ if( sDebugRects )
{
- drawDebugRect();
+ sDepth--;
}
}
+
+ if (sDebugRects)
+ {
+ drawDebugRect();
+ }
+
} // end draw
void LLScrollableContainerView::updateScroll()
diff --git a/indra/llui/llscrollcontainer.h b/indra/llui/llscrollcontainer.h
index 0bffd0438f..db6d7d6198 100644
--- a/indra/llui/llscrollcontainer.h
+++ b/indra/llui/llscrollcontainer.h
@@ -70,8 +70,6 @@ public:
void setScrolledView(LLView* view) { mScrolledView = view; }
virtual void setValue(const LLSD& value) { mInnerRect.setValue(value); }
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_SCROLL_CONTAINER; }
- virtual LLString getWidgetTag() const { return LL_SCROLLABLE_CONTAINER_VIEW_TAG; }
void calcVisibleSize( S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ) const;
void calcVisibleSize( const LLRect& doc_rect, S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ) const;
@@ -90,7 +88,7 @@ public:
// LLView functionality
virtual void reshape(S32 width, S32 height, BOOL called_from_parent);
- virtual BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent);
+ virtual BOOL handleKeyHere(KEY key, MASK mask);
virtual BOOL handleScrollWheel( S32 x, S32 y, S32 clicks );
virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
EDragAndDropType cargo_type,
diff --git a/indra/llui/llscrollingpanellist.cpp b/indra/llui/llscrollingpanellist.cpp
index 70309ba6bc..28755ed30f 100644
--- a/indra/llui/llscrollingpanellist.cpp
+++ b/indra/llui/llscrollingpanellist.cpp
@@ -34,6 +34,9 @@
#include "llscrollingpanellist.h"
+static LLRegisterWidget<LLScrollingPanelList> r("scrolling_panel_list");
+
+
/////////////////////////////////////////////////////////////////////
// LLScrollingPanelList
@@ -129,10 +132,8 @@ void LLScrollingPanelList::updatePanelVisiblilty()
void LLScrollingPanelList::draw()
{
- if( getVisible() )
- {
- updatePanelVisiblilty();
- }
+ updatePanelVisiblilty();
+
LLUICtrl::draw();
}
diff --git a/indra/llui/llscrollingpanellist.h b/indra/llui/llscrollingpanellist.h
index cb832f4bec..dc0dcbd460 100644
--- a/indra/llui/llscrollingpanellist.h
+++ b/indra/llui/llscrollingpanellist.h
@@ -56,8 +56,6 @@ public:
: LLUICtrl(name, rect, TRUE, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_BOTTOM ) {}
virtual void setValue(const LLSD& value) {};
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_SCROLLING_PANEL_LIST; }
- virtual LLString getWidgetTag() const { return LL_SCROLLING_PANEL_LIST_TAG; }
virtual LLXMLNodePtr getXML(bool save_children) const { return LLUICtrl::getXML(); }
diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp
index 35e8f7300b..a4ea08bd5d 100644
--- a/indra/llui/llscrolllistctrl.cpp
+++ b/indra/llui/llscrolllistctrl.cpp
@@ -55,10 +55,11 @@
#include "llkeyboard.h"
#include "llresizebar.h"
-const S32 LIST_BORDER_PAD = 0; // white space inside the border and to the left of the scrollbar
const S32 MIN_COLUMN_WIDTH = 20;
const S32 LIST_SNAP_PADDING = 5;
+static LLRegisterWidget<LLScrollListCtrl> r("scroll_list");
+
// local structures & classes.
struct SortScrollListItem
{
@@ -114,24 +115,49 @@ struct SortScrollListItem
//
// LLScrollListIcon
//
-LLScrollListIcon::LLScrollListIcon(const LLUUID& icon_id, S32 width)
+LLScrollListIcon::LLScrollListIcon(LLUIImagePtr icon, S32 width)
+ : LLScrollListCell(width),
+ mIcon(icon),
+ mColor(LLColor4::white)
+{
+}
+
+LLScrollListIcon::LLScrollListIcon(const LLSD& value, S32 width)
: LLScrollListCell(width),
- mColor(LLColor4::white),
- mImageUUID(icon_id)
+ mColor(LLColor4::white)
{
- // don't use default image specified by LLUUID::null, use no image in that case
- mIcon = icon_id.isNull() ? NULL : LLUI::sImageProvider->getImageByID(icon_id);
+ setValue(value);
}
+
LLScrollListIcon::~LLScrollListIcon()
{
}
void LLScrollListIcon::setValue(const LLSD& value)
{
- mImageUUID = value.asUUID();
- // don't use default image specified by LLUUID::null, use no image in that case
- mIcon = mImageUUID.isNull() ? NULL : LLUI::sImageProvider->getImageByID(mImageUUID);
+ if (value.isUUID())
+ {
+ // don't use default image specified by LLUUID::null, use no image in that case
+ LLUUID image_id = value.asUUID();
+ mIcon = image_id.notNull() ? LLUI::sImageProvider->getUIImageByID(image_id) : LLUIImagePtr(NULL);
+ }
+ else
+ {
+ LLString value_string = value.asString();
+ if (LLUUID::validate(value_string))
+ {
+ setValue(LLUUID(value_string));
+ }
+ else if (!value_string.empty())
+ {
+ mIcon = LLUI::getUIImage(value.asString());
+ }
+ else
+ {
+ mIcon = NULL;
+ }
+ }
}
@@ -143,7 +169,7 @@ void LLScrollListIcon::setColor(const LLColor4& color)
S32 LLScrollListIcon::getWidth() const
{
// if no specified fix width, use width of icon
- if (LLScrollListCell::getWidth() == 0)
+ if (LLScrollListCell::getWidth() == 0 && mIcon.notNull())
{
return mIcon->getWidth();
}
@@ -151,11 +177,11 @@ S32 LLScrollListIcon::getWidth() const
}
-void LLScrollListIcon::draw(const LLColor4& color, const LLColor4& highlight_color) const
+void LLScrollListIcon::draw(const LLColor4& color, const LLColor4& highlight_color) const
{
if (mIcon)
{
- gl_draw_image(0, 0, mIcon, mColor);
+ mIcon->draw(0, 0, mColor);
}
}
@@ -206,6 +232,13 @@ LLScrollListSeparator::LLScrollListSeparator(S32 width) : LLScrollListCell(width
{
}
+//virtual
+S32 LLScrollListSeparator::getHeight() const
+{
+ return 5;
+}
+
+
void LLScrollListSeparator::draw(const LLColor4& color, const LLColor4& highlight_color) const
{
//*FIXME: use dynamic item heights and make separators narrow, and inactive
@@ -234,9 +267,34 @@ LLScrollListText::LLScrollListText( const LLString& text, const LLFontGL* font,
// initialize rounded rect image
if (!mRoundedRectImage)
{
- mRoundedRectImage = LLUI::sImageProvider->getImageByID(LLUUID(LLUI::sAssetsGroup->getString("rounded_square.tga")));
+ mRoundedRectImage = LLUI::sImageProvider->getUIImage("rounded_square.tga");
}
}
+//virtual
+void LLScrollListText::highlightText(S32 offset, S32 num_chars)
+{
+ mHighlightOffset = offset;
+ mHighlightCount = num_chars;
+}
+
+//virtual
+BOOL LLScrollListText::isText() const
+{
+ return TRUE;
+}
+
+//virtual
+BOOL LLScrollListText::getVisible() const
+{
+ return mVisible;
+}
+
+//virtual
+S32 LLScrollListText::getHeight() const
+{
+ return llround(mFont->getLineHeight());
+}
+
LLScrollListText::~LLScrollListText()
{
@@ -266,6 +324,13 @@ void LLScrollListText::setValue(const LLSD& text)
setText(text.asString());
}
+//virtual
+const LLSD LLScrollListText::getValue() const
+{
+ return LLSD(mText.getString());
+}
+
+
void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_color) const
{
LLColor4 display_color;
@@ -280,8 +345,6 @@ void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_col
if (mHighlightCount > 0)
{
- mRoundedRectImage->bind();
- gGL.color4fv(highlight_color.mV);
S32 left = 0;
switch(mFontAlignment)
{
@@ -295,13 +358,11 @@ void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_col
left = (getWidth() - mFont->getWidth(mText.getString())) / 2;
break;
}
- gl_segmented_rect_2d_tex(left - 2,
+ LLRect highlight_rect(left - 2,
llround(mFont->getLineHeight()) + 1,
left + mFont->getWidth(mText.getString(), mHighlightOffset, mHighlightCount) + 1,
- 1,
- mRoundedRectImage->getWidth(),
- mRoundedRectImage->getHeight(),
- 16);
+ 1);
+ mRoundedRectImage->draw(highlight_rect, highlight_color);
}
// Try to draw the entire string
@@ -389,8 +450,6 @@ void LLScrollListItem::draw(const LLRect& rect, const LLColor4& fg_color, const
{
// draw background rect
LLRect bg_rect = rect;
- // pad background rectangle to separate it from contents
- bg_rect.stretch(LIST_BORDER_PAD, 0);
{
LLGLSNoTexture no_texture;
gGL.color4fv(bg_color.mV);
@@ -432,7 +491,7 @@ LLScrollListItemComment::LLScrollListItemComment(const LLString& comment_string,
: LLScrollListItem(FALSE),
mColor(color)
{
- addColumn( comment_string, gResMgr->getRes( LLFONT_SANSSERIF_SMALL ) );
+ addColumn( comment_string, LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL ) );
}
void LLScrollListItemComment::draw(const LLRect& rect, const LLColor4& fg_color, const LLColor4& bg_color, const LLColor4& highlight_color, S32 column_padding)
@@ -541,10 +600,10 @@ LLScrollListCtrl::LLScrollListCtrl(const LLString& name, const LLRect& rect,
mDrewSelected(FALSE)
{
mItemListRect.setOriginAndSize(
- mBorderThickness + LIST_BORDER_PAD,
- mBorderThickness + LIST_BORDER_PAD,
- getRect().getWidth() - 2*( mBorderThickness + LIST_BORDER_PAD ),
- getRect().getHeight() - 2*( mBorderThickness + LIST_BORDER_PAD ) );
+ mBorderThickness,
+ mBorderThickness,
+ getRect().getWidth() - 2 * mBorderThickness,
+ getRect().getHeight() - 2 * mBorderThickness );
updateLineHeight();
@@ -738,10 +797,10 @@ void LLScrollListCtrl::updateLayout()
// reserve room for column headers, if needed
S32 heading_size = (mDisplayColumnHeaders ? mHeadingHeight : 0);
mItemListRect.setOriginAndSize(
- mBorderThickness + LIST_BORDER_PAD,
- mBorderThickness + LIST_BORDER_PAD,
- getRect().getWidth() - 2*( mBorderThickness + LIST_BORDER_PAD ),
- getRect().getHeight() - 2*( mBorderThickness + LIST_BORDER_PAD ) - heading_size );
+ mBorderThickness,
+ mBorderThickness,
+ getRect().getWidth() - 2 * mBorderThickness,
+ getRect().getHeight() - (2 * mBorderThickness ) - heading_size );
// how many lines of content in a single "page"
mPageLines = mLineHeight? mItemListRect.getHeight() / mLineHeight : 0;
@@ -749,7 +808,7 @@ void LLScrollListCtrl::updateLayout()
if (scrollbar_visible)
{
// provide space on the right for scrollbar
- mItemListRect.mRight = getRect().getWidth() - ( mBorderThickness + LIST_BORDER_PAD ) - SCROLLBAR_SIZE;
+ mItemListRect.mRight = getRect().getWidth() - mBorderThickness - SCROLLBAR_SIZE;
}
mScrollbar->reshape(SCROLLBAR_SIZE, mItemListRect.getHeight() + (mDisplayColumnHeaders ? mHeadingHeight : 0));
@@ -775,7 +834,7 @@ LLRect LLScrollListCtrl::getRequiredRect()
{
S32 heading_size = (mDisplayColumnHeaders ? mHeadingHeight : 0);
S32 height = (mLineHeight * getItemCount())
- + (2 * ( mBorderThickness + LIST_BORDER_PAD ))
+ + (2 * mBorderThickness )
+ heading_size;
S32 width = getRect().getWidth();
@@ -1354,7 +1413,6 @@ LLScrollListItem* LLScrollListCtrl::addCommentText(const LLString& comment_text,
LLScrollListItem* item = NULL;
if (getItemCount() < mMaxItemCount)
{
- // simple items have their LLSD data set to their label
// always draw comment text with "enabled" color
item = new LLScrollListItemComment( comment_text, mFgUnselectedColor );
addItem( item, pos, FALSE );
@@ -1522,7 +1580,7 @@ LLScrollListItem* LLScrollListCtrl::addStringUUIDItem(const LLString& item_text,
if (getItemCount() < mMaxItemCount)
{
item = new LLScrollListItem( enabled, NULL, id );
- item->addColumn(item_text, gResMgr->getRes(LLFONT_SANSSERIF_SMALL), column_width);
+ item->addColumn(item_text, LLResMgr::getInstance()->getRes(LLFONT_SANSSERIF_SMALL), column_width);
addItem( item, pos );
}
return item;
@@ -1661,7 +1719,6 @@ void LLScrollListCtrl::drawItems()
fg_color = (item->getEnabled() ? mFgUnselectedColor : mFgDisabledColor);
if( item->getSelected() && mCanSelect)
{
- // Draw background of selected item
bg_color = mBgSelectedColor;
fg_color = (item->getEnabled() ? mFgSelectedColor : mFgDisabledColor);
}
@@ -1694,43 +1751,40 @@ void LLScrollListCtrl::drawItems()
void LLScrollListCtrl::draw()
{
- if( getVisible() )
+ // if user specifies sort, make sure it is maintained
+ if (needsSorting() && !isSorted())
{
- // if user specifies sort, make sure it is maintained
- if (needsSorting() && !isSorted())
- {
- sortItems();
- }
-
- if (mNeedsScroll)
- {
- scrollToShowSelected();
- mNeedsScroll = FALSE;
- }
- LLRect background(0, getRect().getHeight(), getRect().getWidth(), 0);
- // Draw background
- if (mBackgroundVisible)
- {
- LLGLSNoTexture no_texture;
- gGL.color4fv( getEnabled() ? mBgWriteableColor.mV : mBgReadOnlyColor.mV );
- gl_rect_2d(background);
- }
+ sortItems();
+ }
- if (mColumnsDirty)
- {
- updateColumns();
- mColumnsDirty = FALSE;
- }
+ if (mNeedsScroll)
+ {
+ scrollToShowSelected();
+ mNeedsScroll = FALSE;
+ }
+ LLRect background(0, getRect().getHeight(), getRect().getWidth(), 0);
+ // Draw background
+ if (mBackgroundVisible)
+ {
+ LLGLSNoTexture no_texture;
+ glColor4fv( getEnabled() ? mBgWriteableColor.mV : mBgReadOnlyColor.mV );
+ gl_rect_2d(background);
+ }
- drawItems();
+ if (mColumnsDirty)
+ {
+ updateColumns();
+ mColumnsDirty = FALSE;
+ }
- if (mBorder)
- {
- mBorder->setKeyboardFocusHighlight(gFocusMgr.getKeyboardFocus() == this);
- }
+ drawItems();
- LLUICtrl::draw();
+ if (mBorder)
+ {
+ mBorder->setKeyboardFocusHighlight(gFocusMgr.getKeyboardFocus() == this);
}
+
+ LLUICtrl::draw();
}
void LLScrollListCtrl::setEnabled(BOOL enabled)
@@ -1947,23 +2001,21 @@ BOOL LLScrollListCtrl::handleMouseUp(S32 x, S32 y, MASK mask)
BOOL LLScrollListCtrl::handleDoubleClick(S32 x, S32 y, MASK mask)
{
//BOOL handled = FALSE;
- if(getVisible())
- {
- BOOL handled = handleClick(x, y, mask);
+ BOOL handled = handleClick(x, y, mask);
- if (!handled)
+ if (!handled)
+ {
+ // Offer the click to the children, even if we aren't enabled
+ // so the scroll bars will work.
+ if (NULL == LLView::childrenHandleDoubleClick(x, y, mask))
{
- // Offer the click to the children, even if we aren't enabled
- // so the scroll bars will work.
- if (NULL == LLView::childrenHandleDoubleClick(x, y, mask))
+ if( mCanSelect && mOnDoubleClickCallback )
{
- if( mCanSelect && mOnDoubleClickCallback )
- {
- mOnDoubleClickCallback( mCallbackUserData );
- }
+ mOnDoubleClickCallback( mCallbackUserData );
}
}
}
+
return TRUE;
}
@@ -2143,12 +2195,12 @@ BOOL LLScrollListCtrl::handleHover(S32 x,S32 y,MASK mask)
}
-BOOL LLScrollListCtrl::handleKeyHere(KEY key,MASK mask, BOOL called_from_parent )
+BOOL LLScrollListCtrl::handleKeyHere(KEY key,MASK mask )
{
BOOL handled = FALSE;
// not called from parent means we have keyboard focus or a child does
- if (mCanSelect && !called_from_parent)
+ if (mCanSelect)
{
// Ignore capslock
mask = mask;
@@ -2231,7 +2283,7 @@ BOOL LLScrollListCtrl::handleKeyHere(KEY key,MASK mask, BOOL called_from_parent
// JC - Special case: Only claim to have handled it
// if we're the special non-commit-on-move
// type. AND we are visible
- if (!mCommitOnKeyboardMovement && mask == MASK_NONE && getVisible())
+ if (!mCommitOnKeyboardMovement && mask == MASK_NONE)
{
onCommit();
mSearchString.clear();
@@ -2278,7 +2330,7 @@ BOOL LLScrollListCtrl::handleKeyHere(KEY key,MASK mask, BOOL called_from_parent
return handled;
}
-BOOL LLScrollListCtrl::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent)
+BOOL LLScrollListCtrl::handleUnicodeCharHere(llwchar uni_char)
{
if ((uni_char < 0x20) || (uni_char == 0x7F)) // Control character or DEL
{
@@ -3204,17 +3256,16 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& value, EAddPosition p
LLColor4 color = ((*itor)["color"]);
BOOL enabled = !(*itor).has("enabled") || (*itor)["enabled"].asBoolean() == true;
- const LLFontGL *font = gResMgr->getRes(fontname);
+ const LLFontGL *font = LLResMgr::getInstance()->getRes(fontname);
if (!font)
{
- font = gResMgr->getRes( LLFONT_SANSSERIF_SMALL );
+ font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL );
}
U8 font_style = LLFontGL::getStyleFromString(fontstyle);
if (type == "icon")
{
- LLUUID image_id = value.asUUID();
- LLScrollListIcon* cell = new LLScrollListIcon(value.asUUID(), width);
+ LLScrollListIcon* cell = new LLScrollListIcon(value, width);
if (has_color)
{
cell->setColor(color);
@@ -3267,7 +3318,7 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& value, EAddPosition p
if (new_item->getColumn(column_idx) == NULL)
{
LLScrollListColumn* column_ptr = &column_it->second;
- new_item->setColumn(column_idx, new LLScrollListText("", gResMgr->getRes( LLFONT_SANSSERIF_SMALL ), column_ptr->mWidth, LLFontGL::NORMAL));
+ new_item->setColumn(column_idx, new LLScrollListText("", LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL ), column_ptr->mWidth, LLFontGL::NORMAL));
}
}
@@ -3287,7 +3338,7 @@ LLScrollListItem* LLScrollListCtrl::addSimpleElement(const LLString& value, EAdd
LLScrollListItem *new_item = new LLScrollListItem(entry_id);
- const LLFontGL *font = gResMgr->getRes( LLFONT_SANSSERIF_SMALL );
+ const LLFontGL *font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL );
new_item->addColumn(value, font, getRect().getWidth());
@@ -3435,29 +3486,25 @@ LLColumnHeader::~LLColumnHeader()
void LLColumnHeader::draw()
{
- if( getVisible() )
- {
- BOOL draw_arrow = !mColumn->mLabel.empty() && mColumn->mParentCtrl->isSorted() && mColumn->mParentCtrl->getSortColumnName() == mColumn->mSortingColumn;
+ BOOL draw_arrow = !mColumn->mLabel.empty() && mColumn->mParentCtrl->isSorted() && mColumn->mParentCtrl->getSortColumnName() == mColumn->mSortingColumn;
- BOOL is_ascending = mColumn->mParentCtrl->getSortAscending();
- mButton->setImageOverlay(is_ascending ? "up_arrow.tga" : "down_arrow.tga", LLFontGL::RIGHT, draw_arrow ? LLColor4::white : LLColor4::transparent);
- mArrowImage = mButton->getImageOverlay()->getImage();
+ BOOL is_ascending = mColumn->mParentCtrl->getSortAscending();
+ mButton->setImageOverlay(is_ascending ? "up_arrow.tga" : "down_arrow.tga", LLFontGL::RIGHT, draw_arrow ? LLColor4::white : LLColor4::transparent);
+ mArrowImage = mButton->getImageOverlay();
- //BOOL clip = getRect().mRight > mColumn->mParentCtrl->getItemListRect().getWidth();
- //LLGLEnable scissor_test(clip ? GL_SCISSOR_TEST : GL_FALSE);
+ //BOOL clip = getRect().mRight > mColumn->mParentCtrl->getItemListRect().getWidth();
+ //LLGLEnable scissor_test(clip ? GL_SCISSOR_TEST : GL_FALSE);
- //LLRect column_header_local_rect(-getRect().mLeft, getRect().getHeight(), mColumn->mParentCtrl->getItemListRect().getWidth() - getRect().mLeft, 0);
- //LLUI::setScissorRegionLocal(column_header_local_rect);
+ //LLRect column_header_local_rect(-getRect().mLeft, getRect().getHeight(), mColumn->mParentCtrl->getItemListRect().getWidth() - getRect().mLeft, 0);
+ //LLUI::setScissorRegionLocal(column_header_local_rect);
- // Draw children
- LLComboBox::draw();
-
- if (mList->getVisible())
- {
- // sync sort order with list selection every frame
- mColumn->mParentCtrl->sortByColumn(mColumn->mSortingColumn, getCurrentIndex() == 0);
- }
+ // Draw children
+ LLComboBox::draw();
+ if (mList->getVisible())
+ {
+ // sync sort order with list selection every frame
+ mColumn->mParentCtrl->sortByColumn(mColumn->mSortingColumn, getCurrentIndex() == 0);
}
}
diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h
index 6edb2939dd..47683d0ab4 100644
--- a/indra/llui/llscrolllistctrl.h
+++ b/indra/llui/llscrolllistctrl.h
@@ -90,7 +90,7 @@ public:
LLScrollListSeparator(S32 width);
virtual ~LLScrollListSeparator() {};
virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const; // truncate to given width, if possible
- virtual S32 getHeight() const { return 5; };
+ virtual S32 getHeight() const;
virtual BOOL isText() const { return FALSE; }
};
@@ -105,14 +105,14 @@ public:
virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const;
virtual S32 getContentWidth() const;
- virtual S32 getHeight() const { return llround(mFont->getLineHeight()); }
+ virtual S32 getHeight() const;
virtual void setValue(const LLSD& value);
- virtual const LLSD getValue() const { return LLSD(mText.getString()); }
- virtual BOOL getVisible() const { return mVisible; }
- virtual void highlightText(S32 offset, S32 num_chars) {mHighlightOffset = offset; mHighlightCount = num_chars;}
+ virtual const LLSD getValue() const;
+ virtual BOOL getVisible() const;
+ virtual void highlightText(S32 offset, S32 num_chars);
virtual void setColor(const LLColor4&);
- virtual BOOL isText() const { return TRUE; }
+ virtual BOOL isText() const;
void setText(const LLStringExplicit& text);
void setFontStyle(const U8 font_style) { mFontStyle = font_style; }
@@ -128,7 +128,7 @@ private:
S32 mHighlightCount;
S32 mHighlightOffset;
- LLPointer<LLImageGL> mRoundedRectImage;
+ LLPointer<LLUIImage> mRoundedRectImage;
static U32 sCount;
};
@@ -139,20 +139,19 @@ private:
class LLScrollListIcon : public LLScrollListCell
{
public:
- LLScrollListIcon( const LLUUID& icon_id, S32 width = 0);
+ LLScrollListIcon( LLUIImagePtr icon, S32 width = 0);
+ LLScrollListIcon(const LLSD& value, S32 width = 0);
/*virtual*/ ~LLScrollListIcon();
virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const;
virtual S32 getWidth() const;
virtual S32 getHeight() const { return mIcon ? mIcon->getHeight() : 0; }
- // used as sort criterion
- virtual const LLSD getValue() const { return LLSD(mImageUUID); }
+ virtual const LLSD getValue() const { return mIcon.isNull() ? LLString::null : mIcon->getName(); }
virtual void setColor(const LLColor4&);
virtual BOOL isText()const { return FALSE; }
virtual void setValue(const LLSD& value);
private:
- LLPointer<LLImageGL> mIcon;
- LLUUID mImageUUID;
+ LLUIImagePtr mIcon;
LLColor4 mColor;
};
@@ -342,8 +341,8 @@ public:
void addColumn( const LLString& text, const LLFontGL* font, S32 width = 0 , U8 font_style = LLFontGL::NORMAL, LLFontGL::HAlign font_alignment = LLFontGL::LEFT, BOOL visible = TRUE)
{ mColumns.push_back( new LLScrollListText(text, font, width, font_style, font_alignment, LLColor4::black, FALSE, visible) ); }
- void addColumn( const LLUUID& icon_id, S32 width = 0 )
- { mColumns.push_back( new LLScrollListIcon(icon_id, width) ); }
+ void addColumn( LLUIImagePtr icon, S32 width = 0 )
+ { mColumns.push_back( new LLScrollListIcon(icon, width) ); }
void addColumn( LLCheckBoxCtrl* check, S32 width = 0 )
{ mColumns.push_back( new LLScrollListCheck(check,width) ); }
@@ -404,8 +403,7 @@ public:
BOOL draw_border = TRUE);
virtual ~LLScrollListCtrl();
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_SCROLL_LIST; }
- virtual LLString getWidgetTag() const { return LL_SCROLL_LIST_CTRL_TAG; }
+
virtual LLXMLNodePtr getXML(bool save_children = true) const;
void setScrollListParameters(LLXMLNodePtr node);
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
@@ -562,8 +560,8 @@ public:
/*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
/*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
/*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
- /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
- /*virtual*/ BOOL handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent);
+ /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask);
+ /*virtual*/ BOOL handleUnicodeCharHere(llwchar uni_char);
/*virtual*/ BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
/*virtual*/ BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect);
/*virtual*/ void setEnabled(BOOL enabled);
@@ -618,6 +616,7 @@ public:
S32 selectMultiple( LLDynamicArray<LLUUID> ids );
void sortItems();
+
// manually call this whenever editing list items in place to flag need for resorting
void setSorted(BOOL sorted) { mSorted = sorted; }
void dirtyColumns(); // some operation has potentially affected column layout or ordering
diff --git a/indra/llui/llslider.cpp b/indra/llui/llslider.cpp
index 8b5bb1f3f6..d53e957c9c 100644
--- a/indra/llui/llslider.cpp
+++ b/indra/llui/llslider.cpp
@@ -41,6 +41,10 @@
#include "llcontrol.h"
#include "llimagegl.h"
+static LLRegisterWidget<LLSlider> r1("slider_bar");
+static LLRegisterWidget<LLSlider> r2("volume_slider");
+
+
LLSlider::LLSlider(
const LLString& name,
const LLRect& rect,
@@ -68,9 +72,9 @@ LLSlider::LLSlider(
mMouseDownCallback( NULL ),
mMouseUpCallback( NULL )
{
- mThumbImage = LLUI::sImageProvider->getImageByID(LLUUID(LLUI::sAssetsGroup->getString("icn_slide-thumb_dark.tga")));
- mTrackImage = LLUI::sImageProvider->getImageByID(LLUUID(LLUI::sAssetsGroup->getString("icn_slide-groove_dark.tga")));
- mTrackHighlightImage = LLUI::sImageProvider->getImageByID(LLUUID(LLUI::sAssetsGroup->getString("icn_slide-highlight.tga")));
+ mThumbImage = LLUI::sImageProvider->getUIImage("icn_slide-thumb_dark.tga");
+ mTrackImage = LLUI::sImageProvider->getUIImage("icn_slide-groove_dark.tga");
+ mTrackHighlightImage = LLUI::sImageProvider->getUIImage("icn_slide-highlight.tga");
// properly handle setting the starting thumb rect
// do it this way to handle both the operating-on-settings
@@ -217,98 +221,68 @@ BOOL LLSlider::handleMouseDown(S32 x, S32 y, MASK mask)
return TRUE;
}
-BOOL LLSlider::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
+BOOL LLSlider::handleKeyHere(KEY key, MASK mask)
{
BOOL handled = FALSE;
- if( getVisible() && getEnabled() && !called_from_parent )
+ switch(key)
{
- switch(key)
- {
- case KEY_UP:
- case KEY_DOWN:
- // eat up and down keys to be consistent
- handled = TRUE;
- break;
- case KEY_LEFT:
- setValueAndCommit(getValueF32() - getIncrement());
- handled = TRUE;
- break;
- case KEY_RIGHT:
- setValueAndCommit(getValueF32() + getIncrement());
- handled = TRUE;
- break;
- default:
- break;
- }
+ case KEY_UP:
+ case KEY_DOWN:
+ // eat up and down keys to be consistent
+ handled = TRUE;
+ break;
+ case KEY_LEFT:
+ setValueAndCommit(getValueF32() - getIncrement());
+ handled = TRUE;
+ break;
+ case KEY_RIGHT:
+ setValueAndCommit(getValueF32() + getIncrement());
+ handled = TRUE;
+ break;
+ default:
+ break;
}
return handled;
}
void LLSlider::draw()
{
- if( getVisible() )
- {
- // since thumb image might still be decoding, need thumb to accomodate image size
- updateThumbRect();
-
- // Draw background and thumb.
-
- // drawing solids requires texturing be disabled
- LLGLSNoTexture no_texture;
-
- LLRect rect(mDragStartThumbRect);
-
- F32 opacity = getEnabled() ? 1.f : 0.3f;
- LLColor4 center_color = (mThumbCenterColor % opacity);
- LLColor4 track_color = (mTrackColor % opacity);
-
- // Track
- LLRect track_rect(mThumbImage->getWidth() / 2,
- getLocalRect().getCenterY() + (mTrackImage->getHeight() / 2),
- getRect().getWidth() - mThumbImage->getWidth() / 2,
- getLocalRect().getCenterY() - (mTrackImage->getHeight() / 2) );
-
- gl_draw_scaled_image_with_border(track_rect.mLeft, track_rect.mBottom, 3, 3, track_rect.getWidth(), track_rect.getHeight(),
- mTrackImage, track_color);
- gl_draw_scaled_image_with_border(track_rect.mLeft, track_rect.mBottom, 3, 3, mThumbRect.mLeft, track_rect.getHeight(),
- mTrackHighlightImage, track_color);
+ // since thumb image might still be decoding, need thumb to accomodate image size
+ updateThumbRect();
+ // Draw background and thumb.
- // Thumb
- if( hasMouseCapture() )
- {
- gl_draw_scaled_image(mDragStartThumbRect.mLeft, mDragStartThumbRect.mBottom, mDragStartThumbRect.getWidth(), mDragStartThumbRect.getHeight(),
- mThumbImage, mThumbCenterColor % 0.3f);
+ // drawing solids requires texturing be disabled
+ LLGLSNoTexture no_texture;
- if (hasFocus())
- {
- F32 lerp_amt = gFocusMgr.getFocusFlashAmt();
- LLRect highlight_rect = mThumbRect;
- highlight_rect.stretch(llround(lerp(1.f, 3.f, lerp_amt)));
- gl_draw_scaled_image_with_border(highlight_rect.mLeft, highlight_rect.mBottom, 0, 0, highlight_rect.getWidth(), highlight_rect.getHeight(),
- mThumbImage, gFocusMgr.getFocusColor(), TRUE);
- }
+ F32 opacity = getEnabled() ? 1.f : 0.3f;
+ LLColor4 center_color = (mThumbCenterColor % opacity);
+ LLColor4 track_color = (mTrackColor % opacity);
- gl_draw_scaled_image(mThumbRect.mLeft, mThumbRect.mBottom, mThumbRect.getWidth(), mThumbRect.getHeight(),
- mThumbImage, mThumbOutlineColor);
+ // Track
+ LLRect track_rect(mThumbImage->getWidth() / 2,
+ getLocalRect().getCenterY() + (mTrackImage->getHeight() / 2),
+ getRect().getWidth() - mThumbImage->getWidth() / 2,
+ getLocalRect().getCenterY() - (mTrackImage->getHeight() / 2) );
+ LLRect highlight_rect(track_rect.mLeft, track_rect.mTop, mThumbRect.getCenterX(), track_rect.mBottom);
+ mTrackImage->draw(track_rect);
+ mTrackHighlightImage->draw(highlight_rect);
- }
- else
- {
- if (hasFocus())
- {
- F32 lerp_amt = gFocusMgr.getFocusFlashAmt();
- LLRect highlight_rect = mThumbRect;
- highlight_rect.stretch(llround(lerp(1.f, 3.f, lerp_amt)));
- gl_draw_scaled_image_with_border(highlight_rect.mLeft, highlight_rect.mBottom, 0, 0, highlight_rect.getWidth(), highlight_rect.getHeight(),
- mThumbImage, gFocusMgr.getFocusColor(), TRUE);
- }
-
- gl_draw_scaled_image(mThumbRect.mLeft, mThumbRect.mBottom, mThumbRect.getWidth(), mThumbRect.getHeight(),
- mThumbImage, center_color);
- }
- LLUICtrl::draw();
+ // Thumb
+ if( hasMouseCapture() )
+ {
+ // Show ghost where thumb was before dragging began.
+ mThumbImage->draw(mDragStartThumbRect, mThumbCenterColor % 0.3f);
}
+ if (hasFocus())
+ {
+ // Draw focus highlighting.
+ mThumbImage->drawBorder(mThumbRect, gFocusMgr.getFocusColor(), gFocusMgr.getFocusFlashWidth());
+ }
+ // Fill in the thumb.
+ mThumbImage->draw(mThumbRect, hasMouseCapture() ? mThumbOutlineColor : center_color);
+
+ LLUICtrl::draw();
}
// virtual
diff --git a/indra/llui/llslider.h b/indra/llui/llslider.h
index 9ca51120fc..ba0fac1465 100644
--- a/indra/llui/llslider.h
+++ b/indra/llui/llslider.h
@@ -52,8 +52,6 @@ public:
BOOL volume, //TODO: create a "volume" slider sub-class or just use image art, no? -MG
const LLString& control_name = LLString::null );
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_SLIDER_BAR; }
- virtual LLString getWidgetTag() const { return LL_SLIDER_TAG; }
virtual LLXMLNodePtr getXML(bool save_children = true) const;
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory);
@@ -79,7 +77,7 @@ public:
virtual BOOL handleHover(S32 x, S32 y, MASK mask);
virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
- virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
+ virtual BOOL handleKeyHere(KEY key, MASK mask);
virtual void draw();
private:
@@ -96,9 +94,9 @@ private:
S32 mMouseOffset;
LLRect mDragStartThumbRect;
- LLImageGL* mThumbImage;
- LLImageGL* mTrackImage;
- LLImageGL* mTrackHighlightImage;
+ LLUIImage* mThumbImage;
+ LLUIImage* mTrackImage;
+ LLUIImage* mTrackHighlightImage;
LLRect mThumbRect;
LLColor4 mTrackColor;
diff --git a/indra/llui/llsliderctrl.cpp b/indra/llui/llsliderctrl.cpp
index 763be1d7e3..9cf1ca5929 100644
--- a/indra/llui/llsliderctrl.cpp
+++ b/indra/llui/llsliderctrl.cpp
@@ -52,6 +52,7 @@
const U32 MAX_STRING_LENGTH = 10;
+static LLRegisterWidget<LLSliderCtrl> r("slider");
LLSliderCtrl::LLSliderCtrl(const LLString& name, const LLRect& rect,
const LLString& label,
diff --git a/indra/llui/llsliderctrl.h b/indra/llui/llsliderctrl.h
index 4f96b0915c..992fbafe38 100644
--- a/indra/llui/llsliderctrl.h
+++ b/indra/llui/llsliderctrl.h
@@ -63,8 +63,7 @@ public:
const LLString& control_which = LLString::null );
virtual ~LLSliderCtrl() {} // Children all cleaned up by default view destructor.
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_SLIDER; }
- virtual LLString getWidgetTag() const { return LL_SLIDER_CTRL_TAG; }
+
virtual LLXMLNodePtr getXML(bool save_children = true) const;
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
diff --git a/indra/llui/llspinctrl.cpp b/indra/llui/llspinctrl.cpp
index 36f801c2e6..a39b74a610 100644
--- a/indra/llui/llspinctrl.cpp
+++ b/indra/llui/llspinctrl.cpp
@@ -52,6 +52,7 @@
const U32 MAX_STRING_LENGTH = 32;
+static LLRegisterWidget<LLSpinCtrl> r2("spinner");
LLSpinCtrl::LLSpinCtrl( const LLString& name, const LLRect& rect, const LLString& label, const LLFontGL* font,
void (*commit_callback)(LLUICtrl*, void*),
@@ -409,26 +410,23 @@ void LLSpinCtrl::draw()
BOOL LLSpinCtrl::handleScrollWheel(S32 x, S32 y, S32 clicks)
{
- if( getEnabled() )
+ if( clicks > 0 )
{
- if( clicks > 0 )
+ while( clicks-- )
{
- while( clicks-- )
- {
- LLSpinCtrl::onDownBtn(this);
- }
- }
- else
- while( clicks++ )
- {
- LLSpinCtrl::onUpBtn(this);
+ LLSpinCtrl::onDownBtn(this);
}
}
+ else
+ while( clicks++ )
+ {
+ LLSpinCtrl::onUpBtn(this);
+ }
return TRUE;
}
-BOOL LLSpinCtrl::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
+BOOL LLSpinCtrl::handleKeyHere(KEY key, MASK mask)
{
if (mEditor->hasFocus())
{
diff --git a/indra/llui/llspinctrl.h b/indra/llui/llspinctrl.h
index 2e1c06d2c4..21d297fa16 100644
--- a/indra/llui/llspinctrl.h
+++ b/indra/llui/llspinctrl.h
@@ -62,8 +62,7 @@ public:
S32 label_width = SPINCTRL_DEFAULT_LABEL_WIDTH );
virtual ~LLSpinCtrl() {} // Children all cleaned up by default view destructor.
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_SPINNER; }
- virtual LLString getWidgetTag() const { return LL_SPIN_CTRL_TAG; }
+
virtual LLXMLNodePtr getXML(bool save_children = true) const;
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory);
@@ -101,7 +100,7 @@ public:
void forceEditorCommit(); // for commit on external button
virtual BOOL handleScrollWheel(S32 x,S32 y,S32 clicks);
- virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
+ virtual BOOL handleKeyHere(KEY key, MASK mask);
virtual void draw();
diff --git a/indra/llui/llstyle.cpp b/indra/llui/llstyle.cpp
index 695dd2a16f..336fdfe2c3 100644
--- a/indra/llui/llstyle.cpp
+++ b/indra/llui/llstyle.cpp
@@ -138,12 +138,34 @@ void LLStyle::setFontName(const LLString& fontname)
}
-void LLStyle::setImage(const LLString& src)
+void LLStyle::setLinkHREF(const LLString& href)
{
- if (src.size() >= UUID_STR_LENGTH - 1)
- {
- mImagep = LLUI::sImageProvider->getImageByID(LLUUID(src));
- }
+ mLink = href;
+}
+
+BOOL LLStyle::isLink() const
+{
+ return mLink.size();
+}
+
+BOOL LLStyle::isVisible() const
+{
+ return mVisible;
+}
+
+void LLStyle::setVisible(BOOL is_visible)
+{
+ mVisible = is_visible;
+}
+
+LLUIImagePtr LLStyle::getImage() const
+{
+ return mImagep;
+}
+
+void LLStyle::setImage(const LLUUID& src)
+{
+ mImagep = LLUI::sImageProvider->getUIImageByID(src);
}
diff --git a/indra/llui/llstyle.h b/indra/llui/llstyle.h
index b425640a36..8b82a84b46 100644
--- a/indra/llui/llstyle.h
+++ b/indra/llui/llstyle.h
@@ -35,7 +35,7 @@
#include "v4color.h"
#include "llresmgr.h"
#include "llfont.h"
-#include "llimagegl.h"
+#include "llui.h"
class LLStyle
{
@@ -53,19 +53,20 @@ public:
virtual const LLColor4& getColor() const { return mColor; }
virtual void setColor(const LLColor4 &color) { mColor = color; }
- virtual BOOL isVisible() const { return mVisible; }
- virtual void setVisible(BOOL is_visible) { mVisible = is_visible; }
+ virtual BOOL isVisible() const;
+ virtual void setVisible(BOOL is_visible);
virtual const LLString& getFontString() const { return mFontName; }
virtual void setFontName(const LLString& fontname);
virtual LLFONT_ID getFontID() const { return mFontID; }
virtual const LLString& getLinkHREF() const { return mLink; }
- virtual void setLinkHREF(const LLString& href) { mLink = href; }
- virtual BOOL isLink() const { return mLink.size(); }
+ virtual void setLinkHREF(const LLString& href);
+ virtual BOOL isLink() const;
+
+ virtual LLUIImagePtr getImage() const;
+ virtual void setImage(const LLUUID& src);
- virtual LLImageGL *getImage() const { return mImagep; }
- virtual void setImage(const LLString& src);
virtual BOOL isImage() const { return ((mImageWidth != 0) && (mImageHeight != 0)); }
virtual void setImageSize(S32 width, S32 height);
@@ -106,7 +107,7 @@ private:
LLString mFontName;
LLFONT_ID mFontID;
LLString mLink;
- LLPointer<LLImageGL> mImagep;
+ LLUIImagePtr mImagep;
BOOL mIsEmbeddedItem;
};
diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp
index 8d1bab6bd7..a1844d34f9 100644
--- a/indra/llui/lltabcontainer.cpp
+++ b/indra/llui/lltabcontainer.cpp
@@ -64,7 +64,7 @@ const S32 TABCNTRV_HEADER_HEIGHT = LLPANEL_BORDER_WIDTH + TABCNTRV_CLOSE_BTN_SIZ
const S32 TABCNTRV_ARROW_BTN_SIZE = 16;
const S32 TABCNTRV_PAD = 0;
-
+static LLRegisterWidget<LLTabContainer> r("tab_container");
LLTabContainer::LLTabContainer(const LLString& name, const LLRect& rect, TabPosition pos,
BOOL bordered, BOOL is_vertical )
@@ -115,18 +115,6 @@ void LLTabContainer::setValue(const LLSD& value)
}
//virtual
-EWidgetType LLTabContainer::getWidgetType() const
-{
- return WIDGET_TYPE_TAB_CONTAINER;
-}
-
-//virtual
-LLString LLTabContainer::getWidgetTag() const
-{
- return LL_TAB_CONTAINER_COMMON_TAG;
-}
-
-//virtual
void LLTabContainer::reshape(S32 width, S32 height, BOOL called_from_parent)
{
LLPanel::reshape( width, height, called_from_parent );
@@ -134,7 +122,7 @@ void LLTabContainer::reshape(S32 width, S32 height, BOOL called_from_parent)
}
//virtual
-LLView* LLTabContainer::getChildByName(const LLString& name, BOOL recurse) const
+LLView* LLTabContainer::getChildView(const LLString& name, BOOL recurse, BOOL create_if_missing) const
{
tuple_list_t::const_iterator itor;
for (itor = mTabList.begin(); itor != mTabList.end(); ++itor)
@@ -145,19 +133,20 @@ LLView* LLTabContainer::getChildByName(const LLString& name, BOOL recurse) const
return panel;
}
}
+
if (recurse)
{
for (itor = mTabList.begin(); itor != mTabList.end(); ++itor)
{
LLPanel *panel = (*itor)->mTabPanel;
- LLView *child = panel->getChild<LLView>(name, recurse);
+ LLView *child = panel->getChildView(name, recurse, FALSE);
if (child)
{
return child;
}
}
}
- return LLView::getChildByName(name, recurse);
+ return LLView::getChildView(name, recurse, create_if_missing);
}
// virtual
@@ -185,124 +174,122 @@ void LLTabContainer::draw()
}
setScrollPosPixels((S32)lerp((F32)getScrollPosPixels(), (F32)target_pixel_scroll, LLCriticalDamp::getInterpolant(0.08f)));
- if( getVisible() )
+
+ BOOL has_scroll_arrows = (mMaxScrollPos > 0) || (mScrollPosPixels > 0);
+ if (!mIsVertical)
{
- BOOL has_scroll_arrows = (mMaxScrollPos > 0) || (mScrollPosPixels > 0);
- if (!mIsVertical)
- {
- mJumpPrevArrowBtn->setVisible( has_scroll_arrows );
- mJumpNextArrowBtn->setVisible( has_scroll_arrows );
- }
- mPrevArrowBtn->setVisible( has_scroll_arrows );
- mNextArrowBtn->setVisible( has_scroll_arrows );
+ mJumpPrevArrowBtn->setVisible( has_scroll_arrows );
+ mJumpNextArrowBtn->setVisible( has_scroll_arrows );
+ }
+ mPrevArrowBtn->setVisible( has_scroll_arrows );
+ mNextArrowBtn->setVisible( has_scroll_arrows );
- S32 left = 0, top = 0;
- if (mIsVertical)
- {
- top = getRect().getHeight() - getTopBorderHeight() - LLPANEL_BORDER_WIDTH - 1 - (has_scroll_arrows ? TABCNTRV_ARROW_BTN_SIZE : 0);
- top += getScrollPosPixels();
- }
- else
- {
- // Set the leftmost position of the tab buttons.
- left = LLPANEL_BORDER_WIDTH + (has_scroll_arrows ? (TABCNTR_ARROW_BTN_SIZE * 2) : TABCNTR_TAB_H_PAD);
- left -= getScrollPosPixels();
- }
-
- // Hide all the buttons
+ S32 left = 0, top = 0;
+ if (mIsVertical)
+ {
+ top = getRect().getHeight() - getTopBorderHeight() - LLPANEL_BORDER_WIDTH - 1 - (has_scroll_arrows ? TABCNTRV_ARROW_BTN_SIZE : 0);
+ top += getScrollPosPixels();
+ }
+ else
+ {
+ // Set the leftmost position of the tab buttons.
+ left = LLPANEL_BORDER_WIDTH + (has_scroll_arrows ? (TABCNTR_ARROW_BTN_SIZE * 2) : TABCNTR_TAB_H_PAD);
+ left -= getScrollPosPixels();
+ }
+
+ // Hide all the buttons
+ for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
+ {
+ LLTabTuple* tuple = *iter;
+ tuple->mButton->setVisible( FALSE );
+ }
+
+ LLPanel::draw();
+
+ // if tabs are hidden, don't draw them and leave them in the invisible state
+ if (!getTabsHidden())
+ {
+ // Show all the buttons
for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
{
LLTabTuple* tuple = *iter;
- tuple->mButton->setVisible( FALSE );
+ tuple->mButton->setVisible( TRUE );
}
- LLPanel::draw();
-
- // if tabs are hidden, don't draw them and leave them in the invisible state
- if (!getTabsHidden())
+ // Draw some of the buttons...
+ LLRect clip_rect = getLocalRect();
+ if (has_scroll_arrows)
{
- // Show all the buttons
- for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
+ // ...but clip them.
+ if (mIsVertical)
{
- LLTabTuple* tuple = *iter;
- tuple->mButton->setVisible( TRUE );
+ clip_rect.mBottom = mNextArrowBtn->getRect().mTop + 3*TABCNTRV_PAD;
+ clip_rect.mTop = mPrevArrowBtn->getRect().mBottom - 3*TABCNTRV_PAD;
}
-
- // Draw some of the buttons...
- LLRect clip_rect = getLocalRect();
- if (has_scroll_arrows)
+ else
{
- // ...but clip them.
- if (mIsVertical)
- {
- clip_rect.mBottom = mNextArrowBtn->getRect().mTop + 3*TABCNTRV_PAD;
- clip_rect.mTop = mPrevArrowBtn->getRect().mBottom - 3*TABCNTRV_PAD;
- }
- else
- {
- clip_rect.mLeft = mPrevArrowBtn->getRect().mRight;
- clip_rect.mRight = mNextArrowBtn->getRect().mLeft;
- }
+ clip_rect.mLeft = mPrevArrowBtn->getRect().mRight;
+ clip_rect.mRight = mNextArrowBtn->getRect().mLeft;
}
- LLLocalClipRect clip(clip_rect);
+ }
+ LLLocalClipRect clip(clip_rect);
- S32 max_scroll_visible = getTabCount() - getMaxScrollPos() + getScrollPos();
- S32 idx = 0;
- for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
- {
- LLTabTuple* tuple = *iter;
+ S32 max_scroll_visible = getTabCount() - getMaxScrollPos() + getScrollPos();
+ S32 idx = 0;
+ for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
+ {
+ LLTabTuple* tuple = *iter;
- tuple->mButton->translate( left ? left - tuple->mButton->getRect().mLeft : 0,
- top ? top - tuple->mButton->getRect().mTop : 0 );
- if (top) top -= BTN_HEIGHT + TABCNTRV_PAD;
- if (left) left += tuple->mButton->getRect().getWidth();
+ tuple->mButton->translate( left ? left - tuple->mButton->getRect().mLeft : 0,
+ top ? top - tuple->mButton->getRect().mTop : 0 );
+ if (top) top -= BTN_HEIGHT + TABCNTRV_PAD;
+ if (left) left += tuple->mButton->getRect().getWidth();
- if (!mIsVertical)
+ if (!mIsVertical)
+ {
+ if( idx < getScrollPos() )
{
- if( idx < getScrollPos() )
- {
- if( tuple->mButton->getFlashing() )
- {
- mPrevArrowBtn->setFlashing( TRUE );
- }
- }
- else if( max_scroll_visible < idx )
+ if( tuple->mButton->getFlashing() )
{
- if( tuple->mButton->getFlashing() )
- {
- mNextArrowBtn->setFlashing( TRUE );
- }
+ mPrevArrowBtn->setFlashing( TRUE );
}
}
- LLUI::pushMatrix();
+ else if( max_scroll_visible < idx )
{
- LLUI::translate((F32)tuple->mButton->getRect().mLeft, (F32)tuple->mButton->getRect().mBottom, 0.f);
- tuple->mButton->draw();
+ if( tuple->mButton->getFlashing() )
+ {
+ mNextArrowBtn->setFlashing( TRUE );
+ }
}
- LLUI::popMatrix();
-
- idx++;
}
-
-
- if( mIsVertical && has_scroll_arrows )
+ LLUI::pushMatrix();
{
- // Redraw the arrows so that they appears on top.
- gGL.pushMatrix();
- gGL.translatef((F32)mPrevArrowBtn->getRect().mLeft, (F32)mPrevArrowBtn->getRect().mBottom, 0.f);
- mPrevArrowBtn->draw();
- gGL.popMatrix();
-
- gGL.pushMatrix();
- gGL.translatef((F32)mNextArrowBtn->getRect().mLeft, (F32)mNextArrowBtn->getRect().mBottom, 0.f);
- mNextArrowBtn->draw();
- gGL.popMatrix();
+ LLUI::translate((F32)tuple->mButton->getRect().mLeft, (F32)tuple->mButton->getRect().mBottom, 0.f);
+ tuple->mButton->draw();
}
+ LLUI::popMatrix();
+
+ idx++;
}
- mPrevArrowBtn->setFlashing(FALSE);
- mNextArrowBtn->setFlashing(FALSE);
+
+ if( mIsVertical && has_scroll_arrows )
+ {
+ // Redraw the arrows so that they appears on top.
+ gGL.pushMatrix();
+ gGL.translatef((F32)mPrevArrowBtn->getRect().mLeft, (F32)mPrevArrowBtn->getRect().mBottom, 0.f);
+ mPrevArrowBtn->draw();
+ gGL.popMatrix();
+
+ gGL.pushMatrix();
+ gGL.translatef((F32)mNextArrowBtn->getRect().mLeft, (F32)mNextArrowBtn->getRect().mBottom, 0.f);
+ mNextArrowBtn->draw();
+ gGL.popMatrix();
+ }
}
+
+ mPrevArrowBtn->setFlashing(FALSE);
+ mNextArrowBtn->setFlashing(FALSE);
}
@@ -524,12 +511,8 @@ BOOL LLTabContainer::handleToolTip( S32 x, S32 y, LLString& msg, LLRect* sticky_
}
// virtual
-BOOL LLTabContainer::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
+BOOL LLTabContainer::handleKeyHere(KEY key, MASK mask)
{
- if (!getEnabled()) return FALSE;
-
- if (!gFocusMgr.childHasKeyboardFocus(this)) return FALSE;
-
BOOL handled = FALSE;
if (key == KEY_LEFT && mask == MASK_ALT)
{
@@ -687,7 +670,7 @@ void LLTabContainer::addTabPanel(LLPanel* child,
// already a child of mine
return;
}
- const LLFontGL* font = gResMgr->getRes( mIsVertical ? LLFONT_SANSSERIF : LLFONT_SANSSERIF_SMALL );
+ const LLFontGL* font = LLResMgr::getInstance()->getRes( mIsVertical ? LLFONT_SANSSERIF : LLFONT_SANSSERIF_SMALL );
// Store the original label for possible xml export.
child->setLabel(label);
@@ -1272,7 +1255,7 @@ void LLTabContainer::setTabImage(LLPanel* child, std::string image_name, const L
if (!mIsVertical)
{
- const LLFontGL* fontp = gResMgr->getRes( LLFONT_SANSSERIF_SMALL );
+ const LLFontGL* fontp = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL );
// remove current width from total tab strip width
mTotalTabWidth -= tuple->mButton->getRect().getWidth();
@@ -1353,7 +1336,7 @@ void LLTabContainer::setPanelTitle(S32 index, const LLString& title)
{
LLTabTuple* tuple = getTab(index);
LLButton* tab_button = tuple->mButton;
- const LLFontGL* fontp = gResMgr->getRes( LLFONT_SANSSERIF_SMALL );
+ const LLFontGL* fontp = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL );
mTotalTabWidth -= tab_button->getRect().getWidth();
tab_button->reshape(llclamp(fontp->getWidth(title) + TAB_PADDING + tuple->mPadding, mMinTabWidth, mMaxTabWidth), tab_button->getRect().getHeight());
mTotalTabWidth += tab_button->getRect().getWidth();
diff --git a/indra/llui/lltabcontainer.h b/indra/llui/lltabcontainer.h
index 7c0463ee5b..20d04cbf86 100644
--- a/indra/llui/lltabcontainer.h
+++ b/indra/llui/lltabcontainer.h
@@ -62,19 +62,19 @@ public:
// from LLView
/*virtual*/ void setValue(const LLSD& value);
- /*virtual*/ EWidgetType getWidgetType() const;
- /*virtual*/ LLString getWidgetTag() const;
+
/*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent);
/*virtual*/ void draw();
/*virtual*/ BOOL handleMouseDown( S32 x, S32 y, MASK mask );
/*virtual*/ BOOL handleHover( S32 x, S32 y, MASK mask );
/*virtual*/ BOOL handleMouseUp( S32 x, S32 y, MASK mask );
/*virtual*/ BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect );
- /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
+ /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask);
/*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
EDragAndDropType type, void* cargo_data,
EAcceptance* accept, LLString& tooltip);
/*virtual*/ LLXMLNodePtr getXML(bool save_children = true) const;
+ /*virtual*/ LLView* getChildView(const LLString& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const;
void addTabPanel(LLPanel* child,
const LLString& label,
@@ -142,10 +142,6 @@ public:
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
-protected:
- /*virtual*/ LLView* getChildByName(const LLString& name, BOOL recurse = FALSE) const;
-
-
private:
// Structure used to map tab buttons to and from tab panels
struct LLTabTuple
diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp
index 0c5bc2da81..1c3c8329e6 100644
--- a/indra/llui/lltextbox.cpp
+++ b/indra/llui/lltextbox.cpp
@@ -34,6 +34,8 @@
#include "lluictrlfactory.h"
#include "llfocusmgr.h"
+static LLRegisterWidget<LLTextBox> r("text");
+
LLTextBox::LLTextBox(const LLString& name, const LLRect& rect, const LLString& text,
const LLFontGL* font, BOOL mouse_opaque)
: LLUICtrl(name, rect, mouse_opaque, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP ),
@@ -212,7 +214,7 @@ void LLTextBox::setLineLengths()
LLString::size_type cur = 0;
LLString::size_type len = mText.getWString().size();
- while (cur < len)
+ while (cur < len)
{
LLString::size_type end = mText.getWString().find('\n', cur);
LLString::size_type runLen;
@@ -323,63 +325,60 @@ BOOL LLTextBox::setTextArg( const LLString& key, const LLStringExplicit& text )
void LLTextBox::draw()
{
- if( getVisible() )
+ if (mBorderVisible)
{
- if (mBorderVisible)
- {
- gl_rect_2d_offset_local(getLocalRect(), 2, FALSE);
- }
+ gl_rect_2d_offset_local(getLocalRect(), 2, FALSE);
+ }
- if( mBorderDropShadowVisible )
- {
- static LLColor4 color_drop_shadow = LLUI::sColorsGroup->getColor("ColorDropShadow");
- static S32 drop_shadow_tooltip = LLUI::sConfigGroup->getS32("DropShadowTooltip");
- gl_drop_shadow(0, getRect().getHeight(), getRect().getWidth(), 0,
- color_drop_shadow, drop_shadow_tooltip);
- }
-
- if (mBackgroundVisible)
- {
- LLRect r( 0, getRect().getHeight(), getRect().getWidth(), 0 );
- gl_rect_2d( r, mBackgroundColor );
- }
+ if( mBorderDropShadowVisible )
+ {
+ static LLColor4 color_drop_shadow = LLUI::sColorsGroup->getColor("ColorDropShadow");
+ static S32 drop_shadow_tooltip = LLUI::sConfigGroup->getS32("DropShadowTooltip");
+ gl_drop_shadow(0, getRect().getHeight(), getRect().getWidth(), 0,
+ color_drop_shadow, drop_shadow_tooltip);
+ }
- S32 text_x = 0;
- switch( mHAlign )
- {
- case LLFontGL::LEFT:
- text_x = mHPad;
- break;
- case LLFontGL::HCENTER:
- text_x = getRect().getWidth() / 2;
- break;
- case LLFontGL::RIGHT:
- text_x = getRect().getWidth() - mHPad;
- break;
- }
+ if (mBackgroundVisible)
+ {
+ LLRect r( 0, getRect().getHeight(), getRect().getWidth(), 0 );
+ gl_rect_2d( r, mBackgroundColor );
+ }
- S32 text_y = getRect().getHeight() - mVPad;
+ S32 text_x = 0;
+ switch( mHAlign )
+ {
+ case LLFontGL::LEFT:
+ text_x = mHPad;
+ break;
+ case LLFontGL::HCENTER:
+ text_x = getRect().getWidth() / 2;
+ break;
+ case LLFontGL::RIGHT:
+ text_x = getRect().getWidth() - mHPad;
+ break;
+ }
- if ( getEnabled() )
+ S32 text_y = getRect().getHeight() - mVPad;
+
+ if ( getEnabled() )
+ {
+ if(mHasHover)
{
- if(mHasHover)
- {
- drawText( text_x, text_y, mHoverColor );
- }
- else
- {
- drawText( text_x, text_y, mTextColor );
- }
+ drawText( text_x, text_y, mHoverColor );
}
else
{
- drawText( text_x, text_y, mDisabledColor );
- }
+ drawText( text_x, text_y, mTextColor );
+ }
+ }
+ else
+ {
+ drawText( text_x, text_y, mDisabledColor );
+ }
- if (sDebugRects)
- {
- drawDebugRect();
- }
+ if (sDebugRects)
+ {
+ drawDebugRect();
}
mHasHover = FALSE; // This is reset every frame.
diff --git a/indra/llui/lltextbox.h b/indra/llui/lltextbox.h
index ce3a9bb12e..91d47795a5 100644
--- a/indra/llui/lltextbox.h
+++ b/indra/llui/lltextbox.h
@@ -57,8 +57,7 @@ public:
LLTextBox(const LLString& name_and_label);
virtual ~LLTextBox() {}
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_TEXT_BOX; }
- virtual LLString getWidgetTag() const { return LL_TEXT_BOX_TAG; }
+
virtual LLXMLNodePtr getXML(bool save_children = true) const;
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory);
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index 0b6f5d75cc..7c8c0fe81c 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -64,6 +64,8 @@
//
// Globals
//
+static LLRegisterWidget<LLTextEditor> r("simple_text_editor");
+
BOOL gDebugTextEditorTips = FALSE;
//
@@ -304,10 +306,10 @@ LLTextEditor::LLTextEditor(
// Init the scrollbar
LLRect scroll_rect;
scroll_rect.setOriginAndSize(
- getRect().getWidth() - UI_TEXTEDITOR_BORDER - SCROLLBAR_SIZE,
- UI_TEXTEDITOR_BORDER,
+ getRect().getWidth() - SCROLLBAR_SIZE,
+ 1,
SCROLLBAR_SIZE,
- getRect().getHeight() - 2 * UI_TEXTEDITOR_BORDER );
+ getRect().getHeight() - 1);
S32 lines_in_doc = getLineCount();
mScrollbar = new LLScrollbar( "Scrollbar", scroll_rect,
LLScrollbar::VERTICAL,
@@ -1102,14 +1104,7 @@ BOOL LLTextEditor::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rec
BOOL LLTextEditor::handleScrollWheel(S32 x, S32 y, S32 clicks)
{
// Pretend the mouse is over the scrollbar
- if (getVisible())
- {
- return mScrollbar->handleScrollWheel( 0, 0, clicks );
- }
- else
- {
- return FALSE;
- }
+ return mScrollbar->handleScrollWheel( 0, 0, clicks );
}
BOOL LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask)
@@ -1197,91 +1192,88 @@ BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask)
BOOL handled = FALSE;
mHoverSegment = NULL;
- if( getVisible() )
+ if(hasMouseCapture() )
{
- if(hasMouseCapture() )
+ if( mIsSelecting )
{
- if( mIsSelecting )
+ if (x != mLastSelectionX || y != mLastSelectionY)
{
- if (x != mLastSelectionX || y != mLastSelectionY)
- {
- mLastSelectionX = x;
- mLastSelectionY = y;
- }
+ mLastSelectionX = x;
+ mLastSelectionY = y;
+ }
- if( y > mTextRect.mTop )
+ if( y > mTextRect.mTop )
+ {
+ mScrollbar->setDocPos( mScrollbar->getDocPos() - 1 );
+ }
+ else
+ if( y < mTextRect.mBottom )
+ {
+ mScrollbar->setDocPos( mScrollbar->getDocPos() + 1 );
+ }
+
+ setCursorAtLocalPos( x, y, TRUE );
+ mSelectionEnd = mCursorPos;
+
+ updateScrollFromCursor();
+ }
+
+ lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl;
+ getWindow()->setCursor(UI_CURSOR_IBEAM);
+ handled = TRUE;
+ }
+
+ if( !handled )
+ {
+ // Pass to children
+ handled = LLView::childrenHandleHover(x, y, mask) != NULL;
+ }
+
+ if( handled )
+ {
+ // Delay cursor flashing
+ resetKeystrokeTimer();
+ }
+
+ // Opaque
+ if( !handled && mTakesNonScrollClicks)
+ {
+ // Check to see if we're over an HTML-style link
+ if( !mSegments.empty() )
+ {
+ const LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y );
+ if( cur_segment )
+ {
+ if(cur_segment->getStyle().isLink())
{
- mScrollbar->setDocPos( mScrollbar->getDocPos() - 1 );
+ lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (over link, inactive)" << llendl;
+ getWindow()->setCursor(UI_CURSOR_HAND);
+ handled = TRUE;
}
else
- if( y < mTextRect.mBottom )
+ if(cur_segment->getStyle().getIsEmbeddedItem())
{
- mScrollbar->setDocPos( mScrollbar->getDocPos() + 1 );
+ lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (over embedded item, inactive)" << llendl;
+ getWindow()->setCursor(UI_CURSOR_HAND);
+ //getWindow()->setCursor(UI_CURSOR_ARROW);
+ handled = TRUE;
}
-
- setCursorAtLocalPos( x, y, TRUE );
- mSelectionEnd = mCursorPos;
-
- updateScrollFromCursor();
+ mHoverSegment = cur_segment;
}
-
- lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl;
- getWindow()->setCursor(UI_CURSOR_IBEAM);
- handled = TRUE;
}
if( !handled )
{
- // Pass to children
- handled = LLView::childrenHandleHover(x, y, mask) != NULL;
- }
-
- if( handled )
- {
- // Delay cursor flashing
- resetKeystrokeTimer();
- }
-
- // Opaque
- if( !handled && mTakesNonScrollClicks)
- {
- // Check to see if we're over an HTML-style link
- if( !mSegments.empty() )
+ lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive)" << llendl;
+ if (!mScrollbar->getVisible() || x < getRect().getWidth() - SCROLLBAR_SIZE)
{
- const LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y );
- if( cur_segment )
- {
- if(cur_segment->getStyle().isLink())
- {
- lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (over link, inactive)" << llendl;
- getWindow()->setCursor(UI_CURSOR_HAND);
- handled = TRUE;
- }
- else
- if(cur_segment->getStyle().getIsEmbeddedItem())
- {
- lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (over embedded item, inactive)" << llendl;
- getWindow()->setCursor(UI_CURSOR_HAND);
- //getWindow()->setCursor(UI_CURSOR_ARROW);
- handled = TRUE;
- }
- mHoverSegment = cur_segment;
- }
+ getWindow()->setCursor(UI_CURSOR_IBEAM);
}
-
- if( !handled )
+ else
{
- lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive)" << llendl;
- if (!mScrollbar->getVisible() || x < getRect().getWidth() - SCROLLBAR_SIZE)
- {
- getWindow()->setCursor(UI_CURSOR_IBEAM);
- }
- else
- {
- getWindow()->setCursor(UI_CURSOR_ARROW);
- }
- handled = TRUE;
+ getWindow()->setCursor(UI_CURSOR_ARROW);
}
+ handled = TRUE;
}
}
@@ -2154,14 +2146,14 @@ void LLTextEditor::unindentLineBeforeCloseBrace()
}
-BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent )
+BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask )
{
BOOL handled = FALSE;
BOOL selection_modified = FALSE;
BOOL return_key_hit = FALSE;
BOOL text_may_have_changed = TRUE;
- if ( (gFocusMgr.getKeyboardFocus() == this) && getVisible())
+ if ( gFocusMgr.getKeyboardFocus() == this )
{
// Special case for TAB. If want to move to next field, report
// not handled and let the parent take care of field movement.
@@ -2245,7 +2237,7 @@ BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent )
}
-BOOL LLTextEditor::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent)
+BOOL LLTextEditor::handleUnicodeCharHere(llwchar uni_char)
{
if ((uni_char < 0x20) || (uni_char == 0x7F)) // Control character or DEL
{
@@ -2254,7 +2246,7 @@ BOOL LLTextEditor::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_pare
BOOL handled = FALSE;
- if ( (gFocusMgr.getKeyboardFocus() == this) && getVisible())
+ if ( gFocusMgr.getKeyboardFocus() == this )
{
// Handle most keys only if the text editor is writeable.
if( !mReadOnly )
@@ -2939,8 +2931,8 @@ void LLTextEditor::drawText()
LLStyle style = cur_segment->getStyle();
if ( style.isImage() && (cur_segment->getStart() >= seg_start) && (cur_segment->getStart() <= clipped_end))
{
- LLImageGL *image = style.getImage();
- gl_draw_scaled_image( llround(text_x), llround(text_y)+line_height-style.mImageHeight, style.mImageWidth, style.mImageHeight, image, LLColor4::white );
+ LLUIImagePtr image = style.getImage();
+ image->draw(llround(text_x), llround(text_y)+line_height-style.mImageHeight, style.mImageWidth, style.mImageHeight);
}
if (cur_segment == mHoverSegment && style.getIsEmbeddedItem())
@@ -2984,7 +2976,7 @@ void LLTextEditor::drawClippedSegment(const LLWString &text, S32 seg_start, S32
if ( style.getFontString()[0] )
{
- font = gResMgr->getRes(style.getFontID());
+ font = LLResMgr::getInstance()->getRes(style.getFontID());
}
U8 font_flags = LLFontGL::NORMAL;
@@ -3051,10 +3043,6 @@ void LLTextEditor::drawClippedSegment(const LLWString &text, S32 seg_start, S32
void LLTextEditor::draw()
{
- if( !getVisible() )
- {
- return;
- }
{
LLLocalClipRect clip(LLRect(0, getRect().getHeight(), getRect().getWidth() - (mScrollbar->getVisible() ? SCROLLBAR_SIZE : 0), 0));
diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h
index 7055e98a76..d48a162830 100644
--- a/indra/llui/lltexteditor.h
+++ b/indra/llui/lltexteditor.h
@@ -71,9 +71,6 @@ public:
virtual ~LLTextEditor();
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_TEXT_EDITOR; }
- virtual LLString getWidgetTag() const { return LL_TEXT_EDITOR_TAG; }
-
virtual LLXMLNodePtr getXML(bool save_children = true) const;
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory);
void setTextEditorParameters(LLXMLNodePtr node);
@@ -85,8 +82,8 @@ public:
virtual BOOL handleHover(S32 x, S32 y, MASK mask);
virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask );
- virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent );
- virtual BOOL handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent);
+ virtual BOOL handleKeyHere(KEY key, MASK mask );
+ virtual BOOL handleUnicodeCharHere(llwchar uni_char);
virtual BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect);
virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp
index 1e9442805f..4866a4b309 100644
--- a/indra/llui/llui.cpp
+++ b/indra/llui/llui.cpp
@@ -55,6 +55,7 @@
//#include "llstartup.h"
#include "llui.h"
#include "llview.h"
+#include "lllineeditor.h"
#include "llwindow.h"
#include "llglheaders.h"
@@ -73,7 +74,6 @@ std::list<LLString> gUntranslated;
LLControlGroup* LLUI::sConfigGroup = NULL;
LLControlGroup* LLUI::sColorsGroup = NULL;
-LLControlGroup* LLUI::sAssetsGroup = NULL;
LLImageProviderInterface* LLUI::sImageProvider = NULL;
LLUIAudioCallback LLUI::sAudioCallback = NULL;
LLVector2 LLUI::sGLScaleFactor(1.f, 1.f);
@@ -320,7 +320,7 @@ void gl_drop_shadow(S32 left, S32 top, S32 right, S32 bottom, const LLColor4 &st
void gl_line_2d(S32 x1, S32 y1, S32 x2, S32 y2 )
{
// Work around bug in ATI driver: vertical lines are offset by (-1,-1)
- if( gGLManager.mATIOffsetVerticalLines && (x1 == x2) )
+ if( (x1 == x2) && gGLManager.mATIOffsetVerticalLines )
{
x1++;
x2++;
@@ -339,7 +339,7 @@ void gl_line_2d(S32 x1, S32 y1, S32 x2, S32 y2 )
void gl_line_2d(S32 x1, S32 y1, S32 x2, S32 y2, const LLColor4 &color )
{
// Work around bug in ATI driver: vertical lines are offset by (-1,-1)
- if( gGLManager.mATIOffsetVerticalLines && (x1 == x2) )
+ if( (x1 == x2) && gGLManager.mATIOffsetVerticalLines )
{
x1++;
x2++;
@@ -457,24 +457,30 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLIma
return;
}
- // scale screen size of borders down
- LLRectf clipped_scale_rect = uv_rect;
- clipped_scale_rect.intersectWith(scale_rect);
+ // shrink scaling region to be proportional to clipped image region
+ LLRectf scale_rect_uv(
+ uv_rect.mLeft + (scale_rect.mLeft * uv_rect.getWidth()),
+ uv_rect.mBottom + (scale_rect.mTop * uv_rect.getHeight()),
+ uv_rect.mLeft + (scale_rect.mRight * uv_rect.getWidth()),
+ uv_rect.mBottom + (scale_rect.mBottom * uv_rect.getHeight()));
+
+ S32 image_natural_width = llround((F32)image->getWidth(0) * uv_rect.getWidth());
+ S32 image_natural_height = llround((F32)image->getHeight(0) * uv_rect.getHeight());
LLRect draw_rect(0, height, width, 0);
- LLRect draw_scale_rect(llround((F32)image->getWidth() * scale_rect.mLeft),
- llround((F32)image->getHeight() * scale_rect.mTop),
- llround((F32)image->getWidth() * scale_rect.mRight),
- llround((F32)image->getHeight() * scale_rect.mBottom));
- // scale fixed region of image up with drawn region
- draw_scale_rect.mRight += width - image->getWidth();
- draw_scale_rect.mTop += height - image->getHeight();
+ LLRect draw_scale_rect(llround(scale_rect_uv.mLeft * (F32)image->getWidth(0)),
+ llround(scale_rect_uv.mTop * (F32)image->getHeight(0)),
+ llround(scale_rect_uv.mRight * (F32)image->getWidth(0)),
+ llround(scale_rect_uv.mBottom * (F32)image->getHeight(0)));
+ // scale fixed region of image to drawn region
+ draw_scale_rect.mRight += width - image_natural_width;
+ draw_scale_rect.mTop += height - image_natural_height;
S32 border_shrink_width = llmax(0, draw_scale_rect.mLeft - draw_scale_rect.mRight);
S32 border_shrink_height = llmax(0, draw_scale_rect.mBottom - draw_scale_rect.mTop);
- F32 shrink_width_ratio = scale_rect.getWidth() == 1.f ? 0.f : border_shrink_width / ((F32)image->getWidth() * (1.f - scale_rect.getWidth()));
- F32 shrink_height_ratio = scale_rect.getHeight() == 1.f ? 0.f : border_shrink_height / ((F32)image->getHeight() * (1.f - scale_rect.getHeight()));
+ F32 shrink_width_ratio = scale_rect.getWidth() == 1.f ? 0.f : border_shrink_width / ((F32)image_natural_width * (1.f - scale_rect.getWidth()));
+ F32 shrink_height_ratio = scale_rect.getHeight() == 1.f ? 0.f : border_shrink_height / ((F32)image_natural_height * (1.f - scale_rect.getHeight()));
F32 shrink_scale = 1.f - llmax(shrink_width_ratio, shrink_height_ratio);
draw_scale_rect.mLeft = llround((F32)draw_scale_rect.mLeft * shrink_scale);
@@ -514,117 +520,117 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLIma
gGL.texCoord2f(uv_rect.mLeft, uv_rect.mBottom);
gGL.vertex2i(0, 0);
- gGL.texCoord2f(clipped_scale_rect.mLeft, uv_rect.mBottom);
+ gGL.texCoord2f(scale_rect_uv.mLeft, uv_rect.mBottom);
gGL.vertex2i(draw_scale_rect.mLeft, 0);
- gGL.texCoord2f(clipped_scale_rect.mLeft, clipped_scale_rect.mBottom);
+ gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mBottom);
gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mBottom);
- gGL.texCoord2f(uv_rect.mLeft, clipped_scale_rect.mBottom);
+ gGL.texCoord2f(uv_rect.mLeft, scale_rect_uv.mBottom);
gGL.vertex2i(0, draw_scale_rect.mBottom);
// draw bottom middle
- gGL.texCoord2f(clipped_scale_rect.mLeft, uv_rect.mBottom);
+ gGL.texCoord2f(scale_rect_uv.mLeft, uv_rect.mBottom);
gGL.vertex2i(draw_scale_rect.mLeft, 0);
- gGL.texCoord2f(clipped_scale_rect.mRight, uv_rect.mBottom);
+ gGL.texCoord2f(scale_rect_uv.mRight, uv_rect.mBottom);
gGL.vertex2i(draw_scale_rect.mRight, 0);
- gGL.texCoord2f(clipped_scale_rect.mRight, clipped_scale_rect.mBottom);
+ gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mBottom);
gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mBottom);
- gGL.texCoord2f(clipped_scale_rect.mLeft, clipped_scale_rect.mBottom);
+ gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mBottom);
gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mBottom);
// draw bottom right
- gGL.texCoord2f(clipped_scale_rect.mRight, uv_rect.mBottom);
+ gGL.texCoord2f(scale_rect_uv.mRight, uv_rect.mBottom);
gGL.vertex2i(draw_scale_rect.mRight, 0);
gGL.texCoord2f(uv_rect.mRight, uv_rect.mBottom);
gGL.vertex2i(width, 0);
- gGL.texCoord2f(uv_rect.mRight, clipped_scale_rect.mBottom);
+ gGL.texCoord2f(uv_rect.mRight, scale_rect_uv.mBottom);
gGL.vertex2i(width, draw_scale_rect.mBottom);
- gGL.texCoord2f(clipped_scale_rect.mRight, clipped_scale_rect.mBottom);
+ gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mBottom);
gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mBottom);
// draw left
- gGL.texCoord2f(uv_rect.mLeft, clipped_scale_rect.mBottom);
+ gGL.texCoord2f(uv_rect.mLeft, scale_rect_uv.mBottom);
gGL.vertex2i(0, draw_scale_rect.mBottom);
- gGL.texCoord2f(clipped_scale_rect.mLeft, clipped_scale_rect.mBottom);
+ gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mBottom);
gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mBottom);
- gGL.texCoord2f(clipped_scale_rect.mLeft, clipped_scale_rect.mTop);
+ gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mTop);
gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mTop);
- gGL.texCoord2f(uv_rect.mLeft, clipped_scale_rect.mTop);
+ gGL.texCoord2f(uv_rect.mLeft, scale_rect_uv.mTop);
gGL.vertex2i(0, draw_scale_rect.mTop);
// draw middle
- gGL.texCoord2f(clipped_scale_rect.mLeft, clipped_scale_rect.mBottom);
+ gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mBottom);
gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mBottom);
- gGL.texCoord2f(clipped_scale_rect.mRight, clipped_scale_rect.mBottom);
+ gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mBottom);
gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mBottom);
- gGL.texCoord2f(clipped_scale_rect.mRight, clipped_scale_rect.mTop);
+ gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mTop);
gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mTop);
- gGL.texCoord2f(clipped_scale_rect.mLeft, clipped_scale_rect.mTop);
+ gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mTop);
gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mTop);
// draw right
- gGL.texCoord2f(clipped_scale_rect.mRight, clipped_scale_rect.mBottom);
+ gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mBottom);
gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mBottom);
- gGL.texCoord2f(uv_rect.mRight, clipped_scale_rect.mBottom);
+ gGL.texCoord2f(uv_rect.mRight, scale_rect_uv.mBottom);
gGL.vertex2i(width, draw_scale_rect.mBottom);
- gGL.texCoord2f(uv_rect.mRight, clipped_scale_rect.mTop);
+ gGL.texCoord2f(uv_rect.mRight, scale_rect_uv.mTop);
gGL.vertex2i(width, draw_scale_rect.mTop);
- gGL.texCoord2f(clipped_scale_rect.mRight, clipped_scale_rect.mTop);
+ gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mTop);
gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mTop);
// draw top left
- gGL.texCoord2f(uv_rect.mLeft, clipped_scale_rect.mTop);
+ gGL.texCoord2f(uv_rect.mLeft, scale_rect_uv.mTop);
gGL.vertex2i(0, draw_scale_rect.mTop);
- gGL.texCoord2f(clipped_scale_rect.mLeft, clipped_scale_rect.mTop);
+ gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mTop);
gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mTop);
- gGL.texCoord2f(clipped_scale_rect.mLeft, uv_rect.mTop);
+ gGL.texCoord2f(scale_rect_uv.mLeft, uv_rect.mTop);
gGL.vertex2i(draw_scale_rect.mLeft, height);
gGL.texCoord2f(uv_rect.mLeft, uv_rect.mTop);
gGL.vertex2i(0, height);
// draw top middle
- gGL.texCoord2f(clipped_scale_rect.mLeft, clipped_scale_rect.mTop);
+ gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mTop);
gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mTop);
- gGL.texCoord2f(clipped_scale_rect.mRight, clipped_scale_rect.mTop);
+ gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mTop);
gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mTop);
- gGL.texCoord2f(clipped_scale_rect.mRight, uv_rect.mTop);
+ gGL.texCoord2f(scale_rect_uv.mRight, uv_rect.mTop);
gGL.vertex2i(draw_scale_rect.mRight, height);
- gGL.texCoord2f(clipped_scale_rect.mLeft, uv_rect.mTop);
+ gGL.texCoord2f(scale_rect_uv.mLeft, uv_rect.mTop);
gGL.vertex2i(draw_scale_rect.mLeft, height);
// draw top right
- gGL.texCoord2f(clipped_scale_rect.mRight, clipped_scale_rect.mTop);
+ gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mTop);
gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mTop);
- gGL.texCoord2f(uv_rect.mRight, clipped_scale_rect.mTop);
+ gGL.texCoord2f(uv_rect.mRight, scale_rect_uv.mTop);
gGL.vertex2i(width, draw_scale_rect.mTop);
gGL.texCoord2f(uv_rect.mRight, uv_rect.mTop);
gGL.vertex2i(width, height);
- gGL.texCoord2f(clipped_scale_rect.mRight, uv_rect.mTop);
+ gGL.texCoord2f(scale_rect_uv.mRight, uv_rect.mTop);
gGL.vertex2i(draw_scale_rect.mRight, height);
}
gGL.end();
@@ -1563,7 +1569,6 @@ bool handleShowXUINamesChanged(const LLSD& newvalue)
void LLUI::initClass(LLControlGroup* config,
LLControlGroup* colors,
- LLControlGroup* assets,
LLImageProviderInterface* image_provider,
LLUIAudioCallback audio_callback,
const LLVector2* scale_factor,
@@ -1571,7 +1576,6 @@ void LLUI::initClass(LLControlGroup* config,
{
sConfigGroup = config;
sColorsGroup = colors;
- sAssetsGroup = assets;
sImageProvider = image_provider;
sAudioCallback = audio_callback;
sGLScaleFactor = (scale_factor == NULL) ? LLVector2(1.f, 1.f) : *scale_factor;
@@ -1584,6 +1588,8 @@ void LLUI::initClass(LLControlGroup* config,
void LLUI::cleanupClass()
{
+ sImageProvider->cleanUp();
+ LLLineEditor::cleanupClass();
}
@@ -1726,28 +1732,15 @@ void LLUI::glRectToScreen(const LLRect& gl, LLRect *screen)
glPointToScreen(gl.mRight, gl.mBottom, &screen->mRight, &screen->mBottom);
}
-//static
-LLUUID LLUI::findAssetUUIDByName(const LLString &asset_name)
-{
- if(asset_name == LLString::null) return LLUUID::null;
- LLString foundValue = LLUI::sConfigGroup->findString(asset_name);
- if(foundValue==LLString::null)
- {
- foundValue = LLUI::sAssetsGroup->findString(asset_name);
- }
- if(foundValue == LLString::null){
- return LLUUID::null;
- }
- return LLUUID( foundValue );
-}
-
//static
-LLUIImage* LLUI::getUIImageByName(const LLString& name)
+LLUIImage* LLUI::getUIImage(const LLString& name)
{
- return sImageProvider->getUIImageByID(findAssetUUIDByName(name));
+ if (!name.empty())
+ return sImageProvider->getUIImage(name);
+ else
+ return NULL;
}
-
// static
void LLUI::setHtmlHelp(LLHtmlHelp* html_help)
{
@@ -1822,7 +1815,8 @@ LLLocalClipRect::LLLocalClipRect(const LLRect &rect, BOOL enabled)
// LLUIImage
//
-LLUIImage::LLUIImage(LLPointer<LLImageGL> image) :
+LLUIImage::LLUIImage(const LLString& name, LLPointer<LLImageGL> image) :
+ mName(name),
mImage(image),
mScaleRegion(0.f, 1.f, 1.f, 0.f),
mClipRegion(0.f, 1.f, 1.f, 0.f),
@@ -1886,24 +1880,32 @@ void LLUIImage::drawSolid(S32 x, S32 y, S32 width, S32 height, const LLColor4& c
mScaleRegion);
}
-void LLUIImage::drawSolid(S32 x, S32 y, const LLColor4& color) const
+void LLUIImage::drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4& color, S32 border_width) const
{
- gl_draw_scaled_image_with_border(
- x, y,
- getWidth(), getHeight(),
- mImage,
- color,
- TRUE,
- mClipRegion,
- mScaleRegion);
+ LLRect border_rect;
+ border_rect.setOriginAndSize(x, y, width, height);
+ border_rect.stretch(border_width, border_width);
+ drawSolid(border_rect, color);
}
S32 LLUIImage::getWidth() const
{
- return mImage->getWidth(0);
+ // return clipped dimensions of actual image area
+ return llround((F32)mImage->getWidth(0) * mClipRegion.getWidth());
}
S32 LLUIImage::getHeight() const
{
- return mImage->getHeight(0);
+ // return clipped dimensions of actual image area
+ return llround((F32)mImage->getHeight(0) * mClipRegion.getHeight());
+}
+
+S32 LLUIImage::getTextureWidth() const
+{
+ return mImage->getWidth(0);
+}
+
+S32 LLUIImage::getTextureHeight() const
+{
+ return mImage->getHeight(0);
}
diff --git a/indra/llui/llui.h b/indra/llui/llui.h
index e7750087cf..b5a64e7533 100644
--- a/indra/llui/llui.h
+++ b/indra/llui/llui.h
@@ -161,7 +161,6 @@ public:
//
static void initClass(LLControlGroup* config,
LLControlGroup* colors,
- LLControlGroup* assets,
LLImageProviderInterface* image_provider,
LLUIAudioCallback audio_callback = NULL,
const LLVector2 *scale_factor = NULL,
@@ -179,8 +178,7 @@ public:
static void setCursorPositionLocal(const LLView* viewp, S32 x, S32 y);
static void setScaleFactor(const LLVector2& scale_factor);
static void setLineWidth(F32 width);
- static LLUUID findAssetUUIDByName(const LLString& name);
- static LLUIImage* getUIImageByName(const LLString& name);
+ static LLUIImage* getUIImage(const LLString& name);
static LLVector2 getWindowSize();
static void screenPointToGL(S32 screen_x, S32 screen_y, S32 *gl_x, S32 *gl_y);
static void glPointToScreen(S32 gl_x, S32 gl_y, S32 *screen_x, S32 *screen_y);
@@ -193,7 +191,6 @@ public:
//
static LLControlGroup* sConfigGroup;
static LLControlGroup* sColorsGroup;
- static LLControlGroup* sAssetsGroup;
static LLImageProviderInterface* sImageProvider;
static LLUIAudioCallback sAudioCallback;
static LLVector2 sGLScaleFactor;
@@ -203,101 +200,6 @@ public:
};
-// UI widgets
-// This MUST match UICtrlNames in lluictrlfactory.cpp
-typedef enum e_widget_type
-{
- WIDGET_TYPE_VIEW = 0,
- WIDGET_TYPE_ROOT_VIEW,
- WIDGET_TYPE_FLOATER_VIEW,
- WIDGET_TYPE_BUTTON,
- WIDGET_TYPE_JOYSTICK_TURN,
- WIDGET_TYPE_JOYSTICK_SLIDE,
- WIDGET_TYPE_CHECKBOX,
- WIDGET_TYPE_COLOR_SWATCH,
- WIDGET_TYPE_COMBO_BOX,
- WIDGET_TYPE_LINE_EDITOR,
- WIDGET_TYPE_SEARCH_EDITOR,
- WIDGET_TYPE_SCROLL_LIST,
- WIDGET_TYPE_NAME_LIST,
- WIDGET_TYPE_WEBBROWSER,
- WIDGET_TYPE_SLIDER, // actually LLSliderCtrl
- WIDGET_TYPE_SLIDER_BAR, // actually LLSlider
- WIDGET_TYPE_VOLUME_SLIDER,//actually LLVolumeSliderCtrl
- WIDGET_TYPE_MULTI_SLIDER, // actually LLMultiSliderCtrl
- WIDGET_TYPE_MULTI_SLIDER_BAR, // actually LLMultiSlider
- WIDGET_TYPE_SPINNER,
- WIDGET_TYPE_TEXT_EDITOR,
- WIDGET_TYPE_TEXTURE_PICKER,
- WIDGET_TYPE_TEXT_BOX,
- WIDGET_TYPE_PAD, // used in XML for positioning, not a real widget
- WIDGET_TYPE_RADIO_GROUP,
- WIDGET_TYPE_ICON,
- WIDGET_TYPE_LANDMARK_PICKER,
- WIDGET_TYPE_LOCATE, // used in XML for positioning, not a real widget
- WIDGET_TYPE_VIEW_BORDER, // decorative border
- WIDGET_TYPE_PANEL,
- WIDGET_TYPE_MENU,
- WIDGET_TYPE_PIE_MENU,
- WIDGET_TYPE_PIE_MENU_BRANCH,
- WIDGET_TYPE_MENU_ITEM,
- WIDGET_TYPE_MENU_ITEM_SEPARATOR,
- WIDGET_TYPE_MENU_SEPARATOR_VERTICAL,
- WIDGET_TYPE_MENU_ITEM_CALL,
- WIDGET_TYPE_MENU_ITEM_CHECK,
- WIDGET_TYPE_MENU_ITEM_BRANCH,
- WIDGET_TYPE_MENU_ITEM_BRANCH_DOWN,
- WIDGET_TYPE_MENU_ITEM_BLANK,
- WIDGET_TYPE_TEAROFF_MENU,
- WIDGET_TYPE_MENU_BAR,
- WIDGET_TYPE_TAB_CONTAINER,
- WIDGET_TYPE_SCROLL_CONTAINER, // LLScrollableContainerView
- WIDGET_TYPE_SCROLLBAR,
- WIDGET_TYPE_INVENTORY_PANEL, // LLInventoryPanel
- WIDGET_TYPE_FLOATER,
- WIDGET_TYPE_DRAG_HANDLE_TOP,
- WIDGET_TYPE_DRAG_HANDLE_LEFT,
- WIDGET_TYPE_RESIZE_HANDLE,
- WIDGET_TYPE_RESIZE_BAR,
- WIDGET_TYPE_NAME_EDITOR,
- WIDGET_TYPE_MULTI_FLOATER,
- WIDGET_TYPE_MEDIA_REMOTE,
- WIDGET_TYPE_FOLDER_VIEW,
- WIDGET_TYPE_FOLDER_ITEM,
- WIDGET_TYPE_FOLDER,
- WIDGET_TYPE_STAT_GRAPH,
- WIDGET_TYPE_STAT_VIEW,
- WIDGET_TYPE_STAT_BAR,
- WIDGET_TYPE_DROP_TARGET,
- WIDGET_TYPE_TEXTURE_BAR,
- WIDGET_TYPE_TEX_MEM_BAR,
- WIDGET_TYPE_SNAPSHOT_LIVE_PREVIEW,
- WIDGET_TYPE_STATUS_BAR,
- WIDGET_TYPE_PROGRESS_VIEW,
- WIDGET_TYPE_TALK_VIEW,
- WIDGET_TYPE_OVERLAY_BAR,
- WIDGET_TYPE_HUD_VIEW,
- WIDGET_TYPE_HOVER_VIEW,
- WIDGET_TYPE_MORPH_VIEW,
- WIDGET_TYPE_NET_MAP,
- WIDGET_TYPE_PERMISSIONS_VIEW,
- WIDGET_TYPE_MENU_HOLDER,
- WIDGET_TYPE_DEBUG_VIEW,
- WIDGET_TYPE_SCROLLING_PANEL_LIST,
- WIDGET_TYPE_AUDIO_STATUS,
- WIDGET_TYPE_CONTAINER_VIEW,
- WIDGET_TYPE_CONSOLE,
- WIDGET_TYPE_FAST_TIMER_VIEW,
- WIDGET_TYPE_VELOCITY_BAR,
- WIDGET_TYPE_TEXTURE_VIEW,
- WIDGET_TYPE_MEMORY_VIEW,
- WIDGET_TYPE_FRAME_STAT_VIEW,
- WIDGET_TYPE_LAYOUT_STACK,
- WIDGET_TYPE_FLYOUT_BUTTON,
- WIDGET_TYPE_DONTCARE,
- WIDGET_TYPE_COUNT
-} EWidgetType;
-
// FactoryPolicy is a static class that controls the creation and lookup of UI elements,
// such as floaters.
// The key parameter is used to provide a unique identifier and/or associated construction
@@ -503,7 +405,7 @@ public:
class LLUIImage : public LLRefCount
{
public:
- LLUIImage(LLPointer<LLImageGL> image);
+ LLUIImage(const LLString& name, LLPointer<LLImageGL> image);
void setClipRegion(const LLRectf& region);
void setScaleRegion(const LLRectf& region);
@@ -511,15 +413,29 @@ public:
LLPointer<LLImageGL> getImage() { return mImage; }
const LLPointer<LLImageGL>& getImage() const { return mImage; }
- void draw(S32 x, S32 y, const LLColor4& color = UI_VERTEX_COLOR) const;
void draw(S32 x, S32 y, S32 width, S32 height, const LLColor4& color = UI_VERTEX_COLOR) const;
+ void draw(S32 x, S32 y, const LLColor4& color = UI_VERTEX_COLOR) const;
+ void draw(const LLRect& rect, const LLColor4& color = UI_VERTEX_COLOR) const { draw(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color); }
+
void drawSolid(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const;
- void drawSolid(S32 x, S32 y, const LLColor4& color) const;
+ void drawSolid(const LLRect& rect, const LLColor4& color) const { drawSolid(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color); }
+ void drawSolid(S32 x, S32 y, const LLColor4& color) const { drawSolid(x, y, mImage->getWidth(0), mImage->getHeight(0), color); }
+
+ void drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4& color, S32 border_width) const;
+ void drawBorder(const LLRect& rect, const LLColor4& color, S32 border_width) const { drawBorder(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color, border_width); }
+ void drawBorder(S32 x, S32 y, const LLColor4& color, S32 border_width) const { drawBorder(x, y, mImage->getWidth(0), mImage->getHeight(0), color, border_width); }
+
+ const LLString& getName() const { return mName; }
S32 getWidth() const;
S32 getHeight() const;
+ // returns dimensions of underlying textures, which might not be equal to ui image portion
+ S32 getTextureWidth() const;
+ S32 getTextureHeight() const;
+
protected:
+ LLString mName;
LLRectf mScaleRegion;
LLRectf mClipRegion;
LLPointer<LLImageGL> mImage;
@@ -527,6 +443,7 @@ protected:
BOOL mNoClip;
};
+typedef LLPointer<LLUIImage> LLUIImagePtr;
template <typename T>
class LLTombStone : public LLRefCount
@@ -661,6 +578,7 @@ private:
LLRootHandle<T> mHandle;
};
+
//RN: maybe this needs to moved elsewhere?
class LLImageProviderInterface
{
@@ -668,8 +586,9 @@ public:
LLImageProviderInterface() {};
virtual ~LLImageProviderInterface() {};
- virtual LLUIImage* getUIImageByID(const LLUUID& id, BOOL clamped = TRUE) = 0;
- virtual LLImageGL* getImageByID(const LLUUID& id, BOOL clamped = TRUE) = 0;
+ virtual LLUIImagePtr getUIImage(const LLString& name) = 0;
+ virtual LLUIImagePtr getUIImageByID(const LLUUID& id) = 0;
+ virtual void cleanUp() = 0;
};
#endif
diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp
index ade301a32e..aa44663fd0 100644
--- a/indra/llui/lluictrl.cpp
+++ b/indra/llui/lluictrl.cpp
@@ -34,7 +34,9 @@
#include "linden_common.h"
#include "lluictrl.h"
#include "llfocusmgr.h"
+#include "llpanel.h"
+static LLRegisterWidget<LLUICtrl> r("ui_ctrl");
LLFocusableElement::LLFocusableElement()
: mFocusLostCallback(NULL),
@@ -473,7 +475,7 @@ BOOL LLUICtrl::focusPrevItem(BOOL text_fields_only)
return focusPrev(result);
}
-const LLUICtrl* LLUICtrl::findRootMostFocusRoot() const
+LLUICtrl* LLUICtrl::findRootMostFocusRoot() const
{
const LLUICtrl* focus_root = NULL;
const LLUICtrl* next_view = this;
@@ -485,7 +487,9 @@ const LLUICtrl* LLUICtrl::findRootMostFocusRoot() const
}
next_view = next_view->getParentUICtrl();
}
- return focus_root;
+ // since focus_root could be this, need to cast away const to return
+ // a non-const result
+ return const_cast<LLUICtrl*>(focus_root);
}
@@ -538,14 +542,22 @@ LLXMLNodePtr LLUICtrl::getXML(bool save_children) const
return node;
}
+//static
+LLView* LLUICtrl::fromXML(LLXMLNodePtr node, LLView* parent, class LLUICtrlFactory* factory)
+{
+ LLUICtrl* ctrl = new LLUICtrl();
+ ctrl->initFromXML(node, parent);
+ return ctrl;
+}
+
+
// *NOTE: If other classes derive from LLPanel, they will need to be
// added to this function.
LLPanel* LLUICtrl::getParentPanel() const
{
LLView* parent = getParent();
- while (parent
- && parent->getWidgetType() != WIDGET_TYPE_PANEL
- && parent->getWidgetType() != WIDGET_TYPE_FLOATER)
+ LLPanel* parent_panel = dynamic_cast<LLPanel*>(parent);
+ while (!parent_panel)
{
parent = parent->getParent();
}
diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h
index 81b00d4ec3..6863940ddd 100644
--- a/indra/llui/lluictrl.h
+++ b/indra/llui/lluictrl.h
@@ -141,7 +141,9 @@ public:
void setValidateBeforeCommit( BOOL(*cb)(LLUICtrl*, void*) ) { mValidateCallback = cb; }
void setLostTopCallback( void (*cb)(LLUICtrl*, void*) ) { mLostTopCallback = cb; }
- const LLUICtrl* findRootMostFocusRoot() const;
+ static LLView* fromXML(LLXMLNodePtr node, LLView* parent, class LLUICtrlFactory* factory);
+
+ LLUICtrl* findRootMostFocusRoot() const;
class LLTextInputFilter : public LLQueryFilter, public LLSingleton<LLTextInputFilter>
{
diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp
index 4acfc69f3a..c75c6714f8 100644
--- a/indra/llui/lluictrlfactory.cpp
+++ b/indra/llui/lluictrlfactory.cpp
@@ -71,100 +71,6 @@
const char XML_HEADER[] = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n";
-// *NOTE: If you add a new class derived from LLPanel, add a check for its
-// widget type to LLUICtrl::getParentPanel().
-// *NOTE: This MUST match EWidgetType in llui.h
-//static
-const LLString LLUICtrlFactory::sUICtrlNames[WIDGET_TYPE_COUNT] =
-{
- LLString("view"), //WIDGET_TYPE_VIEW
- LLString("root_view"), //WIDGET_TYPE_ROOT_VIEW
- LLString("floater_view"), //WIDGET_TYPE_FLOATER_VIEW
- LLString("button"), //WIDGET_TYPE_BUTTON
- LLString("joystick_turn"), //WIDGET_TYPE_JOYSTICK_TURN
- LLString("joystick_slide"), //WIDGET_TYPE_JOYSTICK_SLIDE
- LLString("check_box"), //WIDGET_TYPE_CHECKBOX
- LLString("color_swatch"), //WIDGET_TYPE_COLOR_SWATCH
- LLString("combo_box"), //WIDGET_TYPE_COMBO_BOX
- LLString("line_editor"), //WIDGET_TYPE_LINE_EDITOR
- LLString("search_editor"), //WIDGET_TYPE_SEARCH_EDITOR
- LLString("scroll_list"), //WIDGET_TYPE_SCROLL_LIST
- LLString("name_list"), //WIDGET_TYPE_NAME_LIST
- LLString("web_browser"), //WIDGET_TYPE_WEBBROWSER
- LLString("slider"), //WIDGET_TYPE_SLIDER, actually LLSliderCtrl
- LLString("slider_bar"), //WIDGET_TYPE_SLIDER_BAR, actually LLSlider
- LLString("volume_slider"), //WIDGET_TYPE_VOLUME_SLIDER, actually LLSlider + "volume" param
- LLString("multi_slider"), //WIDGET_TYPE_MULTI_SLIDER, actually LLMultiSliderCtrl
- LLString("multi_slider_bar"), //WIDGET_TYPE_MULTI_SLIDER_BAR, actually LLMultiSlider
- LLString("spinner"), //WIDGET_TYPE_SPINNER, actually LLSpinCtrl
- LLString("text_editor"), //WIDGET_TYPE_TEXT_EDITOR
- LLString("texture_picker"),//WIDGET_TYPE_TEXTURE_PICKER
- LLString("text"), //WIDGET_TYPE_TEXT_BOX
- LLString("pad"), //WIDGET_TYPE_PAD
- LLString("radio_group"), //WIDGET_TYPE_RADIO_GROUP
- LLString("icon"), //WIDGET_TYPE_ICON
- LLString("locate"), //WIDGET_TYPE_LOCATE
- LLString("view_border"), //WIDGET_TYPE_VIEW_BORDER
- LLString("panel"), //WIDGET_TYPE_PANEL
- LLString("menu"), //WIDGET_TYPE_MENU
- LLString("pie_menu"), //WIDGET_TYPE_PIE_MENU
- LLString("pie_menu_branch"), //WIDGET_TYPE_PIE_MENU_BRANCH
- LLString("menu_item"), //WIDGET_TYPE_MENU_ITEM
- LLString("menu_item_separator"), //WIDGET_TYPE_MENU_ITEM_SEPARATOR
- LLString("menu_separator_vertical"), // WIDGET_TYPE_MENU_SEPARATOR_VERTICAL
- LLString("menu_item_call"), // WIDGET_TYPE_MENU_ITEM_CALL
- LLString("menu_item_check"),// WIDGET_TYPE_MENU_ITEM_CHECK
- LLString("menu_item_branch"), // WIDGET_TYPE_MENU_ITEM_BRANCH
- LLString("menu_item_branch_down"), //WIDGET_TYPE_MENU_ITEM_BRANCH_DOWN,
- LLString("menu_item_blank"), //WIDGET_TYPE_MENU_ITEM_BLANK,
- LLString("tearoff_menu"), //WIDGET_TYPE_TEAROFF_MENU
- LLString("menu_bar"), //WIDGET_TYPE_MENU_BAR
- LLString("tab_container"),//WIDGET_TYPE_TAB_CONTAINER
- LLString("scroll_container"),//WIDGET_TYPE_SCROLL_CONTAINER
- LLString("scrollbar"), //WIDGET_TYPE_SCROLLBAR
- LLString("inventory_panel"), //WIDGET_TYPE_INVENTORY_PANEL
- LLString("floater"), //WIDGET_TYPE_FLOATER
- LLString("drag_handle_top"), //WIDGET_TYPE_DRAG_HANDLE_TOP
- LLString("drag_handle_left"), //WIDGET_TYPE_DRAG_HANDLE_LEFT
- LLString("resize_handle"), //WIDGET_TYPE_RESIZE_HANDLE
- LLString("resize_bar"), //WIDGET_TYPE_RESIZE_BAR
- LLString("name_editor"), //WIDGET_TYPE_NAME_EDITOR
- LLString("multi_floater"), //WIDGET_TYPE_MULTI_FLOATER
- LLString("media_remote"), //WIDGET_TYPE_MEDIA_REMOTE
- LLString("folder_view"), //WIDGET_TYPE_FOLDER_VIEW
- LLString("folder_item"), //WIDGET_TYPE_FOLDER_ITEM
- LLString("folder"), //WIDGET_TYPE_FOLDER
- LLString("stat_graph"), //WIDGET_TYPE_STAT_GRAPH
- LLString("stat_view"), //WIDGET_TYPE_STAT_VIEW
- LLString("stat_bar"), //WIDGET_TYPE_STAT_BAR
- LLString("drop_target"), //WIDGET_TYPE_DROP_TARGET
- LLString("texture_bar"), //WIDGET_TYPE_TEXTURE_BAR
- LLString("tex_mem_bar"), //WIDGET_TYPE_TEX_MEM_BAR
- LLString("snapshot_live_preview"), //WIDGET_TYPE_SNAPSHOT_LIVE_PREVIEW
- LLString("status_bar"), //WIDGET_TYPE_STATUS_BAR
- LLString("progress_view"), //WIDGET_TYPE_PROGRESS_VIEW
- LLString("talk_view"), //WIDGET_TYPE_TALK_VIEW
- LLString("overlay_bar"), //WIDGET_TYPE_OVERLAY_BAR
- LLString("hud_view"), //WIDGET_TYPE_HUD_VIEW
- LLString("hover_view"), //WIDGET_TYPE_HOVER_VIEW
- LLString("morph_view"), //WIDGET_TYPE_MORPH_VIEW
- LLString("net_map"), //WIDGET_TYPE_NET_MAP
- LLString("permissions_view"), //WIDGET_TYPE_PERMISSIONS_VIEW
- LLString("menu_holder"), //WIDGET_TYPE_MENU_HOLDER
- LLString("debug_view"), //WIDGET_TYPE_DEBUG_VIEW
- LLString("scrolling_panel_list"), //WIDGET_TYPE_SCROLLING_PANEL_LIST
- LLString("audio_status"), //WIDGET_TYPE_AUDIO_STATUS
- LLString("container_view"), //WIDGET_TYPE_CONTAINER_VIEW
- LLString("console"), //WIDGET_TYPE_CONSOLE
- LLString("fast_timer_view"), //WIDGET_TYPE_FAST_TIMER_VIEW
- LLString("velocity_bar"), //WIDGET_TYPE_VELOCITY_BAR
- LLString("texture_view"), //WIDGET_TYPE_TEXTURE_VIEW
- LLString("memory_view"), //WIDGET_TYPE_MEMORY_VIEW
- LLString("frame_stat_view"), //WIDGET_TYPE_FRAME_STAT_VIEW
- LLString("layout_stack"), //WIDGET_TYPE_LAYOUT_STACK
- LLString("DONT_CARE"), //WIDGET_TYPE_DONTCARE
-};
-
const S32 HPAD = 4;
const S32 VPAD = 4;
const S32 FLOATER_H_MARGIN = 15;
@@ -179,9 +85,6 @@ public:
LLUICtrlLocate() : LLUICtrl("locate", LLRect(0,0,0,0), FALSE, NULL, NULL) { setTabStop(FALSE); }
virtual void draw() { }
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_LOCATE; }
- virtual LLString getWidgetTag() const { return LL_UI_CTRL_LOCATE_TAG; }
-
static LLView *fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
{
LLString name("pad");
@@ -194,39 +97,14 @@ public:
}
};
+static LLRegisterWidget<LLUICtrlLocate> r1("locate");
+static LLRegisterWidget<LLUICtrlLocate> r2("pad");
+
//-----------------------------------------------------------------------------
// LLUICtrlFactory()
//-----------------------------------------------------------------------------
LLUICtrlFactory::LLUICtrlFactory()
{
- // Register controls
- LLUICtrlCreator<LLButton>::registerCreator(LL_BUTTON_TAG, this);
- LLUICtrlCreator<LLCheckBoxCtrl>::registerCreator(LL_CHECK_BOX_CTRL_TAG, this);
- LLUICtrlCreator<LLComboBox>::registerCreator(LL_COMBO_BOX_TAG, this);
- LLUICtrlCreator<LLFlyoutButton>::registerCreator(LL_FLYOUT_BUTTON_TAG, this);
- LLUICtrlCreator<LLLineEditor>::registerCreator(LL_LINE_EDITOR_TAG, this);
- LLUICtrlCreator<LLSearchEditor>::registerCreator(LL_SEARCH_EDITOR_TAG, this);
- LLUICtrlCreator<LLScrollListCtrl>::registerCreator(LL_SCROLL_LIST_CTRL_TAG, this);
- LLUICtrlCreator<LLSliderCtrl>::registerCreator(LL_SLIDER_CTRL_TAG, this);
- LLUICtrlCreator<LLSlider>::registerCreator(LL_SLIDER_TAG, this);
- LLUICtrlCreator<LLSlider>::registerCreator(LL_VOLUME_SLIDER_CTRL_TAG, this);
- LLUICtrlCreator<LLMultiSliderCtrl>::registerCreator(LL_MULTI_SLIDER_CTRL_TAG, this);
- LLUICtrlCreator<LLMultiSlider>::registerCreator(LL_MULTI_SLIDER_TAG, this);
- LLUICtrlCreator<LLSpinCtrl>::registerCreator(LL_SPIN_CTRL_TAG, this);
- LLUICtrlCreator<LLTextBox>::registerCreator(LL_TEXT_BOX_TAG, this);
- LLUICtrlCreator<LLRadioGroup>::registerCreator(LL_RADIO_GROUP_TAG, this);
- LLUICtrlCreator<LLIconCtrl>::registerCreator(LL_ICON_CTRL_TAG, this);
- LLUICtrlCreator<LLUICtrlLocate>::registerCreator(LL_UI_CTRL_LOCATE_TAG, this);
- LLUICtrlCreator<LLUICtrlLocate>::registerCreator(LL_PAD_TAG, this);
- LLUICtrlCreator<LLViewBorder>::registerCreator(LL_VIEW_BORDER_TAG, this);
- LLUICtrlCreator<LLTabContainer>::registerCreator(LL_TAB_CONTAINER_COMMON_TAG, this);
- LLUICtrlCreator<LLScrollableContainerView>::registerCreator(LL_SCROLLABLE_CONTAINER_VIEW_TAG, this);
- LLUICtrlCreator<LLPanel>::registerCreator(LL_PANEL_TAG, this);
- LLUICtrlCreator<LLMenuGL>::registerCreator(LL_MENU_GL_TAG, this);
- LLUICtrlCreator<LLMenuBarGL>::registerCreator(LL_MENU_BAR_GL_TAG, this);
- LLUICtrlCreator<LLScrollingPanelList>::registerCreator(LL_SCROLLING_PANEL_LIST_TAG, this);
- LLUICtrlCreator<LLLayoutStack>::registerCreator(LL_LAYOUT_STACK_TAG, this);
-
setupPaths();
}
@@ -548,43 +426,33 @@ void LLUICtrlFactory::rebuild()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-// static
-EWidgetType LLUICtrlFactory::getWidgetType(const LLString& ctrl_type)
-{
- U32 ctrl_id;
- for (ctrl_id = 0; ctrl_id < WIDGET_TYPE_COUNT; ctrl_id++)
- {
- if (sUICtrlNames[ctrl_id] == ctrl_type)
- {
- break;
- }
- }
- return (EWidgetType) ctrl_id;
-}
-
-LLString LLUICtrlFactory::getWidgetType(EWidgetType ctrl_type)
-{
- return sUICtrlNames[ctrl_type];
-}
-
LLView *LLUICtrlFactory::createCtrlWidget(LLPanel *parent, LLXMLNodePtr node)
{
+ // panel for holding dummy widgets, so they have a parent for layout purposes, etc.
+ // does not manage lifetime of child widgets
+ static LLPanel dummy_panel;
+
LLString ctrl_type = node->getName()->mString;
LLString::toLower(ctrl_type);
- creator_list_t::const_iterator it = mCreatorFunctions.find(ctrl_type);
- if (it == mCreatorFunctions.end())
+ LLWidgetClassRegistry::factory_func_t func = LLWidgetClassRegistry::getInstance()->getCreatorFunc(ctrl_type);
+
+ if (func == NULL)
{
llwarns << "Unknown control type " << ctrl_type << llendl;
return NULL;
}
- LLView *ctrl = (*it->second)(node, parent, this);
+ if (parent == NULL)
+ {
+ parent = &dummy_panel;
+ }
+ LLView *ctrl = func(node, parent, this);
return ctrl;
}
-void LLUICtrlFactory::createWidget(LLPanel *parent, LLXMLNodePtr node)
+LLView* LLUICtrlFactory::createWidget(LLPanel *parent, LLXMLNodePtr node)
{
LLView* view = createCtrlWidget(parent, node);
@@ -595,6 +463,8 @@ void LLUICtrlFactory::createWidget(LLPanel *parent, LLXMLNodePtr node)
{
parent->addChild(view, tab_group);
}
+
+ return view;
}
//-----------------------------------------------------------------------------
@@ -648,138 +518,3 @@ BOOL LLUICtrlFactory::getAttributeColor(LLXMLNodePtr node, const LLString& name,
return res;
}
-//============================================================================
-
-LLButton* LLUICtrlFactory::getButtonByName(const LLPanel* panelp, const LLString& name)
-{
- return panelp->getChild<LLButton>(name);
-}
-
-LLCheckBoxCtrl* LLUICtrlFactory::getCheckBoxByName(const LLPanel* panelp, const LLString& name)
-{
- return panelp->getChild<LLCheckBoxCtrl>(name);
-}
-
-LLComboBox* LLUICtrlFactory::getComboBoxByName(const LLPanel* panelp, const LLString& name)
-{
- return panelp->getChild<LLComboBox>(name);
-}
-
-LLIconCtrl* LLUICtrlFactory::getIconByName(const LLPanel* panelp, const LLString& name)
-{
- return panelp->getChild<LLIconCtrl>(name);
-}
-
-LLLineEditor* LLUICtrlFactory::getLineEditorByName(const LLPanel* panelp, const LLString& name)
-{
- return panelp->getChild<LLLineEditor>(name);
-}
-
-LLRadioGroup* LLUICtrlFactory::getRadioGroupByName(const LLPanel* panelp, const LLString& name)
-{
- return panelp->getChild<LLRadioGroup>(name);
-}
-
-LLScrollListCtrl* LLUICtrlFactory::getScrollListByName(const LLPanel* panelp, const LLString& name)
-{
- return panelp->getChild<LLScrollListCtrl>(name);
-}
-
-LLSliderCtrl* LLUICtrlFactory::getSliderByName(const LLPanel* panelp, const LLString& name)
-{
- return panelp->getChild<LLSliderCtrl>(name);
-}
-
-LLSlider* LLUICtrlFactory::getSliderBarByName(const LLPanel* panelp, const LLString& name)
-{
- return panelp->getChild<LLSlider>(name);
-}
-
-LLSpinCtrl* LLUICtrlFactory::getSpinnerByName(const LLPanel* panelp, const LLString& name)
-{
- return panelp->getChild<LLSpinCtrl>(name);
-}
-
-LLTextBox* LLUICtrlFactory::getTextBoxByName(const LLPanel* panelp, const LLString& name)
-{
- return panelp->getChild<LLTextBox>(name);
-}
-
-LLTextEditor* LLUICtrlFactory::getTextEditorByName(const LLPanel* panelp, const LLString& name)
-{
- return panelp->getChild<LLTextEditor>(name);
-}
-
-LLTabContainer* LLUICtrlFactory::getTabContainerByName(const LLPanel* panelp, const LLString& name)
-{
- return panelp->getChild<LLTabContainer>(name);
-}
-
-LLScrollableContainerView* LLUICtrlFactory::getScrollableContainerByName(const LLPanel* panelp, const LLString& name)
-{
- return panelp->getChild<LLScrollableContainerView>(name);
-}
-
-LLPanel* LLUICtrlFactory::getPanelByName(const LLPanel* panelp, const LLString& name)
-{
- return panelp->getChild<LLPanel>(name);
-}
-
-LLMenuItemCallGL* LLUICtrlFactory::getMenuItemCallByName(const LLPanel* panelp, const LLString& name)
-{
- return panelp->getChild<LLMenuItemCallGL>(name);
-}
-
-LLScrollingPanelList* LLUICtrlFactory::getScrollingPanelList(const LLPanel* panelp, const LLString& name)
-{
- return panelp->getChild<LLScrollingPanelList>(name);
-}
-
-LLMultiSliderCtrl* LLUICtrlFactory::getMultiSliderByName(const LLPanel* panelp, const LLString& name)
-{
- return panelp->getChild<LLMultiSliderCtrl>(name);
-}
-
-LLMultiSlider* LLUICtrlFactory::getMultiSliderBarByName(const LLPanel* panelp, const LLString& name)
-{
- return panelp->getChild<LLMultiSlider>(name);
-}
-
-
-LLCtrlListInterface* LLUICtrlFactory::getListInterfaceByName(const LLPanel* panelp, const LLString& name)
-{
- LLView* viewp = panelp->getCtrlByNameAndType(name, WIDGET_TYPE_DONTCARE);
- if (viewp && viewp->isCtrl())
- {
- return ((LLUICtrl*)viewp)->getListInterface();
- }
- return NULL;
-}
-
-LLCtrlSelectionInterface* LLUICtrlFactory::getSelectionInterfaceByName(const LLPanel* panelp, const LLString& name)
-{
- LLView* viewp = panelp->getCtrlByNameAndType(name, WIDGET_TYPE_DONTCARE);
- if (viewp && viewp->isCtrl())
- {
- return ((LLUICtrl*)viewp)->getSelectionInterface();
- }
- return NULL;
-}
-
-LLCtrlScrollInterface* LLUICtrlFactory::getScrollInterfaceByName(const LLPanel* panelp, const LLString& name)
-{
- LLView* viewp = panelp->getCtrlByNameAndType(name, WIDGET_TYPE_DONTCARE);
- if (viewp && viewp->isCtrl())
- {
- return ((LLUICtrl*)viewp)->getScrollInterface();
- }
- return NULL;
-}
-
-void LLUICtrlFactory::registerCreator(LLString ctrlname, creator_function_t function)
-{
- LLString::toLower(ctrlname);
- mCreatorFunctions[ctrlname] = function;
-}
-
-
diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h
index c2a6cfe510..651bfa7b88 100644
--- a/indra/llui/lluictrlfactory.h
+++ b/indra/llui/lluictrlfactory.h
@@ -41,7 +41,7 @@
class LLView;
class LLPanel;
-class LLUICtrlFactory
+class LLUICtrlFactory : public LLSingleton<LLUICtrlFactory>
{
public:
LLUICtrlFactory();
@@ -49,7 +49,7 @@ public:
virtual ~LLUICtrlFactory() {}
void setupPaths();
-
+
void buildFloater(LLFloater* floaterp, const LLString &filename,
const LLCallbackMap::map_t* factory_map = NULL, BOOL open = TRUE);
BOOL buildPanel(LLPanel* panelp, const LLString &filename,
@@ -65,84 +65,28 @@ public:
// Returns 0 on success
S32 saveToXML(LLView* viewp, const LLString& filename);
-
// Rebuilds all currently built panels.
void rebuild();
- static EWidgetType getWidgetType(const LLString& ctrl_type);
- static LLString getWidgetType(EWidgetType ctrl_type);
static BOOL getAttributeColor(LLXMLNodePtr node, const LLString& name, LLColor4& color);
- // specific typed getters
- static class LLButton* getButtonByName( const LLPanel* panelp, const LLString& name);
- static class LLCheckBoxCtrl* getCheckBoxByName( const LLPanel* panelp, const LLString& name);
- static class LLComboBox* getComboBoxByName( const LLPanel* panelp, const LLString& name);
- static class LLIconCtrl* getIconByName( const LLPanel* panelp, const LLString& name);
- static class LLLineEditor* getLineEditorByName( const LLPanel* panelp, const LLString& name);
- static class LLRadioGroup* getRadioGroupByName( const LLPanel* panelp, const LLString& name);
- static class LLScrollListCtrl* getScrollListByName( const LLPanel* panelp, const LLString& name);
- static class LLSliderCtrl* getSliderByName( const LLPanel* panelp, const LLString& name);
- static class LLSlider* getSliderBarByName( const LLPanel* panelp, const LLString& name);
- static class LLSpinCtrl* getSpinnerByName( const LLPanel* panelp, const LLString& name);
- static class LLTextBox* getTextBoxByName( const LLPanel* panelp, const LLString& name);
- static class LLTextEditor* getTextEditorByName( const LLPanel* panelp, const LLString& name);
- static class LLTabContainer* getTabContainerByName( const LLPanel* panelp, const LLString& name);
- static class LLScrollableContainerView* getScrollableContainerByName(const LLPanel* panelp, const LLString& name);
- static class LLPanel* getPanelByName( const LLPanel* panelp, const LLString& name);
- static class LLMenuItemCallGL* getMenuItemCallByName( const LLPanel* panelp, const LLString& name);
- static class LLScrollingPanelList* getScrollingPanelList( const LLPanel* panelp, const LLString& name);
- static class LLMultiSliderCtrl* getMultiSliderByName( const LLPanel* panelp, const LLString& name);
- static class LLMultiSlider* getMultiSliderBarByName(const LLPanel* panelp, const LLString& name);
-
- // interface getters
- static LLCtrlListInterface* getListInterfaceByName( const LLPanel* panelp, const LLString& name);
- static LLCtrlSelectionInterface* getSelectionInterfaceByName(const LLPanel* panelp, const LLString& name);
- static LLCtrlScrollInterface* getScrollInterfaceByName(const LLPanel* panelp, const LLString& name);
-
LLPanel* createFactoryPanel(LLString name);
virtual LLView* createCtrlWidget(LLPanel *parent, LLXMLNodePtr node);
- virtual void createWidget(LLPanel *parent, LLXMLNodePtr node);
-
- template <class T> T* createDummyWidget(const LLString& name)
- {
- return NULL;
- //static LLPanel dummy_panel;
- //LLXMLNodePtr new_node_ptr = new LLXMLNode(T::getWidgetTag(), FALSE);
- //return createWidget(&dummy_panel, new_node_ptr);
- }
-
- // Creator library
- typedef LLView* (*creator_function_t)(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
- void registerCreator(LLString ctrlname, creator_function_t function);
+ virtual LLView* createWidget(LLPanel *parent, LLXMLNodePtr node);
static bool getLayeredXMLNode(const LLString &filename, LLXMLNodePtr& root);
-protected:
-
- template<class T>
- class LLUICtrlCreator
- {
- public:
- static void registerCreator(LLString name, LLUICtrlFactory *factory)
- {
- factory->registerCreator(name, T::fromXML);
- }
- };
-
private:
typedef std::map<LLHandle<LLPanel>, LLString> built_panel_t;
built_panel_t mBuiltPanels;
+
typedef std::map<LLHandle<LLFloater>, LLString> built_floater_t;
built_floater_t mBuiltFloaters;
std::deque<const LLCallbackMap::map_t*> mFactoryStack;
- static const LLString sUICtrlNames[];
-
- typedef std::map<LLString, creator_function_t> creator_list_t;
- creator_list_t mCreatorFunctions;
static std::vector<LLString> mXUIPaths;
};
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index 269796e5de..b49ee4338f 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -49,7 +49,16 @@
#include "lluictrl.h"
#include "llwindow.h"
#include "v3color.h"
+#include "lluictrlfactory.h"
+// for ui edit hack
+#include "llbutton.h"
+#include "lllineeditor.h"
+#include "lltexteditor.h"
+#include "lltextbox.h"
+
+//HACK: this allows you to instantiate LLView from xml with "<view/>" which we don't want
+static LLRegisterWidget<LLView> r("view");
BOOL LLView::sDebugRects = FALSE;
BOOL LLView::sDebugKeys = FALSE;
@@ -153,6 +162,8 @@ LLView::~LLView()
std::for_each(mFloaterControls.begin(), mFloaterControls.end(),
DeletePairedPointer());
+ std::for_each(mDummyWidgets.begin(), mDummyWidgets.end(),
+ DeletePairedPointer());
}
// virtual
@@ -716,7 +727,7 @@ BOOL LLView::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_scre
tool_tip = getShowNamesToolTip();
}
- BOOL showNamesTextBox = LLUI::sShowXUINames && (getWidgetType() == WIDGET_TYPE_TEXT_BOX);
+ BOOL showNamesTextBox = LLUI::sShowXUINames && dynamic_cast<LLTextBox*>(this) != NULL;
if( !handled && (blockMouseEvent(x, y) || showNamesTextBox) && !tool_tip.empty())
{
@@ -741,23 +752,21 @@ BOOL LLView::handleKey(KEY key, MASK mask, BOOL called_from_parent)
{
BOOL handled = FALSE;
- if( called_from_parent )
+ if (getVisible() && getEnabled())
{
- // Downward traversal
- if (getVisible() && getEnabled())
+ if( called_from_parent )
{
+ // Downward traversal
handled = childrenHandleKey( key, mask ) != NULL;
}
- }
- // JC: Must pass to disabled views, since they could have
- // keyboard focus, which requires the escape key to exit.
- if (!handled && getVisible())
- {
- handled = handleKeyHere( key, mask, called_from_parent );
- if (handled && LLView::sDebugKeys)
+ if (!handled)
{
- llinfos << "Key handled by " << getName() << llendl;
+ handled = handleKeyHere( key, mask );
+ if (handled && LLView::sDebugKeys)
+ {
+ llinfos << "Key handled by " << getName() << llendl;
+ }
}
}
@@ -771,7 +780,7 @@ BOOL LLView::handleKey(KEY key, MASK mask, BOOL called_from_parent)
// Called from handleKey()
// Handles key in this object. Checking parents and children happens in handleKey()
-BOOL LLView::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
+BOOL LLView::handleKeyHere(KEY key, MASK mask)
{
return FALSE;
}
@@ -780,25 +789,24 @@ BOOL LLView::handleUnicodeChar(llwchar uni_char, BOOL called_from_parent)
{
BOOL handled = FALSE;
- if( called_from_parent )
+ if (getVisible() && getEnabled())
{
- // Downward traversal
- if (getVisible() && getEnabled())
+ if( called_from_parent )
{
+ // Downward traversal
handled = childrenHandleUnicodeChar( uni_char ) != NULL;
}
- }
- if (!handled && getVisible())
- {
- handled = handleUnicodeCharHere(uni_char, called_from_parent);
- if (handled && LLView::sDebugKeys)
+ if (!handled)
{
- llinfos << "Unicode key handled by " << getName() << llendl;
+ handled = handleUnicodeCharHere(uni_char);
+ if (handled && LLView::sDebugKeys)
+ {
+ llinfos << "Unicode key handled by " << getName() << llendl;
+ }
}
}
-
if (!handled && !called_from_parent && mParentView)
{
// Upward traversal
@@ -809,7 +817,7 @@ BOOL LLView::handleUnicodeChar(llwchar uni_char, BOOL called_from_parent)
}
-BOOL LLView::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent )
+BOOL LLView::handleUnicodeCharHere(llwchar uni_char )
{
return FALSE;
}
@@ -903,11 +911,14 @@ BOOL LLView::handleMouseDown(S32 x, S32 y, MASK mask)
if (sEditingUI && handled_view)
{
// need to find leaf views, big hack
- EWidgetType type = handled_view->getWidgetType();
- if (type == WIDGET_TYPE_BUTTON
- || type == WIDGET_TYPE_LINE_EDITOR
- || type == WIDGET_TYPE_TEXT_EDITOR
- || type == WIDGET_TYPE_TEXT_BOX)
+ LLButton* buttonp = dynamic_cast<LLButton*>(handled_view);
+ LLLineEditor* line_editorp = dynamic_cast<LLLineEditor*>(handled_view);
+ LLTextEditor* text_editorp = dynamic_cast<LLTextEditor*>(handled_view);
+ LLTextBox* text_boxp = dynamic_cast<LLTextBox*>(handled_view);
+ if (buttonp
+ || line_editorp
+ || text_editorp
+ || text_boxp)
{
sEditingUIView = handled_view;
}
@@ -971,8 +982,10 @@ LLView* LLView::childrenHandleScrollWheel(S32 x, S32 y, S32 clicks)
LLView* viewp = *child_it;
S32 local_x = x - viewp->getRect().mLeft;
S32 local_y = y - viewp->getRect().mBottom;
- if (viewp->pointInView(local_x, local_y) &&
- viewp->handleScrollWheel( local_x, local_y, clicks ))
+ if (viewp->pointInView(local_x, local_y)
+ && viewp->getVisible()
+ && viewp->getEnabled()
+ && viewp->handleScrollWheel( local_x, local_y, clicks ))
{
if (sDebugMouseHandling)
{
@@ -1528,7 +1541,7 @@ BOOL LLView::hasAncestor(const LLView* parentp) const
BOOL LLView::childHasKeyboardFocus( const LLString& childname ) const
{
- LLView *child = getChildByName(childname);
+ LLView *child = getChildView(childname, TRUE, FALSE);
if (child)
{
return gFocusMgr.childHasKeyboardFocus(child);
@@ -1543,16 +1556,17 @@ BOOL LLView::childHasKeyboardFocus( const LLString& childname ) const
BOOL LLView::hasChild(const LLString& childname, BOOL recurse) const
{
- return getChildByName(childname, recurse) != NULL;
+ return getChildView(childname, recurse, FALSE) != NULL;
}
//-----------------------------------------------------------------------------
-// getChildByName()
+// getChildView()
//-----------------------------------------------------------------------------
-LLView* LLView::getChildByName(const LLString& name, BOOL recurse) const
+LLView* LLView::getChildView(const LLString& name, BOOL recurse, BOOL create_if_missing) const
{
- if(name.empty())
- return NULL;
+ //richard: should we allow empty names?
+ //if(name.empty())
+ // return NULL;
child_list_const_iter_t child_it;
// Look for direct children *first*
for ( child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
@@ -1569,13 +1583,18 @@ LLView* LLView::getChildByName(const LLString& name, BOOL recurse) const
for ( child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
{
LLView* childp = *child_it;
- LLView* viewp = childp->getChildByName(name, recurse);
+ LLView* viewp = childp->getChildView(name, recurse, FALSE);
if ( viewp )
{
return viewp;
}
}
}
+
+ if (create_if_missing)
+ {
+ return createDummyWidget<LLView>(name);
+ }
return NULL;
}
@@ -1692,7 +1711,6 @@ BOOL LLView::translateIntoRect(const LLRect& constraint, BOOL allow_partial_outs
if( getRect().mLeft + KEEP_ONSCREEN_PIXELS > constraint.mRight )
{
delta_x = constraint.mRight - (getRect().mLeft + KEEP_ONSCREEN_PIXELS);
- delta_x += llmax( 0, getRect().getWidth() - constraint.getWidth() );
}
if( getRect().mTop > constraint.mTop )
@@ -1703,7 +1721,6 @@ BOOL LLView::translateIntoRect(const LLRect& constraint, BOOL allow_partial_outs
if( getRect().mTop - KEEP_ONSCREEN_PIXELS < constraint.mBottom )
{
delta_y = constraint.mBottom - (getRect().mTop - KEEP_ONSCREEN_PIXELS);
- delta_y -= llmax( 0, getRect().getHeight() - constraint.getHeight() );
}
}
else
@@ -1716,6 +1733,7 @@ BOOL LLView::translateIntoRect(const LLRect& constraint, BOOL allow_partial_outs
if( getRect().mRight > constraint.mRight )
{
delta_x = constraint.mRight - getRect().mRight;
+ // compensate for left edge possible going off screen
delta_x += llmax( 0, getRect().getWidth() - constraint.getWidth() );
}
@@ -1727,6 +1745,7 @@ BOOL LLView::translateIntoRect(const LLRect& constraint, BOOL allow_partial_outs
if( getRect().mBottom < constraint.mBottom )
{
delta_y = constraint.mBottom - getRect().mBottom;
+ // compensate for top edge possible going off screen
delta_y -= llmax( 0, getRect().getHeight() - constraint.getHeight() );
}
}
@@ -1832,9 +1851,8 @@ BOOL LLView::localRectToOtherView( const LLRect& local, LLRect* other, LLView* o
// virtual
LLXMLNodePtr LLView::getXML(bool save_children) const
{
- const LLString& type_name = getWidgetTag();
-
- LLXMLNodePtr node = new LLXMLNode(type_name, FALSE);
+ //FIXME: need to provide actual derived type tag, probably outside this method
+ LLXMLNodePtr node = new LLXMLNode("view", FALSE);
node->createChild("name", TRUE)->setStringValue(getName());
node->createChild("width", TRUE)->setIntValue(getRect().getWidth());
@@ -1897,6 +1915,14 @@ LLXMLNodePtr LLView::getXML(bool save_children) const
return node;
}
+//static
+LLView* LLView::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
+{
+ LLView* viewp = new LLView();
+ viewp->initFromXML(node, parent);
+ return viewp;
+}
+
// static
void LLView::addColorXML(LLXMLNodePtr node, const LLColor4& color,
const LLString& xml_name, const LLString& control_name)
@@ -2871,3 +2897,41 @@ LLSD LLView::getValue() const
{
return LLSD();
}
+
+LLView* LLView::createWidget(LLXMLNodePtr xml_node) const
+{
+ // forward requests to ui ctrl factory
+ return LLUICtrlFactory::getInstance()->createCtrlWidget(NULL, xml_node);
+}
+
+//
+// LLWidgetClassRegistry
+//
+
+LLWidgetClassRegistry::LLWidgetClassRegistry()
+{
+}
+
+void LLWidgetClassRegistry::registerCtrl(const LLString& tag, LLWidgetClassRegistry::factory_func_t function)
+{
+ LLString lower_case_tag = tag;
+ LLString::toLower(lower_case_tag);
+
+ mCreatorFunctions[lower_case_tag] = function;
+}
+
+BOOL LLWidgetClassRegistry::isTagRegistered(const LLString &tag)
+{
+ return mCreatorFunctions.find(tag) != mCreatorFunctions.end();
+}
+
+LLWidgetClassRegistry::factory_func_t LLWidgetClassRegistry::getCreatorFunc(const LLString& ctrl_type)
+{
+ factory_map_t::const_iterator found_it = mCreatorFunctions.find(ctrl_type);
+ if (found_it == mCreatorFunctions.end())
+ {
+ return NULL;
+ }
+ return found_it->second;
+}
+
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index 24a5eb4f89..6c5bcc5470 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -52,7 +52,6 @@
#include "stdenums.h"
#include "lluistring.h"
-
const U32 FOLLOWS_NONE = 0x00;
const U32 FOLLOWS_LEFT = 0x01;
const U32 FOLLOWS_RIGHT = 0x02;
@@ -119,9 +118,7 @@ virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,EDragAndDropTy
*
virtual void draw();
*
-virtual EWidgetType getWidgetType() const = 0;
- *
-virtual LLString getWidgetTag() const = 0;
+
*
virtual LLXMLNodePtr getXML(bool save_children = true) const;
*
@@ -131,7 +128,7 @@ virtual void onFocusLost() {}
LLUICtrl, LLScrollListCtrl, LLMenuGL, LLLineEditor, LLComboBox
virtual void onFocusReceived() {}
LLUICtrl, LLTextEditor, LLScrollListVtrl, LLMenuGL, LLLineEditor
-virtual LLView* getChildByName(const LLString& name, BOOL recurse = FALSE) const;
+virtual LLView* getChildView(const LLString& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const;
LLTabContainer, LLPanel, LLMenuGL
virtual void setControlName(const LLString& control, LLView *context);
LLSliderCtrl, LLCheckBoxCtrl
@@ -143,12 +140,71 @@ virtual void setValue(const LLSD& value);
*
protected:
-virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
+virtual BOOL handleKeyHere(KEY key, MASK mask);
*
-virtual BOOL handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent);
+virtual BOOL handleUnicodeCharHere(llwchar uni_char);
*
*/
+class LLUICtrlFactory;
+
+// maps xml strings to widget classes
+class LLWidgetClassRegistry : public LLSingleton<LLWidgetClassRegistry>
+{
+ friend class LLSingleton<LLWidgetClassRegistry>;
+public:
+ typedef LLView* (*factory_func_t)(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
+ typedef std::map<LLString, factory_func_t> factory_map_t;
+
+ void registerCtrl(const LLString& xml_tag, factory_func_t function);
+ BOOL isTagRegistered(const LLString& xml_tag);
+ factory_func_t getCreatorFunc(const LLString& xml_tag);
+
+ // get (first) xml tag for a given class
+ template <class T> std::string getTag()
+ {
+ factory_map_t::iterator it;
+ for(it = mCreatorFunctions.begin(); it != mCreatorFunctions.end(); ++it)
+ {
+ if (it->second == T::fromXML)
+ {
+ return it->first;
+ }
+ }
+
+ return "";
+ }
+
+private:
+ LLWidgetClassRegistry();
+ virtual ~LLWidgetClassRegistry() {};
+
+ typedef std::set<LLString> ctrl_name_set_t;
+ ctrl_name_set_t mUICtrlNames;
+
+ // map of xml tags to widget creator functions
+ factory_map_t mCreatorFunctions;
+};
+
+template<class T>
+class LLRegisterWidget
+{
+public:
+ LLRegisterWidget(const std::string& tag)
+ {
+ LLWidgetClassRegistry* registry = LLWidgetClassRegistry::getInstance();
+ if (registry->isTagRegistered(tag))
+ {
+ //error!
+ llerrs << "Widget named " << tag << " already registered!" << llendl;
+ }
+ else
+ {
+ registry->registerCtrl(tag, T::fromXML);
+ }
+ }
+};
+
class LLView : public LLMouseHandler, public LLMortician
{
@@ -353,10 +409,9 @@ public:
virtual void draw();
- virtual EWidgetType getWidgetType() const = 0;
- virtual LLString getWidgetTag() const = 0;
virtual LLXMLNodePtr getXML(bool save_children = true) const;
-
+ //FIXME: make LLView non-instantiable from XML
+ static LLView* fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory);
virtual void initFromXML(LLXMLNodePtr node, LLView* parent);
void parseFollowsFlags(LLXMLNodePtr node);
@@ -420,17 +475,74 @@ public:
/*virtual*/ void screenPointToLocal(S32 screen_x, S32 screen_y, S32* local_x, S32* local_y) const;
/*virtual*/ void localPointToScreen(S32 local_x, S32 local_y, S32* screen_x, S32* screen_y) const;
- template <class T> T* getChild(const LLString& name, BOOL recurse = TRUE) const
+ template <class T> T* getChild(const LLString& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const
{
- T* result = dynamic_cast<T*>(getChildByName(name, TRUE));
- //if (!result)
- //{
- // // create dummy widget instance here
- // result = gUICtrlFactory->createDummyWidget<T>(name);
- //}
+ LLView* child = getChildView(name, recurse, FALSE);
+ T* result = dynamic_cast<T*>(child);
+ if (!result)
+ {
+ // did we find *something* with that name?
+ if (child)
+ {
+ llwarns << "Found child named " << name << " but of wrong type" << llendl;
+ }
+ if (create_if_missing)
+ {
+ // create dummy widget instance here
+ result = createDummyWidget<T>(name);
+ }
+ }
return result;
}
+ virtual LLView* getChildView(const LLString& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const;
+
+ template <class T> T* createDummyWidget(const LLString& name) const
+ {
+ T* widget = getDummyWidget<T>(name);
+ if (!widget)
+ {
+ // get xml tag name corresponding to requested widget type (e.g. "button")
+ LLString xml_tag = LLWidgetClassRegistry::getInstance()->getTag<T>();
+ if (xml_tag.empty())
+ {
+ llwarns << "No xml tag registered for this class " << llendl;
+ return NULL;
+ }
+ // create dummy xml node (<button name="foo"/>)
+ LLXMLNodePtr new_node_ptr = new LLXMLNode(xml_tag, FALSE);
+ new_node_ptr->createChild("name", TRUE)->setStringValue(name);
+
+ widget = dynamic_cast<T*>(createWidget(new_node_ptr));
+ if (widget)
+ {
+ // need non-const to update private dummy widget cache
+ llwarns << "Making dummy " << xml_tag << " named " << name << " in " << getName() << llendl;
+ const_cast<LLView*>(this)->mDummyWidgets.insert(std::make_pair(name, widget));
+ }
+ else
+ {
+ // dynamic cast will fail if T::fromXML only registered for base class
+ llwarns << "Failed to create dummy widget of requested type " << llendl;
+ return NULL;
+ }
+ }
+ return widget;
+ }
+
+ template <class T> T* getDummyWidget(const LLString& name) const
+ {
+ dummy_widget_map_t::const_iterator found_it = mDummyWidgets.find(name);
+ if (found_it == mDummyWidgets.end())
+ {
+ return NULL;
+ }
+ return dynamic_cast<T*>(found_it->second);
+ }
+
+ LLView* createWidget(LLXMLNodePtr xml_node) const;
+
+
// statics
static U32 createRect(LLXMLNodePtr node, LLRect &rect, LLView* parent_view, const LLRect &required_rect = LLRect());
@@ -469,8 +581,8 @@ public:
protected:
- virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
- virtual BOOL handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent);
+ virtual BOOL handleKeyHere(KEY key, MASK mask);
+ virtual BOOL handleUnicodeCharHere(llwchar uni_char);
void drawDebugRect();
void drawChild(LLView* childp, S32 x_offset = 0, S32 y_offset = 0, BOOL force_draw = FALSE);
@@ -497,7 +609,6 @@ protected:
typedef std::map<LLString, LLControlVariable*> control_map_t;
control_map_t mFloaterControls;
- virtual LLView* getChildByName(const LLString& name, BOOL recurse = FALSE) const;
private:
LLView* mParentView;
child_list_t mChildList;
@@ -536,6 +647,10 @@ private:
dispatch_list_t mDispatchList;
LLString mControlName;
+
+ typedef std::map<LLString, LLView*> dummy_widget_map_t;
+ dummy_widget_map_t mDummyWidgets;
+
boost::signals::connection mControlConnection;
public:
@@ -552,9 +667,6 @@ public:
static BOOL sForceReshape;
};
-
-
-
class LLCompareByTabOrder
{
public:
@@ -566,4 +678,5 @@ private:
LLView::child_tab_order_t mTabOrder;
};
+
#endif //LL_LLVIEW_H
diff --git a/indra/llui/llviewborder.cpp b/indra/llui/llviewborder.cpp
index 301efa3872..605b7d84bc 100644
--- a/indra/llui/llviewborder.cpp
+++ b/indra/llui/llviewborder.cpp
@@ -33,6 +33,8 @@
#include "llglimmediate.h"
#include "llfocusmgr.h"
+static LLRegisterWidget<LLViewBorder> r("view_border");
+
LLViewBorder::LLViewBorder( const LLString& name, const LLRect& rect, EBevel bevel, EStyle style, S32 width )
:
LLView( name, rect, FALSE ),
@@ -66,47 +68,45 @@ void LLViewBorder::setColorsExtended( const LLColor4& shadow_light, const LLColo
void LLViewBorder::setTexture( const LLUUID &image_id )
{
- mTexture = LLUI::sImageProvider->getImageByID(image_id);
+ mTexture = LLUI::sImageProvider->getUIImageByID(image_id);
}
void LLViewBorder::draw()
{
- if( getVisible() )
+ if( STYLE_LINE == mStyle )
{
- if( STYLE_LINE == mStyle )
+ if( 0 == mBorderWidth )
+ {
+ // no visible border
+ }
+ else
+ if( 1 == mBorderWidth )
+ {
+ drawOnePixelLines();
+ }
+ else
+ if( 2 == mBorderWidth )
{
- if( 0 == mBorderWidth )
- {
- // no visible border
- }
- else
- if( 1 == mBorderWidth )
- {
- drawOnePixelLines();
- }
- else
- if( 2 == mBorderWidth )
- {
- drawTwoPixelLines();
- }
- else
- {
- llassert( FALSE ); // not implemented
- }
+ drawTwoPixelLines();
}
else
- if( STYLE_TEXTURE == mStyle )
{
- if( mTexture )
- {
- drawTextures();
- }
+ llassert( FALSE ); // not implemented
}
+ }
+ else
+ if( STYLE_TEXTURE == mStyle )
+ {
+ if( mTexture )
+ {
+ drawTextures();
+ }
+ }
+
+ // draw the children
+ LLView::draw();
- // draw the children
- LLView::draw();
- }
}
void LLViewBorder::drawOnePixelLines()
@@ -134,11 +134,10 @@ void LLViewBorder::drawOnePixelLines()
if( mHasKeyboardFocus )
{
- F32 lerp_amt = gFocusMgr.getFocusFlashAmt();
top_color = gFocusMgr.getFocusColor();
bottom_color = top_color;
- LLUI::setLineWidth(lerp(1.f, 3.f, lerp_amt));
+ LLUI::setLineWidth(lerp(1.f, 3.f, gFocusMgr.getFocusFlashAmt()));
}
S32 left = 0;
@@ -225,20 +224,20 @@ void LLViewBorder::drawTwoPixelLines()
void LLViewBorder::drawTextures()
{
- LLGLSUIDefault gls_ui;
+ //LLGLSUIDefault gls_ui;
- llassert( FALSE ); // TODO: finish implementing
+ //llassert( FALSE ); // TODO: finish implementing
- gGL.color4fv(UI_VERTEX_COLOR.mV);
+ //gGL.color4fv(UI_VERTEX_COLOR.mV);
- mTexture->bind();
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
+ //mTexture->bind();
+ //glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
+ //glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
- drawTextureTrapezoid( 0.f, mBorderWidth, getRect().getWidth(), 0, 0 );
- drawTextureTrapezoid( 90.f, mBorderWidth, getRect().getHeight(), (F32)getRect().getWidth(),0 );
- drawTextureTrapezoid( 180.f, mBorderWidth, getRect().getWidth(), (F32)getRect().getWidth(),(F32)getRect().getHeight() );
- drawTextureTrapezoid( 270.f, mBorderWidth, getRect().getHeight(), 0, (F32)getRect().getHeight() );
+ //drawTextureTrapezoid( 0.f, mBorderWidth, getRect().getWidth(), 0, 0 );
+ //drawTextureTrapezoid( 90.f, mBorderWidth, getRect().getHeight(), (F32)getRect().getWidth(),0 );
+ //drawTextureTrapezoid( 180.f, mBorderWidth, getRect().getWidth(), (F32)getRect().getWidth(),(F32)getRect().getHeight() );
+ //drawTextureTrapezoid( 270.f, mBorderWidth, getRect().getHeight(), 0, (F32)getRect().getHeight() );
}
diff --git a/indra/llui/llviewborder.h b/indra/llui/llviewborder.h
index d35663c857..3353103e96 100644
--- a/indra/llui/llviewborder.h
+++ b/indra/llui/llviewborder.h
@@ -44,8 +44,6 @@ public:
LLViewBorder( const LLString& name, const LLRect& rect, EBevel bevel = BEVEL_OUT, EStyle style = STYLE_LINE, S32 width = 1 );
virtual void setValue(const LLSD& val) { setRect(LLRect(val)); }
- virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_VIEW_BORDER; }
- virtual LLString getWidgetTag() const { return LL_VIEW_BORDER_TAG; }
virtual BOOL isCtrl() const { return FALSE; }
@@ -85,7 +83,7 @@ private:
LLColor4 mShadowDark;
LLColor4 mBackgroundColor;
S32 mBorderWidth;
- LLPointer<LLImageGL> mTexture;
+ LLUIImagePtr mTexture;
BOOL mHasKeyboardFocus;
};
diff --git a/indra/llui/llviewquery.cpp b/indra/llui/llviewquery.cpp
index dedc9a6ebb..1e33c2e34c 100644
--- a/indra/llui/llviewquery.cpp
+++ b/indra/llui/llviewquery.cpp
@@ -66,11 +66,6 @@ filterResult_t LLCtrlFilter::operator() (const LLView* const view, const viewLis
return filterResult_t(view->isCtrl(),TRUE);
}
-filterResult_t LLWidgetTypeFilter::operator() (const LLView* const view, const viewList_t & children) const
-{
- return filterResult_t(view->getWidgetType() == mType, TRUE);
-}
-
//
// LLViewQuery
//
diff --git a/indra/llui/llviewquery.h b/indra/llui/llviewquery.h
index 59ef1c1896..d9127e310d 100644
--- a/indra/llui/llviewquery.h
+++ b/indra/llui/llviewquery.h
@@ -87,14 +87,14 @@ class LLCtrlFilter : public LLQueryFilter, public LLSingleton<LLCtrlFilter>
/*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const;
};
+template <class T>
class LLWidgetTypeFilter : public LLQueryFilter
{
-public:
- LLWidgetTypeFilter(EWidgetType type) : mType(type) {};
-private:
- /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const;
+ /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const
+ {
+ return filterResult_t(dynamic_cast<const T*>(view) != NULL, TRUE);
+ }
- EWidgetType mType;
};
// Algorithm for flattening