CHUI-545: Adjusted fix because the old implementation of ::switchIndicator was not very clean and relied on the visiblity of the OutputMonitorCtrl to have a visibility of true even when it wasn't. The fix implemented makes it so that the visibility of OutputMonitorCtrl is always correct and the parent of this ctrl can use this information to adjust children adjacent to OutputMonitorCtrl.

master
Gilbert Gonzales 2012-12-12 16:59:57 -08:00
parent e7a912816e
commit 89671fa1ad
4 changed files with 34 additions and 45 deletions

View File

@ -141,6 +141,17 @@ BOOL LLAvatarListItem::postBuild()
return TRUE;
}
void LLAvatarListItem::handleVisibilityChange ( BOOL new_visibility )
{
//Adjust positions of icons (info button etc) when
//speaking indicator visibility was changed/toggled while panel was closed (not visible)
if(new_visibility && mSpeakingIndicator->getIndicatorToggled())
{
updateChildren();
mSpeakingIndicator->setIndicatorToggled(false);
}
}
void LLAvatarListItem::fetchAvatarName()
{
if (mAvatarNameCacheConnection.connected())

View File

@ -84,6 +84,7 @@ public:
/**
* Processes notification from speaker indicator to update children when indicator's visibility is changed.
*/
virtual void handleVisibilityChange ( BOOL new_visibility );
virtual S32 notifyParent(const LLSD& info);
virtual void onMouseLeave(S32 x, S32 y, MASK mask);
virtual void onMouseEnter(S32 x, S32 y, MASK mask);

View File

@ -73,8 +73,7 @@ LLOutputMonitorCtrl::LLOutputMonitorCtrl(const LLOutputMonitorCtrl::Params& p)
mAutoUpdate(p.auto_update),
mSpeakerId(p.speaker_id),
mIsAgentControl(false),
mIsSwitchDirty(false),
mShouldSwitchOn(false),
mIndicatorToggled(false),
mShowParticipantsSpeaking(false)
{
//static LLUIColor output_monitor_muted_color = LLUIColorTable::instance().getColor("OutputMonitorMutedColor", LLColor4::orange);
@ -116,26 +115,6 @@ void LLOutputMonitorCtrl::setPower(F32 val)
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
@ -323,28 +302,26 @@ void LLOutputMonitorCtrl::onChange()
// 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();
//Visibility has just been updated so make sure not to use the pending visibility when ::draw executes (if one is pending)
mIsSwitchDirty = false;
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();
}
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;
}
}
// 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;
}
}
//////////////////////////////////////////////////////////////////////////

View File

@ -108,6 +108,8 @@ public:
* It will be applied in next draw and parent will be notified.
*/
virtual void switchIndicator(bool switch_on);
bool getIndicatorToggled() { return mIndicatorToggled;}
void setIndicatorToggled(bool value) { mIndicatorToggled = value;}
private:
@ -148,9 +150,7 @@ private:
/** uuid of a speaker being monitored */
LLUUID mSpeakerId;
/** indicates if the instance is dirty and should notify parent */
bool mIsSwitchDirty;
bool mShouldSwitchOn;
bool mIndicatorToggled;
};
#endif