diff options
Diffstat (limited to 'indra/newview/llstatusbar.cpp')
-rw-r--r-- | indra/newview/llstatusbar.cpp | 225 |
1 files changed, 162 insertions, 63 deletions
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index 4dccdfd7e6..b660a2b8ea 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -36,12 +36,14 @@ // viewer includes #include "llagent.h" +#include "llagentcamera.h" #include "llbutton.h" #include "llcommandhandler.h" #include "llviewercontrol.h" #include "llfloaterbuycurrency.h" -#include "llfloaterchat.h" #include "llfloaterlagmeter.h" +#include "llpanelnearbymedia.h" +#include "llpanelvolumepulldown.h" #include "llfloaterregioninfo.h" #include "llfloaterscriptdebug.h" #include "llhudicon.h" @@ -49,8 +51,7 @@ #include "llkeyboard.h" #include "lllineeditor.h" #include "llmenugl.h" -#include "llnotify.h" -#include "llimview.h" +#include "llrootview.h" #include "llsd.h" #include "lltextbox.h" #include "llui.h" @@ -63,6 +64,7 @@ #include "llresmgr.h" #include "llworld.h" #include "llstatgraph.h" +#include "llviewermedia.h" #include "llviewermenu.h" // for gMenuBarView #include "llviewerparcelmgr.h" #include "llviewerthrottle.h" @@ -72,12 +74,14 @@ #include "llfocusmgr.h" #include "llappviewer.h" #include "lltrans.h" + // library includes #include "imageids.h" #include "llfloaterreg.h" #include "llfontgl.h" #include "llrect.h" #include "llerror.h" +#include "llnotificationsutil.h" #include "llparcel.h" #include "llstring.h" #include "message.h" @@ -106,9 +110,9 @@ const F32 ICON_TIMER_EXPIRY = 3.f; // How long the balance and health icons sho const F32 ICON_FLASH_FREQUENCY = 2.f; const S32 TEXT_HEIGHT = 18; -static void onClickBuyCurrency(void*); static void onClickHealth(void*); static void onClickScriptDebug(void*); +static void onClickVolume(void*); std::vector<std::string> LLStatusBar::sDays; std::vector<std::string> LLStatusBar::sMonths; @@ -116,6 +120,11 @@ const U32 LLStatusBar::MAX_DATE_STRING_LENGTH = 2000; LLStatusBar::LLStatusBar(const LLRect& rect) : LLPanel(), + mTextHealth(NULL), + mTextTime(NULL), + mSGBandwidth(NULL), + mSGPacketLoss(NULL), + mBtnVolume(NULL), mBalance(0), mHealth(100), mSquareMetersCredit(0), @@ -125,7 +134,6 @@ LLStatusBar::LLStatusBar(const LLRect& rect) // status bar can possible overlay menus? setMouseOpaque(FALSE); - setIsChrome(TRUE); // size of day of the weeks and year sDays.reserve(7); @@ -135,9 +143,39 @@ LLStatusBar::LLStatusBar(const LLRect& rect) mHealthTimer = new LLFrameTimer(); LLUICtrlFactory::getInstance()->buildPanel(this,"panel_status_bar.xml"); +} + +LLStatusBar::~LLStatusBar() +{ + delete mBalanceTimer; + mBalanceTimer = NULL; + + delete mHealthTimer; + mHealthTimer = NULL; + + // LLView destructor cleans up children +} + +//----------------------------------------------------------------------- +// Overrides +//----------------------------------------------------------------------- - // status bar can never get a tab - setFocusRoot(FALSE); +// virtual +void LLStatusBar::draw() +{ + refresh(); + LLPanel::draw(); +} + +BOOL LLStatusBar::handleRightMouseDown(S32 x, S32 y, MASK mask) +{ + show_navbar_context_menu(this,x,y); + return TRUE; +} + +BOOL LLStatusBar::postBuild() +{ + gMenuBarView->setRightMouseDownCallback(boost::bind(&show_navbar_context_menu, _1, _2, _3)); // build date necessary data (must do after panel built) setupDate(); @@ -145,8 +183,20 @@ LLStatusBar::LLStatusBar(const LLRect& rect) mTextHealth = getChild<LLTextBox>("HealthText" ); mTextTime = getChild<LLTextBox>("TimeText" ); - mBtnBuyCurrency = getChild<LLButton>( "buycurrency" ); - mBtnBuyCurrency->setClickedCallback( onClickBuyCurrency, this ); + getChild<LLUICtrl>("buycurrency")->setCommitCallback( + boost::bind(&LLStatusBar::onClickBuyCurrency, this)); + getChild<LLUICtrl>("buyL")->setCommitCallback( + boost::bind(&LLStatusBar::onClickBuyCurrency, this)); + + mBtnVolume = getChild<LLButton>( "volume_btn" ); + mBtnVolume->setClickedCallback( onClickVolume, this ); + mBtnVolume->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterVolume, this)); + + mMediaToggle = getChild<LLButton>("media_toggle_btn"); + mMediaToggle->setClickedCallback( &LLStatusBar::onClickMediaToggle, this ); + mMediaToggle->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterNearbyMedia, this)); + + gSavedSettings.getControl("MuteAudio")->getSignal()->connect(boost::bind(&LLStatusBar::onVolumeChanged, this, _2)); childSetAction("scriptout", onClickScriptDebug, this); childSetAction("health", onClickHealth, this); @@ -190,48 +240,15 @@ LLStatusBar::LLStatusBar(const LLRect& rect) childSetActionTextbox("stat_btn", onClickStatGraph); -} - -LLStatusBar::~LLStatusBar() -{ - delete mBalanceTimer; - mBalanceTimer = NULL; + mPanelVolumePulldown = new LLPanelVolumePulldown(); + addChild(mPanelVolumePulldown); + mPanelVolumePulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT); + mPanelVolumePulldown->setVisible(FALSE); - delete mHealthTimer; - mHealthTimer = NULL; - - // LLView destructor cleans up children -} - -//----------------------------------------------------------------------- -// Overrides -//----------------------------------------------------------------------- - -// virtual -void LLStatusBar::draw() -{ - refresh(); - - if (isBackgroundVisible()) - { - static LLUICachedControl<S32> drop_shadow_floater ("DropShadowFloater", 0); - static LLUIColor color_drop_shadow = LLUIColorTable::instance().getColor("ColorDropShadow"); - gl_drop_shadow(0, getRect().getHeight(), getRect().getWidth(), 0, - color_drop_shadow, drop_shadow_floater ); - } - LLPanel::draw(); -} - -BOOL LLStatusBar::handleRightMouseDown(S32 x, S32 y, MASK mask) -{ - show_navbar_context_menu(this,x,y); - return TRUE; -} - -BOOL LLStatusBar::postBuild() -{ - - gMenuBarView->setRightMouseDownCallback(boost::bind(&show_navbar_context_menu, _1, _2, _3)); + mPanelNearByMedia = new LLPanelNearByMedia(); + addChild(mPanelNearByMedia); + mPanelNearByMedia->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT); + mPanelNearByMedia->setVisible(FALSE); return TRUE; } @@ -297,7 +314,7 @@ void LLStatusBar::refresh() childSetVisible("scriptout", false); } - if (gAgent.getCameraMode() == CAMERA_MODE_MOUSELOOK && + if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK && ((region && region->getAllowDamage()) || (parcel && parcel->getAllowDamage()))) { // set visibility based on flashing @@ -333,12 +350,30 @@ void LLStatusBar::refresh() mSGBandwidth->setVisible(net_stats_visible); mSGPacketLoss->setVisible(net_stats_visible); childSetEnabled("stat_btn", net_stats_visible); + + // update the master volume button state + bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute(); + mBtnVolume->setToggleState(mute_audio); + + // Disable media toggle if there's no media, parcel media, and no parcel audio + // (or if media is disabled) + bool button_enabled = (gSavedSettings.getBOOL("AudioStreamingMusic")||gSavedSettings.getBOOL("AudioStreamingMedia")) && + (LLViewerMedia::hasInWorldMedia() || LLViewerMedia::hasParcelMedia() || LLViewerMedia::hasParcelAudio()); + mMediaToggle->setEnabled(button_enabled); + // Note the "sense" of the toggle is opposite whether media is playing or not + bool any_media_playing = (LLViewerMedia::isAnyMediaShowing() || + LLViewerMedia::isParcelMediaPlaying() || + LLViewerMedia::isParcelAudioPlaying()); + mMediaToggle->setValue(!any_media_playing); } void LLStatusBar::setVisibleForMouselook(bool visible) { mTextTime->setVisible(visible); - mBtnBuyCurrency->setVisible(visible); + getChild<LLUICtrl>("buycurrency")->setVisible(visible); + getChild<LLUICtrl>("buyL")->setVisible(visible); + mBtnVolume->setVisible(visible); + mMediaToggle->setVisible(visible); mSGBandwidth->setVisible(visible); mSGPacketLoss->setVisible(visible); setBackgroundVisible(visible); @@ -358,17 +393,18 @@ void LLStatusBar::setBalance(S32 balance) { std::string money_str = LLResMgr::getInstance()->getMonetaryString( balance ); + LLButton* btn_buy_currency = getChild<LLButton>("buycurrency"); LLStringUtil::format_map_t string_args; string_args["[AMT]"] = llformat("%s", money_str.c_str()); - std::string labe_str = getString("buycurrencylabel", string_args); - mBtnBuyCurrency->setLabel(labe_str); + std::string label_str = getString("buycurrencylabel", string_args); + btn_buy_currency->setLabel(label_str); // Resize the balance button so that the label fits it, and the button expands to the left. // *TODO: LLButton should have an option where to expand. { - S32 saved_right = mBtnBuyCurrency->getRect().mRight; - mBtnBuyCurrency->autoResize(); - mBtnBuyCurrency->translate(saved_right - mBtnBuyCurrency->getRect().mRight, 0); + S32 saved_right = btn_buy_currency->getRect().mRight; + btn_buy_currency->autoResize(); + btn_buy_currency->translate(saved_right - btn_buy_currency->getRect().mRight, 0); } if (mBalance && (fabs((F32)(mBalance - balance)) > gSavedSettings.getF32("UISndMoneyChangeThreshold"))) @@ -411,11 +447,9 @@ void LLStatusBar::setHealth(S32 health) { if (mHealth > (health + gSavedSettings.getF32("UISndHealthReductionThreshold"))) { - LLVOAvatar *me; - - if ((me = gAgent.getAvatarObject())) + if (isAgentAvatarValid()) { - if (me->getSex() == SEX_FEMALE) + if (gAgentAvatarp->getSex() == SEX_FEMALE) { make_ui_sound("UISndHealthReductionF"); } @@ -473,14 +507,14 @@ S32 LLStatusBar::getSquareMetersLeft() const return mSquareMetersCredit - mSquareMetersCommitted; } -static void onClickBuyCurrency(void* data) +void LLStatusBar::onClickBuyCurrency() { LLFloaterBuyCurrency::buyCurrency(); } static void onClickHealth(void* ) { - LLNotifications::instance().add("NotSafe"); + LLNotificationsUtil::add("NotSafe"); } static void onClickScriptDebug(void*) @@ -488,6 +522,67 @@ static void onClickScriptDebug(void*) LLFloaterScriptDebug::show(LLUUID::null); } +void LLStatusBar::onMouseEnterVolume() +{ + LLButton* volbtn = getChild<LLButton>( "volume_btn" ); + LLRect vol_btn_rect = volbtn->getRect(); + LLRect volume_pulldown_rect = mPanelVolumePulldown->getRect(); + volume_pulldown_rect.setLeftTopAndSize(vol_btn_rect.mLeft - + (volume_pulldown_rect.getWidth() - vol_btn_rect.getWidth())/2, + vol_btn_rect.mBottom, + volume_pulldown_rect.getWidth(), + volume_pulldown_rect.getHeight()); + + mPanelVolumePulldown->setShape(volume_pulldown_rect); + + + // show the master volume pull-down + LLUI::clearPopups(); + LLUI::addPopup(mPanelVolumePulldown); + mPanelNearByMedia->setVisible(FALSE); + mPanelVolumePulldown->setVisible(TRUE); +} + +void LLStatusBar::onMouseEnterNearbyMedia() +{ + LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder"); + LLRect nearby_media_rect = mPanelNearByMedia->getRect(); + LLButton* nearby_media_btn = getChild<LLButton>( "media_toggle_btn" ); + LLRect nearby_media_btn_rect = nearby_media_btn->getRect(); + nearby_media_rect.setLeftTopAndSize(nearby_media_btn_rect.mLeft - + (nearby_media_rect.getWidth() - nearby_media_btn_rect.getWidth())/2, + nearby_media_btn_rect.mBottom, + nearby_media_rect.getWidth(), + nearby_media_rect.getHeight()); + // force onscreen + nearby_media_rect.translate(popup_holder->getRect().getWidth() - nearby_media_rect.mRight, 0); + + // show the master volume pull-down + mPanelNearByMedia->setShape(nearby_media_rect); + LLUI::clearPopups(); + LLUI::addPopup(mPanelNearByMedia); + + mPanelVolumePulldown->setVisible(FALSE); + mPanelNearByMedia->setVisible(TRUE); +} + + +static void onClickVolume(void* data) +{ + // toggle the master mute setting + bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute(); + LLAppViewer::instance()->setMasterSystemAudioMute(!mute_audio); +} + +//static +void LLStatusBar::onClickMediaToggle(void* data) +{ + LLStatusBar *status_bar = (LLStatusBar*)data; + // "Selected" means it was showing the "play" icon (so media was playing), and now it shows "pause", so turn off media + bool enable = ! status_bar->mMediaToggle->getValue(); + LLViewerMedia::setAllMediaEnabled(enable); +} + // sets the static variables necessary for the date void LLStatusBar::setupDate() { @@ -562,6 +657,10 @@ BOOL can_afford_transaction(S32 cost) return((cost <= 0)||((gStatusBar) && (gStatusBar->getBalance() >=cost))); } +void LLStatusBar::onVolumeChanged(const LLSD& newvalue) +{ + refresh(); +} // Implements secondlife:///app/balance/request to request a L$ balance // update via UDP message system. JC |