It is currently April 27th, 2024, 3:55 pm

Simple Text Marquee

Tips and Tricks from the Rainmeter Community
User avatar
Yincognito
Rainmeter Sage
Posts: 7177
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Simple Text Marquee

Post by Yincognito »

pds wrote: October 31st, 2023, 12:03 pm 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
Later than needed, but since you asked, this is exactly how the code (still, till it gets deleted) looks on my side:

Code: Select all

[Variables]
PlayerName=Winamp
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])
; Reset Pos Variant: IfTrueAction=[!DisableMeasure TrackX][!UpdateMeasure TrackX][!EnableMeasure TrackX]
; Ping Pong Variant:
IfTrueAction=[!SetVariable TrackStep (-#TrackStep#)]
; Perpetual Variant: IfCondition=(TrackX<0)||(TrackX>[M_Track:W]+[Container:W]) and X=([Container:W]-[TrackX])
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])
; Reset Pos Variant: IfTrueAction=[!DisableMeasure ArtistX][!UpdateMeasure ArtistX][!EnableMeasure ArtistX]
; Ping Pong Variant: 
IfTrueAction=[!SetVariable ArtistStep (-#ArtistStep#)]
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])
; Reset Pos Variant: IfTrueAction=[!DisableMeasure AlbumX][!UpdateMeasure AlbumX][!EnableMeasure AlbumX]
; Ping Pong Variant: 
IfTrueAction=[!SetVariable AlbumStep (-#AlbumStep#)]
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
Obviously, I don't get the issue you're describing. Try the above just out of curiosity and let me know if you still get the said issue.
EDIT: Well, after trying some more, I do get some issues, but only on some track changes like you said. A refresh fixes the issue, but of course it shouldn't be needed. Most likely the on change idea is close to a working approach, since after all, it has to do with some values being "locked" in a certain state when chenging the playing track. I might take a look at it tomorrow and see if there is a better alternative.
ZXCVBOT wrote: October 31st, 2023, 2:16 pm Maybe, wait for the elders (ahem!) Sages (ahem!).
I was born an elder, just without a tribe... till I found the Rainmeter one. :rolmfao:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7177
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Simple Text Marquee

Post by Yincognito »

pds wrote: October 31st, 2023, 12:45 pm I solved it by adding an OnChangeAction line :
[...]
But maybe you have a better solution?
Yincognito wrote: November 1st, 2023, 12:26 amEDIT: Well, after trying some more, I do get some issues, but only on some track changes like you said. A refresh fixes the issue, but of course it shouldn't be needed. Most likely the on change idea is close to a working approach, since after all, it has to do with some values being "locked" in a certain state when chenging the playing track. I might take a look at it tomorrow and see if there is a better alternative.
Well, I just took a look at the problem and your solution and resetting the measures in the OnChangeActions seems like the best idea - very good solution, well done. However, additionally updating the meters and redrawing (before enabling measures again!) to update the [SomeMeter:W] width values on changing tracks (i.e. the root of the issue), as well as resetting the steps if using the ping pong version, are recommended for best results. Full code, hopefully without any problems (note that this does NOT use any variant, you'll have to use the desired variant lines yourself by simply hitting an ENTER just after : to uncomment the option parts in each case, with recommenting just a matter of hiting BACKSPACE before an uncommented option to place it back after its commented description):

Code: Select all

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

[Rainmeter]
Update=#AnimationSpeed#

---Measures---

[MeasureTrack]
Group=Infos
Measure=Plugin
Plugin=NowPlaying
PlayerName=#PlayerName#
PlayerType=Title
Substitute="":""
; If using the parent - child measure model for NowPlaying below (i.e. PlayerName=[ParentMeasure]), actions should be taken on entire groups in this parent measure
; If using the individual measure model for NowPlaying below (i.e. PlayerName=#PlayerVariable#), actions must be taken on individual sections in the measures below
OnChangeAction=[!SetVariable TrackStep 1][!SetVariable ArtistStep 1][!SetVariable AlbumStep 1][!DisableMeasureGroup Positions][!UpdateMeasureGroup Positions][!UpdateMeterGroup Marquees][!Redraw][!EnableMeasureGroup Positions]

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

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

; To temporarily stop text movement at the time of minimal and maximal positioning or inverting the step in the IfTrueAction:
; - Reset Pos Variant: [!PauseMeasure ...][!Delay ...][!UnpauseMeasure ...][!DisableMeasure ...][!UpdateMeasure ...][!PauseMeasure ...][!Delay ...][!UnpauseMeasure ...][!EnableMeasure ...]
; - Ping Pong Variant: [!PauseMeasure ...][!Delay ...][!UnpauseMeasure ...][!SetVariable ... (-...)]
; - Perpetual Variant: is supposed to move forever, but pausing and unpausing the relevant measures can still be used in the mouse actions from a meter

[TrackX]
Group=Positions
Measure=Calc
; Formula - Reset Pos Variant: Formula=([M_Track:W]-[Container:W]>0?TrackX+#TrackStep#:TrackX)
; Formula - Ping Pong Variant: Formula=([M_Track:W]-[Container:W]>0?TrackX+#TrackStep#:TrackX)
; Formula - Perpetual Variant: Formula=([M_Track:W]-[Container:W]>0?TrackX+#TrackStep#:[Container:W])
; IfCondition - Reset Pos Variant: IfCondition=(TrackX<0)||(TrackX>[M_Track:W]-[Container:W])
; IfCondition - Ping Pong Variant: IfCondition=(TrackX<0)||(TrackX>[M_Track:W]-[Container:W])
; IfCondition - Perpetual Variant: IfCondition=(TrackX<0)||(TrackX>[M_Track:W]+[Container:W])
; IfTrueAction - Reset Pos Variant: IfTrueAction=[!DisableMeasure TrackX][!UpdateMeasure TrackX][!EnableMeasure TrackX]
; IfTrueAction - Ping Pong Variant: IfTrueAction=[!SetVariable TrackStep (-#TrackStep#)]
; IfTrueAction - Perpetual Variant: IfTrueAction=[!DisableMeasure TrackX][!UpdateMeasure TrackX][!EnableMeasure TrackX]
IfConditionMode=1
DynamicVariables=1

[ArtistX]
Group=Positions
Measure=Calc
; Formula - Reset Pos Variant: Formula=([M_Artist:W]-[Container:W]>0?ArtistX+#ArtistStep#:ArtistX)
; Formula - Ping Pong Variant: Formula=([M_Artist:W]-[Container:W]>0?ArtistX+#ArtistStep#:ArtistX)
; Formula - Perpetual Variant: Formula=([M_Artist:W]-[Container:W]>0?ArtistX+#ArtistStep#:[Container:W])
; IfCondition - Reset Pos Variant: IfCondition=(ArtistX<0)||(ArtistX>[M_Artist:W]-[Container:W])
; IfCondition - Ping Pong Variant: IfCondition=(ArtistX<0)||(ArtistX>[M_Artist:W]-[Container:W])
; IfCondition - Perpetual Variant: IfCondition=(ArtistX<0)||(ArtistX>[M_Artist:W]+[Container:W])
; IfTrueAction - Reset Pos Variant: IfTrueAction=[!DisableMeasure ArtistX][!UpdateMeasure ArtistX][!EnableMeasure ArtistX]
; IfTrueAction - Ping Pong Variant: IfTrueAction=[!SetVariable ArtistStep (-#ArtistStep#)]
; IfTrueAction - Perpetual Variant: IfTrueAction=[!DisableMeasure ArtistX][!UpdateMeasure ArtistX][!EnableMeasure ArtistX]
IfConditionMode=1
DynamicVariables=1

[AlbumX]
Group=Positions
Measure=Calc
; Formula - Reset Pos Variant: Formula=([M_Album:W]-[Container:W]>0?AlbumX+#AlbumStep#:AlbumX)
; Formula - Ping Pong Variant: Formula=([M_Album:W]-[Container:W]>0?AlbumX+#AlbumStep#:AlbumX)
; Formula - Perpetual Variant: Formula=([M_Album:W]-[Container:W]>0?AlbumX+#AlbumStep#:[Container:W])
; IfCondition - Reset Pos Variant: IfCondition=(AlbumX<0)||(AlbumX>[M_Album:W]-[Container:W])
; IfCondition - Ping Pong Variant: IfCondition=(AlbumX<0)||(AlbumX>[M_Album:W]-[Container:W])
; IfCondition - Perpetual Variant: IfCondition=(AlbumX<0)||(AlbumX>[M_Album:W]+[Container:W])
; IfTrueAction - Reset Pos Variant: IfTrueAction=[!DisableMeasure AlbumX][!UpdateMeasure AlbumX][!EnableMeasure AlbumX]
; IfTrueAction - Ping Pong Variant: IfTrueAction=[!SetVariable AlbumStep (-#AlbumStep#)]
; IfTrueAction - Perpetual Variant: IfTrueAction=[!DisableMeasure AlbumX][!UpdateMeasure AlbumX][!EnableMeasure AlbumX]
IfConditionMode=1
DynamicVariables=1

---Meters---

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

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

[M_TRACK]
Group=Marquees
Meter=String
MeasureName=MeasureTrack
; Reset Pos Variant: X=(-[TrackX])
; Ping Pong Variant: X=(-[TrackX])
; Perpetual Variant: X=([Container:W]-[TrackX])
Y=1
FontFace=#FONTNAME#
FontColor=#FONTCOLOR#
FontSize=13
Text=%1
Container=Container
AntiAlias=1
DynamicVariables=1

[M_ARTIST]
Group=Marquees
Meter=String
MeasureName=MeasureArtist
; Reset Pos Variant: X=(-[ArtistX])
; Ping Pong Variant: X=(-[ArtistX])
; Perpetual Variant: X=([Container:W]-[ArtistX])
Y=20r
FontFace=#FONTNAME#
FontColor=#FONTCOLOR#
FontSize=12
Text=%1
Container=Container
AntiAlias=1
DynamicVariables=1

[M_ALBUM]
Group=Marquees
Meter=String
MeasureName=MeasureAlbum
; Reset Pos Variant: X=(-[AlbumX])
; Ping Pong Variant: X=(-[AlbumX])
; Perpetual Variant: X=([Container:W]-[AlbumX])
Y=20r
FontFace=#FONTNAME#
FontColor=#FONTCOLOR#
FontSize=12
Text=%1
Container=Container
AntiAlias=1
DynamicVariables=1
I wrote it like this intentionally, to keep the code compact, favor learning and comparison between variants and prevent laziness for others who might read this in the future. :sly:

EDIT: Added the comments for pausing the text movement.
EDIT2: Adjusted a few things as per ZXCVBOT's suggestions below.
Last edited by Yincognito on November 3rd, 2023, 9:47 am, edited 2 times in total.
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: November 1st, 2023, 5:01 pm ...
I wrote it like this intentionally, to keep the code compact, favor learning and comparison between variants and prevent laziness for others who might read this in the future. :sly:
Good work ! :Medal
User avatar
Yincognito
Rainmeter Sage
Posts: 7177
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Simple Text Marquee

Post by Yincognito »

pds wrote: November 1st, 2023, 5:19 pm Good work ! :Medal
Thanks, hopefully it'll be useful for those checking this topic. :great:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
ZXCVBOT

Re: Simple Text Marquee

Post by ZXCVBOT »

Probably a rookie question, but how do I delay this/ stop the text momentarily?
I tried !Delay in IfTrueAction, but it did not work. Is this because of the reason that IfConditionMode=1?

Note: Adding !Delay before the !SetVariable part would make the marquee behave weirdly.

Edit 2: Removed the mistake.
Edit: Yincognito, you have added : instead of ; in: https://forum.rainmeter.net/viewtopic.php?p=219114#p219108 :
Yincognito wrote: November 1st, 2023, 5:01 pm ... note that this does NOT use any variant, you'll have to use the desired variant lines yourself by simply hitting an ENTER just after : ...
Last edited by ZXCVBOT on November 2nd, 2023, 4:03 pm, edited 1 time in total.
User avatar
pds
Posts: 79
Joined: April 12th, 2014, 12:52 pm
Location: Slovakia

Re: Simple Text Marquee

Post by pds »

ZXCVBOT wrote: November 2nd, 2023, 11:59 am
Note: Adding !Delay before the !SetVariable part would make the marquee behave weirdly.

Edit: Yincognito, you have added : instead of ; in: https://forum.rainmeter.net/viewtopic.php?p=219114#p219108 :
Yincognito wrote: ↑01 Nov 2023 18:01
... note that this does NOT use any variant, you'll have to use the desired variant lines yourself by simply hitting an ENTER just after : ...
I think he spelled it right.
; Formula - Reset Pos Variant : Formula=([M_Track:W]-[Container:W]>0?TrackX+#TrackStep#:TrackX)
User avatar
Yincognito
Rainmeter Sage
Posts: 7177
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Simple Text Marquee

Post by Yincognito »

ZXCVBOT wrote: November 2nd, 2023, 11:59 am Probably a rookie question, but how do I delay this/ stop the text momentarily?
I tried !Delay in IfTrueAction, but it did not work. Is this because of the reason that IfConditionMode=1?
Not a rookie question, as it must be done carefully, considering all details. Using !Delay is fine if you want to resume movement at "reset" / "invert step" time, but the relevant measures should be paused beforehand and unpaused after the delay. See if you can do it, if not, I'll try to help.
ZXCVBOT wrote: November 2nd, 2023, 11:59 am Edit: Yincognito, you have added : instead of ; in: https://forum.rainmeter.net/viewtopic.php?p=219114#p219108 :
No, pds is right above, this was no mistake. Just a very easy way to "enable" the desired option while still having the description commented and using just 2 keys on the keyboard, Enter and Backspace (besides the arrow keys, of course).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
ZXCVBOT

Re: Simple Text Marquee

Post by ZXCVBOT »

Okay, I understood that part badly, I thought you wanted to uncomment the part and remove the unrelated text.

Also, thanks for clearing it up - how to delay and pause and unpause marquee.
I also learnt how to pause/unpause the measures - this will help me in several "corrections" and "implementations" in other skins! :bow:
User avatar
Yincognito
Rainmeter Sage
Posts: 7177
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Simple Text Marquee

Post by Yincognito »

ZXCVBOT wrote: November 2nd, 2023, 4:01 pm Okay, I understood that part badly, I thought you wanted to uncomment the part and remove the unrelated text.
It was not so much about what I wanted, anyone can do as you said. It was more about a friendly way to "toggle" between those variants and compare if desired, while still keeping the descriptions in the comments to know what the code part refers to. Once things are understood, there is no need to keep the comments / variants that aren't used, of course. I know you know that, I just mentioned it for future readers (if any).
ZXCVBOT wrote: November 2nd, 2023, 4:01 pm Also, thanks for clearing it up - how to delay and pause and unpause marquee.
I also learnt how to pause/unpause the measures - this will help me in several "corrections" and "implementations" in other skins! :bow:
Excellent, it will surely be useful going forward! Just so you know, I had been already editing the post with the code to include the things about pausing the marquee in the comments before the positional measures - but it's good that you figured it out on your own (though you can compare methods, if you want). :thumbup:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
ZXCVBOT

Re: Simple Text Marquee

Post by ZXCVBOT »

Can you just implement final-touches in your code - none are marquee related, but for beginners and yeah lazy people:
Firstly, the big box is not the container, still, its bigger than the container, also, since shrinking the box that fits the container has been shrunk, shifting the X axis of Container. Next would be my mistake, I forgot to remove the tooltiptext part in M_Artist while posting the code initially - just remove it completely. There's no harm in either, but you know, it will be better.

[M_Shape]
...
Shape=Rectangle 2,2,52,66,2 | Fill Color 0,0,0,128 | StrokeWidth 1 | Stroke Color 255,255,255,255

[Container]
...
X=1
..
H=66
...

[M_ARTIST]
TooltipText=%1

I implemented the pause code from the one you gave, and it's awesome! What's more insane is it is matching the vibe with the current AIMP skin and the timings of their marquee is almost same - :lol: