void LLOutputMonitorCtrl::draw() { // 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. // <FS:Ansariel> Centralized voice power level //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; // </FS:Ansariel> Centralized voice 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)); } } if ((mPower == 0.f && !mIsTalking) && mShowParticipantsSpeaking) { std::set<LLUUID> participant_uuids; LLVoiceClient::instance().getParticipantList(participant_uuids); std::set<LLUUID>::const_iterator part_it = participant_uuids.begin(); F32 power = 0; for (; part_it != participant_uuids.end(); ++part_it) { power = LLVoiceClient::instance().getCurrentPower(*part_it); if (power) { mPower = power; break; } } } LLPointer<LLUIImage> icon; // <FS:Ansariel> Centralized voice power level //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; //} EVoicePowerLevel power_level = LLVoiceClient::getInstance()->getPowerLevel(mSpeakerId); switch (power_level) { case VPL_MUTED: icon = mImageMute; break; case VPL_PTT_Off: icon = mImageOff; break; case VPL_PTT_On: icon = mImageOn; break; case VPL_Level1: icon = mImageLevel1; break; case VPL_Level2: icon = mImageLevel2; break; case VPL_Level3: icon = mImageLevel3; break; default: break; } // </FS:Ansariel> Centralized voice power level 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); }
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); }