It is currently May 24th, 2024, 3:46 am

Simple Text Marquee

Tips and Tricks from the Rainmeter Community
ZXCVBOT

Re: Simple Text Marquee

Post by ZXCVBOT »

Heh Hehe!

Thanks eclectic-tech, I did not notice that. I copied the title-action and edited it.

I did it by the measure process - It starts and goes on forever.

Edit:

I did not understand the Clamp part, can you be more specific as to how can I implement it? Or atleast, how can I count the length of the string in Rainmeter?

I tried !Refresh, so, when the DoOverAction takes place, it also resets the positions for every string in the skin.

The new edited code (Previous one had major flaws, now marquee is visible). Also, all the strings run back together (duh they have a defined beginning and at the same rate they are getting subtracted). I think that Clamp-ing / defining a min and max for the specific strings (that change) would solve this problem.

Code: Select all

[Rainmeter]
Update=32

[Variables]

PlayerName=AIMP
FontName=Segoe UI
FontColor=255,255,255,255

;; Marquee

AnimationSpeed=32
Wait=10

;; Dynamic Marquee Variables

ArtistX=
AlbumX=
TrackX=

; -----------------------------------------------------------------------------------------

[MeasureTrack]
Measure=Plugin
Plugin=NowPlaying
PlayerName=#PlayerName#
PlayerType=Title
Substitute="":""

[MeasureArtist]
Measure=Plugin
Plugin=NowPlaying
PlayerName=#PLayerName#
PlayerType=Artist
Substitute="":""

[MeasureAlbum]
Measure=Plugin
Plugin=NowPlaying
PlayerName=#PLayerName#
PlayerType=Album
Substitute="":""

;; Marquee-ing Title, Artist, Album

[TrackTextOffset]
Group=Marquee
Measure=Calc
Formula=(Max(0,([M_Track:W]-[Container:W])))
DynamicVariables=1

[TrackX]
Measure=Calc
Formula=(TrackX-1)

[ArtistTextOffset]
Group=Marquee
Measure=Calc
Formula=(Max(0,([M_Artist:W]-[Container:W])))
DynamicVariables=1

[ArtistX]
Measure=Calc
Formula=(ArtistX-1)

[AlbumTextOffset]
Group=Marquee
Measure=Calc
Formula=(Max(0,([M_Album:W]-[Container:W])))
DynamicVariables=1

[AlbumX]
Measure=Calc
Formula=(AlbumX-1)

[Marquee]
Group=Marquee
Measure=Plugin
Plugin=ActionTimer

; -----------------------------------------------------------------------------------------

ActionList1=Repeat Move M_Artist,#AnimationSpeed#,[ArtistTextOffset:] | Wait #Wait# | Reset M_Artist | Wait #Wait# | DoOver M_Artist | Wait #Wait#

ResetArtist=[!SetVariable ArtistX 0][!UpdateMeasure Marquee][!UpdateMeter M_Artist][!Redraw]

