It is currently March 29th, 2024, 5:57 am

Scrolling text question

General topics related to Rainmeter.
User avatar
CyberTheWorm
Posts: 860
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Scrolling text question

Post by CyberTheWorm »

Saw a post about scrolling text by jsmorley and thought In would try for scrolling lyrics in a media player skin
MediaPlayer.png

Code: Select all

[MeterContainer]
Meter=Shape
Shape=Rectangle 410,10,190,300 | StrokeWidth 2
UpdateDivider=-1

[MeterLyrics]
Meter=String
MeasureName=MeasureLyrics
X=410
Y=10
W=190
H=300
FontFace=Ariel
StringStyle=Bold
FontSize=10
FontColor=255,255,255,255
AntiAlias=1
ClipString=2
StringAlign=Left
StringEffect=Border
FontEffectColor=0,0,0,255
Text="%1"
Container=MeterContainer
UpdateDivider=-1
DynamicVariables=1
Not sure if this is possible to either scroll by using a mouse or having it auto scroll
Last edited by CyberTheWorm on March 12th, 2019, 9:11 pm, edited 2 times in total.
The only source of knowledge is experience. Albert Einstein
Deviant Art Page
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Scrolling text question

Post by jsmorley »

Take a look at this skin:

https://forum.rainmeter.net/viewtopic.php?f=119&t=31531&p=159479&hilit=casey#p159479

The trick is knowing when you have reached the end of the text to scroll. I think the simplest way is what I have done there, which is to just have an invisible copy of the text in a meter that you can then measure for height. The text will be "contained" in a single invisible pixel that is outside the skin, and thus in no way "drawn", but will actually still measure the height it would have if it was fully displayed. it all has a fun "quantum mechanics" flavor to it...
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Scrolling text question

Post by jsmorley »

I expect this could be made to "auto-scroll" by using the percentage "complete" the song is in NowPlaying, and applying that percentage, factored with the height of the font, and the measured height of the text, to the Y value of the meter displaying the lyrics in the container. I haven't really chewed on this, but I suspect it wouldn't be terribly complicated.

You are not going to get "follow the bouncing ball" by any means, but I expect the text could be made to scroll in the container based on the percentage position you are in the song.
User avatar
CyberTheWorm
Posts: 860
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: Scrolling text question

Post by CyberTheWorm »

Yes I saw the Casey post, that is what made me think I could try with the lyrics.

Will have to try and figure a way to get the length.
The only source of knowledge is experience. Albert Einstein
Deviant Art Page
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Scrolling text question

Post by jsmorley »

CyberTheWorm wrote: March 12th, 2019, 7:01 pm Yes I saw the Casey post, that is what made me think I could try with the lyrics.

Will have to try and figure a way to get the length.

I do that in that example skin. It's easy...
I think the simplest way is what I have done there, which is to just have an invisible copy of the text in a meter that you can then measure for height. The text will be "contained" in a single invisible pixel that is outside the skin, and thus in no way "drawn", but will actually still measure the height it would have if it was fully displayed.
Once you know the height of the entire text if it was simply drawn in a meter, you really have all you need to know. Estimating the height of the font can be useful to make each "scroll" be more pleasing, so you don't end in the horizontal middle of a line of text, but not really critical.

The "length" of the string, in lines or characters is first, impossible to reliably get, and second, irrelevant. All that matters is the "height" of the string if it was drawn in a stand-alone meter.

Don't forget that unless you want a really wide container, or want to truncate lines of text, you are likely to have "wrapping", which makes any measurement of lines or characters (which can only be done in Lua) pointless. It's only height that matters.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Scrolling text question

Post by jsmorley »

Here is an example...

Download and install Poiru's Soita skin from https://www.deviantart.com/poiru/art/Soita-for-Rainmeter-209864541

Open Soita.ini and first, change the parent PlayerName to PlayerName=Winamp or whatever supported player you use.

Scroll down to the very bottom of Soita.ini and add these lines:

Code: Select all

; New Stuff

[Variables]
LeastY=0
CurrentY=0
FontHeight=16

[mLyrics]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=[mPlayer]
PlayerType=LYRICS

[MeterHider]
Meter=Shape
X=-1
Y=-1
W=1
H=1
SolidColor=0,0,0,1

[MeterLyricsHeight]
Meter=String
MeasureName=mLyrics
FontFace=Trebuchet MS
FontColor=255,255,255,255
AntiAlias=1
Container=MeterHider

[lyricsContainerVisible]
Meter=Shape
X=420
Y=0
Shape=Rectangle 0,0,400,255 | StrokeWidth 0 | Fill Color 0,0,0,255

[lyricsContainer]
Meter=Shape
X=425
Y=5
Shape=Rectangle 0,0,395,250 | StrokeWidth 0
DynamicVariables=1
MouseScrollDownAction=[!SetVariable CurrentY "(Clamp((#CurrentY# - (#FontHeight#*2)),(-([&MeterLyricsHeight:H]-250)),#LeastY#))"][!UpdateMeter *][!Redraw]
MouseScrollUpAction=[!SetVariable CurrentY "(Clamp((#CurrentY# + (#FontHeight#*2)),(-([&MeterLyricsHeight:H]-250)),#LeastY#))"][!UpdateMeter *][!Redraw]

[MeterLyrics]
Meter=String
MeasureName=mLyrics
X=0
Y=#CurrentY#
FontFace=Trebuchet MS
FontColor=255,255,255,255
AntiAlias=1
DynamicVariables=1
Container=lyricsContainer

Save and refresh / load the skin, and voila...



Click to animate:
GIF.gif
You do not have the required permissions to view the files attached to this post.
User avatar
CyberTheWorm
Posts: 860
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: Scrolling text question

Post by CyberTheWorm »

Very cool, works great with my player too
The only source of knowledge is experience. Albert Einstein
Deviant Art Page
vidya31
Posts: 1
Joined: March 18th, 2019, 12:17 pm

Re: Scrolling text question

Post by vidya31 »

Excellent thread.!!