From 8147fc6630d8d4d7d001f59b64145b4654f55e7c Mon Sep 17 00:00:00 2001 From: Cinder <cinder@sdf.org> Date: Tue, 30 Jun 2015 09:55:02 -0600 Subject: [PATCH] General cleanup to music ticker --- indra/newview/alpanelmusicticker.cpp | 69 +++--- indra/newview/alpanelmusicticker.h | 1 - .../default/xui/en/floater_music_ticker.xml | 6 +- .../skins/default/xui/en/menu_viewer.xml | 27 ++- .../default/xui/en/panel_music_ticker.xml | 227 +++++++++--------- 5 files changed, 167 insertions(+), 163 deletions(-) diff --git a/indra/newview/alpanelmusicticker.cpp b/indra/newview/alpanelmusicticker.cpp index c36aa15a70..f4a4692d32 100644 --- a/indra/newview/alpanelmusicticker.cpp +++ b/indra/newview/alpanelmusicticker.cpp @@ -21,16 +21,14 @@ ALPanelMusicTicker::ALPanelMusicTicker() : LLPanel(), mArtistScrollChars(0), mTitleScrollChars(0), mCurScrollChar(0), - mTickerBackground(NULL), - mArtistText(NULL), - mTitleText(NULL), - mVisualizer(NULL) + mArtistText(nullptr), + mTitleText(nullptr), + mVisualizer(nullptr) { } BOOL ALPanelMusicTicker::postBuild() { - mTickerBackground = getChild<LLIconCtrl>("ticker_background"); mArtistText = getChild<LLTextBox>("artist_text"); mTitleText = getChild<LLTextBox>("title_text"); mVisualizer = getChild<LLUICtrl>("visualizer_box"); @@ -57,12 +55,13 @@ void ALPanelMusicTicker::reshape(S32 width, S32 height, BOOL called_from_parent/ if(width_changed) { if(mTitleText) - mTitleScrollChars = countExtraChars(mTitleText,mszTitle); + mTitleScrollChars = countExtraChars(mTitleText, mszTitle); if(mArtistText) - mArtistScrollChars = countExtraChars(mArtistText,mszArtist); + mArtistScrollChars = countExtraChars(mArtistText, mszArtist); resetTicker(); } } + void ALPanelMusicTicker::updateTickerText() //called via draw. { if(!gAudiop) @@ -88,9 +87,9 @@ void ALPanelMusicTicker::updateTickerText() //called via draw. else if(mLoadTimer.getStarted() && mLoadTimer.getElapsedTimeF64() > 10.f) //It has been 10 seconds.. give up. { if(!artist.isDefined()) - dirty |= setArtist(""); + dirty |= setArtist(LLStringUtil::null); if(!title.isDefined()) - dirty |= setTitle(""); + dirty |= setTitle(LLStringUtil::null); mLoadTimer.stop(); } } @@ -109,10 +108,10 @@ void ALPanelMusicTicker::drawOscilloscope() //called via draw. static const S32 NUM_LINE_STRIPS = 64; //How many lines to draw. 64 is more than enough. static const S32 WAVE_DATA_STEP_SIZE = 4; //Increase to provide more history at expense of cpu/memory. - static const S32 NUM_WAVE_DATA_VALUES = NUM_LINE_STRIPS*WAVE_DATA_STEP_SIZE; //Actual buffer size. Don't toy with this. Change above vars to tweak. + static const S32 NUM_WAVE_DATA_VALUES = NUM_LINE_STRIPS * WAVE_DATA_STEP_SIZE; //Actual buffer size. Don't toy with this. Change above vars to tweak. static F32 buf[NUM_WAVE_DATA_VALUES]; - LLRect root_rect = mVisualizer->getRect(); + const LLRect& root_rect = mVisualizer->getRect(); F32 height = root_rect.getHeight(); F32 height_scale = height / 2.f; //WaveData ranges from 1 to -1, so height_scale = height / 2 @@ -122,16 +121,20 @@ void ALPanelMusicTicker::drawOscilloscope() //called via draw. gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4fv(mOscillatorColor.mV); gGL.pushMatrix(); - gGL.translatef((F32)root_rect.mLeft, (F32)root_rect.mBottom + height*.5f, 0.f); + const auto& ui_scale = gGL.getUIScale(); + F32 x = (F32) root_rect.mLeft * ui_scale[VX]; + F32 y = (F32) (root_rect.mBottom + height * 0.5f) * ui_scale[VY]; + gGL.translatef(x, y, 0.f); gGL.begin( LLRender::LINE_STRIP ); - if(mPlayState == STATE_PAUSED || !gAudiop->getStreamingAudioImpl()->getWaveData(&buf[0],NUM_WAVE_DATA_VALUES,WAVE_DATA_STEP_SIZE)) + if(mPlayState == STATE_PAUSED + || !gAudiop->getStreamingAudioImpl()->getWaveData(&buf[0], NUM_WAVE_DATA_VALUES,WAVE_DATA_STEP_SIZE)) { - gGL.vertex2i(0,0); - gGL.vertex2i((S32)width,0); + gGL.vertex2i(0, 0); + gGL.vertex2i((S32)width, 0); } else - for(S32 i = NUM_WAVE_DATA_VALUES-1; i>=0;i-=WAVE_DATA_STEP_SIZE) - gGL.vertex2f((F32)i * width_scale, buf[i]*height_scale); + for(S32 i = NUM_WAVE_DATA_VALUES - 1; i >= 0; i -= WAVE_DATA_STEP_SIZE) + gGL.vertex2f((F32)i * width_scale, buf[i] * height_scale); gGL.end(); gGL.popMatrix(); gGL.flush(); @@ -153,9 +156,11 @@ bool ALPanelMusicTicker::setPaused(bool pause) void ALPanelMusicTicker::resetTicker() { mScrollTimer.reset(); - mCurScrollChar=0; - if(mArtistText) mArtistText->setText(LLStringExplicit(mszArtist.substr(0,mszArtist.length()-mArtistScrollChars))); - if(mTitleText) mTitleText->setText(LLStringExplicit(mszTitle.substr(0,mszTitle.length()-mTitleScrollChars))); + mCurScrollChar = 0; + if(mArtistText) + mArtistText->setText(LLStringExplicit(mszArtist.substr(0, mszArtist.length() - mArtistScrollChars))); + if(mTitleText) + mTitleText->setText(LLStringExplicit(mszTitle.substr(0, mszTitle.length() - mTitleScrollChars))); } bool ALPanelMusicTicker::setArtist(const std::string &artist) @@ -164,7 +169,7 @@ bool ALPanelMusicTicker::setArtist(const std::string &artist) return false; mszArtist = artist; mArtistText->setText(mszArtist); - mArtistScrollChars = countExtraChars(mArtistText,mszArtist); + mArtistScrollChars = countExtraChars(mArtistText, mszArtist); return true; } @@ -172,9 +177,9 @@ bool ALPanelMusicTicker::setTitle(const std::string &title) { if(!mTitleText || mszTitle == title) return false; - mszTitle=title; + mszTitle = title; mTitleText->setText(mszTitle); - mTitleScrollChars = countExtraChars(mTitleText,mszTitle); + mTitleScrollChars = countExtraChars(mTitleText, mszTitle); return true; } @@ -185,11 +190,11 @@ S32 ALPanelMusicTicker::countExtraChars(LLTextBox *texbox, const std::string &te if(text_width > box_width) { const LLFontGL* font = texbox->getFont(); - for(S32 count = 1;count<(S32)text.length();count++) + for(S32 count = 1; count < (S32)text.length(); count++) { //This isn't very efficient... - const std::string substr = text.substr(0,text.length()-count); - if(font->getWidth(substr) <= box_width) + const std::string substr = text.substr(0, text.length() - count); + if (font->getWidth(substr) <= box_width) return count; } } @@ -198,10 +203,10 @@ S32 ALPanelMusicTicker::countExtraChars(LLTextBox *texbox, const std::string &te void ALPanelMusicTicker::iterateTickerOffset() { - if( (mPlayState != STATE_PAUSED) && - (mArtistScrollChars || mTitleScrollChars) && - ((!mCurScrollChar && mScrollTimer.getElapsedTimeF32() >= 5.f) || - ( mCurScrollChar && mScrollTimer.getElapsedTimeF32() >= .5f))) + if((mPlayState != STATE_PAUSED) + && (mArtistScrollChars || mTitleScrollChars) + && ((!mCurScrollChar && mScrollTimer.getElapsedTimeF32() >= 5.f) + || (mCurScrollChar && mScrollTimer.getElapsedTimeF32() >= .5f))) { if(++mCurScrollChar > llmax(mArtistScrollChars, mTitleScrollChars)) { @@ -213,11 +218,11 @@ void ALPanelMusicTicker::iterateTickerOffset() mScrollTimer.reset(); if(mArtistText && mCurScrollChar <= mArtistScrollChars) { - mArtistText->setText(LLStringExplicit(mszArtist.substr(mCurScrollChar,mszArtist.length()-mArtistScrollChars+mCurScrollChar))); + mArtistText->setText(LLStringExplicit(mszArtist.substr(mCurScrollChar, mszArtist.length()-mArtistScrollChars + mCurScrollChar))); } if(mTitleText && mCurScrollChar <= mTitleScrollChars) { - mTitleText->setText(LLStringExplicit(mszTitle.substr(mCurScrollChar,mszTitle.length()-mTitleScrollChars+mCurScrollChar))); + mTitleText->setText(LLStringExplicit(mszTitle.substr(mCurScrollChar, mszTitle.length()-mTitleScrollChars + mCurScrollChar))); } } } diff --git a/indra/newview/alpanelmusicticker.h b/indra/newview/alpanelmusicticker.h index 915b926d3c..39306dc155 100644 --- a/indra/newview/alpanelmusicticker.h +++ b/indra/newview/alpanelmusicticker.h @@ -45,7 +45,6 @@ private: LLColor4 mOscillatorColor; //UI elements - LLIconCtrl* mTickerBackground; LLTextBox* mArtistText; LLTextBox* mTitleText; LLUICtrl* mVisualizer; diff --git a/indra/newview/skins/default/xui/en/floater_music_ticker.xml b/indra/newview/skins/default/xui/en/floater_music_ticker.xml index d81bed119f..99daa03b41 100644 --- a/indra/newview/skins/default/xui/en/floater_music_ticker.xml +++ b/indra/newview/skins/default/xui/en/floater_music_ticker.xml @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="utf-8" standalone="yes" ?> <floater - width="305" + width="320" height="39" layout="topleft" - min_width="305" + min_width="300" min_height="39" name="floater_music_ticker" positioning="cascading" @@ -21,7 +21,7 @@ filename="panel_music_ticker.xml" layout="topleft" follows="all" - width="350" + width="296" top="0" mouse_opaque="false"/> </floater> diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 4ed7942931..9b1545b80c 100755 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -74,6 +74,19 @@ parameter="experiences"/> </menu_item_call> <menu_item_separator/> + <menu_item_check + label="Music Ticker..." + name="music_ticker_check"> + <menu_item_check.on_check + function="Floater.Visible" + parameter="music_ticker" /> + <menu_item_check.on_click + function="Floater.Toggle" + parameter="music_ticker" /> + <menu_item_check.on_enable + function="EnableMusicTicker" /> + </menu_item_check> + <menu_item_separator/> <menu_item_call label="Camera Controls..." name="Camera Controls"> @@ -482,7 +495,7 @@ parameter="mini_map" /> </menu_item_check> <menu_item_check - label="Region Tracker" + label="Region Tracker..." name="Region Tracker"> <menu_item_check.on_check function="Floater.Visible" @@ -491,18 +504,6 @@ function="Floater.Toggle" parameter="region_tracker" /> </menu_item_check> - <menu_item_check - label="Music Ticker" - name="music_ticker_check"> - <menu_item_check.on_check - function="Floater.Visible" - parameter="music_ticker" /> - <menu_item_check.on_click - function="Floater.Toggle" - parameter="music_ticker" /> - <menu_item_check.on_enable - function="EnableMusicTicker" /> - </menu_item_check> <menu_item_check label="Search" name="Search" diff --git a/indra/newview/skins/default/xui/en/panel_music_ticker.xml b/indra/newview/skins/default/xui/en/panel_music_ticker.xml index 5714d8a35c..4c380ec932 100644 --- a/indra/newview/skins/default/xui/en/panel_music_ticker.xml +++ b/indra/newview/skins/default/xui/en/panel_music_ticker.xml @@ -1,114 +1,113 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes" ?> -<panel - layout="topleft" - width="300" - height="34" - name="music_ticker"> - <icon - top="19" - color="AlAshGrey" - follows="left|top|right" - height="1" - layout="topleft" - image_name="white.tga" - left="0" - mouse_opaque="false" - name="ticker_background" - width="177" /> - <locate - top="0" - height="38" - left="177" - name="visualizer_box" - width="60" - follows="top|right" - use_bounding_rect="true" - layout="topleft"/> - <icon - top="0" - color="AlAshGrey" - follows="top|right" - height="37" - layout="topleft" - image_name="Ticker_Grid" - left="177" - mouse_opaque="false" - name="visualizer_grid" - width="60" /> - <text - text_color="AlBlue" - bg_visible="false" - border_visible="false" - layout="topleft" - top="0" - follows="top|left" - font="SansSerifBold" - h_pad="0" - halign="left" - height="16" - left="4" - mouse_opaque="false" - name="artist_label" - v_pad="0" - width="50"> - Artist: - </text> - <text - bg_visible="false" - border_visible="false" - layout="topleft" - top="0" - follows="top|left|right" - font="SansSerifBold" - h_pad="0" - halign="left" - height="16" - left="50" - mouse_opaque="false" - name="artist_text" - v_pad="0" - width="125"> - </text> - <text - text_color="AlBlue" - bg_visible="false" - border_visible="false" - layout="topleft" - top="19" - follows="top|left" - font="SansSerifBold" - h_pad="0" - halign="left" - height="16" - left="4" - mouse_opaque="false" - name="title_label" - v_pad="0" - width="50"> - Title: - </text> - <text - bg_visible="false" - border_visible="false" - layout="topleft" - top="19" - follows="top|left|right" - font="SansSerifBold" - h_pad="0" - halign="left" - height="16" - left="50" - mouse_opaque="false" - name="title_text" - v_pad="0" - width="125"> - </text> - - - <string name="paused"> - (not playing) - </string> - <string name="loading"> - (loading...) - </string> - </panel> +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<panel + layout="topleft" + follows="top|right|left" + width="300" + height="38" + name="music_ticker"> + <string name="paused"> + (not playing) + </string> + <string name="loading"> + (loading...) + </string> + <icon + top="19" + 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 + top="0" + bottom="-1" + left="244" + name="visualizer_box" + width="60" + follows="top|right" + use_bounding_rect="true" + layout="topleft"/> + <icon + top="0" + bottom="-1" + color="AlAshGrey" + follows="top|right" + layout="topleft" + image_name="Ticker_Grid" + left="244" + mouse_opaque="false" + name="visualizer_grid" + width="60" /> + <text + text_color="AlBlue" + bg_visible="false" + border_visible="false" + layout="topleft" + top="0" + follows="top|left" + font="SansSerifBold" + h_pad="0" + halign="left" + height="16" + left="4" + mouse_opaque="false" + name="artist_label" + v_pad="0" + width="50"> + Artist: + </text> + <text + bg_visible="false" + border_visible="false" + layout="topleft" + top="0" + follows="top|left|right" + font="SansSerifBold" + h_pad="0" + halign="left" + height="16" + left="50" + mouse_opaque="false" + name="artist_text" + v_pad="0" + width="193"> + </text> + <text + text_color="AlBlue" + bg_visible="false" + border_visible="false" + layout="topleft" + top="19" + follows="top|left" + font="SansSerifBold" + h_pad="0" + halign="left" + height="16" + left="4" + mouse_opaque="false" + name="title_label" + v_pad="0" + width="50"> + Title: + </text> + <text + bg_visible="false" + border_visible="false" + layout="topleft" + top="19" + follows="top|left|right" + font="SansSerifBold" + h_pad="0" + halign="left" + height="16" + left="50" + mouse_opaque="false" + name="title_text" + v_pad="0" + width="193"> + </text> +</panel> -- GitLab