MoveArtist=[!SetVariable ArtistX (#ArtistX#-1)][!UpdateMeasure Marquee][!UpdateMeter M_Artist][!Redraw]

DoOverArtist=[!CommandMeasure Marquee "Stop 1"][!CommandMeasure Marquee "Execute 1"][!Refresh]

; -----------------------------------------------------------------------------------------

ActionList2=Repeat Move M_Track,#AnimationSpeed#,[TitleTextOffset:] | Wait #Wait# | ResetM_Track | Wait #Wait# | DoOver M_Track | Wait #Wait#

ResetTitle=[!SetVariable TrackX 0][!UpdateMeasure Marquee][!UpdateMeter M_Track][!Redraw]

MoveTitle=[!SetVariable TrackX (#TitleX#-1)][!UpdateMeasure Marquee][!UpdateMeter M_Track][!Redraw]

DoOverTitle=[!CommandMeasure Marquee "Stop 2"][!CommandMeasure Marquee "Execute 2"][!Refresh]

; -----------------------------------------------------------------------------------------

ActionList3=Repeat Move M_Album,#AnimationSpeed#,[AlbumTextOffset:] | Wait #Wait# | ResetTitle | Wait #Wait# | DoOver M_Album | Wait #Wait#

ResetTitle=[!SetVariable AlbumX 0][!UpdateMeasure Marquee][!UpdateMeter M_Album][!Redraw]

MoveTitle=[!SetVariable AlbumX (#AlbumX#-1)][!UpdateMeasure Marquee][!UpdateMeter M_Album][!Redraw]

DoOverTitle=[!CommandMeasure Marquee "Stop 3"][!CommandMeasure Marquee "Execute 3"][!Refresh]

DynamicVariables=1

; ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[M_TRACK]
Meter=String
MeasureName=MeasureTrack
;X=(#XPos#+1)
X=[TrackX]
Y=1
W=392
FontFace=#FONTNAME#
FontColor=#FONTCOLOR#
FontSize=13
Text=%1
Group=Marquee
Container=Container
AntiAlias=1
DynamicVariables=1

[M_ARTIST]
Meter=String
MeasureName=MeasureArtist
;X=(#XPos#+1)
X=[ArtistX]
Y=([M_TRACK:Y]+20)
W=392
FontFace=#FONTNAME#
FontColor=#FONTCOLOR#
FontSize=12
Text=%1
TooltipText=%1
Group=Marquee
Container=Container
AntiAlias=1
DynamicVariables=1

[M_ALBUM]
Meter=String
MeasureName=MeasureAlbum
;X=(#XPos#+1)
X=[AlbumX]
Y=([M_ARTIST:Y]+20)
W=392
FontFace=#FONTNAME#
FontColor=#FONTCOLOR#
FontSize=12
Text=%1
Group=Marquee
Container=Container
AntiAlias=1
DynamicVariables=1

[M_Shape]
Meter=Shape
Shape=Rectangle 2,2,394,75,2 | Fill Color 0,0,0,128 | StrokeWidth 1 | Stroke Color 255,255,255,255

[Container]
Meter=Image
W=([M_Track:W])
H=75
SolidColor=255,255,255,255
PS: I added the refresh and update to the shape earlier, as I was unable to see anything: it was all invisible. Now, that I can see the text I can remove the shape or the leftmouseupaction.
User avatar
Yincognito
Rainmeter Sage
Posts: 7319
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Simple Text Marquee

Post by Yincognito »

ZXCVBOT wrote: October 30th, 2023, 4:27 pmI did not understand the Clamp part, can you be more specific as to how can I implement it? Or atleast, how can I count the length of the string in Rainmeter?
Like I said, clamping will not reset to the start position, it will stay at the end position, so the movement will only happen once and be stuck at the end of the string. I only mentioned it to point out why the modulo choice was a way to "do over" (e.g. 0 % 3 = 0, 1 % 3 = 1, 2 % 3 = 2, but then again 3 % 3 = 0, 4 % 3 = 1, 5 % 3 = 2 and the cycle repeats forever). That being said, while this can be done using modulo, I believe it's simpler without it in this case, to better see what happens. Therefore, meet IfConditions (which replace what the additional Offset measures were supposed to do earlier) and a clearer version of the code (I made some other changes too, check them out):

Code: Select all

[Variables]
PlayerName=AIMP
FontName=Segoe UI
FontColor=255,255,255,255
AnimationSpeed=32
TrackStep=1
ArtistStep=1
AlbumStep=1

[Rainmeter]
Update=#AnimationSpeed#

---Measures---

[MeasureTrack]
Measure=Plugin
Plugin=NowPlaying
PlayerName=#PlayerName#
PlayerType=Title
Substitute="":""

[MeasureArtist]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasureTrack]
PlayerType=Artist
Substitute="":""

[MeasureAlbum]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasureTrack]
PlayerType=Album
Substitute="":""

[TrackX]
Measure=Calc
Formula=([M_Track:W]-[Container:W]>0?TrackX+#TrackStep#:TrackX)
IfCondition=(TrackX<0)||(TrackX>[M_Track:W]-[Container:W])
IfTrueAction=[!DisableMeasure TrackX][!UpdateMeasure TrackX][!EnableMeasure TrackX]
IfConditionMode=1
DynamicVariables=1

[ArtistX]
Measure=Calc
Formula=([M_Artist:W]-[Container:W]>0?ArtistX+#ArtistStep#:ArtistX)
IfCondition=(ArtistX<0)||(ArtistX>[M_Artist:W]-[Container:W])
IfTrueAction=[!DisableMeasure ArtistX][!UpdateMeasure ArtistX][!EnableMeasure ArtistX]
IfConditionMode=1
DynamicVariables=1

[AlbumX]
Measure=Calc
Formula=([M_Album:W]-[Container:W]>0?AlbumX+#AlbumStep#:AlbumX)
IfCondition=(AlbumX<0)||(AlbumX>[M_Album:W]-[Container:W])
IfTrueAction=[!DisableMeasure AlbumX][!UpdateMeasure AlbumX][!EnableMeasure AlbumX]
IfConditionMode=1
DynamicVariables=1

---Meters---

[M_Shape]
Meter=Shape
Shape=Rectangle 2,2,394,75,2 | Fill Color 0,0,0,128 | StrokeWidth 1 | Stroke Color 255,255,255,255

[Container]
Meter=Image
X=172
W=50
H=75
SolidColor=255,255,255,255
DynamicVariables=1

[M_TRACK]
Meter=String
MeasureName=MeasureTrack
X=(-[TrackX])
Y=1
FontFace=#FONTNAME#
FontColor=#FONTCOLOR#
FontSize=13
Text=%1
Group=Marquee
Container=Container
AntiAlias=1
DynamicVariables=1

[M_ARTIST]
Meter=String
MeasureName=MeasureArtist
X=(-[ArtistX])
Y=20r
FontFace=#FONTNAME#
FontColor=#FONTCOLOR#
FontSize=12
Text=%1
TooltipText=%1
Group=Marquee
Container=Container
AntiAlias=1
DynamicVariables=1

[M_ALBUM]
Meter=String
MeasureName=MeasureAlbum
X=(-[AlbumX])
Y=20r
FontFace=#FONTNAME#
FontColor=#FONTCOLOR#
FontSize=12
Text=%1
Group=Marquee
Container=Container
AntiAlias=1
DynamicVariables=1
The above will reset the measure values giving the text positions when the movement ends, so it can begin again (aka the do over system). However, you can do some ping pong to slide back and forth and avoid sudden position jumping, by changing to IfTrueAction=[!SetVariable TrackStep (-#TrackStep#)] in the last 3 measures. Or, you can slide forever from the right of the container once the text dissapears at the its left, by changing to IfCondition=(TrackX<0)||(TrackX>[M_Track:W]+[Container:W]) and similar in those measures, along with changing to X=([Container:W]-[TrackX]) and similar in the corresponding meters. The numerical conditionals in the Formula options are mainly to not slide if the text width is smaller than the container width, and having the X options as the negatives of the measures is mostly for the process in the measure to feel more natural, i.e. a number incrementing from 0 to something. The different Step variables are to be able to control the ping pong individually for each text.

P.S. Removed the ActionTimer measure and the other unused stuff from the code as well.
P.S.S. You can set the Container's W to whatever you want (same for its X or Y). The [M_Track:W] value doesn't make much sense as its W though, maybe some fraction of the M_Shape background meter... :???:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
ZXCVBOT

Re: Simple Text Marquee

Post by ZXCVBOT »

Whaa?! You made it look easy even more! And what's good is that it actually works! :bow: I never thought it would work without the ActionTimer! O.O

I took your advice and am avoiding ping-pong movement and using the conditions in the below code.

PS: Testing it took too long, as I was using an edited mp3 file with tooooooooooooooooooooooooooooooooo long title, album and artist. Yeah no kidding. The TrackX, ArtistX and AlbumX went upto 3000++ even after combined might of long container.

I believe this is owed :Trophy
User avatar
Yincognito
Rainmeter Sage
Posts: 7319
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Simple Text Marquee

Post by Yincognito »

ZXCVBOT wrote: October 31st, 2023, 10:24 am Whaa?! You made it look easy even more! And what's good is that it actually works! :bow: I never thought it would work without the ActionTimer! O.O

I took your advice and am avoiding ping-pong movement and using the conditions in the below code.

PS: Testing it took too long, as I was using an edited mp3 file with tooooooooooooooooooooooooooooooooo long title, album and artist. Yeah no kidding. The TrackX, ArtistX and AlbumX went upto 3000++ even after combined might of long container.

I believe this is owed :Trophy
Oh, thanks - yet another trophy for me. Can I sell it? :lol:

Anyways, joking aside, I think you misunderstood: it's the ping pong movement that avoids sudden text jumps (like the one when resetting positions), not the other way around. But yeah, I'm glad you like the result, hopefully you'll keep the ideas there in mind and put them to good use in other cases in the future! :great:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
pds
Posts: 79
Joined: April 12th, 2014, 12:52 pm
Location: Slovakia

Re: Simple Text Marquee

Post by pds »

Yincognito wrote: October 30th, 2023, 11:55 pm
The above will reset the measure values giving the text positions when the movement ends, so it can begin again (aka the do over system). However, you can do some ping pong to slide back and forth and avoid sudden position jumping, by changing to IfTrueAction=[!SetVariable TrackStep (-#TrackStep#)] in the last 3 measures. Or, you can slide forever from the right of the container once the text dissapears at the its left, by changing to IfCondition=(TrackX<0)||(TrackX>[M_Track:W]+[Container:W]) and similar in those measures, along with changing to X=([Container:W]-[TrackX]) and similar in the corresponding meters. The numerical conditionals in the Formula options are mainly to not slide if the text width is smaller than the container width, and having the X options as the negatives of the measures is mostly for the process in the measure to feel more natural, i.e. a number incrementing from 0 to something. The different Step variables are to be able to control the ping pong individually for each text...
I tried your code and it's great. The ping-pong version is better. But there is a small problem when changing, that the text is not overwritten or will remain stuck.

Maybe I just changed it wrong. Could you show the code with the ping effect?

Well thank you
ZXCVBOT

Re: Simple Text Marquee

Post by ZXCVBOT »

The whole code with changes required is posted above: https://forum.rainmeter.net/viewtopic.php?p=219078#p219071
Anyways, I am not the master at this, so look around in this forum, it's quite knowledgeable. Since I do not know what is the purpose you are trying to fulfil, so if you are trying to move just a string and using ActionTimer, you should look no further from this one: https://forum.rainmeter.net/viewtopic.php?t=31790#p160574
User avatar
pds
Posts: 79
Joined: April 12th, 2014, 12:52 pm
Location: Slovakia

Re: Simple Text Marquee

Post by pds »

Yincognito wrote: October 30th, 2023, 11:55 pm
I solved it by adding an OnChangeAction line :

Code: Select all

[MeasureTrack]
Measure=Plugin
Plugin=NowPlaying
PlayerName=#PlayerName#
PlayerType=Title
Substitute="":""
OnChangeAction=[!DisableMeasure TrackX][!UpdateMeasure TrackX][!EnableMeasure TrackX]

[TrackX]
Measure=Calc
Formula=([M_Track:W]-[Container:W]>0?TrackX+#TrackStep#:TrackX)
IfCondition=(TrackX<0)||(TrackX>[M_Track:W]-[Container:W])
IfTrueAction=[!SetVariable TrackStep (-#TrackStep#)]
IfConditionMode=1
DynamicVariables=1
But maybe you have a better solution?
ZXCVBOT

Re: Simple Text Marquee

Post by ZXCVBOT »

ZXCVBOT wrote: October 31st, 2023, 12:12 pm I am not the master at this, so look around in this forum, it's quite knowledgeable.
Maybe, wait for the elders (ahem!) Sages (ahem!).

Edit: This does not work properly, when the string is short and container is long. I can't figure out a reason. I'll look at it tomorrow.

Happy Halloween! 🎃
User avatar
pds
Posts: 79
Joined: April 12th, 2014, 12:52 pm
Location: Slovakia

Re: Simple Text Marquee

Post by pds »

ZXCVBOT wrote: October 31st, 2023, 2:16 pm Maybe, wait for the elders (ahem!) Sages (ahem!).

Edit: This does not work properly, when the string is short and container is long. I can't figure out a reason. I'll look at it tomorrow.

Happy Halloween! 🎃
it works perfectly for me.
ZXCVBOT

Re: Simple Text Marquee

Post by ZXCVBOT »

Oh.. I figured it out.. I was using "-" instead of "+" which disabled it when it was less than 0 in iftruecondition. Corrected it:

Formula=([M_Track:W]+[Container:W]>0?TrackX+#TrackStep#:TrackX)
Formula=([M_Artist:W]+[Container:W]>0?ArtistX+#ArtistStep#:ArtistX)
Formula=([M_Album:W]+[Container:W]>0?AlbumX+#AlbumStep#:AlbumX)