Skip to content
Snippets Groups Projects
Commit 2d1f241f authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Further improvements to the music ticker Add station and clean up toasts, add toast to chat option

parent bbe8eeaa
No related branches found
No related tags found
2 merge requests!3Update to main branch,!2Rebase onto current main branch
...@@ -137,6 +137,11 @@ void LLTextBox::setClickedCallback( boost::function<void (void*)> cb, void* user ...@@ -137,6 +137,11 @@ void LLTextBox::setClickedCallback( boost::function<void (void*)> cb, void* user
mClickedCallback = boost::bind(cb, userdata); mClickedCallback = boost::bind(cb, userdata);
} }
void LLTextBox::clearClickedCallback()
{
mClickedCallback.clear();
}
S32 LLTextBox::getTextPixelWidth() S32 LLTextBox::getTextPixelWidth()
{ {
return getTextBoundingRect().getWidth(); return getTextBoundingRect().getWidth();
......
...@@ -59,6 +59,7 @@ class LLTextBox : ...@@ -59,6 +59,7 @@ class LLTextBox :
void setRightAlign() { mHAlign = LLFontGL::RIGHT; } void setRightAlign() { mHAlign = LLFontGL::RIGHT; }
void setHAlign( LLFontGL::HAlign align ) { mHAlign = align; } void setHAlign( LLFontGL::HAlign align ) { mHAlign = align; }
void setClickedCallback( boost::function<void (void*)> cb, void* userdata = NULL ); void setClickedCallback( boost::function<void (void*)> cb, void* userdata = NULL );
void clearClickedCallback();
void reshapeToFitText(BOOL called_from_parent = FALSE); void reshapeToFitText(BOOL called_from_parent = FALSE);
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include "lltextbox.h" #include "lltextbox.h"
#include "lluicolortable.h" #include "lluicolortable.h"
#include "lluictrl.h" #include "lluictrl.h"
#include "lltrans.h"
#include "llurlaction.h"
// Viewer includes // Viewer includes
#include "llviewercontrol.h" #include "llviewercontrol.h"
...@@ -37,12 +39,10 @@ static LLPanelInjector<ALPanelMusicTicker> t_music_ticker("music_ticker"); ...@@ -37,12 +39,10 @@ static LLPanelInjector<ALPanelMusicTicker> t_music_ticker("music_ticker");
ALPanelMusicTicker::ALPanelMusicTicker() : LLPanel(), ALPanelMusicTicker::ALPanelMusicTicker() : LLPanel(),
mPlayState(STATE_PLAYING), mPlayState(STATE_PLAYING),
mStationScrollChars(0),
mArtistScrollChars(0), mArtistScrollChars(0),
mTitleScrollChars(0), mTitleScrollChars(0),
mCurScrollChar(0), mCurScrollChar(0)
mArtistText(nullptr),
mTitleText(nullptr),
mVisualizer(nullptr)
{ {
} }
...@@ -56,6 +56,7 @@ ALPanelMusicTicker::~ALPanelMusicTicker() ...@@ -56,6 +56,7 @@ ALPanelMusicTicker::~ALPanelMusicTicker()
BOOL ALPanelMusicTicker::postBuild() BOOL ALPanelMusicTicker::postBuild()
{ {
mStationText = getChild<LLTextBox>("station_text");
mArtistText = getChild<LLTextBox>("artist_text"); mArtistText = getChild<LLTextBox>("artist_text");
mTitleText = getChild<LLTextBox>("title_text"); mTitleText = getChild<LLTextBox>("title_text");
mVisualizer = getChild<LLUICtrl>("visualizer_box"); mVisualizer = getChild<LLUICtrl>("visualizer_box");
...@@ -90,6 +91,8 @@ void ALPanelMusicTicker::reshape(S32 width, S32 height, BOOL called_from_parent/ ...@@ -90,6 +91,8 @@ void ALPanelMusicTicker::reshape(S32 width, S32 height, BOOL called_from_parent/
LLPanel::reshape(width, height, called_from_parent); LLPanel::reshape(width, height, called_from_parent);
if(width_changed) if(width_changed)
{ {
if (mStationText)
mStationScrollChars = countExtraChars(mStationText, mszStation);
if(mTitleText) if(mTitleText)
mTitleScrollChars = countExtraChars(mTitleText, mszTitle); mTitleScrollChars = countExtraChars(mTitleText, mszTitle);
if(mArtistText) if(mArtistText)
...@@ -118,6 +121,9 @@ void ALPanelMusicTicker::metadataUpdateCallback(const LLSD& metadata) ...@@ -118,6 +121,9 @@ void ALPanelMusicTicker::metadataUpdateCallback(const LLSD& metadata)
LLSD artist = metadata["ARTIST"]; LLSD artist = metadata["ARTIST"];
LLSD title = metadata["TITLE"]; LLSD title = metadata["TITLE"];
std::string station = metadata.has("TRSN") ? metadata["TRSN"].asString() : metadata.has("icy-name") ? metadata["icy-name"].asString() : LLTrans::getString("NowPlaying");
std::string station_url = metadata.has("URL") ? metadata["URL"].asString() : metadata.has("icy-url") ? metadata["icy-url"].asString() : std::string();
dirty |= setStation(station, station_url);
dirty |= setArtist(artist.isDefined() ? artist.asString() : LLStringUtil::null); dirty |= setArtist(artist.isDefined() ? artist.asString() : LLStringUtil::null);
dirty |= setTitle(title.isDefined() ? title.asString() : LLStringUtil::null); dirty |= setTitle(title.isDefined() ? title.asString() : LLStringUtil::null);
} }
...@@ -172,8 +178,9 @@ bool ALPanelMusicTicker::setPaused(bool pause) ...@@ -172,8 +178,9 @@ bool ALPanelMusicTicker::setPaused(bool pause)
mPlayState = pause ? STATE_PAUSED : STATE_PLAYING; mPlayState = pause ? STATE_PAUSED : STATE_PLAYING;
if(pause) if(pause)
{ {
setArtist(mszPaused); setStation(mszPaused, LLStringUtil::null);
setTitle(mszPaused); setArtist(LLStringUtil::null);
setTitle(LLStringUtil::null);
} }
return true; return true;
} }
...@@ -182,12 +189,33 @@ void ALPanelMusicTicker::resetTicker() ...@@ -182,12 +189,33 @@ void ALPanelMusicTicker::resetTicker()
{ {
mScrollTimer.reset(); mScrollTimer.reset();
mCurScrollChar = 0; mCurScrollChar = 0;
if (mStationText)
mStationText->setText(LLStringExplicit(mszStation.substr(0, mszStation.length() - mStationScrollChars)));
if(mArtistText) if(mArtistText)
mArtistText->setText(LLStringExplicit(mszArtist.substr(0, mszArtist.length() - mArtistScrollChars))); mArtistText->setText(LLStringExplicit(mszArtist.substr(0, mszArtist.length() - mArtistScrollChars)));
if(mTitleText) if(mTitleText)
mTitleText->setText(LLStringExplicit(mszTitle.substr(0, mszTitle.length() - mTitleScrollChars))); mTitleText->setText(LLStringExplicit(mszTitle.substr(0, mszTitle.length() - mTitleScrollChars)));
} }
bool ALPanelMusicTicker::setStation(const std::string& station, const std::string& url)
{
if (!mStationText || (mszStation == station && mszStationURL == url))
return false;
mszStation = station;
mszStationURL = url;
if (mszStationURL.empty())
{
mStationText->clearClickedCallback();
}
else
{
mStationText->setClickedCallback([this](void*) { if (!mszStationURL.empty()) LLUrlAction::openURL(mszStationURL); });
}
mStationText->setText(mszStation);
mStationScrollChars = countExtraChars(mStationText, mszStation);
return true;
}
bool ALPanelMusicTicker::setArtist(const std::string &artist) bool ALPanelMusicTicker::setArtist(const std::string &artist)
{ {
if(!mArtistText || mszArtist == artist) if(!mArtistText || mszArtist == artist)
...@@ -229,11 +257,11 @@ S32 ALPanelMusicTicker::countExtraChars(LLTextBox *texbox, const std::string &te ...@@ -229,11 +257,11 @@ S32 ALPanelMusicTicker::countExtraChars(LLTextBox *texbox, const std::string &te
void ALPanelMusicTicker::iterateTickerOffset() void ALPanelMusicTicker::iterateTickerOffset()
{ {
if((mPlayState != STATE_PAUSED) if((mPlayState != STATE_PAUSED)
&& (mArtistScrollChars || mTitleScrollChars) && (mStationScrollChars || mArtistScrollChars || mTitleScrollChars)
&& ((!mCurScrollChar && mScrollTimer.getElapsedTimeF32() >= 5.f) && ((!mCurScrollChar && mScrollTimer.getElapsedTimeF32() >= 5.f)
|| (mCurScrollChar && mScrollTimer.getElapsedTimeF32() >= .5f))) || (mCurScrollChar && mScrollTimer.getElapsedTimeF32() >= .5f)))
{ {
if(++mCurScrollChar > llmax(mArtistScrollChars, mTitleScrollChars)) if(++mCurScrollChar > llmax(mStationScrollChars, llmax(mArtistScrollChars, mTitleScrollChars)))
{ {
if(mScrollTimer.getElapsedTimeF32() >= 2.f) //pause for a bit when it reaches beyond last character. if(mScrollTimer.getElapsedTimeF32() >= 2.f) //pause for a bit when it reaches beyond last character.
resetTicker(); resetTicker();
...@@ -241,6 +269,10 @@ void ALPanelMusicTicker::iterateTickerOffset() ...@@ -241,6 +269,10 @@ void ALPanelMusicTicker::iterateTickerOffset()
else else
{ {
mScrollTimer.reset(); mScrollTimer.reset();
if (mStationText && mCurScrollChar <= mStationScrollChars)
{
mStationText->setText(LLStringExplicit(mszStation.substr(mCurScrollChar, mszStation.length() - mStationScrollChars + mCurScrollChar)));
}
if(mArtistText && mCurScrollChar <= mArtistScrollChars) if(mArtistText && mCurScrollChar <= mArtistScrollChars)
{ {
mArtistText->setText(LLStringExplicit(mszArtist.substr(mCurScrollChar, mszArtist.length()-mArtistScrollChars + mCurScrollChar))); mArtistText->setText(LLStringExplicit(mszArtist.substr(mCurScrollChar, mszArtist.length()-mArtistScrollChars + mCurScrollChar)));
......
...@@ -40,6 +40,7 @@ class ALPanelMusicTicker final : public LLPanel ...@@ -40,6 +40,7 @@ class ALPanelMusicTicker final : public LLPanel
void drawOscilloscope(); //called via draw. void drawOscilloscope(); //called via draw.
bool setPaused(bool pause); //returns true on state change. bool setPaused(bool pause); //returns true on state change.
void resetTicker(); //Resets tickers to their innitial values (no offset). void resetTicker(); //Resets tickers to their innitial values (no offset).
bool setStation(const std::string& station, const std::string& url); //returns true on change
bool setArtist(const std::string &artist); //returns true on change bool setArtist(const std::string &artist); //returns true on change
bool setTitle(const std::string &title); //returns true on change bool setTitle(const std::string &title); //returns true on change
S32 countExtraChars(LLTextBox *texbox, const std::string &text); //calculates how many characters are truncated by bounds. S32 countExtraChars(LLTextBox *texbox, const std::string &text); //calculates how many characters are truncated by bounds.
...@@ -58,8 +59,11 @@ class ALPanelMusicTicker final : public LLPanel ...@@ -58,8 +59,11 @@ class ALPanelMusicTicker final : public LLPanel
std::string mszPaused; std::string mszPaused;
std::string mszArtist; std::string mszArtist;
std::string mszTitle; std::string mszTitle;
std::string mszStation;
std::string mszStationURL;
LLTimer mScrollTimer; LLTimer mScrollTimer;
LLTimer mLoadTimer; LLTimer mLoadTimer;
S32 mStationScrollChars;
S32 mArtistScrollChars; S32 mArtistScrollChars;
S32 mTitleScrollChars; S32 mTitleScrollChars;
S32 mCurScrollChar; S32 mCurScrollChar;
...@@ -67,9 +71,10 @@ class ALPanelMusicTicker final : public LLPanel ...@@ -67,9 +71,10 @@ class ALPanelMusicTicker final : public LLPanel
LLColor4 mOscillatorColor; LLColor4 mOscillatorColor;
//UI elements //UI elements
LLTextBox* mArtistText; LLTextBox* mStationText = nullptr;
LLTextBox* mTitleText; LLTextBox* mArtistText = nullptr;
LLUICtrl* mVisualizer; LLTextBox* mTitleText = nullptr;
LLUICtrl* mVisualizer = nullptr;
boost::signals2::connection mMetadataUpdateConnection; boost::signals2::connection mMetadataUpdateConnection;
}; };
......
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
#include "llfloater.h" #include "llfloater.h"
#include "llfloaterreg.h" #include "llfloaterreg.h"
#include "llnotifications.h"
ALStreamInfo::ALStreamInfo() ALStreamInfo::ALStreamInfo()
{ {
if (gAudiop && gAudiop->getStreamingAudioImpl() && gAudiop->getStreamingAudioImpl()->supportsMetaData()) if (gAudiop && gAudiop->getStreamingAudioImpl() && gAudiop->getStreamingAudioImpl()->supportsMetaData())
...@@ -62,8 +64,10 @@ void ALStreamInfo::handleMetadataUpdate(const LLSD& metadata) ...@@ -62,8 +64,10 @@ void ALStreamInfo::handleMetadataUpdate(const LLSD& metadata)
static LLCachedControl<bool> show_stream_info(gSavedSettings, "ShowStreamInfo", false); static LLCachedControl<bool> show_stream_info(gSavedSettings, "ShowStreamInfo", false);
if (!show_stream_info) return; if (!show_stream_info) return;
bool stream_info_to_chat = gSavedSettings.getBOOL("ShowStreamInfoToChat");
LLFloater* music_ticker = LLFloaterReg::findInstance("music_ticker"); LLFloater* music_ticker = LLFloaterReg::findInstance("music_ticker");
if (music_ticker) if (!stream_info_to_chat && music_ticker)
return; return;
if (metadata.size() > 0) if (metadata.size() > 0)
...@@ -86,15 +90,30 @@ void ALStreamInfo::handleMetadataUpdate(const LLSD& metadata) ...@@ -86,15 +90,30 @@ void ALStreamInfo::handleMetadataUpdate(const LLSD& metadata)
if (metadata.has("ARTIST")) if (metadata.has("ARTIST"))
info << metadata["ARTIST"].asString(); info << metadata["ARTIST"].asString();
args["INFO"] = info.str(); args["INFO"] = info.str();
std::string station_url;
if (metadata.has("URL")) if (metadata.has("URL"))
LLNotificationsUtil::add("StreamInfo", args, station_url = metadata["URL"].asString();
LLSD().with("respond_on_mousedown", TRUE),
boost::bind(&LLUrlAction::openURL, metadata["URL"].asString()));
else if (metadata.has("icy-url")) else if (metadata.has("icy-url"))
LLNotificationsUtil::add("StreamInfo", args, station_url = metadata["icy-url"].asString();
LLSD().with("respond_on_mousedown", TRUE),
boost::bind(&LLUrlAction::openURL, metadata["icy-url"].asString())); LLNotification::Params notify_params;
notify_params.name = "StreamInfo";
notify_params.substitutions = args;
if (!station_url.empty())
{
notify_params.payload = payload.with("respond_on_mousedown", TRUE);
LLNotification::Params::Functor functor_p;
functor_p.function = [=](const LLSD&, const LLSD&) {LLUrlAction::openURL(station_url); };
notify_params.functor = functor_p;
}
else else
LLNotificationsUtil::add("StreamInfo", args); {
notify_params.payload = payload;
}
notify_params.force_to_chat = stream_info_to_chat;
LLNotificationPtr notification = LLNotifications::instance().add(notify_params);
} }
} }
...@@ -1377,6 +1377,17 @@ ...@@ -1377,6 +1377,17 @@
<key>Value</key> <key>Value</key>
<integer>1</integer> <integer>1</integer>
</map> </map>
<key>ShowStreamInfoToChat</key>
<map>
<key>Comment</key>
<string>Show audio stream info in nearby chat</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>SnapshotDetection</key> <key>SnapshotDetection</key>
<map> <map>
<key>Comment</key> <key>Comment</key>
......
<?xml version="1.0" encoding="utf-8" standalone="yes" ?> <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<floater <floater
width="360" width="400"
height="46" height="66"
layout="topleft" layout="topleft"
min_width="280" min_width="350"
min_height="46" min_height="66"
name="floater_music_ticker" name="floater_music_ticker"
positioning="cascading" positioning="cascading"
title="" title=""
...@@ -14,14 +14,16 @@ ...@@ -14,14 +14,16 @@
can_resize_height="false" can_resize_height="false"
show_title="false" show_title="false"
save_rect="true" save_rect="true"
chrome="true"> chrome="true"
single_instance="true"
reuse_instance="false">
<panel <panel
class="music_ticker" class="music_ticker"
name="music_ticker" name="music_ticker"
filename="panel_music_ticker.xml" filename="panel_music_ticker.xml"
layout="topleft" layout="topleft"
follows="all" follows="all"
width="336" width="382"
top="0" top="0"
mouse_opaque="false"/> mouse_opaque="false"/>
</floater> </floater>
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
<panel <panel
layout="topleft" layout="topleft"
follows="top|right|left" follows="top|right|left"
width="300" width="350"
height="46" height="66"
name="music_ticker" name="music_ticker"
class="music_ticker"> class="music_ticker">
<string name="paused"> <string name="paused">
...@@ -12,23 +12,12 @@ ...@@ -12,23 +12,12 @@
<string name="loading"> <string name="loading">
(loading...) (loading...)
</string> </string>
<icon
top="23"
color="AlAshGrey"
follows="left|top|right"
height="1"
layout="topleft"
image_name="white.tga"
left="0"
mouse_opaque="false"
name="ticker_background"
width="244" />
<locate <locate
top="0" top="0"
bottom="-1" bottom="-1"
left="244" left="244"
name="visualizer_box" name="visualizer_box"
width="60" width="110"
follows="top|right" follows="top|right"
use_bounding_rect="true" use_bounding_rect="true"
layout="topleft"/> layout="topleft"/>
...@@ -42,47 +31,89 @@ ...@@ -42,47 +31,89 @@
left="244" left="244"
mouse_opaque="false" mouse_opaque="false"
name="visualizer_grid" name="visualizer_grid"
width="60" /> width="110" />
<text <text
text_color="AlBlue" text_color="AlBlue"
bg_visible="false" bg_visible="false"
border_visible="false" border_visible="false"
layout="topleft" layout="topleft"
top="2" top="2"
follows="top|left|right"
font="SansSerifBoldLarge"
h_pad="0"
halign="left"
height="16"
left="4"
mouse_opaque="false"
name="station_text"
v_pad="0"
width="240">
Bark
</text>
<icon
top="20"
color="AlAshGrey"
follows="left|top|right"
height="1"
layout="topleft"
image_name="white.tga"
left="0"
mouse_opaque="false"
name="ticker_sep1"
width="244" />
<text
text_color="AlBlue"
bg_visible="false"
border_visible="false"
layout="topleft"
top="23"
follows="top|left" follows="top|left"
font="SansSerifBoldLarge" font="SansSerifBoldLarge"
h_pad="0" h_pad="0"
halign="left" halign="left"
height="16" height="16"
left="4" left="4"
mouse_opaque="false" mouse_opaque="false"
name="artist_label" name="title_label"
v_pad="0" v_pad="0"
width="50"> width="50">
Artist: Title:
</text> </text>
<text <text
bg_visible="false" bg_visible="false"
border_visible="false" border_visible="false"
layout="topleft" layout="topleft"
top="2" top="23"
follows="top|left|right" follows="top|left|right"
font="SansSerifLarge" font="SansSerifLarge"
h_pad="0" h_pad="0"
halign="left" halign="left"
height="16" height="16"
left="56" left="57"
mouse_opaque="false" mouse_opaque="false"
name="artist_text" name="title_text"
v_pad="0" v_pad="0"
width="193"> width="188">
Woof
</text> </text>
<text <icon
top="44"
color="AlAshGrey"
follows="left|top|right"
height="1"
layout="topleft"
image_name="white.tga"
left="0"
mouse_opaque="false"
name="ticker_sep2"
width="244"
/>
<text
text_color="AlBlue" text_color="AlBlue"
bg_visible="false" bg_visible="false"
border_visible="false" border_visible="false"
layout="topleft" layout="topleft"
top="26" top="46"
follows="top|left" follows="top|left"
font="SansSerifBoldLarge" font="SansSerifBoldLarge"
h_pad="0" h_pad="0"
...@@ -90,26 +121,26 @@ ...@@ -90,26 +121,26 @@
height="16" height="16"
left="4" left="4"
mouse_opaque="false" mouse_opaque="false"
name="title_label" name="artist_label"
v_pad="0" v_pad="0"
width="50"> width="50">
Title: Artist:
</text> </text>
<text <text
bg_visible="false" bg_visible="false"
border_visible="false" border_visible="false"
layout="topleft" layout="topleft"
top="26" top="46"
follows="top|left|right" follows="top|left|right"
font="SansSerifLarge" font="SansSerifLarge"
h_pad="0" h_pad="0"
halign="left" halign="left"
height="16" height="16"
left="50" left="57"
mouse_opaque="false" mouse_opaque="false"
name="title_text" name="artist_text"
v_pad="0" v_pad="0"
width="193"> width="188">
Cummies Arf
</text> </text>
</panel> </panel>
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
height="16" height="16"
label="When my friends log in or out" label="When my friends log in or out"
layout="topleft" layout="topleft"
left_delta="150" left_delta="130"
name="friends_online_notify_checkbox" name="friends_online_notify_checkbox"
width="30" /> width="30" />
<check_box <check_box
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
height="16" height="16"
label="When I get L$" label="When I get L$"
layout="topleft" layout="topleft"
left_delta="-320" left_delta="-300"
top_pad="4" top_pad="4"
name="notify_money_received_checkbox" name="notify_money_received_checkbox"
width="300" /> width="300" />
...@@ -59,9 +59,17 @@ ...@@ -59,9 +59,17 @@
height="16" height="16"
label="When music stream titles change" label="When music stream titles change"
layout="topleft" layout="topleft"
left_delta="150" left_delta="130"
name="music_stream_title" name="music_stream_title"
width="30" /> width="30" />
<check_box
control_name="ShowStreamInfoToChat"
height="16"
label="In Nearby Chat"
layout="topleft"
left_delta="190"
name="music_stream_title_checkbox_chat"
width="20" />
<text <text
type="string" type="string"
length="1" length="1"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment