diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 888dc2e6e..daa7de213 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -544,7 +544,7 @@ void LLButton::getOverlayImageSize(S32& overlay_width, S32& overlay_height) // virtual void LLButton::draw() { - F32 alpha = mAlpha; + F32 alpha = mAlpha * getDrawContext().mAlpha; bool flash = FALSE; if( mFlashing ) { diff --git a/indra/llui/lliconctrl.cpp b/indra/llui/lliconctrl.cpp index 1e4a5dcec..889878af1 100644 --- a/indra/llui/lliconctrl.cpp +++ b/indra/llui/lliconctrl.cpp @@ -106,7 +106,8 @@ void LLIconCtrl::draw() { if( mImagep.notNull() ) { - mImagep->draw(getLocalRect(), mColor ); + const F32 alpha = getDrawContext().mAlpha; + mImagep->draw(getLocalRect(), mColor % alpha ); } LLUICtrl::draw(); diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 811de99a9..0e6a22e3e 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -1702,6 +1702,7 @@ void LLLineEditor::drawMisspelled(LLRect background) if (glggHunSpell->getSpellCheckHighlight()) { + F32 alpha = getDrawContext().mAlpha; for (int i =0; i<(int)misspellLocations.size(); i++) { S32 wstart =findPixelNearestPos( misspellLocations[i]-getCursor()); @@ -1716,7 +1717,7 @@ void LLLineEditor::drawMisspelled(LLRect background) { wstart = maxw; } - gGL.color4ub(255,0,0,200); + gGL.color4ub(255,0,0,200*alpha); //3 line zig zags.. while (wstart < wend) { @@ -1733,6 +1734,7 @@ void LLLineEditor::drawMisspelled(LLRect background) void LLLineEditor::draw() { + F32 alpha = getDrawContext().mAlpha; S32 text_len = mText.length(); std::string saved_text; @@ -1776,7 +1778,7 @@ void LLLineEditor::draw() bg_color = mWriteableBgColor; } } - gl_rect_2d(background, bg_color); + gl_rect_2d(background, bg_color % alpha); } #endif @@ -1801,7 +1803,9 @@ void LLLineEditor::draw() { text_color = mReadOnlyFgColor; } - LLColor4 label_color = mTentativeFgColor; + + text_color %= alpha; + LLColor4 label_color = mTentativeFgColor % alpha; if (hasPreeditString()) { @@ -1824,7 +1828,7 @@ void LLLineEditor::draw() background.mBottom + PREEDIT_STANDOUT_POSITION, preedit_pixels_right - PREEDIT_STANDOUT_GAP - 1, background.mBottom + PREEDIT_STANDOUT_POSITION - PREEDIT_STANDOUT_THICKNESS, - (text_color * PREEDIT_STANDOUT_BRIGHTNESS + bg_color * (1 - PREEDIT_STANDOUT_BRIGHTNESS)).setAlpha(1.0f)); + (text_color * PREEDIT_STANDOUT_BRIGHTNESS + bg_color * (1 - PREEDIT_STANDOUT_BRIGHTNESS)).setAlpha(alpha)); } else { @@ -1832,7 +1836,7 @@ void LLLineEditor::draw() background.mBottom + PREEDIT_MARKER_POSITION, preedit_pixels_right - PREEDIT_MARKER_GAP - 1, background.mBottom + PREEDIT_MARKER_POSITION - PREEDIT_MARKER_THICKNESS, - (text_color * PREEDIT_MARKER_BRIGHTNESS + bg_color * (1 - PREEDIT_MARKER_BRIGHTNESS)).setAlpha(1.0f)); + (text_color * PREEDIT_MARKER_BRIGHTNESS + bg_color * (1 - PREEDIT_MARKER_BRIGHTNESS)).setAlpha(alpha)); } } } @@ -1874,7 +1878,7 @@ void LLLineEditor::draw() if( (rendered_pixels_right < (F32)mMaxHPixels) && (rendered_text < text_len) ) { - LLColor4 color(1.f - bg_color.mV[0], 1.f - bg_color.mV[1], 1.f - bg_color.mV[2], 1.f); + LLColor4 color(1.f - bg_color.mV[0], 1.f - bg_color.mV[1], 1.f - bg_color.mV[2], alpha ); // selected middle S32 width = mGLFont->getWidth(mText.getWString().c_str(), mScrollHPos + rendered_text, select_right - mScrollHPos - rendered_text); width = llmin(width, mMaxHPixels - llround(rendered_pixels_right)); @@ -1883,7 +1887,7 @@ void LLLineEditor::draw() rendered_text += mGLFont->render( mText, mScrollHPos + rendered_text, rendered_pixels_right, text_bottom, - LLColor4( 1.f - text_color.mV[0], 1.f - text_color.mV[1], 1.f - text_color.mV[2], 1 ), + LLColor4( 1.f - text_color.mV[0], 1.f - text_color.mV[1], 1.f - text_color.mV[2], alpha ), LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, @@ -1953,7 +1957,7 @@ void LLLineEditor::draw() if (LL_KIM_OVERWRITE == gKeyboard->getInsertMode() && !hasSelection()) { mGLFont->render(mText, getCursor(), (F32)(cursor_left + UI_LINEEDITOR_CURSOR_THICKNESS / 2), text_bottom, - LLColor4( 1.f - text_color.mV[0], 1.f - text_color.mV[1], 1.f - text_color.mV[2], 1 ), + LLColor4( 1.f - text_color.mV[0], 1.f - text_color.mV[1], 1.f - text_color.mV[2], alpha ), LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index 938676225..799441a99 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -286,6 +286,7 @@ BOOL LLTextBox::setTextArg( const std::string& key, const LLStringExplicit& text void LLTextBox::draw() { + F32 alpha = getDrawContext().mAlpha; if (mBorderVisible) { gl_rect_2d_offset_local(getLocalRect(), 2, FALSE); @@ -296,12 +297,12 @@ void LLTextBox::draw() 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); + color_drop_shadow % alpha, drop_shadow_tooltip); } if (mBackgroundVisible) { - gl_rect_2d( getLocalRect(), mBackgroundColor ); + gl_rect_2d( getLocalRect(), mBackgroundColor % alpha ); } S32 text_x = 0; @@ -324,16 +325,16 @@ void LLTextBox::draw() { if(mHasHover) { - drawText( text_x, text_y, mHoverColor ); + drawText( text_x, text_y, mHoverColor % alpha ); } else { - drawText( text_x, text_y, mTextColor ); + drawText( text_x, text_y, mTextColor % alpha ); } } else { - drawText( text_x, text_y, mDisabledColor ); + drawText( text_x, text_y, mDisabledColor % alpha ); } if (sDebugRects) diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 9f7cfa092..6d2ae643a 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -74,6 +74,7 @@ BOOL LLView::sForceReshape = FALSE; LLView* LLView::sEditingUIView = NULL; S32 LLView::sLastLeftXML = S32_MIN; S32 LLView::sLastBottomXML = S32_MIN; +std::vector LLViewDrawContext::sDrawContextStack; LLView::DrilldownFunc LLView::sDrilldown = boost::bind(&LLView::pointInView, _1, _2, _3, HIT_TEST_USE_BOUNDING_RECT); @@ -3014,6 +3015,22 @@ bool LLView::notifyChildren(const LLSD& info) return ret; } +// convenient accessor for draw context +const LLViewDrawContext& LLView::getDrawContext() +{ + return LLViewDrawContext::getCurrentContext(); +} + +const LLViewDrawContext& LLViewDrawContext::getCurrentContext() +{ + static LLViewDrawContext default_context; + + if (sDrawContextStack.empty()) + return default_context; + + return *sDrawContextStack.back(); +} + LLView* LLView::createWidget(LLXMLNodePtr xml_node) const { // forward requests to ui ctrl factory diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 9bc969ea6..b009bab41 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -131,6 +131,35 @@ public: } }; +// maintains render state during traversal of UI tree +class LLViewDrawContext +{ +public: + F32 mAlpha; + + LLViewDrawContext(F32 alpha = 1.f) + : mAlpha(alpha) + { + if (!sDrawContextStack.empty()) + { + LLViewDrawContext* context_top = sDrawContextStack.back(); + // merge with top of stack + mAlpha *= context_top->mAlpha; + } + sDrawContextStack.push_back(this); + } + + ~LLViewDrawContext() + { + sDrawContextStack.pop_back(); + } + + static const LLViewDrawContext& getCurrentContext(); + +private: + static std::vector sDrawContextStack; +}; + class LLView : public LLMouseHandler, // handles mouse events public LLFocusableElement, // handles keyboard events @@ -635,6 +664,9 @@ public: //send custom notification to current view virtual S32 notify(const LLSD& info) { return 0;}; + + static const LLViewDrawContext& getDrawContext(); + protected: void drawDebugRect(); void drawChild(LLView* childp, S32 x_offset = 0, S32 y_offset = 0, BOOL force_draw = FALSE); diff --git a/indra/llui/llviewborder.cpp b/indra/llui/llviewborder.cpp index cd2987fe8..2fdd7dac0 100644 --- a/indra/llui/llviewborder.cpp +++ b/indra/llui/llviewborder.cpp @@ -104,6 +104,8 @@ void LLViewBorder::draw() void LLViewBorder::drawOnePixelLines() { + F32 alpha = getDrawContext().mAlpha; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLColor4 top_color = mHighlightLight; @@ -138,6 +140,9 @@ void LLViewBorder::drawOnePixelLines() S32 right = getRect().getWidth(); S32 bottom = 0; + top_color %= alpha; + bottom_color %= alpha; + gGL.color4fv( top_color.mV ); gl_line_2d(left, bottom, left, top); gl_line_2d(left, top, right, top); diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp index b57c3fdcb..3ebc38710 100644 --- a/indra/newview/llpanelprimmediacontrols.cpp +++ b/indra/newview/llpanelprimmediacontrols.cpp @@ -730,7 +730,7 @@ void LLPanelPrimMediaControls::draw() } } - F32 alpha = 1.f; + F32 alpha = getDrawContext().mAlpha; if(mHideImmediately) { //hide this panel @@ -781,7 +781,7 @@ void LLPanelPrimMediaControls::draw() } { - //LLViewDrawContext context(alpha); + LLViewDrawContext context(alpha); LLPanel::draw(); } }