F32 LLUICtrl::getCurrentTransparency() { F32 alpha = 0; switch(mTransparencyType) { case TT_DEFAULT: alpha = getDrawContext().mAlpha; break; case TT_ACTIVE: alpha = sActiveControlTransparency; break; case TT_INACTIVE: alpha = sInactiveControlTransparency; break; case TT_FADING: alpha = sInactiveControlTransparency / 2.f; break; } return alpha; }
void LLIconCtrl::draw() { if( mImagep.notNull() ) { mImagep->draw(getLocalRect(), mColor.get() % getDrawContext().mAlpha ); } LLUICtrl::draw(); }
void LLSlider::draw() { F32 alpha = getDrawContext().mAlpha; // since thumb image might still be decoding, need thumb to accomodate image size updateThumbRect(); // Draw background and thumb. // drawing solids requires texturing be disabled gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // 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, LLColor4::white % alpha); mTrackHighlightImage->draw(highlight_rect, LLColor4::white % alpha); // Thumb if (hasFocus()) { // Draw focus highlighting. mThumbImage->drawBorder(mThumbRect, gFocusMgr.getFocusColor() % alpha, gFocusMgr.getFocusFlashWidth()); } if( hasMouseCapture() ) { // Show ghost where thumb was before dragging began. if (mThumbImage.notNull()) { mThumbImage->draw(mDragStartThumbRect, mThumbCenterColor % (0.3f * alpha)); mThumbImage->draw(mThumbRect, mThumbOutlineColor % alpha); } } else if(!getEnabled()) { if (mThumbImage.notNull()) { mThumbImage->draw(mThumbRect, mThumbCenterColor % (0.3f * alpha)); } } else { if (mThumbImage.notNull()) { mThumbImage->draw(mThumbRect, mThumbCenterColor % alpha); } } // Fill in the thumb. LLUICtrl::draw(); }
void LLIconCtrl::draw() { if( mImagep.notNull() ) { const F32 alpha = getDrawContext().mAlpha; mImagep->draw(getLocalRect(), mColor % alpha ); } LLUICtrl::draw(); }
void LLIconCtrl::draw() { if( mImagep.notNull() ) { const F32 alpha = mUseDrawContextAlpha ? getDrawContext().mAlpha : getCurrentTransparency(); mImagep->draw(getLocalRect(), mColor.get() % alpha ); } LLUICtrl::draw(); }
void LLViewBorder::drawOnePixelLines() { F32 alpha = getDrawContext().mAlpha; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLColor4 top_color = mHighlightLight; LLColor4 bottom_color = mHighlightLight; switch( mBevel ) { case BEVEL_OUT: top_color = mHighlightLight; bottom_color = mShadowDark; break; case BEVEL_IN: top_color = mShadowDark; bottom_color = mHighlightLight; break; case BEVEL_NONE: // use defaults break; default: llassert(0); } if( mHasKeyboardFocus ) { top_color = gFocusMgr.getFocusColor(); bottom_color = top_color; LLUI::setLineWidth(lerp(1.f, 3.f, gFocusMgr.getFocusFlashAmt())); } S32 left = 0; S32 top = getRect().getHeight(); 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); gGL.color4fv( bottom_color.mV ); gl_line_2d(right, top, right, bottom); gl_line_2d(left, bottom, right, bottom); LLUI::setLineWidth(1.f); }
void LLProgressBar::draw() { static LLTimer timer; F32 alpha = getDrawContext().mAlpha; LLColor4 image_bar_color = mColorBackground.get(); image_bar_color.setAlpha(alpha); mImageBar->draw(getLocalRect(), image_bar_color); alpha *= 0.5f + 0.5f*0.5f*(1.f + (F32)sin(3.f*timer.getElapsedTimeF32())); LLColor4 bar_color = mColorBar.get(); bar_color.mV[VALPHA] *= alpha; // modulate alpha LLRect progress_rect = getLocalRect(); progress_rect.mRight = llround(getRect().getWidth() * (mPercentDone / 100.f)); mImageFill->draw(progress_rect, bar_color); }
void LLLoadingIndicator::draw() { // Time to switch to the next image? if (mImageSwitchTimer.getStarted() && mImageSwitchTimer.hasExpired()) { // Switch to the next image. mCurImagep = Data::instance().getNextImage(mCurImageIdx); // Restart timer. start(); } // Draw current image. if( mCurImagep.notNull() ) { mCurImagep->draw(getLocalRect(), LLColor4::white % getDrawContext().mAlpha); } LLUICtrl::draw(); }
void LLPanel::draw() { F32 alpha = getDrawContext().mAlpha; // draw background if( mBgVisible ) { alpha = getCurrentTransparency(); LLRect local_rect = getLocalRect(); if (mBgOpaque ) { // opaque, in-front look if (mBgOpaqueImage.notNull()) { mBgOpaqueImage->draw( local_rect, mBgOpaqueImageOverlay % alpha ); } else { // fallback to flat colors when there are no images gl_rect_2d( local_rect, mBgOpaqueColor.get() % alpha); } } else { // transparent, in-back look if (mBgAlphaImage.notNull()) { mBgAlphaImage->draw( local_rect, mBgAlphaImageOverlay % alpha ); } else { gl_rect_2d( local_rect, mBgAlphaColor.get() % alpha ); } } } updateDefaultBtn(); LLView::draw(); }
/*virtual*/ void LLPanelPrimMediaControls::draw() { F32 alpha = getDrawContext().mAlpha; if(mFadeTimer.getStarted()) { F32 time = mFadeTimer.getElapsedTimeF32(); alpha *= llmax(lerp(1.0, 0.0, time / mControlFadeTime), 0.0f); if(time >= mControlFadeTime) { if(mClearFaceOnFade) { // Hiding this object makes scroll events go missing after it fades out // (see DEV-41755 for a full description of the train wreck). // Only hide the controls when we're untargeting. setVisible(FALSE); mClearFaceOnFade = false; mVolumeSliderVisible = 0; mTargetImplID = LLUUID::null; mTargetObjectID = LLUUID::null; mTargetObjectFace = 0; } } } // Build rect for icon area in coord system of this panel // Assumes layout_stack is a direct child of this panel mMediaControlsStack->updateLayout(); // adjust for layout stack spacing S32 space = mMediaControlsStack->getPanelSpacing() + 2; LLRect controls_bg_area = mMediaControlsStack->getRect(); controls_bg_area.mTop += space + 2; // adjust to ignore space from volume slider controls_bg_area.mBottom += mVolumeSliderCtrl->getRect().getHeight(); // adjust to ignore space from left bookend padding controls_bg_area.mLeft += mLeftBookend->getRect().getWidth() - space; // ignore space from right bookend padding controls_bg_area.mRight -= mRightBookend->getRect().getWidth() - space - 2; // draw control background UI image mBackgroundImage->draw( controls_bg_area, UI_VERTEX_COLOR % alpha); // draw volume slider background UI image if (mVolumeSliderCtrl->getVisible()) { LLRect volume_slider_rect; screenRectToLocal(mVolumeSliderCtrl->calcScreenRect(), &volume_slider_rect); mVolumeSliderBackgroundImage->draw(volume_slider_rect, UI_VERTEX_COLOR % alpha); } { LLViewDrawContext context(alpha); LLPanel::draw(); } }
// virtual void LLButton::draw() { F32 alpha = getDrawContext().mAlpha; bool flash = FALSE; static LLUICachedControl<F32> button_flash_rate("ButtonFlashRate", 0); static LLUICachedControl<S32> button_flash_count("ButtonFlashCount", 0); if( mFlashing ) { F32 elapsed = mFlashingTimer.getElapsedTimeF32(); S32 flash_count = S32(elapsed * button_flash_rate * 2.f); // flash on or off? flash = (flash_count % 2 == 0) || flash_count > S32((F32)button_flash_count * 2.f); } bool pressed_by_keyboard = FALSE; if (hasFocus()) { pressed_by_keyboard = gKeyboard->getKeyDown(' ') || (mCommitOnReturn && gKeyboard->getKeyDown(KEY_RETURN)); } // Unselected image assignments bool enabled = isInEnabledChain(); bool pressed = pressed_by_keyboard || (hasMouseCapture() && mMouseOver) || mForcePressedState; bool selected = getToggleState(); bool use_glow_effect = FALSE; LLColor4 glow_color = LLColor4::white; LLRender::eBlendType glow_type = LLRender::BT_ADD_WITH_ALPHA; LLUIImage* imagep = NULL; if (pressed) { imagep = selected ? mImagePressedSelected : mImagePressed; } else if ( mNeedsHighlight ) { if (selected) { if (mImageHoverSelected) { imagep = mImageHoverSelected; } else { imagep = mImageSelected; use_glow_effect = TRUE; } } else { if (mImageHoverUnselected) { imagep = mImageHoverUnselected; } else { imagep = mImageUnselected; use_glow_effect = TRUE; } } } else { imagep = selected ? mImageSelected : 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() && ( (enabled && getTentative()) || (!enabled && selected ) ) ) { imagep = mImageDisabledSelected; } else if (!mImageDisabled.isNull() && !enabled && !selected) { imagep = mImageDisabled; } if (mFlashing) { // if button should flash and we have icon for flashing, use it as image for button if(flash && mImageFlash) { // setting flash to false to avoid its further influence on glow flash = false; imagep = mImageFlash; } // else use usual flashing via flash_color else { LLColor4 flash_color = mFlashBgColor.get(); use_glow_effect = TRUE; glow_type = LLRender::BT_ALPHA; // blend the glow if (mNeedsHighlight) // highlighted AND flashing glow_color = (glow_color*0.5f + flash_color*0.5f) % 2.0f; // average between flash and highlight colour, with sum of the opacity else glow_color = flash_color; } } if (mNeedsHighlight && !imagep) { use_glow_effect = TRUE; } // Figure out appropriate color for the text LLColor4 label_color; // label changes when button state changes, not when pressed if ( enabled ) { if ( getToggleState() ) { label_color = mSelectedLabelColor.get(); } else { label_color = mUnselectedLabelColor.get(); } } else { if ( getToggleState() ) { label_color = mDisabledSelectedLabelColor.get(); } else { label_color = mDisabledLabelColor.get(); } } // Unselected label assignments LLWString label; if( getToggleState() ) { label = mSelectedLabel; } else { label = mUnselectedLabel; } // overlay with keyboard focus border if (hasFocus()) { F32 lerp_amt = gFocusMgr.getFocusFlashAmt(); drawBorder(imagep, gFocusMgr.getFocusColor() % alpha, llround(lerp(1.f, 3.f, lerp_amt))); } if (use_glow_effect) { mCurGlowStrength = lerp(mCurGlowStrength, mFlashing ? (flash? 1.0 : 0.0) : 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 (imagep != NULL) { // apply automatic 50% alpha fade to disabled image LLColor4 disabled_color = mFadeWhenDisabled ? mDisabledImageColor.get() % 0.5f : mDisabledImageColor.get(); if ( mScaleImage) { imagep->draw(getLocalRect(), (enabled ? mImageColor.get() : disabled_color) % alpha ); if (mCurGlowStrength > 0.01f) { gGL.setSceneBlendType(glow_type); imagep->drawSolid(0, 0, getRect().getWidth(), getRect().getHeight(), glow_color % (mCurGlowStrength * alpha)); gGL.setSceneBlendType(LLRender::BT_ALPHA); } } else { imagep->draw(0, 0, (enabled ? mImageColor.get() : disabled_color) % alpha ); if (mCurGlowStrength > 0.01f) { gGL.setSceneBlendType(glow_type); imagep->drawSolid(0, 0, glow_color % (mCurGlowStrength * alpha)); gGL.setSceneBlendType(LLRender::BT_ALPHA); } } } else { // no image lldebugs << "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 % alpha, 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(); 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); S32 center_x = getLocalRect().getCenterX(); S32 center_y = getLocalRect().getCenterY(); //FUGLY HACK FOR "DEPRESSED" BUTTONS if (pressed) { center_y--; center_x++; } center_y += (mImageOverlayBottomPad - mImageOverlayTopPad); // fade out overlay images on disabled buttons LLColor4 overlay_color = mImageOverlayColor.get(); if (!enabled) { overlay_color.mV[VALPHA] = 0.5f; } overlay_color.mV[VALPHA] *= alpha; switch(mImageOverlayAlignment) { case LLFontGL::LEFT: text_left += overlay_width + mImgOverlayLabelSpace; 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 + mImgOverlayLabelSpace; mImageOverlay->draw( getRect().getWidth() - mRightHPad - overlay_width, center_y - (overlay_height / 2), overlay_width, overlay_height, overlay_color); break; default: // draw nothing break; } } // Draw label if( !label.empty() ) { LLWStringUtil::trim(label); S32 x; switch( mHAlign ) { case LLFontGL::RIGHT: x = text_right; break; case LLFontGL::HCENTER: x = text_left + (text_width / 2); break; case LLFontGL::LEFT: default: x = text_left; break; } S32 y_offset = 2 + (getRect().getHeight() - 20)/2; if (pressed) { y_offset--; x++; } // *NOTE: mantipov: before mUseEllipses is implemented in EXT-279 U32_MAX has been passed as // max_chars. // LLFontGL::render expects S32 max_chars variable but process in a separate way -1 value. // Due to U32_MAX is equal to S32 -1 value I have rest this value for non-ellipses mode. // Not sure if it is really needed. Probably S32_MAX should be always passed as max_chars. mLastDrawCharsCount = mGLFont->render(label, 0, (F32)x, (F32)(mBottomVPad + y_offset), label_color % alpha, mHAlign, LLFontGL::BOTTOM, LLFontGL::NORMAL, mDropShadowedText ? LLFontGL::DROP_SHADOW_SOFT : LLFontGL::NO_SHADOW, S32_MAX, text_width, NULL, mUseEllipses); } LLUICtrl::draw(); }
/*virtual*/ void LLPanelPrimMediaControls::draw() { LLViewerMediaImpl* impl = getTargetMediaImpl(); if (impl) { LLNotificationPtr notification = impl->getCurrentNotification(); if (notification != mActiveNotification) { mActiveNotification = notification; if (notification) { showNotification(notification); } else { hideNotification(); } } } F32 alpha = getDrawContext().mAlpha; if(mHideImmediately) { //hide this panel clearFaceOnFade(); mHideImmediately = false; } else if(mFadeTimer.getStarted()) { F32 time = mFadeTimer.getElapsedTimeF32(); alpha *= llmax(lerp(1.0, 0.0, time / mControlFadeTime), 0.0f); if(time >= mControlFadeTime) { //hide this panel clearFaceOnFade(); } } // Build rect for icon area in coord system of this panel // Assumes layout_stack is a direct child of this panel mMediaControlsStack->updateLayout(); // adjust for layout stack spacing S32 space = mMediaControlsStack->getPanelSpacing() + 2; LLRect controls_bg_area = mMediaControlsStack->getRect(); controls_bg_area.mTop += space + 2; // adjust to ignore space from volume slider controls_bg_area.mBottom += mVolumeSliderCtrl->getRect().getHeight(); // adjust to ignore space from left bookend padding controls_bg_area.mLeft += mLeftBookend->getRect().getWidth() - space; // ignore space from right bookend padding controls_bg_area.mRight -= mRightBookend->getRect().getWidth() - space - 2; // draw control background UI image mBackgroundImage->draw( controls_bg_area, UI_VERTEX_COLOR % alpha); // draw volume slider background UI image if (mVolumeSliderCtrl->getVisible()) { LLRect volume_slider_rect; screenRectToLocal(mVolumeSliderCtrl->calcScreenRect(), &volume_slider_rect); mVolumeSliderBackgroundImage->draw(volume_slider_rect, UI_VERTEX_COLOR % alpha); } { LLViewDrawContext context(alpha); LLPanel::draw(); } }
// virtual void LLButton::draw() { static LLCachedControl<bool> sEnableButtonFlashing(*LLUI::sSettingGroups["config"], "EnableButtonFlashing", true); F32 alpha = mUseDrawContextAlpha ? getDrawContext().mAlpha : getCurrentTransparency(); bool pressed_by_keyboard = FALSE; if (hasFocus()) { pressed_by_keyboard = gKeyboard->getKeyDown(' ') || (mCommitOnReturn && gKeyboard->getKeyDown(KEY_RETURN)); } bool mouse_pressed_and_over = false; if (hasMouseCapture()) { S32 local_mouse_x ; S32 local_mouse_y; LLUI::getMousePositionLocal(this, &local_mouse_x, &local_mouse_y); mouse_pressed_and_over = pointInView(local_mouse_x, local_mouse_y); } bool enabled = isInEnabledChain(); bool pressed = pressed_by_keyboard || mouse_pressed_and_over || mForcePressedState; bool selected = getToggleState(); bool use_glow_effect = FALSE; LLColor4 highlighting_color = LLColor4::white; LLColor4 glow_color = LLColor4::white; LLRender::eBlendType glow_type = LLRender::BT_ADD_WITH_ALPHA; LLUIImage* imagep = NULL; // Cancel sticking of color, if the button is pressed, // or when a flashing of the previously selected button is ended if (mFlashingTimer && ((selected && !mFlashingTimer->isFlashingInProgress() && !mForceFlashing) || pressed)) { mFlashing = false; } bool flash = mFlashing && sEnableButtonFlashing; if (pressed && mDisplayPressedState) { imagep = selected ? mImagePressedSelected : mImagePressed; } else if ( mNeedsHighlight ) { if (selected) { if (mImageHoverSelected) { imagep = mImageHoverSelected; } else { imagep = mImageSelected; use_glow_effect = TRUE; } } else { if (mImageHoverUnselected) { imagep = mImageHoverUnselected; } else { imagep = mImageUnselected; use_glow_effect = TRUE; } } } else { imagep = selected ? mImageSelected : 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() && ( (enabled && getTentative()) || (!enabled && selected ) ) ) { imagep = mImageDisabledSelected; } else if (!mImageDisabled.isNull() && !enabled && !selected) { imagep = mImageDisabled; } if (mFlashing) { // if button should flash and we have icon for flashing, use it as image for button if(flash && mImageFlash) { // setting flash to false to avoid its further influence on glow flash = false; imagep = mImageFlash; } // else use usual flashing via flash_color else if (mFlashingTimer) { LLColor4 flash_color = mFlashBgColor.get(); use_glow_effect = TRUE; glow_type = LLRender::BT_ALPHA; // blend the glow if (mFlashingTimer->isCurrentlyHighlighted() || !mFlashingTimer->isFlashingInProgress()) { glow_color = flash_color; } else if (mNeedsHighlight) { glow_color = highlighting_color; } } } if (mNeedsHighlight && !imagep) { use_glow_effect = TRUE; } // Figure out appropriate color for the text LLColor4 label_color; // label changes when button state changes, not when pressed if ( enabled ) { if ( getToggleState() ) { label_color = mSelectedLabelColor.get(); } else { label_color = mUnselectedLabelColor.get(); } } else { if ( getToggleState() ) { label_color = mDisabledSelectedLabelColor.get(); } else { label_color = mDisabledLabelColor.get(); } } // <FS::ND> Highlight if needed if( nd::ui::SearchableControl::getHighlighted() ) label_color = nd::ui::SearchableControl::getHighlightColor(); // </FS:ND> // Unselected label assignments LLWString label = getCurrentLabel(); // overlay with keyboard focus border if (hasFocus()) { F32 lerp_amt = gFocusMgr.getFocusFlashAmt(); drawBorder(imagep, gFocusMgr.getFocusColor() % alpha, ll_round(lerp(1.f, 3.f, lerp_amt))); } if (use_glow_effect) { mCurGlowStrength = lerp(mCurGlowStrength, // <FS:Ansariel> Crash fix; Calling setFlashing can cause mFlashing being true while is mFlashingTimer is NULL //mFlashing ? (mFlashingTimer->isCurrentlyHighlighted() || !mFlashingTimer->isFlashingInProgress() || mNeedsHighlight? 1.0 : 0.0) : mHoverGlowStrength, (mFlashing && mFlashingTimer) ? (mFlashingTimer->isCurrentlyHighlighted() || !mFlashingTimer->isFlashingInProgress() || mNeedsHighlight? 1.0 : 0.0) : mHoverGlowStrength, LLSmoothInterpolation::getInterpolant(0.05f)); } else { mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLSmoothInterpolation::getInterpolant(0.05f)); } // Draw button image, if available. // Otherwise draw basic rectangular button. if (imagep != NULL) { // apply automatic 50% alpha fade to disabled image LLColor4 disabled_color = mFadeWhenDisabled ? mDisabledImageColor.get() % 0.5f : mDisabledImageColor.get(); if ( mScaleImage) { imagep->draw(getLocalRect(), (enabled ? mImageColor.get() : disabled_color) % alpha ); if (mCurGlowStrength > 0.01f) { gGL.setSceneBlendType(glow_type); imagep->drawSolid(0, 0, getRect().getWidth(), getRect().getHeight(), glow_color % (mCurGlowStrength * alpha)); gGL.setSceneBlendType(LLRender::BT_ALPHA); } } else { imagep->draw(0, 0, (enabled ? mImageColor.get() : disabled_color) % alpha ); if (mCurGlowStrength > 0.01f) { gGL.setSceneBlendType(glow_type); imagep->drawSolid(0, 0, glow_color % (mCurGlowStrength * alpha)); gGL.setSceneBlendType(LLRender::BT_ALPHA); } } } else { // no image LL_DEBUGS() << "No image for button " << getName() << LL_ENDL; // draw it in pink so we can find it gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4::pink1 % alpha, 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; S32 overlay_height; getOverlayImageSize(overlay_width, overlay_height); S32 center_x = getLocalRect().getCenterX(); S32 center_y = getLocalRect().getCenterY(); //FUGLY HACK FOR "DEPRESSED" BUTTONS if (pressed && mDisplayPressedState) { center_y--; center_x++; } center_y += (mImageOverlayBottomPad - mImageOverlayTopPad); // fade out overlay images on disabled buttons LLColor4 overlay_color = mImageOverlayColor.get(); if (!enabled) { overlay_color = mImageOverlayDisabledColor.get(); } else if (getToggleState()) { overlay_color = mImageOverlaySelectedColor.get(); } overlay_color.mV[VALPHA] *= alpha; switch(mImageOverlayAlignment) { case LLFontGL::LEFT: text_left += overlay_width + mImgOverlayLabelSpace; text_width -= overlay_width + mImgOverlayLabelSpace; 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 + mImgOverlayLabelSpace; text_width -= overlay_width + mImgOverlayLabelSpace; mImageOverlay->draw( getRect().getWidth() - mRightHPad - overlay_width, center_y - (overlay_height / 2), overlay_width, overlay_height, overlay_color); break; default: // draw nothing break; } } // Draw label if( !label.empty() ) { LLWStringUtil::trim(label); S32 x; switch( mHAlign ) { case LLFontGL::RIGHT: x = text_right; break; case LLFontGL::HCENTER: x = text_left + (text_width / 2); break; case LLFontGL::LEFT: default: x = text_left; break; } S32 y_offset = 2 + (getRect().getHeight() - 20)/2; if (pressed && mDisplayPressedState) { y_offset--; x++; } // *NOTE: mantipov: before mUseEllipses is implemented in EXT-279 U32_MAX has been passed as // max_chars. // LLFontGL::render expects S32 max_chars variable but process in a separate way -1 value. // Due to U32_MAX is equal to S32 -1 value I have rest this value for non-ellipses mode. // Not sure if it is really needed. Probably S32_MAX should be always passed as max_chars. mLastDrawCharsCount = mGLFont->render(label, 0, (F32)x, (F32)(getRect().getHeight() / 2 + mBottomVPad), label_color % alpha, mHAlign, LLFontGL::VCENTER, LLFontGL::NORMAL, mDropShadowedText ? LLFontGL::DROP_SHADOW_SOFT : LLFontGL::NO_SHADOW, S32_MAX, text_width, NULL, mUseEllipses); } // <FS:Zi> Add checkbox control toggle if(mCheckboxControlPanel) { mCheckboxControlPanel->setOrigin(0,0); mCheckboxControlPanel->reshape(getRect().getWidth(),getRect().getHeight()); mCheckboxControlPanel->draw(); } // <FS:Zi> LLUICtrl::draw(); }
void LLMediaCtrl::draw() { F32 alpha = getDrawContext().mAlpha; if ( gRestoreGL == 1 ) { LLRect r = getRect(); reshape( r.getWidth(), r.getHeight(), FALSE ); return; } // NOTE: optimization needed here - probably only need to do this once // unless tearoffs change the parent which they probably do. const LLUICtrl* ptr = findRootMostFocusRoot(); if ( ptr && ptr->hasFocus() ) { setFrequentUpdates( true ); } else { setFrequentUpdates( false ); }; bool draw_media = false; LLPluginClassMedia* media_plugin = NULL; LLViewerMediaTexture* media_texture = NULL; if(mMediaSource && mMediaSource->hasMedia()) { media_plugin = mMediaSource->getMediaPlugin(); if(media_plugin && (media_plugin->textureValid())) { media_texture = LLViewerTextureManager::findMediaTexture(mMediaTextureID); if(media_texture) { draw_media = true; } } } bool background_visible = isBackgroundVisible(); bool background_opaque = isBackgroundOpaque(); if(draw_media) { gGL.pushUIMatrix(); { mMediaSource->setPageZoomFactor( LLUI::getScaleFactor().mV[ VX ] ); // scale texture to fit the space using texture coords gGL.getTexUnit(0)->bind(media_texture); LLColor4 media_color = LLColor4::white % alpha; gGL.color4fv( media_color.mV ); F32 max_u = ( F32 )media_plugin->getWidth() / ( F32 )media_plugin->getTextureWidth(); F32 max_v = ( F32 )media_plugin->getHeight() / ( F32 )media_plugin->getTextureHeight(); LLRect r = getRect(); S32 width, height; S32 x_offset = 0; S32 y_offset = 0; if(mStretchToFill) { if(mMaintainAspectRatio) { F32 media_aspect = (F32)(media_plugin->getWidth()) / (F32)(media_plugin->getHeight()); F32 view_aspect = (F32)(r.getWidth()) / (F32)(r.getHeight()); if(media_aspect > view_aspect) { // max width, adjusted height width = r.getWidth(); height = llmin(llmax(llround(width / media_aspect), 0), r.getHeight()); } else { // max height, adjusted width height = r.getHeight(); width = llmin(llmax(llround(height * media_aspect), 0), r.getWidth()); } } else { width = r.getWidth(); height = r.getHeight(); } } else { width = llmin(media_plugin->getWidth(), r.getWidth()); height = llmin(media_plugin->getHeight(), r.getHeight()); } x_offset = (r.getWidth() - width) / 2; y_offset = (r.getHeight() - height) / 2; // draw the browser gGL.begin( LLRender::QUADS ); if (! media_plugin->getTextureCoordsOpenGL()) { // render using web browser reported width and height, instead of trying to invert GL scale gGL.texCoord2f( max_u, 0.f ); gGL.vertex2i( x_offset + width, y_offset + height ); gGL.texCoord2f( 0.f, 0.f ); gGL.vertex2i( x_offset, y_offset + height ); gGL.texCoord2f( 0.f, max_v ); gGL.vertex2i( x_offset, y_offset ); gGL.texCoord2f( max_u, max_v ); gGL.vertex2i( x_offset + width, y_offset ); } else { // render using web browser reported width and height, instead of trying to invert GL scale gGL.texCoord2f( max_u, max_v ); gGL.vertex2i( x_offset + width, y_offset + height ); gGL.texCoord2f( 0.f, max_v ); gGL.vertex2i( x_offset, y_offset + height ); gGL.texCoord2f( 0.f, 0.f ); gGL.vertex2i( x_offset, y_offset ); gGL.texCoord2f( max_u, 0.f ); gGL.vertex2i( x_offset + width, y_offset ); } gGL.end(); } gGL.popUIMatrix(); } else { // Setting these will make LLPanel::draw draw the opaque background color. setBackgroundVisible(true); setBackgroundOpaque(true); } // highlight if keyboard focus here. (TODO: this needs some work) if ( mBorder && mBorder->getVisible() ) mBorder->setKeyboardFocusHighlight( gFocusMgr.childHasKeyboardFocus( this ) ); LLPanel::draw(); // Restore the previous values setBackgroundVisible(background_visible); setBackgroundOpaque(background_opaque); }
void LLSlider::draw() { F32 alpha = getDrawContext().mAlpha; // since thumb image might still be decoding, need thumb to accomodate image size updateThumbRect(); // Draw background and thumb. // drawing solids requires texturing be disabled gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // Track LLPointer<LLUIImage>& trackImage = ( mOrientation == HORIZONTAL ) ? mTrackImageHorizontal : mTrackImageVertical; LLPointer<LLUIImage>& trackHighlightImage = ( mOrientation == HORIZONTAL ) ? mTrackHighlightHorizontalImage : mTrackHighlightVerticalImage; LLRect track_rect; LLRect highlight_rect; if ( mOrientation == HORIZONTAL ) { track_rect.set(mThumbImage->getWidth() / 2, getLocalRect().getCenterY() + (trackImage->getHeight() / 2), getRect().getWidth() - mThumbImage->getWidth() / 2, getLocalRect().getCenterY() - (trackImage->getHeight() / 2) ); highlight_rect.set(track_rect.mLeft, track_rect.mTop, mThumbRect.getCenterX(), track_rect.mBottom); } else { track_rect.set(getLocalRect().getCenterX() - (trackImage->getWidth() / 2), getRect().getHeight(), getLocalRect().getCenterX() + (trackImage->getWidth() / 2), 0); highlight_rect.set(track_rect.mLeft, track_rect.mTop, track_rect.mRight, track_rect.mBottom); } trackImage->draw(track_rect, LLColor4::white % alpha); trackHighlightImage->draw(highlight_rect, LLColor4::white % alpha); // Thumb if (hasFocus()) { // Draw focus highlighting. mThumbImage->drawBorder(mThumbRect, gFocusMgr.getFocusColor() % alpha, gFocusMgr.getFocusFlashWidth()); } if( hasMouseCapture() ) // currently clicking on slider { // Show ghost where thumb was before dragging began. if (mThumbImage.notNull()) { mThumbImage->draw(mDragStartThumbRect, mThumbCenterColor.get() % (0.3f * alpha)); } if (mThumbImagePressed.notNull()) { mThumbImagePressed->draw(mThumbRect, mThumbOutlineColor % alpha); } } else if (!isInEnabledChain()) { if (mThumbImageDisabled.notNull()) { mThumbImageDisabled->draw(mThumbRect, mThumbCenterColor % alpha); } } else { if (mThumbImage.notNull()) { mThumbImage->draw(mThumbRect, mThumbCenterColor % alpha); } } LLUICtrl::draw(); }
/*virtual*/ void LLPanelPrimMediaControls::draw() { LLViewerMediaImpl* impl = getTargetMediaImpl(); if (impl) { LLNotificationPtr notification = impl->getCurrentNotification(); if (notification != mActiveNotification) { mActiveNotification = notification; if (notification) { showNotification(notification); } else { hideNotification(); } } } F32 alpha = getDrawContext().mAlpha; if(mHideImmediately) { //hide this panel clearFaceOnFade(); mHideImmediately = false; } else if(mFadeTimer.getStarted()) { F32 time = mFadeTimer.getElapsedTimeF32(); alpha *= llmax(lerp(1.0, 0.0, time / mControlFadeTime), 0.0f); if(time >= mControlFadeTime) { //hide this panel clearFaceOnFade(); } } // Show/hide the lock icon for secure browsing mSecureLockIcon->setVisible(mSecureURL && !mMediaAddress->hasFocus()); // Build rect for icon area in coord system of this panel // Assumes layout_stack is a direct child of this panel mMediaControlsStack->updateLayout(); // adjust for layout stack spacing S32 space = mMediaControlsStack->getPanelSpacing() + 2; LLRect controls_bg_area = mMediaControlsStack->getRect(); controls_bg_area.mTop += space + 2; // adjust to ignore space from volume slider controls_bg_area.mBottom += mVolumeSliderCtrl->getRect().getHeight(); // adjust to ignore space from left bookend padding controls_bg_area.mLeft += mLeftBookend->getRect().getWidth() - space; // ignore space from right bookend padding controls_bg_area.mRight -= mRightBookend->getRect().getWidth() - space - 2; // draw control background UI image // <FS:ND> VWR-29449; Only draw mBackgroundImage when the user has MEDIA_PERM_CONTROL. Otherwise we did hide all media controls above and drawing mBackgroundImage draws a useless grey square. // mBackgroundImage->draw( controls_bg_area, UI_VERTEX_COLOR % alpha); LLViewerObject* objectp = getTargetObject(); LLMediaEntry *media_data(0); if( objectp ) media_data = objectp->getTE(mTargetObjectFace)->getMediaData(); if( !dynamic_cast<LLVOVolume*>(objectp) || !media_data || dynamic_cast<LLVOVolume*>(objectp)->hasMediaPermission(media_data, LLVOVolume::MEDIA_PERM_CONTROL) ) mBackgroundImage->draw( controls_bg_area, UI_VERTEX_COLOR % alpha); // </FS:ND> // draw volume slider background UI image if (mVolumeSliderCtrl->getVisible()) { LLRect volume_slider_rect; screenRectToLocal(mVolumeSliderCtrl->calcScreenRect(), &volume_slider_rect); mVolumeSliderBackgroundImage->draw(volume_slider_rect, UI_VERTEX_COLOR % alpha); } { LLViewDrawContext context(alpha); LLPanel::draw(); } }