// virtual void LLOutputMonitorCtrl::switchIndicator(bool switch_on) { if(getVisible() != (BOOL)switch_on) { setVisible(switch_on); //Let parent adjust positioning of icons adjacent to speaker indicator //(when speaker indicator hidden, adjacent icons move to right and when speaker //indicator visible, adjacent icons move to the left) if (getParent() && getParent()->isInVisibleChain()) { notifyParentVisibilityChanged(); //Ignore toggled state in case it was set when parent visibility was hidden mIndicatorToggled = false; } else { //Makes sure to only adjust adjacent icons when parent becomes visible //(!mIndicatorToggled ensures that changes of TFT and FTF are discarded, real state changes are TF or FT) mIndicatorToggled = !mIndicatorToggled; } } }
// virtual void LLOutputMonitorCtrl::switchIndicator(bool switch_on) { // ensure indicator is visible in case it is not in visible chain // to be called when parent became visible next time to notify parent that visibility is changed. setVisible(TRUE); // if parent is in visible chain apply switch_on state and notify it immediately if (getParent() && getParent()->isInVisibleChain()) { LL_DEBUGS("SpeakingIndicator") << "Indicator is in visible chain, notifying parent: " << mSpeakerId << LL_ENDL; setVisible((BOOL)switch_on); notifyParentVisibilityChanged(); } // otherwise remember necessary state and mark itself as dirty. // State will be applied in next draw when parents chain becomes visible. else { LL_DEBUGS("SpeakingIndicator") << "Indicator is not in visible chain, parent won't be notified: " << mSpeakerId << LL_ENDL; mIsSwitchDirty = true; mShouldSwitchOn = switch_on; } }
void LLOutputMonitorCtrl::draw() { // see also switchIndicator() if (mIsSwitchDirty) { mIsSwitchDirty = false; if (mShouldSwitchOn) { // just notify parent visibility may have changed notifyParentVisibilityChanged(); } else { // make itself invisible and notify parent about this setVisible(FALSE); notifyParentVisibilityChanged(); // no needs to render for invisible element return; } } // Copied from llmediaremotectrl.cpp // *TODO: Give the LLOutputMonitorCtrl an agent-id to monitor, then // call directly into LLVoiceClient::getInstance() to ask if that agent-id is muted, is // speaking, and what power. This avoids duplicating data, which can get // out of sync. const F32 LEVEL_0 = LLVoiceClient::OVERDRIVEN_POWER_LEVEL / 3.f; const F32 LEVEL_1 = LLVoiceClient::OVERDRIVEN_POWER_LEVEL * 2.f / 3.f; const F32 LEVEL_2 = LLVoiceClient::OVERDRIVEN_POWER_LEVEL; if (getVisible() && mAutoUpdate && !mIsMuted && mSpeakerId.notNull()) { setPower(LLVoiceClient::getInstance()->getCurrentPower(mSpeakerId)); if(mIsAgentControl) { setIsTalking(LLVoiceClient::getInstance()->getUserPTTState()); } else { setIsTalking(LLVoiceClient::getInstance()->getIsSpeaking(mSpeakerId)); } } LLPointer<LLUIImage> icon; if (mIsMuted) { icon = mImageMute; } else if (mPower == 0.f && !mIsTalking) { // only show off if PTT is not engaged icon = mImageOff; } else if (mPower < LEVEL_0) { // PTT is on, possibly with quiet background noise icon = mImageOn; } else if (mPower < LEVEL_1) { icon = mImageLevel1; } else if (mPower < LEVEL_2) { icon = mImageLevel2; } else { // overdriven icon = mImageLevel3; } if (icon) { icon->draw(0, 0); } // // Fill the monitor with a bunch of small rectangles. // The rectangles will be filled with gradient color, // beginning with sColorNormal and ending with sColorOverdriven. // // *TODO: would using a (partially drawn) pixmap instead be faster? // const int monh = getRect().getHeight(); const int monw = getRect().getWidth(); //int maxrects = sRectsNumber; //const int period = llmax(1, monw / maxrects, 0, 0); // "1" - min value for the period //const int rectw = llmax(1, llfloor(period * sRectWidthRatio), 0, 0); // "1" - min value for the rect's width //const int recth = llfloor(monh * sRectHeightRatio); //if(period == 1 && rectw == 1) //if we have so small control, then "maxrects = monitor's_width - 2*monitor_border's_width // maxrects = monw-2; //const int nrects = mIsMuted ? maxrects : llfloor(mPower * maxrects); // how many rects to draw? //const int rectbtm = (monh - recth) / 2; //const int recttop = rectbtm + recth; // //LLColor4 rect_color; // //for (int i=1, xpos = 0; i <= nrects; i++) //{ // // Calculate color to use for the current rectangle. // if (mIsMuted) // { // rect_color = sColorMuted; // } // else // { // F32 frac = (mPower * i/nrects) / LLVoiceClient::OVERDRIVEN_POWER_LEVEL; // // Use overdriven color if the power exceeds overdriven level. // if (frac > 1.0f) // frac = 1.0f; // rect_color = lerp(sColorNormal, sColorOverdriven, frac); // } // // Draw rectangle filled with the color. // gl_rect_2d(xpos, recttop, xpos+rectw, rectbtm, rect_color, TRUE); // xpos += period; //} // // Draw bounding box. // if(mBorder) gl_rect_2d(0, monh, monw, 0, sColorBound, FALSE); }