From d2b13f515d436df9d3ef110bde90f2a7f83a6115 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Fri, 3 Aug 2012 20:51:53 -0500 Subject: [PATCH] Avoid several excessive per-frame LLView::getChildView calls by instead caching the results in postBuild. (Added CachedUICtrl, which is basically just a self-nulling pointer to not have to make ui ctors dirtier) --- indra/llrender/llrender.cpp | 30 +++----------------- indra/llrender/llrender.h | 14 ++++++---- indra/llui/llview.h | 9 ++++++ indra/newview/llchatbar.cpp | 7 +++-- indra/newview/llchatbar.h | 3 ++ indra/newview/llfloateractivespeakers.cpp | 25 +++++++++-------- indra/newview/llfloateractivespeakers.h | 10 +++++++ indra/newview/llfloaterchat.cpp | 7 +++-- indra/newview/llfloaterchat.h | 4 +++ indra/newview/llimpanel.cpp | 29 ++++++++++++------- indra/newview/llimpanel.h | 9 ++++++ indra/newview/llmediaremotectrl.cpp | 34 +++++++++++++++-------- indra/newview/llmediaremotectrl.h | 11 ++++++++ indra/newview/lloverlaybar.cpp | 34 +++++++++++++++++------ indra/newview/lloverlaybar.h | 12 +++++++- indra/newview/lltoolbar.cpp | 26 +++++++++++------ indra/newview/lltoolbar.h | 9 ++++++ indra/newview/llviewerwindow.cpp | 2 +- indra/newview/llvoiceremotectrl.cpp | 26 ++++++++++------- indra/newview/llvoiceremotectrl.h | 8 ++++++ 20 files changed, 210 insertions(+), 99 deletions(-) diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 2d5fbf1b6..31cc03994 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1915,7 +1915,7 @@ void LLRender::flush() } } -void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z) +void LLRender::vertex4a(const LLVector4a& vertex) { //the range of mVerticesp, mColorsp and mTexcoordsp is [0, 4095] if (mCount > 2048) @@ -1937,15 +1937,13 @@ void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z) if (mUIOffset.empty()) { - mVerticesp[mCount].set(x,y,z); + mVerticesp[mCount]=vertex; } else { //LLVector3 vert = (LLVector3(x,y,z)+mUIOffset.back()).scaledVec(mUIScale.back()); - LLVector4a& vert = mVerticesp[mCount]; - vert.set(x,y,z); - vert.add(*mUIOffset.back()); - vert.mul(*mUIScale.back()); + mVerticesp[mCount].setAdd(vertex,*mUIOffset.back()); + mVerticesp[mCount].mul(*mUIScale.back()); } if (mMode == LLRender::QUADS && LLRender::sGLCoreProfile) @@ -2148,26 +2146,6 @@ void LLRender::vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, LLCo mColorsp[mCount] = mColorsp[mCount-1]; } -void LLRender::vertex2i(const GLint& x, const GLint& y) -{ - vertex3f((GLfloat) x, (GLfloat) y, 0); -} - -void LLRender::vertex2f(const GLfloat& x, const GLfloat& y) -{ - vertex3f(x,y,0); -} - -void LLRender::vertex2fv(const GLfloat* v) -{ - vertex3f(v[0], v[1], 0); -} - -void LLRender::vertex3fv(const GLfloat* v) -{ - vertex3f(v[0], v[1], v[2]); -} - void LLRender::texCoord2f(const GLfloat& x, const GLfloat& y) { mTexcoordsp[mCount] = LLVector2(x,y); diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index a4c1cf2b5..6e412926d 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -364,12 +364,14 @@ public: void begin(const GLuint& mode); void end(); - void vertex2i(const GLint& x, const GLint& y); - void vertex2f(const GLfloat& x, const GLfloat& y); - void vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z); - void vertex2fv(const GLfloat* v); - void vertex3fv(const GLfloat* v); - + + LL_FORCE_INLINE void vertex2i(const GLint& x, const GLint& y) { vertex4a(LLVector4a((GLfloat)x,(GLfloat)y,0.f)); } + LL_FORCE_INLINE void vertex2f(const GLfloat& x, const GLfloat& y) { vertex4a(LLVector4a(x,y,0.f)); } + LL_FORCE_INLINE void vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z) { vertex4a(LLVector4a(x,y,z)); } + LL_FORCE_INLINE void vertex2fv(const GLfloat* v) { vertex4a(LLVector4a(v[0],v[1],0.f)); } + LL_FORCE_INLINE void vertex3fv(const GLfloat* v) { vertex4a(LLVector4a(v[0],v[1],v[2])); } + void vertex4a(const LLVector4a& v); + void texCoord2i(const GLint& x, const GLint& y); void texCoord2f(const GLfloat& x, const GLfloat& y); void texCoord2fv(const GLfloat* tc); diff --git a/indra/llui/llview.h b/indra/llui/llview.h index bec83dfeb..2d507636c 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -187,6 +187,15 @@ public: void initFromParams(const LLView::Params&); + template + struct CachedUICtrl + { + CachedUICtrl():mPtr(NULL){} + T* connect(LLView* parent,const char* pName){return mPtr = parent->getChild(pName);} + T* operator->(){return mPtr;} + operator T*() const{return mPtr;} + T* mPtr; + }; protected: LLView(const LLView::Params&); //friend class LLUICtrlFactory; diff --git a/indra/newview/llchatbar.cpp b/indra/newview/llchatbar.cpp index c34fee56b..12e26b1c4 100644 --- a/indra/newview/llchatbar.cpp +++ b/indra/newview/llchatbar.cpp @@ -165,6 +165,9 @@ BOOL LLChatBar::postBuild() mInputEditor->setEnableLineHistory(TRUE); } + mHistoryBtn.connect(this,"History"); + mSayBtn.connect(this,"Say"); + mIsBuilt = TRUE; return TRUE; @@ -228,9 +231,9 @@ void LLChatBar::refresh() gAgent.stopTyping(); } - childSetValue("History", LLFloaterChat::instanceVisible(LLSD())); + mHistoryBtn->setValue(LLFloaterChat::instanceVisible(LLSD())); - childSetEnabled("Say", mInputEditor->getText().size() > 0); + mSayBtn->setEnabled(mInputEditor->getText().size() > 0); //childSetEnabled("Shout", mInputEditor->getText().size() > 0); createDummyWidget Making Dummy -HgB } diff --git a/indra/newview/llchatbar.h b/indra/newview/llchatbar.h index c4fed67d9..5e0391d08 100644 --- a/indra/newview/llchatbar.h +++ b/indra/newview/llchatbar.h @@ -110,6 +110,9 @@ protected: LLComboBox* mGestureCombo; LLChatBarGestureObserver* mObserver; + + CachedUICtrl mHistoryBtn; + CachedUICtrl mSayBtn; }; extern LLChatBar *gChatBar; diff --git a/indra/newview/llfloateractivespeakers.cpp b/indra/newview/llfloateractivespeakers.cpp index 321a825f1..ea902fa9d 100644 --- a/indra/newview/llfloateractivespeakers.cpp +++ b/indra/newview/llfloateractivespeakers.cpp @@ -353,6 +353,13 @@ BOOL LLPanelActiveSpeakers::postBuild() childSetCommitCallback("moderator_allow_text", onModeratorMuteText, this); childSetCommitCallback("moderation_mode", onChangeModerationMode, this); + mVolumeSlider.connect(this,"speaker_volume"); + mModeratorCtrlLbl.connect(this,"moderator_controls_label"); + mModeratorAllowVoiceCheckbox.connect(this,"moderator_allow_voice"); + mModeratorAllowTextCheckbox.connect(this,"moderator_allow_text"); + mModeratorModePanel.connect(this,"moderation_mode_panel"); + mModeratorControlsPanel.connect(this,"moderator_controls"); + // update speaker UI handleSpeakerSelect(); @@ -618,25 +625,21 @@ void LLPanelActiveSpeakers::refreshSpeakers() //&& !LLMuteList::getInstance()->isLinden(selected_speakerp->mDisplayName)); && !LLMuteList::getInstance()->isLinden(selected_speakerp->mLegacyName)); } - childSetValue("speaker_volume", gVoiceClient->getUserVolume(selected_id)); - childSetEnabled("speaker_volume", LLVoiceClient::voiceEnabled() + mVolumeSlider->setValue(gVoiceClient->getUserVolume(selected_id)); + mVolumeSlider->setEnabled(LLVoiceClient::voiceEnabled() && gVoiceClient->getVoiceEnabled(selected_id) && selected_id.notNull() && selected_id != gAgent.getID() && (selected_speakerp.notNull() && (selected_speakerp->mType == LLSpeaker::SPEAKER_AGENT || selected_speakerp->mType == LLSpeaker::SPEAKER_EXTERNAL))); - childSetEnabled( - "moderator_controls_label", - selected_id.notNull()); + mModeratorCtrlLbl->setEnabled(selected_id.notNull()); - childSetEnabled( - "moderator_allow_voice", + mModeratorAllowVoiceCheckbox->setEnabled( selected_id.notNull() && mSpeakerMgr->isVoiceActive() && gVoiceClient->getVoiceEnabled(selected_id)); - childSetEnabled( - "moderator_allow_text", + mModeratorAllowTextCheckbox->setEnabled( selected_id.notNull()); if (mProfileBtn) @@ -661,8 +664,8 @@ void LLPanelActiveSpeakers::refreshSpeakers() LLPointer self_speakerp = mSpeakerMgr->findSpeaker(gAgent.getID()); if(self_speakerp) { - childSetVisible("moderation_mode_panel", self_speakerp->mIsModerator && mSpeakerMgr->isVoiceActive()); - childSetVisible("moderator_controls", self_speakerp->mIsModerator); + mModeratorModePanel->setVisible(self_speakerp->mIsModerator && mSpeakerMgr->isVoiceActive()); + mModeratorControlsPanel->setVisible(self_speakerp->mIsModerator); } // keep scroll value stable diff --git a/indra/newview/llfloateractivespeakers.h b/indra/newview/llfloateractivespeakers.h index 97221cb60..b8a9ece01 100644 --- a/indra/newview/llfloateractivespeakers.h +++ b/indra/newview/llfloateractivespeakers.h @@ -46,6 +46,9 @@ class LLButton; class LLPanelActiveSpeakers; class LLSpeakerMgr; class LLVoiceChannel; +class LLSlider; +class LLTextBox; +class LLCheckBoxCtrl; // data for a given participant in a voice channel @@ -296,6 +299,13 @@ protected: LLPointer mSpeakerAddListener; LLPointer mSpeakerRemoveListener; LLPointer mSpeakerClearListener; + + CachedUICtrl mVolumeSlider; + CachedUICtrl mModeratorCtrlLbl; + CachedUICtrl mModeratorAllowVoiceCheckbox; + CachedUICtrl mModeratorAllowTextCheckbox; + CachedUICtrl mModeratorModePanel; + CachedUICtrl mModeratorControlsPanel; }; diff --git a/indra/newview/llfloaterchat.cpp b/indra/newview/llfloaterchat.cpp index dec68245d..ed55ecbae 100644 --- a/indra/newview/llfloaterchat.cpp +++ b/indra/newview/llfloaterchat.cpp @@ -135,9 +135,9 @@ void LLFloaterChat::draw() { // enable say and shout only when text available - childSetValue("toggle_active_speakers_btn", childIsVisible("active_speakers_panel")); + mToggleActiveSpeakersBtn->setValue(mPanel->getVisible()); - LLChatBar* chat_barp = getChild("chat_panel", TRUE); + LLChatBar* chat_barp = mChatPanel; if (chat_barp) { chat_barp->refresh(); @@ -156,6 +156,9 @@ BOOL LLFloaterChat::postBuild() { chat_barp->setGestureCombo(getChild( "Gesture")); } + + mToggleActiveSpeakersBtn.connect(this,"toggle_active_speakers_btn"); + mChatPanel.connect(this,"chat_panel"); return TRUE; } diff --git a/indra/newview/llfloaterchat.h b/indra/newview/llfloaterchat.h index 4f9a03be5..a3ef23fd0 100644 --- a/indra/newview/llfloaterchat.h +++ b/indra/newview/llfloaterchat.h @@ -50,6 +50,7 @@ class LLUUID; class LLCheckBoxCtrl; class LLPanelActiveSpeakers; class LLLogChat; +class LLChatBar; class LLFloaterChat : public LLFloater, public LLUISingleton @@ -95,6 +96,9 @@ public: LLPanelActiveSpeakers* mPanel; BOOL mScrolledToEnd; + + CachedUICtrl mToggleActiveSpeakersBtn; + CachedUICtrl mChatPanel; }; #endif diff --git a/indra/newview/llimpanel.cpp b/indra/newview/llimpanel.cpp index ed2349717..27774273a 100644 --- a/indra/newview/llimpanel.cpp +++ b/indra/newview/llimpanel.cpp @@ -1411,6 +1411,15 @@ BOOL LLFloaterIMPanel::postBuild() } setDefaultBtn("send_btn"); + + mActiveSpeakersPanel.connect(this,"active_speakers_panel"); + mToggleActiveSpeakersBtn.connect(this,"toggle_active_speakers_btn"); + mVolumeSlider.connect(this,"speaker_volume"); + mEndCallBtn.connect(this,"end_call_btn"); + mStartCallBtn.connect(this,"start_call_btn"); + mSendBtn.connect(this,"send_btn"); + mMuteBtn.connect(this,"mute_btn"); + return TRUE; } @@ -1466,10 +1475,10 @@ void LLFloaterIMPanel::draw() && mCallBackEnabled; // hide/show start call and end call buttons - childSetVisible("end_call_btn", LLVoiceClient::voiceEnabled() && mVoiceChannel->getState() >= LLVoiceChannel::STATE_CALL_STARTED); - childSetVisible("start_call_btn", LLVoiceClient::voiceEnabled() && mVoiceChannel->getState() < LLVoiceChannel::STATE_CALL_STARTED); - childSetEnabled("start_call_btn", enable_connect); - childSetEnabled("send_btn", !childGetValue("chat_editor").asString().empty()); + mEndCallBtn->setVisible(LLVoiceClient::voiceEnabled() && mVoiceChannel->getState() >= LLVoiceChannel::STATE_CALL_STARTED); + mStartCallBtn->setVisible(LLVoiceClient::voiceEnabled() && mVoiceChannel->getState() < LLVoiceChannel::STATE_CALL_STARTED); + mStartCallBtn->setEnabled(enable_connect); + mSendBtn->setEnabled(!childGetValue("chat_editor").asString().empty()); LLPointer self_speaker = mSpeakers->findSpeaker(gAgent.getID()); if(!mTextIMPossible) @@ -1497,10 +1506,10 @@ void LLFloaterIMPanel::draw() // show speakers window when voice first connects if (mShowSpeakersOnConnect && mVoiceChannel->isActive()) { - childSetVisible("active_speakers_panel", TRUE); + mActiveSpeakersPanel->setVisible(true); mShowSpeakersOnConnect = FALSE; } - childSetValue("toggle_active_speakers_btn", childIsVisible("active_speakers_panel")); + mToggleActiveSpeakersBtn->setValue(mActiveSpeakersPanel->getVisible()); if (mTyping) { @@ -1531,11 +1540,11 @@ void LLFloaterIMPanel::draw() else { // refresh volume and mute checkbox - childSetVisible("speaker_volume", LLVoiceClient::voiceEnabled() && mVoiceChannel->isActive()); - childSetValue("speaker_volume", gVoiceClient->getUserVolume(mOtherParticipantUUID)); + mVolumeSlider->setVisible(LLVoiceClient::voiceEnabled() && mVoiceChannel->isActive()); + mVolumeSlider->setValue(gVoiceClient->getUserVolume(mOtherParticipantUUID)); - childSetValue("mute_btn", LLMuteList::getInstance()->isMuted(mOtherParticipantUUID, LLMute::flagVoiceChat)); - childSetVisible("mute_btn", LLVoiceClient::voiceEnabled() && mVoiceChannel->isActive()); + mMuteBtn->setValue(LLMuteList::getInstance()->isMuted(mOtherParticipantUUID, LLMute::flagVoiceChat)); + mMuteBtn->setVisible(LLVoiceClient::voiceEnabled() && mVoiceChannel->isActive()); } LLFloater::draw(); } diff --git a/indra/newview/llimpanel.h b/indra/newview/llimpanel.h index 9daed909f..943bd37c1 100644 --- a/indra/newview/llimpanel.h +++ b/indra/newview/llimpanel.h @@ -48,6 +48,8 @@ class LLInventoryItem; class LLInventoryCategory; class LLIMSpeakerMgr; class LLPanelActiveSpeakers; +class LLPanel; +class LLButton; class LLVoiceChannel : public LLVoiceClientStatusObserver { @@ -385,6 +387,13 @@ private: boost::signals2::connection mFocusLostSignal; + CachedUICtrl mActiveSpeakersPanel; + CachedUICtrl mToggleActiveSpeakersBtn; + CachedUICtrl mVolumeSlider; + CachedUICtrl mEndCallBtn; + CachedUICtrl mStartCallBtn; + CachedUICtrl mSendBtn; + CachedUICtrl mMuteBtn; void disableWhileSessionStarting(); diff --git a/indra/newview/llmediaremotectrl.cpp b/indra/newview/llmediaremotectrl.cpp index 68db6b6b3..e8d04ff2b 100644 --- a/indra/newview/llmediaremotectrl.cpp +++ b/indra/newview/llmediaremotectrl.cpp @@ -89,6 +89,16 @@ BOOL LLMediaRemoteCtrl::postBuild() childSetAction("media_pause",LLOverlayBar::toggleMediaPlay,this); childSetAction("music_pause",LLOverlayBar::toggleMusicPlay,this); + mMusicPlayBtn.connect(this,"music_play"); + mMusicStopBtn.connect(this,"music_stop"); + mMusicPauseBtn.connect(this,"music_pause"); + mMediaPlayBtn.connect(this,"media_play"); + mMediaStopBtn.connect(this,"media_stop"); + mMediaPauseBtn.connect(this,"media_pause"); + mMediaIcon.connect(this,"media_icon"); + mMusicIcon.connect(this,"music_icon"); + mExpandBtn.connect(this,"expand"); + childSetAction("expand", onClickExpandBtn, this); LLButton *pause = getChild("music_pause"); @@ -101,7 +111,7 @@ void LLMediaRemoteCtrl::draw() { enableMediaButtons(); - LLButton* expand_button = getChild("expand"); + LLButton* expand_button = mExpandBtn; if (expand_button) { if (expand_button->getToggleState()) @@ -147,8 +157,8 @@ void LLMediaRemoteCtrl::setToolTip(const std::string& msg) std::string tool_tip = LLMIMETypes::findToolTip(mime_type); std::string play_tip = LLMIMETypes::findPlayTip(mime_type); // childSetToolTip("media_stop", mControls->getString("stop_label") + "\n" + tool_tip); - childSetToolTip("media_icon", tool_tip); - childSetToolTip("media_play", play_tip); + mMediaIcon->setToolTip(tool_tip); + mMediaIcon->setToolTip(play_tip); } void LLMediaRemoteCtrl::enableMediaButtons() @@ -227,13 +237,13 @@ void LLMediaRemoteCtrl::enableMediaButtons() // Don't test the mime-type: this is not updated in a consistent basis. The existence of a valid gAudiop is enough guarantee. } const std::string media_icon_name = LLMIMETypes::findIcon(media_type); - LLButton* music_play_btn = getChild("music_play"); - LLButton* music_stop_btn = getChild("music_stop"); - LLButton* music_pause_btn = getChild("music_pause"); - LLButton* media_play_btn = getChild("media_play"); - LLButton* media_stop_btn = getChild("media_stop"); - LLButton* media_pause_btn = getChild("media_pause"); - LLIconCtrl* media_icon = getChild("media_icon"); + LLButton* music_play_btn = mMusicPlayBtn; + LLButton* music_stop_btn = mMusicStopBtn; + LLButton* music_pause_btn = mMusicPauseBtn; + LLButton* media_play_btn = mMediaPlayBtn; + LLButton* media_stop_btn = mMediaPlayBtn; + LLButton* media_pause_btn = mMediaPauseBtn; + LLIconCtrl* media_icon = mMediaIcon; music_play_btn->setEnabled(play_music_enabled); music_stop_btn->setEnabled(stop_music_enabled); @@ -262,7 +272,7 @@ void LLMediaRemoteCtrl::enableMediaButtons() music_pause_btn->setToolTip(mCachedPauseTip); } - childSetColor("music_icon", music_icon_color); + mMusicIcon->setColor(music_icon_color); if(!media_icon_name.empty()) { media_icon->setImage(media_icon_name); @@ -273,7 +283,7 @@ void LLMediaRemoteCtrl::enableMediaButtons() media_pause_btn->setEnabled(media_show_pause); media_pause_btn->setVisible(media_show_pause); media_play_btn->setVisible(! media_show_pause); - childSetColor("media_icon", media_icon_color); + mMediaIcon->setColor(media_icon_color); setToolTip(media_url); } diff --git a/indra/newview/llmediaremotectrl.h b/indra/newview/llmediaremotectrl.h index 9fedfd386..22ff29866 100644 --- a/indra/newview/llmediaremotectrl.h +++ b/indra/newview/llmediaremotectrl.h @@ -36,6 +36,7 @@ #include "llpanel.h" class LLButton; +class LLIconCtrl; //////////////////////////////////////////////////////////////////////////////// // @@ -61,6 +62,16 @@ protected: void build(); std::string mCachedPauseTip; + + CachedUICtrl mMusicPlayBtn; + CachedUICtrl mMusicStopBtn; + CachedUICtrl mMusicPauseBtn; + CachedUICtrl mMediaPlayBtn; + CachedUICtrl mMediaStopBtn; + CachedUICtrl mMediaPauseBtn; + CachedUICtrl mExpandBtn; + CachedUICtrl mMediaIcon; + CachedUICtrl mMusicIcon; }; #endif diff --git a/indra/newview/lloverlaybar.cpp b/indra/newview/lloverlaybar.cpp index ebbe2d114..78b162c1c 100644 --- a/indra/newview/lloverlaybar.cpp +++ b/indra/newview/lloverlaybar.cpp @@ -189,7 +189,16 @@ BOOL LLOverlayBar::postBuild() setFocusRoot(TRUE); mBuilt = true; - mOriginalIMLabel = getChild("New IM")->getLabelSelected(); + mChatbarAndButtons.connect(this,"chatbar_and_buttons"); + mNewIM.connect(this,"New IM"); + mNotBusy.connect(this,"Set Not Busy"); + mMouseLook.connect(this,"Mouselook"); + mStandUp.connect(this,"Stand Up"); + mFlyCam.connect(this,"Flycam"); + mChatBar.connect(this,"chat_bar"); + mVoiceRemoteContainer.connect(this,"voice_remote_container"); + + mOriginalIMLabel = mNewIM->getLabelSelected(); layoutButtons(); @@ -203,6 +212,7 @@ BOOL LLOverlayBar::postBuild() childSetVisible("AdvSettings_container_exp", sAdvSettingsPopup); childSetVisible("ao_remote_container", gSavedSettings.getBOOL("EnableAORemote")); + return TRUE; } @@ -214,6 +224,12 @@ LLOverlayBar::~LLOverlayBar() // virtual void LLOverlayBar::reshape(S32 width, S32 height, BOOL called_from_parent) { + S32 delta_width = width - getRect().getWidth(); + S32 delta_height = height - getRect().getHeight(); + + if (!delta_width && !delta_height && !sForceReshape) + return; + LLView::reshape(width, height, called_from_parent); if (mBuilt) @@ -266,7 +282,7 @@ void LLOverlayBar::refresh() BOOL im_received = gIMMgr->getIMReceived(); int unread_count = gIMMgr->getIMUnreadCount(); - LLButton* button = getChild("New IM"); + LLButton* button = mNewIM; if ((button && button->getVisible() != im_received) || (button && button->getVisible())) @@ -291,7 +307,7 @@ void LLOverlayBar::refresh() } BOOL busy = gAgent.getBusy(); - button = getChild("Set Not Busy"); + button = mNotBusy; if (button && button->getVisible() != busy) { button->setVisible(busy); @@ -301,7 +317,7 @@ void LLOverlayBar::refresh() } BOOL flycam = LLViewerJoystick::getInstance()->getOverrideCamera(); - button = getChild("Flycam"); + button = mFlyCam; if (button && button->getVisible() != flycam) { button->setVisible(flycam); @@ -313,7 +329,7 @@ void LLOverlayBar::refresh() BOOL mouselook_grabbed; mouselook_grabbed = gAgent.isControlGrabbed(CONTROL_ML_LBUTTON_DOWN_INDEX) || gAgent.isControlGrabbed(CONTROL_ML_LBUTTON_UP_INDEX); - button = getChild("Mouselook"); + button = mMouseLook; if (button && button->getVisible() != mouselook_grabbed) { @@ -331,7 +347,7 @@ void LLOverlayBar::refresh() sitting = gAgentAvatarp->isSitting() && !gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT); // [/RLVa:KB] } - button = getChild("Stand Up"); + button = mStandUp; if (button && button->getVisible() != sitting) { @@ -355,7 +371,7 @@ void LLOverlayBar::refresh() } - button = getChild("Cancel TP"); + button = mCancelBtn; if (button && button->getVisible() != teleporting) { @@ -398,11 +414,11 @@ void LLOverlayBar::refresh() } } if(!in_mouselook) - childSetVisible("voice_remote_container", LLVoiceClient::voiceEnabled()); + mVoiceRemoteContainer->setVisible(LLVoiceClient::voiceEnabled()); // always let user toggle into and out of chatbar static const LLCachedControl chat_visible("ChatVisible",true); - childSetVisible("chat_bar", chat_visible); + mChatBar->setVisible(chat_visible); if (buttons_changed) { diff --git a/indra/newview/lloverlaybar.h b/indra/newview/lloverlaybar.h index 8f9c8ed2f..06ebebe47 100644 --- a/indra/newview/lloverlaybar.h +++ b/indra/newview/lloverlaybar.h @@ -52,6 +52,7 @@ class LLSlider; class LLVoiceRemoteCtrl; class wlfPanel_AdvSettings; class AORemoteCtrl; +class LLChatBar; class LLOverlayBar : public LLPanel @@ -68,6 +69,8 @@ public: // helpers for returning desired state BOOL musicPlaying() { return mMusicState == PLAYING; } + + LLView* getChatbarAndButtons() const {return mChatbarAndButtons;} static void onClickIMReceived(void* data); static void onClickSetNotBusy(void* data); @@ -114,7 +117,14 @@ protected: S32 mMusicState; std::string mOriginalIMLabel; - + CachedUICtrl mChatbarAndButtons; + CachedUICtrl mNewIM; + CachedUICtrl mNotBusy; + CachedUICtrl mMouseLook; + CachedUICtrl mStandUp; + CachedUICtrl mFlyCam; + CachedUICtrl mChatBar; + CachedUICtrl mVoiceRemoteContainer; private: diff --git a/indra/newview/lltoolbar.cpp b/indra/newview/lltoolbar.cpp index 08a1b26ef..f668f5bfc 100644 --- a/indra/newview/lltoolbar.cpp +++ b/indra/newview/lltoolbar.cpp @@ -161,6 +161,13 @@ BOOL LLToolBar::postBuild() childSetAction("inventory_btn", onClickInventory, this); childSetControlName("inventory_btn", "ShowInventory"); + mCommunicateBtn.connect(this, "communicate_btn"); + mFlyBtn.connect(this, "fly_btn"); + mBuildBtn.connect(this, "build_btn"); + mMapBtn.connect(this, "map_btn"); + mRadarBtn.connect(this, "radar_btn"); + mInventoryBtn.connect(this, "inventory_button"); + for (child_list_const_iter_t child_iter = getChildList()->begin(); child_iter != getChildList()->end(); ++child_iter) { @@ -292,7 +299,9 @@ void LLToolBar::refresh() if(!isAgentAvatarValid()) return; - BOOL show = gSavedSettings.getBOOL("ShowToolBar"); + static LLCachedControl show("ShowToolBar", true); + static LLCachedControl ascent_fly_always_enabled("AscentFlyAlwaysEnabled", true); + static LLCachedControl ascent_build_always_enabled("AscentBuildAlwaysEnabled", true); BOOL mouselook = gAgentCamera.cameraMouselook(); setVisible(show && !mouselook); @@ -302,9 +311,8 @@ void LLToolBar::refresh() sitting = gAgentAvatarp->isSitting(); } - childSetEnabled("fly_btn", (gAgent.canFly() || gAgent.getFlying() || gSavedSettings.getBOOL("AscentFlyAlwaysEnabled")) && !sitting ); - - childSetEnabled("build_btn", (LLViewerParcelMgr::getInstance()->allowAgentBuild() || gSavedSettings.getBOOL("AscentBuildAlwaysEnabled")) ); + mFlyBtn->setEnabled((gAgent.canFly() || gAgent.getFlying() || ascent_fly_always_enabled) && !sitting ); + mBuildBtn->setEnabled((LLViewerParcelMgr::getInstance()->allowAgentBuild() || ascent_build_always_enabled)); // Check to see if we're in build mode BOOL build_mode = LLToolMgr::getInstance()->inEdit(); @@ -323,11 +331,11 @@ void LLToolBar::refresh() { // If we're rez-restricted, we can still edit => allow build floater // If we're edit-restricted, we can still rez => allow build floater - childSetEnabled("build_btn", !(gRlvHandler.hasBehaviour(RLV_BHVR_REZ) && gRlvHandler.hasBehaviour(RLV_BHVR_EDIT)) ); + mBuildBtn->setEnabled(!(gRlvHandler.hasBehaviour(RLV_BHVR_REZ) && gRlvHandler.hasBehaviour(RLV_BHVR_EDIT))); - childSetEnabled("map_btn", !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWWORLDMAP) ); - childSetEnabled("radar_btn", !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWMINIMAP) ); - childSetEnabled("inventory_btn", !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWINV) ); + mMapBtn->setEnabled(!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWWORLDMAP)); + mRadarBtn->setEnabled(!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWMINIMAP)); + mInventoryBtn->setEnabled(!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWINV)); } // [/RLVa:KB] @@ -339,7 +347,7 @@ void LLToolBar::refresh() void LLToolBar::updateCommunicateList() { - LLFlyoutButton* communicate_button = getChild("communicate_btn"); + LLFlyoutButton* communicate_button = mCommunicateBtn; LLSD selected = communicate_button->getValue(); communicate_button->removeall(); diff --git a/indra/newview/lltoolbar.h b/indra/newview/lltoolbar.h index 197d16dd3..24b05c8ae 100644 --- a/indra/newview/lltoolbar.h +++ b/indra/newview/lltoolbar.h @@ -44,6 +44,8 @@ extern S32 TOOL_BAR_HEIGHT; class LLFakeResizeHandle; #endif // LL_DARWIN +class LLFlyoutButton; + class LLToolBar : public LLPanel { @@ -97,6 +99,13 @@ private: #if LL_DARWIN LLFakeResizeHandle *mResizeHandle; #endif // LL_DARWIN + + CachedUICtrl mCommunicateBtn; + CachedUICtrl mFlyBtn; + CachedUICtrl mBuildBtn; + CachedUICtrl mMapBtn; + CachedUICtrl mRadarBtn; + CachedUICtrl mInventoryBtn; }; extern LLToolBar *gToolBar; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index d31c262ea..6c807c255 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -3094,7 +3094,7 @@ void LLViewerWindow::updateUI() } // snap floaters to top of chat bar/button strip - LLView* chatbar_and_buttons = gOverlayBar->getChild("chatbar_and_buttons", TRUE); + LLView* chatbar_and_buttons = gOverlayBar->getChatbarAndButtons(); // find top of chatbar and state buttons, if either are visible if (chatbar_and_buttons && chatbar_and_buttons->getLocalBoundingRect().notEmpty()) { diff --git a/indra/newview/llvoiceremotectrl.cpp b/indra/newview/llvoiceremotectrl.cpp index b496f07a7..f89a3cf27 100644 --- a/indra/newview/llvoiceremotectrl.cpp +++ b/indra/newview/llvoiceremotectrl.cpp @@ -90,7 +90,12 @@ BOOL LLVoiceRemoteCtrl::postBuild() childSetAction("voice_channel_bg", onClickVoiceChannel, this); - + mEndCallBtn.connect(this,"end_call_btn"); + mVoiceVolIcon.connect(this,"voice_volume"); + mVoiceChanIcon.connect(this,"voice_channel_icon"); + mVoiceChanBgBtn.connect(this,"voice_channel_bg"); + mChanLabelTextBox.connect(this,"channel_label"); + mShowChanBtn.connect(this,"show_channel"); return TRUE; } @@ -106,14 +111,15 @@ void LLVoiceRemoteCtrl::draw() mTalkBtn->setEnabled(voice_active); mTalkLockBtn->setEnabled(voice_active); + static LLCachedControl ptt_currently_enabled("PPTCurrentlyEnabled",false); // propagate ptt state to button display, if (!mTalkBtn->hasMouseCapture()) { // not in push to talk mode, or push to talk is active means I'm talking - mTalkBtn->setToggleState(!gSavedSettings.getBOOL("PTTCurrentlyEnabled") || gVoiceClient->getUserPTTState()); + mTalkBtn->setToggleState(!ptt_currently_enabled || gVoiceClient->getUserPTTState()); } mSpeakersBtn->setToggleState(LLFloaterActiveSpeakers::instanceVisible(LLSD())); - mTalkLockBtn->setToggleState(!gSavedSettings.getBOOL("PTTCurrentlyEnabled")); + mTalkLockBtn->setToggleState(!ptt_currently_enabled); std::string talk_blip_image; if (gVoiceClient->getIsSpeaking(gAgent.getID())) @@ -148,7 +154,7 @@ void LLVoiceRemoteCtrl::draw() talk_blip_image = "icn_voice_ptt-off.tga"; } - LLIconCtrl* icon = getChild("voice_volume"); + LLIconCtrl* icon = mVoiceVolIcon; if (icon) { icon->setImage(talk_blip_image); @@ -162,23 +168,23 @@ void LLVoiceRemoteCtrl::draw() } LLVoiceChannel* current_channel = LLVoiceChannel::getCurrentVoiceChannel(); - childSetEnabled("end_call_btn", LLVoiceClient::voiceEnabled() + mEndCallBtn->setEnabled(LLVoiceClient::voiceEnabled() && current_channel && current_channel->isActive() && current_channel != LLVoiceChannelProximal::getInstance()); - childSetValue("channel_label", active_channel_name); - childSetToolTip("voice_channel_bg", active_channel_name); + mChanLabelTextBox->setValue(active_channel_name); + mVoiceChanBgBtn->setToolTip(active_channel_name); if (current_channel) { - LLIconCtrl* voice_channel_icon = getChild("voice_channel_icon"); + LLIconCtrl* voice_channel_icon = mVoiceChanIcon; if (voice_channel_icon && voice_floater) { voice_channel_icon->setImage(voice_floater->getString("voice_icon")); } - LLButton* voice_channel_bg = getChild("voice_channel_bg"); + LLButton* voice_channel_bg = mVoiceChanBgBtn; if (voice_channel_bg) { LLColor4 bg_color; @@ -198,7 +204,7 @@ void LLVoiceRemoteCtrl::draw() } } - LLButton* expand_button = getChild("show_channel"); + LLButton* expand_button = mShowChanBtn; if (expand_button) { if (expand_button->getToggleState()) diff --git a/indra/newview/llvoiceremotectrl.h b/indra/newview/llvoiceremotectrl.h index 8522a6f37..86504fe38 100644 --- a/indra/newview/llvoiceremotectrl.h +++ b/indra/newview/llvoiceremotectrl.h @@ -36,6 +36,8 @@ #include "llpanel.h" class LLButton; +class LLIconCtrl; +class LLTextBox; class LLVoiceRemoteCtrl : public LLPanel { @@ -59,6 +61,12 @@ protected: LLButton* mTalkBtn; LLButton* mTalkLockBtn; LLButton* mSpeakersBtn; + CachedUICtrl mEndCallBtn; + CachedUICtrl mVoiceVolIcon; + CachedUICtrl mVoiceChanIcon; + CachedUICtrl mVoiceChanBgBtn; + CachedUICtrl mChanLabelTextBox; + CachedUICtrl mShowChanBtn; }; #endif // LL_LLVOICEREMOTECTRL_H