From 6c5b984bf670e34fd88a8f1a0bdeb1042fa531b2 Mon Sep 17 00:00:00 2001 From: richard Date: Thu, 11 Feb 2010 18:06:25 -0800 Subject: converted llfloaternearbymedia to llpanelnearbymedia moved from LLTransientDockableFloater model to popup panel model like volume popup --- indra/newview/llpanelnearbymedia.cpp | 825 +++++++++++++++++++++++++++++++++++ 1 file changed, 825 insertions(+) create mode 100644 indra/newview/llpanelnearbymedia.cpp (limited to 'indra/newview/llpanelnearbymedia.cpp') diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp new file mode 100644 index 0000000000..82aa67783d --- /dev/null +++ b/indra/newview/llpanelnearbymedia.cpp @@ -0,0 +1,825 @@ +/** + * @file llpanelnearbymedia.cpp + * @brief Management interface for muting and controlling nearby media + * + * $LicenseInfo:firstyear=2005&license=viewergpl$ + * + * Copyright (c) 2005-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llpanelnearbymedia.h" + +#include "llaudioengine.h" +#include "llcheckboxctrl.h" +#include "llcombobox.h" +#include "llscrolllistctrl.h" +#include "llscrolllistitem.h" +#include "llscrolllistcell.h" +#include "llsliderctrl.h" +#include "llagent.h" +#include "llagentui.h" +#include "llbutton.h" +#include "lltextbox.h" +#include "llviewermedia.h" +#include "llviewerparcelmedia.h" +#include "llviewerregion.h" +#include "llviewermediafocus.h" +#include "llviewerparcelmgr.h" +#include "llparcel.h" +#include "llpluginclassmedia.h" +#include "llvovolume.h" +#include "llstatusbar.h" +#include "llsdutil.h" + +#include + +extern LLControlGroup gSavedSettings; + +// Ugh, isInternetStreamPlaying() returns not a bool, but an *int*, with +// 0 = stopped, 1 = playing, 2 = paused. +static const int PARCEL_AUDIO_STOPPED = 0; +static const int PARCEL_AUDIO_PLAYING = 1; +static const int PARCEL_AUDIO_PAUSED = 2; + +// +// LLPanelNearByMedia +// + +LLPanelNearByMedia::LLPanelNearByMedia() +: mMediaList(NULL), + mEnableAllCtrl(NULL), + mEnableParcelMediaCtrl(NULL), + mAllMediaDisabled(false), + mDebugInfoVisible(false) +{ + mParcelAudioAutoStart = gSavedSettings.getBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING); + + mCommitCallbackRegistrar.add("MediaListCtrl.EnableAll", boost::bind(&LLPanelNearByMedia::onClickEnableAll, this)); + mCommitCallbackRegistrar.add("MediaListCtrl.DisableAll", boost::bind(&LLPanelNearByMedia::onClickDisableAll, this)); + mCommitCallbackRegistrar.add("ParcelMediaCtrl.ParcelMediaVolume", boost::bind(&LLPanelNearByMedia::onParcelMediaVolumeSlider, this)); + mCommitCallbackRegistrar.add("ParcelMediaCtrl.MuteParcelMedia", boost::bind(&LLPanelNearByMedia::onClickMuteParcelMedia, this)); + mCommitCallbackRegistrar.add("ParcelMediaCtrl.EnableParcelMedia", boost::bind(&LLPanelNearByMedia::onClickEnableParcelMedia, this)); + mCommitCallbackRegistrar.add("ParcelMediaCtrl.DisableParcelMedia", boost::bind(&LLPanelNearByMedia::onClickDisableParcelMedia, this)); + mCommitCallbackRegistrar.add("ParcelMediaCtrl.Play", boost::bind(&LLPanelNearByMedia::onClickParcelMediaPlay, this)); + mCommitCallbackRegistrar.add("ParcelMediaCtrl.Stop", boost::bind(&LLPanelNearByMedia::onClickParcelMediaStop, this)); + mCommitCallbackRegistrar.add("ParcelMediaCtrl.Pause", boost::bind(&LLPanelNearByMedia::onClickParcelMediaPause, this)); + mCommitCallbackRegistrar.add("ParcelAudioCtrl.Play", boost::bind(&LLPanelNearByMedia::onClickParcelAudioPlay, this)); + mCommitCallbackRegistrar.add("ParcelAudioCtrl.Stop", boost::bind(&LLPanelNearByMedia::onClickParcelAudioStop, this)); + mCommitCallbackRegistrar.add("ParcelAudioCtrl.Pause", boost::bind(&LLPanelNearByMedia::onClickParcelAudioPause, this)); + LLUICtrlFactory::instance().buildPanel(this, "panel_nearby_media.xml"); +} + +LLPanelNearByMedia::~LLPanelNearByMedia() +{ +} + +BOOL LLPanelNearByMedia::postBuild() +{ + LLPanel::postBuild(); + + mMediaList = getChild("media_list"); + mEnableAllCtrl = getChild("all_nearby_media_enable_btn"); + mDisableAllCtrl = getChild("all_nearby_media_disable_btn"); + mParcelMediaVolumeSlider = getChild("parcel_media_volume"); + mParcelMediaMuteCtrl = getChild("parcel_media_mute"); + mEnableParcelMediaCtrl = getChild("parcel_media_enable_btn"); + mDisableParcelMediaCtrl = getChild("parcel_media_disable_btn"); + mParcelMediaText = getChild("parcel_media_name"); + mItemCountText = getChild("media_item_count"); + mParcelMediaPlayCtrl = getChild("parcel_media_play_btn"); + mParcelMediaPauseCtrl = getChild("parcel_media_pause_btn"); + mParcelMediaCtrl = getChild("parcel_media_ctrls"); + mParcelAudioPlayCtrl = getChild("parcel_audio_play_btn"); + mParcelAudioPauseCtrl = getChild("parcel_audio_pause_btn"); + mParcelAudioCtrl = getChild("parcel_audio_ctrls"); + mShowCtrl = getChild("show_combo"); + + mEmptyNameString = getString("empty_item_text"); + mDefaultParcelMediaName = getString("default_parcel_media_name"); + mDefaultParcelMediaToolTip = getString("default_parcel_media_tool_tip"); + + mMediaList->setDoubleClickCallback(onZoomMedia, this); + mMediaList->sortByColumnIndex(PROXIMITY_COLUMN, TRUE); + mMediaList->sortByColumnIndex(VISIBILITY_COLUMN, FALSE); + + std::string url = LLViewerParcelMedia::getURL(); + if (!url.empty()) + { + std::string name = LLViewerParcelMedia::getName(); + mParcelMediaText->setValue(name.empty()?url:name); + mParcelMediaText->setToolTip(url); + } + refreshList(); + updateColumns(); + + return TRUE; +} + +/*virtual*/ +void LLPanelNearByMedia::onMouseEnter(S32 x, S32 y, MASK mask) +{ + mHoverTimer.stop(); + LLPanel::onMouseEnter(x,y,mask); +} + + +/*virtual*/ +void LLPanelNearByMedia::onMouseLeave(S32 x, S32 y, MASK mask) +{ + mHoverTimer.start(); + LLPanel::onMouseLeave(x,y,mask); +} + +/*virtual*/ +void LLPanelNearByMedia::handleVisibilityChange ( BOOL new_visibility ) +{ + if (new_visibility) + { + mHoverTimer.start(); // timer will be stopped when mouse hovers over panel + gFocusMgr.setTopCtrl(this); + } + else + { + mHoverTimer.stop(); + if (gFocusMgr.getTopCtrl() == this) + { + gFocusMgr.setTopCtrl(NULL); + } + } +} + +/*virtual*/ +void LLPanelNearByMedia::onTopLost () +{ + setVisible(FALSE); +} + + +const F32 AUTO_CLOSE_FADE_TIME_START= 4.0f; +const F32 AUTO_CLOSE_FADE_TIME_END = 5.0f; + +void LLPanelNearByMedia::draw() +{ + mItemCountText->setValue(llformat(getString("media_item_count_format").c_str(), mMediaList->getItemCount())); + + refreshParcelMediaUI(); + refreshParcelAudioUI(); + refreshList(); + + F32 alpha = mHoverTimer.getStarted() + ? clamp_rescale(mHoverTimer.getElapsedTimeF32(), AUTO_CLOSE_FADE_TIME_START, AUTO_CLOSE_FADE_TIME_END, 1.f, 0.f) + : 1.0f; + LLViewDrawContext context(alpha); + + LLPanel::draw(); + + if (alpha == 0.f) + { + setVisible(false); + } +} + +bool LLPanelNearByMedia::getParcelAudioAutoStart() +{ + return mParcelAudioAutoStart; +} + +void LLPanelNearByMedia::addMediaItem(const LLUUID &id) +{ + if (NULL == mMediaList) return; + + // Just set up the columns -- the values will be filled in by updateMediaItem(). + + LLSD row; + row["id"] = id; + + LLSD &columns = row["columns"]; + + columns[CHECKBOX_COLUMN]["column"] = "media_checkbox_ctrl"; + columns[CHECKBOX_COLUMN]["type"] = "checkbox"; + //if(mDebugInfoVisible) + { + columns[PROXIMITY_COLUMN]["column"] = "media_proximity"; + columns[PROXIMITY_COLUMN]["value"] = ""; + columns[VISIBILITY_COLUMN]["column"] = "media_visibility"; + columns[VISIBILITY_COLUMN]["value"] = ""; + columns[CLASS_COLUMN]["column"] = "media_class"; + columns[CLASS_COLUMN]["type"] = "text"; + columns[CLASS_COLUMN]["value"] = ""; + } + columns[NAME_COLUMN]["column"] = "media_name"; + columns[NAME_COLUMN]["type"] = "text"; + columns[NAME_COLUMN]["value"] = ""; + //if(mDebugInfoVisible) + { + columns[DEBUG_COLUMN]["column"] = "media_debug"; + columns[DEBUG_COLUMN]["type"] = "text"; + columns[DEBUG_COLUMN]["value"] = ""; + } + + LLScrollListItem* new_item = mMediaList->addElement(row); + LLScrollListCheck* scroll_list_check = dynamic_cast(new_item->getColumn(CHECKBOX_COLUMN)); + if (scroll_list_check) + { + LLCheckBoxCtrl *check = scroll_list_check->getCheckBox(); + check->setCommitCallback(boost::bind(&LLPanelNearByMedia::onCheckItem, this, _1, id)); + } +} + +void LLPanelNearByMedia::updateMediaItem(LLScrollListItem* item, LLViewerMediaImpl* impl) +{ + LLScrollListCell* cell = item->getColumn(PROXIMITY_COLUMN); + if(cell) + { + // since we are forced to sort by text, encode sort order as string + std::string proximity_string = STRINGIZE(/*llformat("%010d", */impl->getProximity()); + std::string old_proximity_string = cell->getValue().asString(); + if(proximity_string != old_proximity_string) + { + cell->setValue(proximity_string); + mMediaList->setNeedsSort(true); + } + } + + cell = item->getColumn(CHECKBOX_COLUMN); + if(cell) + { + cell->setValue(!impl->isMediaDisabled()); + } + + cell = item->getColumn(VISIBILITY_COLUMN); + if(cell) + { + S32 old_visibility = cell->getValue(); + S32 new_visibility = (impl->hasMedia()) ? 1 : ((impl->isMediaDisabled()) ? 0 : -1); + cell->setValue(STRINGIZE(new_visibility)); + if (new_visibility != old_visibility) + { + mMediaList->setNeedsSort(true); + } + } + + S32 media_class = -1; + cell = item->getColumn(NAME_COLUMN); + if(cell) + { + std::string name; + std::string url; + + getNameAndUrlHelper(impl, name, url, mEmptyNameString); + + cell->setToolTip(url); + std::string old_name = cell->getValue().asString(); + if(old_name != name) + { + cell->setValue(name); + } + + LLColor4 cell_color = LLColor4::white; + U8 font_style = LLFontGL::NORMAL; + + // Focused + if (impl->hasFocus()) + { + if (mDebugInfoVisible) cell_color = LLColor4::yellow; + media_class = MEDIA_CLASS_FOCUSED; + } + // Is attached to another avatar? + else if (impl->isAttachedToAnotherAvatar()) + { + if (mDebugInfoVisible) cell_color = LLColor4::red; + media_class = MEDIA_CLASS_ON_OTHERS; + } + // Outside agent parcel + else if (!impl->isInAgentParcel()) + { + if (mDebugInfoVisible) cell_color = LLColor4::orange; + media_class = MEDIA_CLASS_OUTSIDE_PARCEL; + } + else { + // inside parcel + media_class = MEDIA_CLASS_WITHIN_PARCEL; + } + if (impl->isMediaDisabled()) + { + if (mDebugInfoVisible) font_style |= LLFontGL::ITALIC; + if (mDebugInfoVisible) cell_color = LLColor4::black; + } + // Dim it if it isn't "showing" + else if (!impl->hasMedia()) + { + cell_color.setAlpha(0.25); + } + // Bold it if it is time-based media and it is playing + else if (impl->isMediaTimeBased() && + impl->isMediaPlaying()) + { + if (mDebugInfoVisible) font_style |= LLFontGL::BOLD; + } + cell->setColor(cell_color); + LLScrollListText *text_cell = dynamic_cast (cell); + if (text_cell) + { + text_cell->setFontStyle(font_style); + } + } + + cell = item->getColumn(CLASS_COLUMN); + if(cell) + { + // TODO: clean this up! + cell->setValue(STRINGIZE(media_class)); + } + + if(mDebugInfoVisible) + { + cell = item->getColumn(DEBUG_COLUMN); + if(cell) + { + std::string s; + + s += llformat("%g/", (float)impl->getInterest()); + + // proximity distance is actually distance squared -- display it as straight distance. + s += llformat("%g/", fsqrtf(impl->getProximityDistance())); + +// s += llformat("%g/", (float)impl->getCPUUsage()); +// s += llformat("%g/", (float)impl->getApproximateTextureInterest()); + s += llformat("%g/", (float)(NULL == impl->getSomeObject()) ? 0.0 : impl->getSomeObject()->getPixelArea()); + + s += LLPluginClassMedia::priorityToString(impl->getPriority()); + + if(impl->hasMedia()) + { + s += '@'; + } + else if(impl->isPlayable()) + { + s += '+'; + } + else if(impl->isForcedUnloaded()) + { + s += '!'; + } + + cell->setValue(s); + } + } +} + +void LLPanelNearByMedia::removeMediaItem(const LLUUID &id) +{ + if (NULL == mMediaList) return; + + mMediaList->deleteSingleItem(mMediaList->getItemIndex(id)); +} + +void LLPanelNearByMedia::refreshParcelMediaUI() +{ + std::string url = LLViewerParcelMedia::getURL(); + LLStyle::Params style_params; + if (url.empty()) + { + style_params.font.style = "ITALIC"; + mParcelMediaText->setText(mDefaultParcelMediaName, style_params); + mParcelMediaText->setToolTip(mDefaultParcelMediaToolTip); + mEnableParcelMediaCtrl->setEnabled(false); + mDisableParcelMediaCtrl->setEnabled(false); + } + else { + std::string name = LLViewerParcelMedia::getName(); + if (name.empty()) name = url; + mParcelMediaText->setText(name, style_params); + mParcelMediaText->setToolTip(url); + mEnableParcelMediaCtrl->setEnabled(true); + mDisableParcelMediaCtrl->setEnabled(true); + } + + // Set up the default play controls state + mParcelMediaPauseCtrl->setEnabled(false); + mParcelMediaPauseCtrl->setVisible(false); + mParcelMediaPlayCtrl->setEnabled(true); + mParcelMediaPlayCtrl->setVisible(true); + mParcelMediaCtrl->setEnabled(false); + + if (LLViewerParcelMedia::getParcelMedia()) + { + if (LLViewerParcelMedia::getParcelMedia()->getMediaPlugin() && + LLViewerParcelMedia::getParcelMedia()->getMediaPlugin()->pluginSupportsMediaTime()) + { + mParcelMediaCtrl->setEnabled(true); + + switch(LLViewerParcelMedia::getParcelMedia()->getMediaPlugin()->getStatus()) + { + case LLPluginClassMediaOwner::MEDIA_PLAYING: + mParcelMediaPlayCtrl->setEnabled(false); + mParcelMediaPlayCtrl->setVisible(false); + mParcelMediaPauseCtrl->setEnabled(true); + mParcelMediaPauseCtrl->setVisible(true); + break; + case LLPluginClassMediaOwner::MEDIA_PAUSED: + default: + // default play status is kosher + break; + } + } + } +} + +void LLPanelNearByMedia::refreshParcelAudioUI() +{ + bool parcel_audio_enabled = !getParcelAudioURL().empty(); + + mParcelAudioCtrl->setToolTip(getParcelAudioURL()); + + if (gAudiop && parcel_audio_enabled) + { + mParcelAudioCtrl->setEnabled(true); + + if (PARCEL_AUDIO_PLAYING == gAudiop->isInternetStreamPlaying()) + { + mParcelAudioPlayCtrl->setEnabled(false); + mParcelAudioPlayCtrl->setVisible(false); + mParcelAudioPauseCtrl->setEnabled(true); + mParcelAudioPauseCtrl->setVisible(true); + } + else { + mParcelAudioPlayCtrl->setEnabled(true); + mParcelAudioPlayCtrl->setVisible(true); + mParcelAudioPauseCtrl->setEnabled(false); + mParcelAudioPauseCtrl->setVisible(false); + } + } + else { + mParcelAudioCtrl->setEnabled(false); + mParcelAudioPlayCtrl->setEnabled(true); + mParcelAudioPlayCtrl->setVisible(true); + mParcelAudioPauseCtrl->setEnabled(false); + mParcelAudioPauseCtrl->setVisible(false); + } +} + +void LLPanelNearByMedia::refreshList() +{ + bool all_items_deleted = false; + + if(!mMediaList) + { + // None of this makes any sense if the media list isn't there. + return; + } + + // Check whether the debug column has been shown/hidden. + bool debug_info_visible = gSavedSettings.getBOOL("MediaPerformanceManagerDebug"); + if(debug_info_visible != mDebugInfoVisible) + { + mDebugInfoVisible = debug_info_visible; + + // Clear all items so the list gets regenerated. + mMediaList->deleteAllItems(); + all_items_deleted = true; + + updateColumns(); + } + + // Get the canonical list from LLViewerMedia + LLViewerMedia::impl_list impls = LLViewerMedia::getPriorityList(); + LLViewerMedia::impl_list::iterator priority_iter; + + // iterate over the impl list, creating rows as necessary. + for(priority_iter = impls.begin(); priority_iter != impls.end(); priority_iter++) + { + // If we just emptied out the list, every flag needs to be reset. + if(all_items_deleted) + { + (*priority_iter)->setInNearbyMediaList(false); + } + + if(! (*priority_iter)->isParcelMedia()) + { + LLUUID media_id = (*priority_iter)->getMediaTextureID(); + S32 proximity = (*priority_iter)->getProximity(); + // This is expensive (i.e. a linear search) -- don't use it here. We now use mInNearbyMediaList instead. +// S32 index = mMediaList->getItemIndex(media_id); + + if(proximity < 0 || !shouldShow(*priority_iter)) + { + // This isn't inworld media -- don't show it in the list. + if ((*priority_iter)->getInNearbyMediaList()) + { + // There's a row for this impl -- remove it. + removeMediaItem(media_id); + (*priority_iter)->setInNearbyMediaList(false); + } + } + else + { + if (!(*priority_iter)->getInNearbyMediaList()) + { + // We don't have a row for this impl -- add one. + addMediaItem(media_id); + (*priority_iter)->setInNearbyMediaList(true); + } + } + } + } + + int disabled_count = 0; + int enabled_count = 0; + + // Iterate over the rows in the control, updating ones whose impl exists, and deleting ones whose impl has gone away. + std::vector items = mMediaList->getAllData(); + + for (std::vector::iterator item_it = items.begin(); + item_it != items.end(); + ++item_it) + { + LLScrollListItem* item = (*item_it); + LLUUID row_id = item->getUUID(); + + LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(row_id); + if(impl) + { + updateMediaItem(item, impl); + if(impl->isMediaDisabled()) + disabled_count++; + else + enabled_count++; + } + else + { + // This item's impl has been deleted -- remove the row. + // Removing the row won't throw off our iteration, since we have a local copy of the array. + // We just need to make sure we don't access this item after the delete. + removeMediaItem(row_id); + } + } + mEnableAllCtrl->setEnabled(! LLViewerMedia::getInWorldMediaDisabled() && disabled_count > 0); + mDisableAllCtrl->setEnabled(! LLViewerMedia::getInWorldMediaDisabled() && enabled_count > 0); + + // Set the selection to whatever media impl the media focus/hover is on. + // This is an experiment, and can be removed by ifdefing out these 4 lines. + LLUUID media_target = LLViewerMediaFocus::getInstance()->getControlsMediaID(); + if(media_target.notNull()) + { + mMediaList->selectByID(media_target); + } +} + +void LLPanelNearByMedia::updateColumns() +{ + if (!mDebugInfoVisible) + { + mMediaList->getColumn(VISIBILITY_COLUMN)->setWidth(-1); + mMediaList->getColumn(PROXIMITY_COLUMN)->setWidth(-1); + mMediaList->getColumn(CLASS_COLUMN)->setWidth(-1); + mMediaList->getColumn(DEBUG_COLUMN)->setWidth(-1); + } + else { + mMediaList->getColumn(VISIBILITY_COLUMN)->setWidth(20); + mMediaList->getColumn(PROXIMITY_COLUMN)->setWidth(30); + mMediaList->getColumn(CLASS_COLUMN)->setWidth(20); + mMediaList->getColumn(DEBUG_COLUMN)->setWidth(200); + } +} + +void LLPanelNearByMedia::onClickEnableAll() + { + enableAllHelper(true); + } + +void LLPanelNearByMedia::onClickDisableAll() +{ + enableAllHelper(false); +} + +void LLPanelNearByMedia::enableAllHelper(bool enabled) +{ + bool disabled = !enabled; + + // Iterate over the rows in the control, setting the disable flag on the impl for each. + std::vector items = mMediaList->getAllData(); + + for (std::vector::iterator item_it = items.begin(); + item_it != items.end(); + ++item_it) + { + setDisabled((*item_it)->getUUID(), disabled); + } + + // Now do the parcel media + if (LLViewerParcelMedia::getParcelMedia()) + { + LLViewerParcelMedia::getParcelMedia()->setDisabled(disabled); + } + + // And finally, parcel audio + if (disabled) + { + onClickParcelAudioStop(); + } + else { + onClickParcelAudioPlay(); + } + + // The hilight state of the control will be adjusted the next time through refreshList(). +} + +void LLPanelNearByMedia::onClickEnableParcelMedia() +{ + LLViewerParcelMedia::play(LLViewerParcelMgr::getInstance()->getAgentParcel()); + } + +void LLPanelNearByMedia::onClickDisableParcelMedia() +{ + // This actually unloads the impl, as opposed to "stop"ping the media + LLViewerParcelMedia::stop(); + } + +void LLPanelNearByMedia::onCheckItem(LLUICtrl* ctrl, const LLUUID &row_id) +{ + LLCheckBoxCtrl* check = static_cast(ctrl); + + setDisabled(row_id, ! check->getValue()); +} + +bool LLPanelNearByMedia::setDisabled(const LLUUID &row_id, bool disabled) +{ + LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(row_id); + if(impl) + { + impl->setDisabled(disabled); + return true; + } + return false; +} + +//static +void LLPanelNearByMedia::onZoomMedia(void* user_data) +{ + LLPanelNearByMedia* panelp = (LLPanelNearByMedia*)user_data; + LLUUID media_id = panelp->mMediaList->getValue().asUUID(); + + LLViewerMediaFocus::getInstance()->focusZoomOnMedia(media_id); +} + +void LLPanelNearByMedia::onClickMuteParcelMedia() +{ + if (LLViewerParcelMedia::getParcelMedia()) + { + bool muted = mParcelMediaMuteCtrl->getValue(); + LLViewerParcelMedia::getParcelMedia()->setVolume(muted ? (F32)0 : mParcelMediaVolumeSlider->getValueF32() ); + } +} + +void LLPanelNearByMedia::onParcelMediaVolumeSlider() +{ + if (LLViewerParcelMedia::getParcelMedia()) + { + LLViewerParcelMedia::getParcelMedia()->setVolume(mParcelMediaVolumeSlider->getValueF32()); + } +} + +void LLPanelNearByMedia::onClickParcelMediaPlay() +{ + LLViewerParcelMedia::play(LLViewerParcelMgr::getInstance()->getAgentParcel()); +} + +void LLPanelNearByMedia::onClickParcelMediaStop() +{ + if (LLViewerParcelMedia::getParcelMedia()) + { + // This stops the media playing, as opposed to unloading it like + // LLViewerParcelMedia::stop() does + LLViewerParcelMedia::getParcelMedia()->stop(); + } +} + +void LLPanelNearByMedia::onClickParcelMediaPause() +{ + LLViewerParcelMedia::pause(); +} + +void LLPanelNearByMedia::onClickParcelAudioPlay() +{ + // User *explicitly* started the internet stream, so keep the stream + // playing and updated as they cross to other parcels etc. + mParcelAudioAutoStart = true; + + if (!gAudiop) + return; + + if (PARCEL_AUDIO_PAUSED == gAudiop->isInternetStreamPlaying()) + { + // 'false' means unpause + gAudiop->pauseInternetStream(false); + } + else { + gAudiop->startInternetStream(getParcelAudioURL()); + } +} + +void LLPanelNearByMedia::onClickParcelAudioStop() +{ + // User *explicitly* stopped the internet stream, so don't + // re-start audio when i.e. they move to another parcel, until + // they explicitly start it again. + mParcelAudioAutoStart = false; + + if (!gAudiop) + return; + + gAudiop->stopInternetStream(); +} + +void LLPanelNearByMedia::onClickParcelAudioPause() +{ + if (!gAudiop) + return; + + // 'true' means pause + gAudiop->pauseInternetStream(true); +} + +bool LLPanelNearByMedia::shouldShow(LLViewerMediaImpl* impl) +{ + const LLSD &choice_llsd = mShowCtrl->getSelectedValue(); + MediaClass choice = (MediaClass)choice_llsd.asInteger(); + + switch (choice) + { + case MEDIA_CLASS_ALL: + return true; + break; + case MEDIA_CLASS_WITHIN_PARCEL: + return impl->isInAgentParcel(); + break; + case MEDIA_CLASS_OUTSIDE_PARCEL: + return ! impl->isInAgentParcel(); + break; + case MEDIA_CLASS_ON_OTHERS: + return impl->isAttachedToAnotherAvatar(); + break; + default: + break; + } + return true; +} + +// static +void LLPanelNearByMedia::getNameAndUrlHelper(LLViewerMediaImpl* impl, std::string& name, std::string & url, const std::string &defaultName) +{ + if (NULL == impl) return; + + name = impl->getName(); + url = impl->getCurrentMediaURL(); // This is the URL the media impl actually has loaded + if (url.empty()) + { + url = impl->getMediaEntryURL(); // This is the current URL from the media data + } + if (url.empty()) + { + url = impl->getHomeURL(); // This is the home URL from the media data + } + if (name.empty()) + { + name = url; + } + if (name.empty()) + { + name = defaultName; + } +} + +// static +std::string LLPanelNearByMedia::getParcelAudioURL() +{ + return LLViewerParcelMgr::getInstance()->getAgentParcel()->getMusicURL(); +} + + -- cgit v1.2.3 From 31e08f5a53bdee93d976386f8e40b8531f9dc753 Mon Sep 17 00:00:00 2001 From: richard Date: Thu, 11 Feb 2010 19:38:26 -0800 Subject: more/less button sorta working --- indra/newview/llpanelnearbymedia.cpp | 45 +++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'indra/newview/llpanelnearbymedia.cpp') diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp index b7c3b98032..a4da194a20 100644 --- a/indra/newview/llpanelnearbymedia.cpp +++ b/indra/newview/llpanelnearbymedia.cpp @@ -83,20 +83,20 @@ LLPanelNearByMedia::LLPanelNearByMedia() { mParcelAudioAutoStart = gSavedSettings.getBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING); - mCommitCallbackRegistrar.add("MediaListCtrl.EnableAll", boost::bind(&LLFloaterNearbyMedia::onClickEnableAll, this)); - mCommitCallbackRegistrar.add("MediaListCtrl.DisableAll", boost::bind(&LLFloaterNearbyMedia::onClickDisableAll, this)); - mCommitCallbackRegistrar.add("MediaListCtrl.GoMediaPrefs", boost::bind(&LLFloaterNearbyMedia::onAdvancedButtonClick, this)); - mCommitCallbackRegistrar.add("MediaListCtrl.MoreLess", boost::bind(&LLFloaterNearbyMedia::onMoreLess, this)); - mCommitCallbackRegistrar.add("ParcelMediaCtrl.ParcelMediaVolume", boost::bind(&LLFloaterNearbyMedia::onParcelMediaVolumeSlider, this)); - mCommitCallbackRegistrar.add("ParcelMediaCtrl.MuteParcelMedia", boost::bind(&LLFloaterNearbyMedia::onClickMuteParcelMedia, this)); - mCommitCallbackRegistrar.add("ParcelMediaCtrl.EnableParcelMedia", boost::bind(&LLFloaterNearbyMedia::onClickEnableParcelMedia, this)); - mCommitCallbackRegistrar.add("ParcelMediaCtrl.DisableParcelMedia", boost::bind(&LLFloaterNearbyMedia::onClickDisableParcelMedia, this)); - mCommitCallbackRegistrar.add("ParcelMediaCtrl.Play", boost::bind(&LLFloaterNearbyMedia::onClickParcelMediaPlay, this)); - mCommitCallbackRegistrar.add("ParcelMediaCtrl.Stop", boost::bind(&LLFloaterNearbyMedia::onClickParcelMediaStop, this)); - mCommitCallbackRegistrar.add("ParcelMediaCtrl.Pause", boost::bind(&LLFloaterNearbyMedia::onClickParcelMediaPause, this)); - mCommitCallbackRegistrar.add("ParcelAudioCtrl.Play", boost::bind(&LLFloaterNearbyMedia::onClickParcelAudioPlay, this)); - mCommitCallbackRegistrar.add("ParcelAudioCtrl.Stop", boost::bind(&LLFloaterNearbyMedia::onClickParcelAudioStop, this)); - mCommitCallbackRegistrar.add("ParcelAudioCtrl.Pause", boost::bind(&LLFloaterNearbyMedia::onClickParcelAudioPause, this)); + mCommitCallbackRegistrar.add("MediaListCtrl.EnableAll", boost::bind(&LLPanelNearByMedia::onClickEnableAll, this)); + mCommitCallbackRegistrar.add("MediaListCtrl.DisableAll", boost::bind(&LLPanelNearByMedia::onClickDisableAll, this)); + mCommitCallbackRegistrar.add("MediaListCtrl.GoMediaPrefs", boost::bind(&LLPanelNearByMedia::onAdvancedButtonClick, this)); + mCommitCallbackRegistrar.add("MediaListCtrl.MoreLess", boost::bind(&LLPanelNearByMedia::onMoreLess, this)); + mCommitCallbackRegistrar.add("ParcelMediaCtrl.ParcelMediaVolume", boost::bind(&LLPanelNearByMedia::onParcelMediaVolumeSlider, this)); + mCommitCallbackRegistrar.add("ParcelMediaCtrl.MuteParcelMedia", boost::bind(&LLPanelNearByMedia::onClickMuteParcelMedia, this)); + mCommitCallbackRegistrar.add("ParcelMediaCtrl.EnableParcelMedia", boost::bind(&LLPanelNearByMedia::onClickEnableParcelMedia, this)); + mCommitCallbackRegistrar.add("ParcelMediaCtrl.DisableParcelMedia", boost::bind(&LLPanelNearByMedia::onClickDisableParcelMedia, this)); + mCommitCallbackRegistrar.add("ParcelMediaCtrl.Play", boost::bind(&LLPanelNearByMedia::onClickParcelMediaPlay, this)); + mCommitCallbackRegistrar.add("ParcelMediaCtrl.Stop", boost::bind(&LLPanelNearByMedia::onClickParcelMediaStop, this)); + mCommitCallbackRegistrar.add("ParcelMediaCtrl.Pause", boost::bind(&LLPanelNearByMedia::onClickParcelMediaPause, this)); + mCommitCallbackRegistrar.add("ParcelAudioCtrl.Play", boost::bind(&LLPanelNearByMedia::onClickParcelAudioPlay, this)); + mCommitCallbackRegistrar.add("ParcelAudioCtrl.Stop", boost::bind(&LLPanelNearByMedia::onClickParcelAudioStop, this)); + mCommitCallbackRegistrar.add("ParcelAudioCtrl.Pause", boost::bind(&LLPanelNearByMedia::onClickParcelAudioPause, this)); LLUICtrlFactory::instance().buildPanel(this, "panel_nearby_media.xml"); } @@ -651,7 +651,7 @@ void LLPanelNearByMedia::onClickEnableAll() onClickParcelAudioPlay(); } -void LLFloaterNearbyMedia::onClickDisableAll() +void LLPanelNearByMedia::onClickDisableAll() { LLViewerMedia::setAllMediaEnabled(false); // Parcel Audio, too @@ -799,7 +799,7 @@ bool LLPanelNearByMedia::shouldShow(LLViewerMediaImpl* impl) return true; } -void LLFloaterNearbyMedia::onAdvancedButtonClick() +void LLPanelNearByMedia::onAdvancedButtonClick() { // bring up the prefs floater LLFloaterPreference* prefsfloater = dynamic_cast(LLFloaterReg::showInstance("preferences")); @@ -816,15 +816,18 @@ void LLFloaterNearbyMedia::onAdvancedButtonClick() } } -void LLFloaterNearbyMedia::onMoreLess() +void LLPanelNearByMedia::onMoreLess() { bool is_more = getChild("more_less_btn")->getValue(); mNearbyMediaPanel->setVisible(is_more); -// S32 new_height = mOriginalHeight; -// if (!is_more) new_height -= mNearbyMediaPanelHeight; -// -// reshape(getRect().getWidth(), new_height, false); + S32 new_height = mOriginalHeight; + if (!is_more) new_height -= mNearbyMediaPanelHeight; + + LLRect new_rect = getRect(); + new_rect.mBottom = new_rect.mTop - new_height; + + setShape(new_rect); } // static -- cgit v1.2.3 From 8f54407fe69d5dedad472906470f5e0b6186bf23 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 12 Feb 2010 13:33:10 -0800 Subject: can resize bottom of nearby media panel now, and remembers size when expanding/collapsing --- indra/newview/llpanelnearbymedia.cpp | 42 ++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) (limited to 'indra/newview/llpanelnearbymedia.cpp') diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp index a4da194a20..3480abcf40 100644 --- a/indra/newview/llpanelnearbymedia.cpp +++ b/indra/newview/llpanelnearbymedia.cpp @@ -37,6 +37,7 @@ #include "llaudioengine.h" #include "llcheckboxctrl.h" #include "llcombobox.h" +#include "llresizebar.h" #include "llscrolllistctrl.h" #include "llscrolllistitem.h" #include "llscrolllistcell.h" @@ -108,6 +109,15 @@ BOOL LLPanelNearByMedia::postBuild() { LLPanel::postBuild(); + const S32 RESIZE_BAR_THICKNESS = 6; + LLResizeBar::Params p; + p.rect = LLRect(0, RESIZE_BAR_THICKNESS, getRect().getWidth(), 0); + p.name = "resizebar_bottom"; + p.min_size = getRect().getHeight(); + p.side = LLResizeBar::BOTTOM; + p.resizing_view = this; + addChild( LLUICtrlFactory::create(p) ); + mNearbyMediaPanel = getChild("nearby_media_panel"); mMediaList = getChild("media_list"); mEnableAllCtrl = getChild("all_nearby_media_enable_btn"); @@ -144,8 +154,9 @@ BOOL LLPanelNearByMedia::postBuild() refreshList(); updateColumns(); - mOriginalHeight = getRect().getHeight(); - mNearbyMediaPanelHeight = mNearbyMediaPanel->getRect().getHeight(); + LLView* minimized_controls = getChildView("minimized_controls"); + mMoreHeight = getRect().getHeight(); + mLessHeight = getRect().getHeight() - minimized_controls->getRect().mBottom; getChild("more_less_btn")->setValue(false); onMoreLess(); @@ -191,12 +202,33 @@ void LLPanelNearByMedia::onTopLost () setVisible(FALSE); } +/*virtual*/ +void LLPanelNearByMedia::reshape(S32 width, S32 height, BOOL called_from_parent) +{ + LLPanel::reshape(width, height, called_from_parent); + + LLButton* more_less_btn = getChild("more_less_btn"); + if (more_less_btn->getValue().asBoolean()) + { + mMoreHeight = getRect().getHeight(); + } + +} const F32 AUTO_CLOSE_FADE_TIME_START= 4.0f; const F32 AUTO_CLOSE_FADE_TIME_END = 5.0f; void LLPanelNearByMedia::draw() { + // keep bottom of panel on screen + LLRect screen_rect = calcScreenRect(); + if (screen_rect.mBottom < 0) + { + LLRect new_rect = getRect(); + new_rect.mBottom += 0 - screen_rect.mBottom; + setShape(new_rect); + } + mItemCountText->setValue(llformat(getString("media_item_count_format").c_str(), mMediaList->getItemCount())); // refreshParcelMediaUI(); @@ -821,8 +853,10 @@ void LLPanelNearByMedia::onMoreLess() bool is_more = getChild("more_less_btn")->getValue(); mNearbyMediaPanel->setVisible(is_more); - S32 new_height = mOriginalHeight; - if (!is_more) new_height -= mNearbyMediaPanelHeight; + // enable resizing when expanded + getChildView("resizebar_bottom")->setEnabled(is_more); + + S32 new_height = is_more ? mMoreHeight : mLessHeight; LLRect new_rect = getRect(); new_rect.mBottom = new_rect.mTop - new_height; -- cgit v1.2.3 From ffd962f3a3eafd7b65f90039a5bb04dccb0205bc Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Fri, 12 Feb 2010 13:38:17 -0800 Subject: EXT-5267 EXT-5268: Add Parcel Media and Parcel Audio items to nearby media panel Review #109 This (fairly major) change adds new "items" to the media list for Parcel Media and Parcel Audio. Since these items are special (before the items were always MoaP impls), they had to be treated special. Moreover, actions on all of "media" had to be centralized so that they would have similar behavior. --- indra/newview/llpanelnearbymedia.cpp | 508 ++++++++++++++++++++--------------- 1 file changed, 284 insertions(+), 224 deletions(-) (limited to 'indra/newview/llpanelnearbymedia.cpp') diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp index a4da194a20..35ba0d2347 100644 --- a/indra/newview/llpanelnearbymedia.cpp +++ b/indra/newview/llpanelnearbymedia.cpp @@ -64,11 +64,8 @@ extern LLControlGroup gSavedSettings; -// Ugh, isInternetStreamPlaying() returns not a bool, but an *int*, with -// 0 = stopped, 1 = playing, 2 = paused. -static const int PARCEL_AUDIO_STOPPED = 0; -static const int PARCEL_AUDIO_PLAYING = 1; -static const int PARCEL_AUDIO_PAUSED = 2; +static const LLUUID PARCEL_MEDIA_LIST_ITEM_UUID = LLUUID("CAB5920F-E484-4233-8621-384CF373A321"); +static const LLUUID PARCEL_AUDIO_LIST_ITEM_UUID = LLUUID("DF4B020D-8A24-4B95-AB5D-CA970D694822"); // // LLPanelNearByMedia @@ -79,7 +76,9 @@ LLPanelNearByMedia::LLPanelNearByMedia() mEnableAllCtrl(NULL), mEnableParcelMediaCtrl(NULL), mAllMediaDisabled(false), - mDebugInfoVisible(false) + mDebugInfoVisible(false), + mParcelMediaItem(NULL), + mParcelAudioItem(NULL) { mParcelAudioAutoStart = gSavedSettings.getBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING); @@ -116,7 +115,6 @@ BOOL LLPanelNearByMedia::postBuild() mParcelMediaMuteCtrl = getChild("parcel_media_mute"); mEnableParcelMediaCtrl = getChild("parcel_media_enable_btn"); mDisableParcelMediaCtrl = getChild("parcel_media_disable_btn"); - mParcelMediaText = getChild("parcel_media_name"); mItemCountText = getChild("media_item_count"); mParcelMediaPlayCtrl = getChild("parcel_media_play_btn"); mParcelMediaPauseCtrl = getChild("parcel_media_pause_btn"); @@ -127,20 +125,13 @@ BOOL LLPanelNearByMedia::postBuild() mShowCtrl = getChild("show_combo"); mEmptyNameString = getString("empty_item_text"); - mDefaultParcelMediaName = getString("default_parcel_media_name"); + mParcelMediaName = getString("parcel_media_name"); + mParcelAudioName = getString("parcel_audio_name"); mPlayingString = getString("playing_suffix"); mMediaList->setDoubleClickCallback(onZoomMedia, this); mMediaList->sortByColumnIndex(PROXIMITY_COLUMN, TRUE); mMediaList->sortByColumnIndex(VISIBILITY_COLUMN, FALSE); - - std::string url = LLViewerParcelMedia::getURL(); - if (!url.empty()) - { - std::string name = LLViewerParcelMedia::getName(); - mParcelMediaText->setValue(name.empty()?url:name); - mParcelMediaText->setToolTip(url); - } refreshList(); updateColumns(); @@ -199,8 +190,6 @@ void LLPanelNearByMedia::draw() { mItemCountText->setValue(llformat(getString("media_item_count_format").c_str(), mMediaList->getItemCount())); -// refreshParcelMediaUI(); -// refreshParcelAudioUI(); refreshList(); F32 alpha = mHoverTimer.getStarted() @@ -221,11 +210,11 @@ bool LLPanelNearByMedia::getParcelAudioAutoStart() return mParcelAudioAutoStart; } -void LLPanelNearByMedia::addMediaItem(const LLUUID &id) +LLScrollListItem* LLPanelNearByMedia::addListItem(const LLUUID &id) { - if (NULL == mMediaList) return; + if (NULL == mMediaList) return NULL; - // Just set up the columns -- the values will be filled in by updateMediaItem(). + // Just set up the columns -- the values will be filled in by updateListItem(). LLSD row; row["id"] = id; @@ -255,22 +244,98 @@ void LLPanelNearByMedia::addMediaItem(const LLUUID &id) } LLScrollListItem* new_item = mMediaList->addElement(row); - LLScrollListCheck* scroll_list_check = dynamic_cast(new_item->getColumn(CHECKBOX_COLUMN)); - if (scroll_list_check) + if (NULL != new_item) { - LLCheckBoxCtrl *check = scroll_list_check->getCheckBox(); - check->setCommitCallback(boost::bind(&LLPanelNearByMedia::onCheckItem, this, _1, id)); - } + LLScrollListCheck* scroll_list_check = dynamic_cast(new_item->getColumn(CHECKBOX_COLUMN)); + if (scroll_list_check) + { + LLCheckBoxCtrl *check = scroll_list_check->getCheckBox(); + check->setCommitCallback(boost::bind(&LLPanelNearByMedia::onCheckItem, this, _1, id)); + } + } + return new_item; } -void LLPanelNearByMedia::updateMediaItem(LLScrollListItem* item, LLViewerMediaImpl* impl) +void LLPanelNearByMedia::updateListItem(LLScrollListItem* item, LLViewerMediaImpl* impl) +{ + std::string item_name; + std::string item_tooltip; + std::string debug_str; + LLPanelNearByMedia::MediaClass media_class = MEDIA_CLASS_ALL; + + getNameAndUrlHelper(impl, item_name, item_tooltip, mEmptyNameString); + // Focused + if (impl->hasFocus()) + { + media_class = MEDIA_CLASS_FOCUSED; + } + // Is attached to another avatar? + else if (impl->isAttachedToAnotherAvatar()) + { + media_class = MEDIA_CLASS_ON_OTHERS; + } + // Outside agent parcel + else if (!impl->isInAgentParcel()) + { + media_class = MEDIA_CLASS_OUTSIDE_PARCEL; + } + else { + // inside parcel + media_class = MEDIA_CLASS_WITHIN_PARCEL; + } + + if(mDebugInfoVisible) + { + debug_str += llformat("%g/", (float)impl->getInterest()); + + // proximity distance is actually distance squared -- display it as straight distance. + debug_str += llformat("%g/", fsqrtf(impl->getProximityDistance())); + + // s += llformat("%g/", (float)impl->getCPUUsage()); + // s += llformat("%g/", (float)impl->getApproximateTextureInterest()); + debug_str += llformat("%g/", (float)(NULL == impl->getSomeObject()) ? 0.0 : impl->getSomeObject()->getPixelArea()); + + debug_str += LLPluginClassMedia::priorityToString(impl->getPriority()); + + if(impl->hasMedia()) + { + debug_str += '@'; + } + else if(impl->isPlayable()) + { + debug_str += '+'; + } + else if(impl->isForcedUnloaded()) + { + debug_str += '!'; + } + } + + updateListItem(item, + item_name, + item_tooltip, + impl->getProximity(), + impl->isMediaDisabled(), + impl->hasMedia(), + impl->isMediaTimeBased() && impl->isMediaPlaying(), + media_class, + debug_str); +} + +void LLPanelNearByMedia::updateListItem(LLScrollListItem* item, + const std::string &item_name, + const std::string &item_tooltip, + S32 proximity, + bool is_disabled, + bool has_media, + bool is_time_based_and_playing, + LLPanelNearByMedia::MediaClass media_class, + const std::string &debug_str) { LLScrollListCell* cell = item->getColumn(PROXIMITY_COLUMN); if(cell) { // since we are forced to sort by text, encode sort order as string - // proximity of -1 means "closest" - S32 proximity = impl->isParcelMedia() ? -1 : impl->getProximity(); std::string proximity_string = STRINGIZE(proximity); std::string old_proximity_string = cell->getValue().asString(); if(proximity_string != old_proximity_string) @@ -283,86 +348,83 @@ void LLPanelNearByMedia::updateMediaItem(LLScrollListItem* item, LLViewerMediaIm cell = item->getColumn(CHECKBOX_COLUMN); if(cell) { - cell->setValue(!impl->isMediaDisabled()); + cell->setValue(!is_disabled); } cell = item->getColumn(VISIBILITY_COLUMN); if(cell) { S32 old_visibility = cell->getValue(); - S32 new_visibility = (impl->hasMedia()) ? 1 : ((impl->isMediaDisabled()) ? 0 : -1); + // *HACK ALERT: force ordering of Media before Audio before the rest of the list + S32 new_visibility = + item->getUUID() == PARCEL_MEDIA_LIST_ITEM_UUID ? 3 + : item->getUUID() == PARCEL_AUDIO_LIST_ITEM_UUID ? 2 + : (has_media) ? 1 + : ((is_disabled) ? 0 + : -1); cell->setValue(STRINGIZE(new_visibility)); if (new_visibility != old_visibility) { mMediaList->setNeedsSort(true); } } - - S32 media_class = -1; + cell = item->getColumn(NAME_COLUMN); if(cell) { - std::string name; - std::string url; + std::string name = item_name; std::string old_name = cell->getValue().asString(); - - getNameAndUrlHelper(impl, name, url, mEmptyNameString); - - if (impl->isParcelMedia()) + if (has_media) { - cell->setToolTip(name + " : " + url); - name = mDefaultParcelMediaName; - } - else { - cell->setToolTip(url); + name += " " + mPlayingString; } - if (impl->hasMedia()) name += " " + mPlayingString; if (name != old_name) { cell->setValue(name); } + cell->setToolTip(item_tooltip); // *TODO: Make these font styles/colors configurable via XUI - LLColor4 cell_color = LLColor4::white; U8 font_style = LLFontGL::NORMAL; + LLColor4 cell_color = LLColor4::white; - // Focused - if (impl->hasFocus()) - { - if (mDebugInfoVisible) cell_color = LLColor4::yellow; - media_class = MEDIA_CLASS_FOCUSED; - } - // Is attached to another avatar? - else if (impl->isAttachedToAnotherAvatar()) - { - if (mDebugInfoVisible) cell_color = LLColor4::red; - media_class = MEDIA_CLASS_ON_OTHERS; - } - // Outside agent parcel - else if (!impl->isInAgentParcel()) + // Only colorize by class in debug + if (mDebugInfoVisible) { - if (mDebugInfoVisible) cell_color = LLColor4::orange; - media_class = MEDIA_CLASS_OUTSIDE_PARCEL; - } - else { - // inside parcel - media_class = MEDIA_CLASS_WITHIN_PARCEL; + switch (media_class) { + case MEDIA_CLASS_FOCUSED: + cell_color = LLColor4::yellow; + break; + case MEDIA_CLASS_ON_OTHERS: + cell_color = LLColor4::red; + break; + case MEDIA_CLASS_OUTSIDE_PARCEL: + cell_color = LLColor4::orange; + break; + case MEDIA_CLASS_WITHIN_PARCEL: + default: + break; + } } - if (impl->isMediaDisabled()) + if (is_disabled) { - //font_style |= LLFontGL::ITALIC; - //cell_color = LLColor4::black; - // Dim it if it is disabled - cell_color.setAlpha(0.25); + if (mDebugInfoVisible) + { + font_style |= LLFontGL::ITALIC; + cell_color = LLColor4::black; + } + else { + // Dim it if it is disabled + cell_color.setAlpha(0.25); + } } // Dim it if it isn't "showing" - else if (!impl->hasMedia()) + else if (!has_media) { cell_color.setAlpha(0.25); } // Bold it if it is time-based media and it is playing - else if (impl->isMediaTimeBased() && - impl->isMediaPlaying()) + else if (is_time_based_and_playing) { if (mDebugInfoVisible) font_style |= LLFontGL::BOLD; } @@ -386,125 +448,101 @@ void LLPanelNearByMedia::updateMediaItem(LLScrollListItem* item, LLViewerMediaIm cell = item->getColumn(DEBUG_COLUMN); if(cell) { - std::string s; - - s += llformat("%g/", (float)impl->getInterest()); - - // proximity distance is actually distance squared -- display it as straight distance. - s += llformat("%g/", fsqrtf(impl->getProximityDistance())); - -// s += llformat("%g/", (float)impl->getCPUUsage()); -// s += llformat("%g/", (float)impl->getApproximateTextureInterest()); - s += llformat("%g/", (float)(NULL == impl->getSomeObject()) ? 0.0 : impl->getSomeObject()->getPixelArea()); - - s += LLPluginClassMedia::priorityToString(impl->getPriority()); - - if(impl->hasMedia()) - { - s += '@'; - } - else if(impl->isPlayable()) - { - s += '+'; - } - else if(impl->isForcedUnloaded()) - { - s += '!'; - } - - cell->setValue(s); + cell->setValue(debug_str); } } } - -void LLPanelNearByMedia::removeMediaItem(const LLUUID &id) + +void LLPanelNearByMedia::removeListItem(const LLUUID &id) { if (NULL == mMediaList) return; mMediaList->deleteSingleItem(mMediaList->getItemIndex(id)); } -void LLPanelNearByMedia::refreshParcelMediaUI() -{ - std::string url = LLViewerParcelMedia::getURL(); - LLStyle::Params style_params; - if (url.empty()) - { - style_params.font.style = "ITALIC"; - mParcelMediaText->setText(mDefaultParcelMediaName, style_params); - mEnableParcelMediaCtrl->setEnabled(false); - mDisableParcelMediaCtrl->setEnabled(false); - } - else { - std::string name = LLViewerParcelMedia::getName(); - if (name.empty()) name = url; - mParcelMediaText->setText(name, style_params); - mParcelMediaText->setToolTip(url); - mEnableParcelMediaCtrl->setEnabled(true); - mDisableParcelMediaCtrl->setEnabled(true); - } - - // Set up the default play controls state - mParcelMediaPauseCtrl->setEnabled(false); - mParcelMediaPauseCtrl->setVisible(false); - mParcelMediaPlayCtrl->setEnabled(true); - mParcelMediaPlayCtrl->setVisible(true); - mParcelMediaCtrl->setEnabled(false); +void LLPanelNearByMedia::refreshParcelItems() +{ + // + // First add/remove the "fake" items Parcel Media and Parcel Audio. + // These items will have special UUIDs + // PARCEL_MEDIA_LIST_ITEM_UUID + // PARCEL_AUDIO_LIST_ITEM_UUID + // + // Get the filter choice. + const LLSD &choice_llsd = mShowCtrl->getSelectedValue(); + MediaClass choice = (MediaClass)choice_llsd.asInteger(); + // Only show "special parcel items" if "All" or "Within" filter + bool should_include = choice == MEDIA_CLASS_ALL || choice == MEDIA_CLASS_WITHIN_PARCEL; - if (LLViewerParcelMedia::getParcelMedia()) + // First Parcel Media: add or remove it as necessary + if (should_include && LLViewerMedia::hasParcelMedia()) { - if (LLViewerParcelMedia::getParcelMedia()->getMediaPlugin() && - LLViewerParcelMedia::getParcelMedia()->getMediaPlugin()->pluginSupportsMediaTime()) + // Yes, there is parcel media. + if (NULL == mParcelMediaItem) { - mParcelMediaCtrl->setEnabled(true); - - switch(LLViewerParcelMedia::getParcelMedia()->getMediaPlugin()->getStatus()) - { - case LLPluginClassMediaOwner::MEDIA_PLAYING: - mParcelMediaPlayCtrl->setEnabled(false); - mParcelMediaPlayCtrl->setVisible(false); - mParcelMediaPauseCtrl->setEnabled(true); - mParcelMediaPauseCtrl->setVisible(true); - break; - case LLPluginClassMediaOwner::MEDIA_PAUSED: - default: - // default play status is kosher - break; - } + mParcelMediaItem = addListItem(PARCEL_MEDIA_LIST_ITEM_UUID); + mMediaList->setNeedsSort(true); } } -} - -void LLPanelNearByMedia::refreshParcelAudioUI() -{ - bool parcel_audio_enabled = !getParcelAudioURL().empty(); - - mParcelAudioCtrl->setToolTip(getParcelAudioURL()); + else if (NULL != mParcelMediaItem) { + removeListItem(PARCEL_MEDIA_LIST_ITEM_UUID); + mParcelMediaItem = NULL; + mMediaList->setNeedsSort(true); + } - if (gAudiop && parcel_audio_enabled) + // ... then update it + if (NULL != mParcelMediaItem) { - mParcelAudioCtrl->setEnabled(true); - - if (PARCEL_AUDIO_PLAYING == gAudiop->isInternetStreamPlaying()) + std::string name, url, tooltip; + getNameAndUrlHelper(LLViewerParcelMedia::getParcelMedia(), name, url, ""); + if (name.empty()) { - mParcelAudioPlayCtrl->setEnabled(false); - mParcelAudioPlayCtrl->setVisible(false); - mParcelAudioPauseCtrl->setEnabled(true); - mParcelAudioPauseCtrl->setVisible(true); + tooltip = url; } else { - mParcelAudioPlayCtrl->setEnabled(true); - mParcelAudioPlayCtrl->setVisible(true); - mParcelAudioPauseCtrl->setEnabled(false); - mParcelAudioPauseCtrl->setVisible(false); + tooltip = name + " : " + url; } + LLViewerMediaImpl *impl = LLViewerParcelMedia::getParcelMedia(); + updateListItem(mParcelMediaItem, + mParcelMediaName, + tooltip, + -2, // Proximity closer than anything else, before Parcel Audio + impl == NULL || impl->isMediaDisabled(), + impl != NULL && !LLViewerParcelMedia::getURL().empty(), + impl != NULL && impl->isMediaTimeBased() && impl->isMediaPlaying(), + MEDIA_CLASS_ALL, + "parcel media"); } - else { - mParcelAudioCtrl->setEnabled(false); - mParcelAudioPlayCtrl->setEnabled(true); - mParcelAudioPlayCtrl->setVisible(true); - mParcelAudioPauseCtrl->setEnabled(false); - mParcelAudioPauseCtrl->setVisible(false); + + // Next Parcel Audio: add or remove it as necessary + if (should_include && LLViewerMedia::hasParcelAudio()) + { + // Yes, there is parcel audio. + if (NULL == mParcelAudioItem) + { + mParcelAudioItem = addListItem(PARCEL_AUDIO_LIST_ITEM_UUID); + mMediaList->setNeedsSort(true); + } + } + else if (NULL != mParcelAudioItem) { + removeListItem(PARCEL_AUDIO_LIST_ITEM_UUID); + mParcelAudioItem = NULL; + mMediaList->setNeedsSort(true); + } + + // ... then update it + if (NULL != mParcelAudioItem) + { + bool is_playing = LLViewerMedia::isParcelAudioPlaying(); + updateListItem(mParcelAudioItem, + mParcelAudioName, + LLViewerMedia::getParcelAudioURL(), + -1, // Proximity after Parcel Media, but closer than anything else + !is_playing, + is_playing, + is_playing, + MEDIA_CLASS_ALL, + "parcel audio"); } } @@ -531,6 +569,8 @@ void LLPanelNearByMedia::refreshList() updateColumns(); } + refreshParcelItems(); + // Get the canonical list from LLViewerMedia LLViewerMedia::impl_list impls = LLViewerMedia::getPriorityList(); LLViewerMedia::impl_list::iterator priority_iter; @@ -548,27 +588,19 @@ void LLPanelNearByMedia::refreshList() { impl->setInNearbyMediaList(false); } - + + if (!impl->isParcelMedia()) { - bool remove_item = false; LLUUID media_id = impl->getMediaTextureID(); - if (impl->isParcelMedia()) - { - remove_item = LLViewerParcelMedia::getURL().empty(); - } - else { - S32 proximity = impl->getProximity(); + S32 proximity = impl->getProximity(); // This is expensive (i.e. a linear search) -- don't use it here. We now use mInNearbyMediaList instead. -// S32 index = mMediaList->getItemIndex(media_id); - remove_item = (proximity < 0 || !shouldShow(impl)); - } - if (remove_item) + //S32 index = mMediaList->getItemIndex(media_id); + if (proximity < 0 || !shouldShow(impl)) { - // This isn't inworld media -- don't show it in the list. if (impl->getInNearbyMediaList()) { // There's a row for this impl -- remove it. - removeMediaItem(media_id); + removeListItem(media_id); impl->setInNearbyMediaList(false); } } @@ -577,7 +609,7 @@ void LLPanelNearByMedia::refreshList() if (!impl->getInNearbyMediaList()) { // We don't have a row for this impl -- add one. - addMediaItem(media_id); + addListItem(media_id); impl->setInNearbyMediaList(true); } } @@ -590,9 +622,15 @@ void LLPanelNearByMedia::refreshList() enabled_count++; } } - } - mDisableAllCtrl->setEnabled(LLViewerMedia::isAnyMediaShowing()); - mEnableAllCtrl->setEnabled(disabled_count > 0); + } + mDisableAllCtrl->setEnabled(LLViewerMedia::isAnyMediaShowing() || + LLViewerMedia::isParcelMediaPlaying() || + LLViewerMedia::isParcelAudioPlaying()); + mEnableAllCtrl->setEnabled(disabled_count > 0 || + // parcel media (if we have it, and it isn't playing, enable "start") + (LLViewerMedia::hasParcelMedia() && ! LLViewerMedia::isParcelMediaPlaying()) || + // parcel audio (if we have it, and it isn't playing, enable "start") + (LLViewerMedia::hasParcelAudio() && ! LLViewerMedia::isParcelAudioPlaying())); // Iterate over the rows in the control, updating ones whose impl exists, and deleting ones whose impl has gone away. std::vector items = mMediaList->getAllData(); @@ -604,17 +642,21 @@ void LLPanelNearByMedia::refreshList() LLScrollListItem* item = (*item_it); LLUUID row_id = item->getUUID(); - LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(row_id); - if(impl) - { - updateMediaItem(item, impl); - } - else + if (row_id != PARCEL_MEDIA_LIST_ITEM_UUID && + row_id != PARCEL_AUDIO_LIST_ITEM_UUID) { - // This item's impl has been deleted -- remove the row. - // Removing the row won't throw off our iteration, since we have a local copy of the array. - // We just need to make sure we don't access this item after the delete. - removeMediaItem(row_id); + LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(row_id); + if(impl) + { + updateListItem(item, impl); + } + else + { + // This item's impl has been deleted -- remove the row. + // Removing the row won't throw off our iteration, since we have a local copy of the array. + // We just need to make sure we don't access this item after the delete. + removeListItem(row_id); + } } } @@ -645,29 +687,28 @@ void LLPanelNearByMedia::updateColumns() } void LLPanelNearByMedia::onClickEnableAll() - { +{ LLViewerMedia::setAllMediaEnabled(true); - // Parcel Audio, too - onClickParcelAudioPlay(); - } +} void LLPanelNearByMedia::onClickDisableAll() - { +{ LLViewerMedia::setAllMediaEnabled(false); - // Parcel Audio, too - onClickParcelAudioStop(); - } +} void LLPanelNearByMedia::onClickEnableParcelMedia() { + if ( ! LLViewerMedia::isParcelMediaPlaying() ) + { LLViewerParcelMedia::play(LLViewerParcelMgr::getInstance()->getAgentParcel()); } +} void LLPanelNearByMedia::onClickDisableParcelMedia() { - // This actually unloads the impl, as opposed to "stop"ping the media - LLViewerParcelMedia::stop(); - } + // This actually unloads the impl, as opposed to "stop"ping the media + LLViewerParcelMedia::stop(); +} void LLPanelNearByMedia::onCheckItem(LLUICtrl* ctrl, const LLUUID &row_id) { @@ -678,12 +719,26 @@ void LLPanelNearByMedia::onCheckItem(LLUICtrl* ctrl, const LLUUID &row_id) bool LLPanelNearByMedia::setDisabled(const LLUUID &row_id, bool disabled) { - LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(row_id); - if(impl) + if (row_id == PARCEL_AUDIO_LIST_ITEM_UUID) { - impl->setDisabled(disabled); + if (disabled) onClickParcelAudioStop(); + else onClickParcelAudioStart(); return true; } + else if (row_id == PARCEL_MEDIA_LIST_ITEM_UUID) + { + if (disabled) onClickDisableParcelMedia(); + else onClickEnableParcelMedia(); + return true; + } + else { + LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(row_id); + if(impl) + { + impl->setDisabled(disabled); + return true; + } + } return false; } @@ -733,6 +788,18 @@ void LLPanelNearByMedia::onClickParcelMediaPause() LLViewerParcelMedia::pause(); } +void LLPanelNearByMedia::onClickParcelAudioStart() +{ + // User *explicitly* started the internet stream, so keep the stream + // playing and updated as they cross to other parcels etc. + mParcelAudioAutoStart = true; + + if (!gAudiop) + return; + + gAudiop->startInternetStream(LLViewerMedia::getParcelAudioURL()); +} + void LLPanelNearByMedia::onClickParcelAudioPlay() { // User *explicitly* started the internet stream, so keep the stream @@ -742,13 +809,13 @@ void LLPanelNearByMedia::onClickParcelAudioPlay() if (!gAudiop) return; - if (PARCEL_AUDIO_PAUSED == gAudiop->isInternetStreamPlaying()) + if (LLAudioEngine::AUDIO_PAUSED == gAudiop->isInternetStreamPlaying()) { // 'false' means unpause gAudiop->pauseInternetStream(false); } else { - gAudiop->startInternetStream(getParcelAudioURL()); + gAudiop->startInternetStream(LLViewerMedia::getParcelAudioURL()); } } @@ -829,7 +896,7 @@ void LLPanelNearByMedia::onMoreLess() setShape(new_rect); } - + // static void LLPanelNearByMedia::getNameAndUrlHelper(LLViewerMediaImpl* impl, std::string& name, std::string & url, const std::string &defaultName) { @@ -855,10 +922,3 @@ void LLPanelNearByMedia::getNameAndUrlHelper(LLViewerMediaImpl* impl, std::strin } } -// static -std::string LLPanelNearByMedia::getParcelAudioURL() -{ - return LLViewerParcelMgr::getInstance()->getAgentParcel()->getMusicURL(); -} - - -- cgit v1.2.3 From e159873eec4137b041fc8045f6d79ac6c21d2101 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 12 Feb 2010 16:54:47 -0800 Subject: added popup panel to hold nearby media popup and stopped using top view --- indra/newview/llpanelnearbymedia.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'indra/newview/llpanelnearbymedia.cpp') diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp index 3480abcf40..9753fd9b54 100644 --- a/indra/newview/llpanelnearbymedia.cpp +++ b/indra/newview/llpanelnearbymedia.cpp @@ -184,22 +184,26 @@ void LLPanelNearByMedia::handleVisibilityChange ( BOOL new_visibility ) if (new_visibility) { mHoverTimer.start(); // timer will be stopped when mouse hovers over panel - gFocusMgr.setTopCtrl(this); + //gFocusMgr.setTopCtrl(this); } else { mHoverTimer.stop(); - if (gFocusMgr.getTopCtrl() == this) - { - gFocusMgr.setTopCtrl(NULL); - } + //if (gFocusMgr.getTopCtrl() == this) + //{ + // gFocusMgr.setTopCtrl(NULL); + //} } } /*virtual*/ void LLPanelNearByMedia::onTopLost () { - setVisible(FALSE); + //LLUICtrl* new_top = gFocusMgr.getTopCtrl(); + //if (!new_top || !new_top->hasAncestor(this)) + //{ + // setVisible(FALSE); + //} } /*virtual*/ @@ -220,6 +224,13 @@ const F32 AUTO_CLOSE_FADE_TIME_END = 5.0f; void LLPanelNearByMedia::draw() { + //LLUICtrl* new_top = gFocusMgr.getTopCtrl(); + //if (new_top != this) + //{ + // // reassert top ctrl + // gFocusMgr.setTopCtrl(this); + //} + // keep bottom of panel on screen LLRect screen_rect = calcScreenRect(); if (screen_rect.mBottom < 0) -- cgit v1.2.3 From 0e234edcc67ecf534df15f088158ef236f6de102 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Tue, 16 Feb 2010 15:42:33 -0800 Subject: EXT-5270: Implement "dynamic" controls based on the selected item in Nearby Media Review #112 This change adds controls that change state based on the selection in the nearby media panel. There are basically 3 sets: - Time-based - Web-based ("Normal") - Disabled Again, these change based on what you've got selected in the panel --- indra/newview/llpanelnearbymedia.cpp | 309 +++++++++++++++++++++++++++++------ 1 file changed, 260 insertions(+), 49 deletions(-) (limited to 'indra/newview/llpanelnearbymedia.cpp') diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp index 464ba97278..6a88c916d7 100644 --- a/indra/newview/llpanelnearbymedia.cpp +++ b/indra/newview/llpanelnearbymedia.cpp @@ -41,6 +41,7 @@ #include "llscrolllistctrl.h" #include "llscrolllistitem.h" #include "llscrolllistcell.h" +#include "llslider.h" #include "llsliderctrl.h" #include "llagent.h" #include "llagentui.h" @@ -75,28 +76,26 @@ static const LLUUID PARCEL_AUDIO_LIST_ITEM_UUID = LLUUID("DF4B020D-8A24-4B95-AB5 LLPanelNearByMedia::LLPanelNearByMedia() : mMediaList(NULL), mEnableAllCtrl(NULL), - mEnableParcelMediaCtrl(NULL), mAllMediaDisabled(false), mDebugInfoVisible(false), mParcelMediaItem(NULL), mParcelAudioItem(NULL) { - mParcelAudioAutoStart = gSavedSettings.getBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING); + mParcelAudioAutoStart = gSavedSettings.getBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING) && + gSavedSettings.getBOOL("MediaTentativeAutoPlay"); mCommitCallbackRegistrar.add("MediaListCtrl.EnableAll", boost::bind(&LLPanelNearByMedia::onClickEnableAll, this)); mCommitCallbackRegistrar.add("MediaListCtrl.DisableAll", boost::bind(&LLPanelNearByMedia::onClickDisableAll, this)); mCommitCallbackRegistrar.add("MediaListCtrl.GoMediaPrefs", boost::bind(&LLPanelNearByMedia::onAdvancedButtonClick, this)); mCommitCallbackRegistrar.add("MediaListCtrl.MoreLess", boost::bind(&LLPanelNearByMedia::onMoreLess, this)); - mCommitCallbackRegistrar.add("ParcelMediaCtrl.ParcelMediaVolume", boost::bind(&LLPanelNearByMedia::onParcelMediaVolumeSlider, this)); - mCommitCallbackRegistrar.add("ParcelMediaCtrl.MuteParcelMedia", boost::bind(&LLPanelNearByMedia::onClickMuteParcelMedia, this)); - mCommitCallbackRegistrar.add("ParcelMediaCtrl.EnableParcelMedia", boost::bind(&LLPanelNearByMedia::onClickEnableParcelMedia, this)); - mCommitCallbackRegistrar.add("ParcelMediaCtrl.DisableParcelMedia", boost::bind(&LLPanelNearByMedia::onClickDisableParcelMedia, this)); - mCommitCallbackRegistrar.add("ParcelMediaCtrl.Play", boost::bind(&LLPanelNearByMedia::onClickParcelMediaPlay, this)); - mCommitCallbackRegistrar.add("ParcelMediaCtrl.Stop", boost::bind(&LLPanelNearByMedia::onClickParcelMediaStop, this)); - mCommitCallbackRegistrar.add("ParcelMediaCtrl.Pause", boost::bind(&LLPanelNearByMedia::onClickParcelMediaPause, this)); - mCommitCallbackRegistrar.add("ParcelAudioCtrl.Play", boost::bind(&LLPanelNearByMedia::onClickParcelAudioPlay, this)); - mCommitCallbackRegistrar.add("ParcelAudioCtrl.Stop", boost::bind(&LLPanelNearByMedia::onClickParcelAudioStop, this)); - mCommitCallbackRegistrar.add("ParcelAudioCtrl.Pause", boost::bind(&LLPanelNearByMedia::onClickParcelAudioPause, this)); + mCommitCallbackRegistrar.add("SelectedMediaCtrl.Stop", boost::bind(&LLPanelNearByMedia::onClickSelectedMediaStop, this)); + mCommitCallbackRegistrar.add("SelectedMediaCtrl.Play", boost::bind(&LLPanelNearByMedia::onClickSelectedMediaPlay, this)); + mCommitCallbackRegistrar.add("SelectedMediaCtrl.Pause", boost::bind(&LLPanelNearByMedia::onClickSelectedMediaPause, this)); + mCommitCallbackRegistrar.add("SelectedMediaCtrl.Mute", boost::bind(&LLPanelNearByMedia::onClickSelectedMediaMute, this)); + mCommitCallbackRegistrar.add("SelectedMediaCtrl.Volume", boost::bind(&LLPanelNearByMedia::onCommitSelectedMediaVolume, this)); + mCommitCallbackRegistrar.add("SelectedMediaCtrl.Zoom", boost::bind(&LLPanelNearByMedia::onClickSelectedMediaZoom, this)); + mCommitCallbackRegistrar.add("SelectedMediaCtrl.Unzoom", boost::bind(&LLPanelNearByMedia::onClickSelectedMediaUnzoom, this)); + LLUICtrlFactory::instance().buildPanel(this, "panel_nearby_media.xml"); } @@ -121,18 +120,19 @@ BOOL LLPanelNearByMedia::postBuild() mMediaList = getChild("media_list"); mEnableAllCtrl = getChild("all_nearby_media_enable_btn"); mDisableAllCtrl = getChild("all_nearby_media_disable_btn"); - mParcelMediaVolumeSlider = getChild("parcel_media_volume"); - mParcelMediaMuteCtrl = getChild("parcel_media_mute"); - mEnableParcelMediaCtrl = getChild("parcel_media_enable_btn"); - mDisableParcelMediaCtrl = getChild("parcel_media_disable_btn"); mItemCountText = getChild("media_item_count"); - mParcelMediaPlayCtrl = getChild("parcel_media_play_btn"); - mParcelMediaPauseCtrl = getChild("parcel_media_pause_btn"); - mParcelMediaCtrl = getChild("parcel_media_ctrls"); - mParcelAudioPlayCtrl = getChild("parcel_audio_play_btn"); - mParcelAudioPauseCtrl = getChild("parcel_audio_pause_btn"); - mParcelAudioCtrl = getChild("parcel_audio_ctrls"); mShowCtrl = getChild("show_combo"); + + // Dynamic (selection-dependent) controls + mStopCtrl = getChild("stop"); + mPlayCtrl = getChild("play"); + mPauseCtrl = getChild("pause"); + mMuteCtrl = getChild("mute"); + mVolumeSliderCtrl = getChild("volume_slider_ctrl"); + mZoomCtrl = getChild("zoom"); + mUnzoomCtrl = getChild("unzoom"); + mVolumeSlider = getChild("volume_slider"); + mMuteBtn = getChild("mute_btn"); mEmptyNameString = getString("empty_item_text"); mParcelMediaName = getString("parcel_media_name"); @@ -142,7 +142,9 @@ BOOL LLPanelNearByMedia::postBuild() mMediaList->setDoubleClickCallback(onZoomMedia, this); mMediaList->sortByColumnIndex(PROXIMITY_COLUMN, TRUE); mMediaList->sortByColumnIndex(VISIBILITY_COLUMN, FALSE); + refreshList(); + updateControls(); updateColumns(); LLView* minimized_controls = getChildView("minimized_controls"); @@ -234,6 +236,7 @@ void LLPanelNearByMedia::draw() mItemCountText->setValue(llformat(getString("media_item_count_format").c_str(), mMediaList->getItemCount())); refreshList(); + updateControls(); F32 alpha = mHoverTimer.getStarted() ? clamp_rescale(mHoverTimer.getElapsedTimeF32(), AUTO_CLOSE_FADE_TIME_START, AUTO_CLOSE_FADE_TIME_END, 1.f, 0.f) @@ -527,10 +530,12 @@ void LLPanelNearByMedia::refreshParcelItems() mMediaList->setNeedsSort(true); } } - else if (NULL != mParcelMediaItem) { - removeListItem(PARCEL_MEDIA_LIST_ITEM_UUID); - mParcelMediaItem = NULL; - mMediaList->setNeedsSort(true); + else { + if (NULL != mParcelMediaItem) { + removeListItem(PARCEL_MEDIA_LIST_ITEM_UUID); + mParcelMediaItem = NULL; + mMediaList->setNeedsSort(true); + } } // ... then update it @@ -538,7 +543,7 @@ void LLPanelNearByMedia::refreshParcelItems() { std::string name, url, tooltip; getNameAndUrlHelper(LLViewerParcelMedia::getParcelMedia(), name, url, ""); - if (name.empty()) + if (name.empty() || name == url) { tooltip = url; } @@ -567,10 +572,12 @@ void LLPanelNearByMedia::refreshParcelItems() mMediaList->setNeedsSort(true); } } - else if (NULL != mParcelAudioItem) { - removeListItem(PARCEL_AUDIO_LIST_ITEM_UUID); - mParcelAudioItem = NULL; - mMediaList->setNeedsSort(true); + else { + if (NULL != mParcelAudioItem) { + removeListItem(PARCEL_AUDIO_LIST_ITEM_UUID); + mParcelAudioItem = NULL; + mMediaList->setNeedsSort(true); + } } // ... then update it @@ -716,12 +723,14 @@ void LLPanelNearByMedia::updateColumns() { if (!mDebugInfoVisible) { + if (mMediaList->getColumn(CHECKBOX_COLUMN)) mMediaList->getColumn(VISIBILITY_COLUMN)->setWidth(-1); if (mMediaList->getColumn(VISIBILITY_COLUMN)) mMediaList->getColumn(VISIBILITY_COLUMN)->setWidth(-1); if (mMediaList->getColumn(PROXIMITY_COLUMN)) mMediaList->getColumn(PROXIMITY_COLUMN)->setWidth(-1); if (mMediaList->getColumn(CLASS_COLUMN)) mMediaList->getColumn(CLASS_COLUMN)->setWidth(-1); if (mMediaList->getColumn(DEBUG_COLUMN)) mMediaList->getColumn(DEBUG_COLUMN)->setWidth(-1); } else { + if (mMediaList->getColumn(CHECKBOX_COLUMN)) mMediaList->getColumn(VISIBILITY_COLUMN)->setWidth(20); if (mMediaList->getColumn(VISIBILITY_COLUMN)) mMediaList->getColumn(VISIBILITY_COLUMN)->setWidth(20); if (mMediaList->getColumn(PROXIMITY_COLUMN)) mMediaList->getColumn(PROXIMITY_COLUMN)->setWidth(30); if (mMediaList->getColumn(CLASS_COLUMN)) mMediaList->getColumn(CLASS_COLUMN)->setWidth(20); @@ -778,7 +787,7 @@ bool LLPanelNearByMedia::setDisabled(const LLUUID &row_id, bool disabled) LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(row_id); if(impl) { - impl->setDisabled(disabled); + impl->setDisabled(disabled, true); return true; } } @@ -794,23 +803,6 @@ void LLPanelNearByMedia::onZoomMedia(void* user_data) LLViewerMediaFocus::getInstance()->focusZoomOnMedia(media_id); } -void LLPanelNearByMedia::onClickMuteParcelMedia() -{ - if (LLViewerParcelMedia::getParcelMedia()) - { - bool muted = mParcelMediaMuteCtrl->getValue(); - LLViewerParcelMedia::getParcelMedia()->setVolume(muted ? (F32)0 : mParcelMediaVolumeSlider->getValueF32() ); - } -} - -void LLPanelNearByMedia::onParcelMediaVolumeSlider() -{ - if (LLViewerParcelMedia::getParcelMedia()) - { - LLViewerParcelMedia::getParcelMedia()->setVolume(mParcelMediaVolumeSlider->getValueF32()); - } -} - void LLPanelNearByMedia::onClickParcelMediaPlay() { LLViewerParcelMedia::play(LLViewerParcelMgr::getInstance()->getAgentParcel()); @@ -941,7 +933,226 @@ void LLPanelNearByMedia::onMoreLess() setShape(new_rect); } + +void LLPanelNearByMedia::updateControls() +{ + LLUUID selected_media_id = mMediaList->getValue().asUUID(); + + if (selected_media_id == PARCEL_AUDIO_LIST_ITEM_UUID) + { + showTimeBasedControls(LLViewerMedia::isParcelAudioPlaying(), + false, // include_zoom + false, // is_zoomed + gSavedSettings.getBOOL("MuteMusic"), + gSavedSettings.getF32("AudioLevelMusic") ); + } + else if (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID) + { + if (!LLViewerMedia::hasParcelMedia()) + { + // Shouldn't happen, but do this anyway + showDisabledControls(); + } + else { + LLViewerMediaImpl* impl = LLViewerParcelMedia::getParcelMedia(); + if (NULL == impl) + { + // Just means it hasn't started yet + showBasicControls(false, false, false); + } + else if (impl->isMediaTimeBased()) + { + showTimeBasedControls(impl->isMediaPlaying(), + false, // include_zoom + false, // is_zoomed + impl->getVolume() == 0.0, + impl->getVolume() ); + } + else { + // non-time-based parcel media + showBasicControls(LLViewerMedia::isParcelMediaPlaying(), false, false); + } + } + } + else { + LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(selected_media_id); + if (NULL == impl) + { + showDisabledControls(); + } + else { + if (impl->isMediaTimeBased()) + { + showTimeBasedControls(impl->isMediaPlaying(), + ! impl->isParcelMedia(), // include_zoom + LLViewerMediaFocus::getInstance()->isZoomed(), + impl->getVolume() == 0.0, + impl->getVolume()); + } + else { + showBasicControls(!impl->isMediaDisabled(), + ! impl->isParcelMedia(), // include_zoom + LLViewerMediaFocus::getInstance()->isZoomed()); + } + } + } +} + +void LLPanelNearByMedia::showBasicControls(bool playing, bool include_zoom, bool is_zoomed) +{ + mStopCtrl->setVisible(playing); + mPlayCtrl->setVisible(!playing); + mPauseCtrl->setVisible(false); + mMuteCtrl->setVisible(false); + mVolumeSliderCtrl->setVisible(false); + mZoomCtrl->setVisible(include_zoom && !is_zoomed); + mUnzoomCtrl->setVisible(include_zoom && is_zoomed); + mStopCtrl->setEnabled(true); + mZoomCtrl->setEnabled(true); +} + +void LLPanelNearByMedia::showTimeBasedControls(bool playing, bool include_zoom, bool is_zoomed, bool muted, F32 volume) +{ + mStopCtrl->setVisible(true); + mPlayCtrl->setVisible(!playing); + mPauseCtrl->setVisible(playing); + mMuteCtrl->setVisible(true); + mVolumeSliderCtrl->setVisible(true); + mZoomCtrl->setVisible(include_zoom); + mZoomCtrl->setVisible(include_zoom && !is_zoomed); + mUnzoomCtrl->setVisible(include_zoom && is_zoomed); + mStopCtrl->setEnabled(true); + mZoomCtrl->setEnabled(true); + mMuteBtn->setValue(muted); + mVolumeSlider->setValue(volume); +} + +void LLPanelNearByMedia::showDisabledControls() +{ + mStopCtrl->setVisible(true); + mPlayCtrl->setVisible(false); + mPauseCtrl->setVisible(false); + mMuteCtrl->setVisible(false); + mVolumeSliderCtrl->setVisible(false); + mZoomCtrl->setVisible(true); + mUnzoomCtrl->setVisible(false); + mStopCtrl->setEnabled(false); + mZoomCtrl->setEnabled(false); +} + +void LLPanelNearByMedia::onClickSelectedMediaStop() +{ + setDisabled(mMediaList->getValue().asUUID(), true); +} + +void LLPanelNearByMedia::onClickSelectedMediaPlay() +{ + LLUUID selected_media_id = mMediaList->getValue().asUUID(); + + // First enable it + setDisabled(selected_media_id, false); + + // Special code to make play "unpause" if time-based and playing + if (selected_media_id != PARCEL_AUDIO_LIST_ITEM_UUID) + { + LLViewerMediaImpl *impl = (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID) ? + ((LLViewerMediaImpl*)LLViewerParcelMedia::getParcelMedia()) : LLViewerMedia::getMediaImplFromTextureID(selected_media_id); + if (NULL != impl && impl->isMediaTimeBased() && impl->isMediaPaused()) + { + // Aha! It's really time-based media that's paused, so unpause + impl->play(); + return; + } + else if (impl->isParcelMedia()) + { + LLViewerParcelMedia::play(LLViewerParcelMgr::getInstance()->getAgentParcel()); + } + } +} + +void LLPanelNearByMedia::onClickSelectedMediaPause() +{ + LLUUID selected_media_id = mMediaList->getValue().asUUID(); + if (selected_media_id == PARCEL_AUDIO_LIST_ITEM_UUID) + { + onClickParcelAudioPause(); + } + else if (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID) + { + onClickParcelMediaPause(); + } + else { + LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(selected_media_id); + if (NULL != impl && impl->isMediaTimeBased() && impl->isMediaPlaying()) + { + impl->pause(); + } + } +} + +void LLPanelNearByMedia::onClickSelectedMediaMute() +{ + LLUUID selected_media_id = mMediaList->getValue().asUUID(); + if (selected_media_id == PARCEL_AUDIO_LIST_ITEM_UUID) + { + gSavedSettings.setBOOL("MuteMusic", mMuteBtn->getValue()); + } + else { + LLViewerMediaImpl* impl = (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID) ? + ((LLViewerMediaImpl*)LLViewerParcelMedia::getParcelMedia()) : LLViewerMedia::getMediaImplFromTextureID(selected_media_id); + if (NULL != impl && impl->isMediaTimeBased()) + { + F32 volume = impl->getVolume(); + if(volume > 0.0) + { + impl->setVolume(0.0); + } + else if (mVolumeSlider->getValueF32() == 0.0) + { + impl->setVolume(1.0); + mVolumeSlider->setValue(1.0); + } + else + { + impl->setVolume(mVolumeSlider->getValueF32()); + } + } + } +} + +void LLPanelNearByMedia::onCommitSelectedMediaVolume() +{ + LLUUID selected_media_id = mMediaList->getValue().asUUID(); + if (selected_media_id == PARCEL_AUDIO_LIST_ITEM_UUID) + { + F32 vol = mVolumeSlider->getValueF32(); + gSavedSettings.setF32("AudioLevelMusic", vol); + } + else { + LLViewerMediaImpl* impl = (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID) ? + ((LLViewerMediaImpl*)LLViewerParcelMedia::getParcelMedia()) : LLViewerMedia::getMediaImplFromTextureID(selected_media_id); + if (NULL != impl && impl->isMediaTimeBased()) + { + impl->setVolume(mVolumeSlider->getValueF32()); + } + } +} + +void LLPanelNearByMedia::onClickSelectedMediaZoom() +{ + LLUUID selected_media_id = mMediaList->getValue().asUUID(); + if (selected_media_id == PARCEL_AUDIO_LIST_ITEM_UUID || selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID) + return; + LLViewerMediaFocus::getInstance()->focusZoomOnMedia(selected_media_id); +} + +void LLPanelNearByMedia::onClickSelectedMediaUnzoom() +{ + LLViewerMediaFocus::getInstance()->unZoom(); +} + + // static void LLPanelNearByMedia::getNameAndUrlHelper(LLViewerMediaImpl* impl, std::string& name, std::string & url, const std::string &defaultName) { -- cgit v1.2.3 From 1c0603bef2bac6e006df7566aa2a3f8c351a1b7f Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Wed, 17 Feb 2010 14:00:16 -0800 Subject: Fix crash when turning on MediaPerformanceManagerDebug flag --- indra/newview/llpanelnearbymedia.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/llpanelnearbymedia.cpp') diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp index 6a88c916d7..d38dd0f870 100644 --- a/indra/newview/llpanelnearbymedia.cpp +++ b/indra/newview/llpanelnearbymedia.cpp @@ -614,6 +614,8 @@ void LLPanelNearByMedia::refreshList() // Clear all items so the list gets regenerated. mMediaList->deleteAllItems(); + mParcelAudioItem = NULL; + mParcelMediaItem = NULL; all_items_deleted = true; updateColumns(); -- cgit v1.2.3 From f6079c93820f354401e5431a9fcfd006859f9e21 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 17 Feb 2010 22:21:58 -0800 Subject: EXT-5515 - Allow resizing on left and lower left of nearby media popup --- indra/newview/llpanelnearbymedia.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'indra/newview/llpanelnearbymedia.cpp') diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp index d38dd0f870..8ad5389566 100644 --- a/indra/newview/llpanelnearbymedia.cpp +++ b/indra/newview/llpanelnearbymedia.cpp @@ -38,6 +38,7 @@ #include "llcheckboxctrl.h" #include "llcombobox.h" #include "llresizebar.h" +#include "llresizehandle.h" #include "llscrolllistctrl.h" #include "llscrolllistitem.h" #include "llscrolllistcell.h" @@ -116,6 +117,20 @@ BOOL LLPanelNearByMedia::postBuild() p.resizing_view = this; addChild( LLUICtrlFactory::create(p) ); + p.rect = LLRect( 0, getRect().getHeight(), RESIZE_BAR_THICKNESS, 0); + p.name = "resizebar_left"; + p.min_size = getRect().getWidth(); + p.side = LLResizeBar::LEFT; + addChild( LLUICtrlFactory::create(p) ); + + LLResizeHandle::Params resize_handle_p; + resize_handle_p.rect = LLRect( 0, RESIZE_HANDLE_HEIGHT, RESIZE_HANDLE_WIDTH, 0 ); + resize_handle_p.mouse_opaque(false); + resize_handle_p.min_width(getRect().getWidth()); + resize_handle_p.min_height(getRect().getHeight()); + resize_handle_p.corner(LLResizeHandle::LEFT_BOTTOM); + addChild(LLUICtrlFactory::create(resize_handle_p)); + mNearbyMediaPanel = getChild("nearby_media_panel"); mMediaList = getChild("media_list"); mEnableAllCtrl = getChild("all_nearby_media_enable_btn"); @@ -148,8 +163,10 @@ BOOL LLPanelNearByMedia::postBuild() updateColumns(); LLView* minimized_controls = getChildView("minimized_controls"); - mMoreHeight = getRect().getHeight(); - mLessHeight = getRect().getHeight() - minimized_controls->getRect().mBottom; + mMoreRect = getRect(); + mLessRect = getRect(); + mLessRect.mBottom = minimized_controls->getRect().mBottom; + getChild("more_less_btn")->setValue(false); onMoreLess(); @@ -207,7 +224,7 @@ void LLPanelNearByMedia::reshape(S32 width, S32 height, BOOL called_from_parent) LLButton* more_less_btn = getChild("more_less_btn"); if (more_less_btn->getValue().asBoolean()) { - mMoreHeight = getRect().getHeight(); + mMoreRect = getRect(); } } @@ -928,10 +945,8 @@ void LLPanelNearByMedia::onMoreLess() // enable resizing when expanded getChildView("resizebar_bottom")->setEnabled(is_more); - S32 new_height = is_more ? mMoreHeight : mLessHeight; - - LLRect new_rect = getRect(); - new_rect.mBottom = new_rect.mTop - new_height; + LLRect new_rect = is_more ? mMoreRect : mLessRect; + new_rect.translate(getRect().mRight - new_rect.mRight, getRect().mTop - new_rect.mTop); setShape(new_rect); } -- cgit v1.2.3 From 98a0c11da9e1c7ee8351cb9ab6d9cd5345a4e002 Mon Sep 17 00:00:00 2001 From: angela Date: Mon, 22 Feb 2010 17:34:28 +0800 Subject: EXT-5410 Streaming audio does ignores preference setting. --- indra/newview/llpanelnearbymedia.cpp | 47 +++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 11 deletions(-) (limited to 'indra/newview/llpanelnearbymedia.cpp') diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp index 8ad5389566..6d6edcc9ee 100644 --- a/indra/newview/llpanelnearbymedia.cpp +++ b/indra/newview/llpanelnearbymedia.cpp @@ -568,11 +568,20 @@ void LLPanelNearByMedia::refreshParcelItems() tooltip = name + " : " + url; } LLViewerMediaImpl *impl = LLViewerParcelMedia::getParcelMedia(); + bool is_enabled = gSavedSettings.getBOOL("AudioStreamingMedia"); + if(is_enabled) + { + mParcelMediaName = getString("parcel_media_name"); + } + else + { + mParcelMediaName = getString("parcel_media_name_disabled"); + } updateListItem(mParcelMediaItem, mParcelMediaName, tooltip, -2, // Proximity closer than anything else, before Parcel Audio - impl == NULL || impl->isMediaDisabled(), + impl == NULL || impl->isMediaDisabled() || (!is_enabled), impl != NULL && !LLViewerParcelMedia::getURL().empty(), impl != NULL && impl->isMediaTimeBased() && impl->isMediaPlaying(), MEDIA_CLASS_ALL, @@ -601,11 +610,20 @@ void LLPanelNearByMedia::refreshParcelItems() if (NULL != mParcelAudioItem) { bool is_playing = LLViewerMedia::isParcelAudioPlaying(); + bool is_enabled = gSavedSettings.getBOOL("AudioStreamingMusic"); + if(is_enabled) + { + mParcelAudioName = getString("parcel_audio_name"); + } + else + { + mParcelAudioName = getString("parcel_audio_name_disabled"); + } updateListItem(mParcelAudioItem, mParcelAudioName, LLViewerMedia::getParcelAudioURL(), -1, // Proximity after Parcel Media, but closer than anything else - !is_playing, + (!is_playing) && is_enabled, is_playing, is_playing, MEDIA_CLASS_ALL, @@ -824,7 +842,10 @@ void LLPanelNearByMedia::onZoomMedia(void* user_data) void LLPanelNearByMedia::onClickParcelMediaPlay() { - LLViewerParcelMedia::play(LLViewerParcelMgr::getInstance()->getAgentParcel()); + if (gSavedSettings.getBOOL("AudioStreamingMedia")) + { + LLViewerParcelMedia::play(LLViewerParcelMgr::getInstance()->getAgentParcel()); + } } void LLPanelNearByMedia::onClickParcelMediaStop() @@ -844,14 +865,18 @@ void LLPanelNearByMedia::onClickParcelMediaPause() void LLPanelNearByMedia::onClickParcelAudioStart() { - // User *explicitly* started the internet stream, so keep the stream - // playing and updated as they cross to other parcels etc. - mParcelAudioAutoStart = true; - - if (!gAudiop) - return; + //only do this when it's audio streaming is enabled + if (gSavedSettings.getBOOL("AudioStreamingMusic")) + { + // User *explicitly* started the internet stream, so keep the stream + // playing and updated as they cross to other parcels etc. + mParcelAudioAutoStart = true; + + if (!gAudiop) + return; - gAudiop->startInternetStream(LLViewerMedia::getParcelAudioURL()); + gAudiop->startInternetStream(LLViewerMedia::getParcelAudioURL()); + } } void LLPanelNearByMedia::onClickParcelAudioPlay() @@ -1081,7 +1106,7 @@ void LLPanelNearByMedia::onClickSelectedMediaPlay() impl->play(); return; } - else if (impl->isParcelMedia()) + else if (NULL != impl && impl->isParcelMedia()) { LLViewerParcelMedia::play(LLViewerParcelMgr::getInstance()->getAgentParcel()); } -- cgit v1.2.3 From e55bb59a785b67ad9267d71789b08821f0a991ae Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Mon, 22 Feb 2010 15:39:22 -0800 Subject: EXT-5633: Fix crash pressing PLAY on parcel media when media is disabled Good catch, Leyla --- indra/newview/llpanelnearbymedia.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'indra/newview/llpanelnearbymedia.cpp') diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp index 8ad5389566..52cdd386c9 100644 --- a/indra/newview/llpanelnearbymedia.cpp +++ b/indra/newview/llpanelnearbymedia.cpp @@ -1075,15 +1075,18 @@ void LLPanelNearByMedia::onClickSelectedMediaPlay() { LLViewerMediaImpl *impl = (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID) ? ((LLViewerMediaImpl*)LLViewerParcelMedia::getParcelMedia()) : LLViewerMedia::getMediaImplFromTextureID(selected_media_id); - if (NULL != impl && impl->isMediaTimeBased() && impl->isMediaPaused()) + if (NULL != impl) { - // Aha! It's really time-based media that's paused, so unpause - impl->play(); - return; - } - else if (impl->isParcelMedia()) - { - LLViewerParcelMedia::play(LLViewerParcelMgr::getInstance()->getAgentParcel()); + if (impl->isMediaTimeBased() && impl->isMediaPaused()) + { + // Aha! It's really time-based media that's paused, so unpause + impl->play(); + return; + } + else if (impl->isParcelMedia()) + { + LLViewerParcelMedia::play(LLViewerParcelMgr::getInstance()->getAgentParcel()); + } } } } -- cgit v1.2.3 From ea2e72f4502fe58b01a00f8e6b0ae3e47c269e8b Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Mon, 22 Feb 2010 17:47:19 -0800 Subject: FIX (unposted bug): Nearby media "dynamic" controls not disabled properly when media disabled --- indra/newview/llpanelnearbymedia.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpanelnearbymedia.cpp') diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp index 52cdd386c9..877b31513a 100644 --- a/indra/newview/llpanelnearbymedia.cpp +++ b/indra/newview/llpanelnearbymedia.cpp @@ -953,15 +953,29 @@ void LLPanelNearByMedia::onMoreLess() void LLPanelNearByMedia::updateControls() { + if (! gSavedSettings.getBOOL("AudioStreamingMedia")) + { + // Just show disabled controls + showDisabledControls(); + return; + } + LLUUID selected_media_id = mMediaList->getValue().asUUID(); if (selected_media_id == PARCEL_AUDIO_LIST_ITEM_UUID) { - showTimeBasedControls(LLViewerMedia::isParcelAudioPlaying(), + if (!LLViewerMedia::hasParcelAudio()) + { + // Shouldn't happen, but do this anyway + showDisabledControls(); + } + else { + showTimeBasedControls(LLViewerMedia::isParcelAudioPlaying(), false, // include_zoom false, // is_zoomed gSavedSettings.getBOOL("MuteMusic"), gSavedSettings.getF32("AudioLevelMusic") ); + } } else if (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID) { -- cgit v1.2.3 From 50a99d5419cd0ea9fe3375726bdc6a34e8102824 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Mon, 22 Feb 2010 19:04:27 -0800 Subject: FIX (unposted bug): "hasMedia" and "hasAudio" no longer checks preferences: it's now up to callers to decide to do that Review #137 --- indra/newview/llpanelnearbymedia.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'indra/newview/llpanelnearbymedia.cpp') diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp index 877b31513a..b73d7db770 100644 --- a/indra/newview/llpanelnearbymedia.cpp +++ b/indra/newview/llpanelnearbymedia.cpp @@ -535,7 +535,9 @@ void LLPanelNearByMedia::refreshParcelItems() const LLSD &choice_llsd = mShowCtrl->getSelectedValue(); MediaClass choice = (MediaClass)choice_llsd.asInteger(); // Only show "special parcel items" if "All" or "Within" filter - bool should_include = choice == MEDIA_CLASS_ALL || choice == MEDIA_CLASS_WITHIN_PARCEL; + // (and if media is "enabled") + bool should_include = gSavedSettings.getBOOL("AudioStreamingMedia") && + (choice == MEDIA_CLASS_ALL || choice == MEDIA_CLASS_WITHIN_PARCEL); // First Parcel Media: add or remove it as necessary if (should_include && LLViewerMedia::hasParcelMedia()) @@ -579,8 +581,8 @@ void LLPanelNearByMedia::refreshParcelItems() "parcel media"); } - // Next Parcel Audio: add or remove it as necessary - if (should_include && LLViewerMedia::hasParcelAudio()) + // Next Parcel Audio: add or remove it as necessary (don't show if disabled in prefs) + if (should_include && LLViewerMedia::hasParcelAudio() && gSavedSettings.getBOOL("AudioStreamingMusic")) { // Yes, there is parcel audio. if (NULL == mParcelAudioItem) @@ -692,14 +694,16 @@ void LLPanelNearByMedia::refreshList() } } } - mDisableAllCtrl->setEnabled(LLViewerMedia::isAnyMediaShowing() || - LLViewerMedia::isParcelMediaPlaying() || - LLViewerMedia::isParcelAudioPlaying()); - mEnableAllCtrl->setEnabled(disabled_count > 0 || - // parcel media (if we have it, and it isn't playing, enable "start") - (LLViewerMedia::hasParcelMedia() && ! LLViewerMedia::isParcelMediaPlaying()) || - // parcel audio (if we have it, and it isn't playing, enable "start") - (LLViewerMedia::hasParcelAudio() && ! LLViewerMedia::isParcelAudioPlaying())); + mDisableAllCtrl->setEnabled(gSavedSettings.getBOOL("AudioStreamingMedia") && + (LLViewerMedia::isAnyMediaShowing() || + LLViewerMedia::isParcelMediaPlaying() || + LLViewerMedia::isParcelAudioPlaying())); + mEnableAllCtrl->setEnabled(gSavedSettings.getBOOL("AudioStreamingMedia") && + (disabled_count > 0 || + // parcel media (if we have it, and it isn't playing, enable "start") + (LLViewerMedia::hasParcelMedia() && ! LLViewerMedia::isParcelMediaPlaying()) || + // parcel audio (if we have it, and it isn't playing, enable "start") + (LLViewerMedia::hasParcelAudio() && ! LLViewerMedia::isParcelAudioPlaying()))); // Iterate over the rows in the control, updating ones whose impl exists, and deleting ones whose impl has gone away. std::vector items = mMediaList->getAllData(); @@ -964,7 +968,7 @@ void LLPanelNearByMedia::updateControls() if (selected_media_id == PARCEL_AUDIO_LIST_ITEM_UUID) { - if (!LLViewerMedia::hasParcelAudio()) + if (!LLViewerMedia::hasParcelAudio() || !gSavedSettings.getBOOL("AudioStreamingMusic")) { // Shouldn't happen, but do this anyway showDisabledControls(); -- cgit v1.2.3 From 0eea585ef13426bf343fb5bcc3642cdfc769c022 Mon Sep 17 00:00:00 2001 From: angela Date: Tue, 23 Feb 2010 11:30:12 +0800 Subject: revert some changed from EXT-5410 but keep the changes for disabling streaming audio when music or media is disabled. reviewed by rick --- indra/newview/llpanelnearbymedia.cpp | 41 +++++++++--------------------------- 1 file changed, 10 insertions(+), 31 deletions(-) (limited to 'indra/newview/llpanelnearbymedia.cpp') diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp index 6d6edcc9ee..e1676d2299 100644 --- a/indra/newview/llpanelnearbymedia.cpp +++ b/indra/newview/llpanelnearbymedia.cpp @@ -568,20 +568,11 @@ void LLPanelNearByMedia::refreshParcelItems() tooltip = name + " : " + url; } LLViewerMediaImpl *impl = LLViewerParcelMedia::getParcelMedia(); - bool is_enabled = gSavedSettings.getBOOL("AudioStreamingMedia"); - if(is_enabled) - { - mParcelMediaName = getString("parcel_media_name"); - } - else - { - mParcelMediaName = getString("parcel_media_name_disabled"); - } updateListItem(mParcelMediaItem, mParcelMediaName, tooltip, -2, // Proximity closer than anything else, before Parcel Audio - impl == NULL || impl->isMediaDisabled() || (!is_enabled), + impl == NULL || impl->isMediaDisabled(), impl != NULL && !LLViewerParcelMedia::getURL().empty(), impl != NULL && impl->isMediaTimeBased() && impl->isMediaPlaying(), MEDIA_CLASS_ALL, @@ -610,20 +601,12 @@ void LLPanelNearByMedia::refreshParcelItems() if (NULL != mParcelAudioItem) { bool is_playing = LLViewerMedia::isParcelAudioPlaying(); - bool is_enabled = gSavedSettings.getBOOL("AudioStreamingMusic"); - if(is_enabled) - { - mParcelAudioName = getString("parcel_audio_name"); - } - else - { - mParcelAudioName = getString("parcel_audio_name_disabled"); - } + updateListItem(mParcelAudioItem, mParcelAudioName, LLViewerMedia::getParcelAudioURL(), -1, // Proximity after Parcel Media, but closer than anything else - (!is_playing) && is_enabled, + (!is_playing), is_playing, is_playing, MEDIA_CLASS_ALL, @@ -865,18 +848,14 @@ void LLPanelNearByMedia::onClickParcelMediaPause() void LLPanelNearByMedia::onClickParcelAudioStart() { - //only do this when it's audio streaming is enabled - if (gSavedSettings.getBOOL("AudioStreamingMusic")) - { - // User *explicitly* started the internet stream, so keep the stream - // playing and updated as they cross to other parcels etc. - mParcelAudioAutoStart = true; + // User *explicitly* started the internet stream, so keep the stream + // playing and updated as they cross to other parcels etc. + mParcelAudioAutoStart = true; - if (!gAudiop) - return; - - gAudiop->startInternetStream(LLViewerMedia::getParcelAudioURL()); - } + if (!gAudiop) + return; + gAudiop->startInternetStream(LLViewerMedia::getParcelAudioURL()); + } void LLPanelNearByMedia::onClickParcelAudioPlay() -- cgit v1.2.3