It is currently September 15th, 2019, 8:59 pm

Scrolling text not updating correctly

Help with creating, editing & fixing problems with skins
Cryden
Posts: 3
Joined: September 6th, 2019, 5:21 pm

Scrolling text not updating correctly

Cryden » September 6th, 2019, 5:30 pm

Hello, I have run into a problem with a script I'm making for a taskbar player. Whenever the song/artist updates at a length that requires scrolling, the formatting gets all messed up and it either overlaps if going from a shorter to longer or has a massive space if going from longer to shorter. I've tried everything I could think of! Please help!
Code below, thanks to raiguard for getting me started.

Code: Select all

[Rainmeter]
Update=1000
OnRefreshAction=[!CommandMeasure MeasureActionTimer "Stop 1"][!CommandMeasure MeasureActionTimer "Stop 2"][!SetVariable titleMarquee1 0][!SetVariable artistMarquee1 0][!UpdateMeasure MeasureTitleMarqueeOffset][!UpdateMeasure MeasureArtistMarqueeOffset]
AccurateText=1


; Setup ------------------------------------------------------------------------------


[Variables]
width=150
playername=Spotify
spacing=75

; Marquee settings
animationSpeed=32
marqueeWait=1500

; Dynamic variables - do not change
titleMarquee1=0
titleMarquee2=[MeasureTitleMarqueeOffset:]
artistMarquee1=0
artistMarquee2=[MeasureArtistMarqueeOffset:]

[StyleText]
FontFace=Calibri
FontColor=230,230,230
FontSize=15
FontWeight=600
X=0
Y=1R
Antialias=1
DynamicVariables=1


; Measures ---------------------------------------------------------------------------


[MeasureTitle]
Measure=NowPlaying
PlayerName=#playername#
PlayerType=Title


[MeasureArtist]
Measure=NowPlaying
PlayerName=#playername#
PlayerType=Artist


[MeasureTitleMarqueeOffset]
Measure=Calc
Formula=([MeterTitle1:W]+#spacing#)
DynamicVariables=1
IfConditionMode=1
IfCondition=([MeterTitle1:W]<#width#)
IfTrueAction=[!SetOption #CURRENTSECTION# Formula 0][!SetOption MeterTitle2 Text " "][!CommandMeasure MeasureActionTimer "Stop 1"][!SetVariable titleMarquee1 0]
IfFalseAction=[!SetOption #CURRENTSECTION# Formula ([MeterTitle1:W]+50)][!SetOption MeterTitle2 Text "%1"][!CommandMeasure MeasureActionTimer "Execute 1"]

[MeasureArtistMarqueeOffset]
Measure=Calc
Formula=([MeterArtist1:W]+#spacing#)
DynamicVariables=1
IfConditionMode=1
IfCondition=([MeterArtist1:W]<#width#)
IfTrueAction=[!SetOption #CURRENTSECTION# Formula 0][!SetOption MeterArtist2 Text " "][!CommandMeasure MeasureActionTimer "Stop 2"]
IfFalseAction=[!SetOption #CURRENTSECTION# Formula ([MeterArtist1:W]+50)][!SetOption MeterArtist2 Text "%1"][!CommandMeasure MeasureActionTimer "Execute 2"]


; Formatting Functions ---------------------------------------------------------------


[MeasureActionTimer]
Measure=Plugin
Plugin=ActionTimer

; Marquee 1
ActionList1=Repeat Move1,#animationSpeed#,[MeasureTitleMarqueeOffset:] | Wait #marqueeWait# | Reset1 | DoOver1
Reset1=[!SetVariable titleMarquee1 0][!SetVariable titleMarquee2 [MeasureTitleMarqueeOffset:]][!UpdateMeasure MeasureActionTimer][!UpdateMeter MeterTitle1][!UpdateMeter MeterTitle2][!Redraw]
Move1=[!SetVariable titleMarquee1 "(#titleMarquee1# - 1)"][!SetVariable titleMarquee2 "(#titleMarquee2# - 1)"][!UpdateMeasure MeasureActionTimer][!UpdateMeter MeterTitle1][!UpdateMeter MeterTitle2][!Redraw]
DoOver1=[!CommandMeasure MeasureActionTimer "Execute 1"]

; Marquee 2
ActionList2=Repeat Move2,#animationSpeed#,[MeasureArtistMarqueeOffset:] | Reset2 | DoOver2
Reset2=[!SetVariable artistMarquee1 0][!SetVariable artistMarquee2 [MeasureArtistMarqueeOffset:]][!UpdateMeasure MeasureActionTimer][!UpdateMeter MeterArtist1][!UpdateMeter MeterArtist2][!Redraw]
Move2=[!SetVariable artistMarquee1 "(#artistMarquee1# - 1)"][!SetVariable artistMarquee2 "(#artistMarquee2#-1)"][!UpdateMeasure MeasureActionTimer][!UpdateMeter MeterArtist1][!UpdateMeter MeterArtist2][!Redraw]
DoOver2=[!CommandMeasure MeasureActionTimer "Execute 2"]

DynamicVariables=1

[TitleContainer]
Meter=Image
SolidColor=255,255,255,255
X=0
Y=0
W=#width#
H=25

[ArtistContainer]
Meter=Image
SolidColor=255,255,255,255
X=#width#
Y=0
W=#width#
H=25


; Meters ---------------------------------------------------------------------------


[MeterTitle1]
Meter=String
MeasureName=MeasureTitle
Container=TitleContainer
MeterStyle=StyleText
X=#titleMarquee1#
Y=0
text=%1
OnChangeAction=!Refresh

[MeterTitle2]
Meter=String
MeasureName=MeasureTitle
Container=TitleContainer
MeterStyle=StyleText
X=#titleMarquee2#
Y=0
text=%1

[MeterArtist1]
Meter=String
MeasureName=MeasureArtist
Container=ArtistContainer
MeterStyle=StyleText
X=#artistMarquee1#
Y=0
text=%1

[MeterArtist2]
Meter=String
MeasureName=MeasureArtist
Container=ArtistContainer
MeterStyle=StyleText
X=#artistMarquee2#
Y=0
text=%1
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3536
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Scrolling text not updating correctly

eclectic-tech » September 7th, 2019, 12:19 am

Move OnChangeAction=[!Refresh] from [MeterTitle1] to [MeasureTitle]...

I would add IgnoreWarnings=1 to [MeasureActionTimer] to eliminate warning messages in the log.
I might add SolidColor=0,0,0,1 to your string meters to make it easier to drag for placement.
Lastly, you may want to add a few pixels to [ArtistContainer] X value to separate this info from the title; X=(#width#+4).

With those changes, the skin displays the scrolling info.
Note: The artist info can sometimes "mis-scroll" and only show part of the info, but a quick right-click skin "Refresh" corrects...

EDIT: I also added "Wait #marqueeWait#" to "ActionList2", so the Artist info pauses briefly before scrolling (same as the Title). :)
User avatar
balala
Rainmeter Sage
Posts: 8617
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Scrolling text not updating correctly

balala » September 7th, 2019, 5:44 am

eclectic-tech wrote:
September 7th, 2019, 12:19 am
Move OnChangeAction=[!Refresh] from [MeterTitle1] to [MeasureTitle]...
The truth is that OnChangeAction can't even be used on meters, just on measures. OnUpdateAction can be on both, meters and measures, because both are regularly updated, but OnChangeAction makes not too much sense on meters, because a meter has no value which might or might not change. So the initial OnChangeAction=[!Refresh] on [MeterTitle1] didn't work.
Cryden
Posts: 3
Joined: September 6th, 2019, 5:21 pm

Re: Scrolling text not updating correctly

Cryden » September 7th, 2019, 1:04 pm

Thanks for the responses! I updated the code with your suggestions and it does work better, but the base problem of overlapping/overspacing still is present. What I mean is if the title is something like 'This is a long title' and then it skips to 'This is an even longer title', the longer title will show as 'This is an even This is an even longer title', overlapping. Or going the other way from longer to shorter, it'll say 'this is a long title--------------------------this is a long title' with overspacing. Any ideas?
Also, adding [!Refresh] to the measure actually just made the text twitch, and not scroll.
Fully updated code below:

Code: Select all

[Rainmeter]
Update=1000
OnRefreshAction=[!CommandMeasure MeasureActionTimer "Stop 1"][!CommandMeasure MeasureActionTimer "Stop 2"][!SetVariable titleMarquee1 0][!SetVariable artistMarquee1 0][!UpdateMeasure MeasureTitleMarqueeOffset][!UpdateMeasure MeasureArtistMarqueeOffset]
AccurateText=1
AlwaysOnTop=2


; Setup ------------------------------------------------------------------------------


[Variables]
width=175
playername=Spotify
spacing=75
btnSize=30

; Stored Info
title=""
artist=""

; Marquee settings
animationSpeed=32
marqueeWait=1500

; Dynamic variables - do not change
titleMarquee1=0
titleMarquee2=[MeasureTitleMarqueeOffset:]
artistMarquee1=0
artistMarquee2=[MeasureArtistMarqueeOffset:]

[StyleText]
FontFace=Calibri
FontColor=230,230,230
FontSize=(#btnSize#/1.5)
X=0
Y=1R
Antialias=1
DynamicVariables=1


; Measures ---------------------------------------------------------------------------


[MeasureTitle]
Measure=NowPlaying
PlayerName=#playername#
PlayerType=Title
Substitute="":"#title#"

[MeasureArtist]
Measure=NowPlaying
PlayerName=#playername#
PlayerType=Artist
Substitute="":"#artist#"

[MeasureControls]
Measure=NowPlaying
PlayerName=#playername#
PlayerType=State
Substitute="0":"play","1":"pause","2":"play"


[MeasureTitleMarqueeOffset]
Measure=Calc
Formula=([MeterTitle1:W]+#spacing#)
DynamicVariables=1
IfConditionMode=1
IfCondition=([MeterTitle1:W]<#width#)
IfTrueAction=[!SetOption #CURRENTSECTION# Formula 0][!SetOption MeterTitle2 Text " "][!CommandMeasure MeasureActionTimer "Stop 1"][!SetVariable titleMarquee1 0][!SetVariable titleMarquee2 [MeasureArtistMarqueeOffset:]]
IfFalseAction=[!SetOption #CURRENTSECTION# Formula ([MeterTitle1:W]+50)][!SetOption MeterTitle2 Text "%1"][!CommandMeasure MeasureActionTimer "Execute 1"]
IfCondition2=([MeterTitle1:W]>0)
IfTrueAction2=[!WriteKeyValue Variables title [MeasureTitle]]

[MeasureArtistMarqueeOffset]
Measure=Calc
Formula=([MeterArtist1:W]+#spacing#)
DynamicVariables=1
IfConditionMode=1
IfCondition=([MeterArtist1:W]<#width#)
IfTrueAction=[!SetOption #CURRENTSECTION# Formula 0][!SetOption MeterArtist2 Text " "][!CommandMeasure MeasureActionTimer "Stop 2"][!SetVariable artistMarquee1 0][!SetVariable artistMarquee2 [MeasureArtistMarqueeOffset:]]
IfFalseAction=[!SetOption #CURRENTSECTION# Formula ([MeterArtist1:W]+50)][!SetOption MeterArtist2 Text "%1"][!CommandMeasure MeasureActionTimer "Execute 2"]
IfCondition2=([MeterArtist1:W]>0)
IfTrueAction2=[!WriteKeyValue Variables artist [MeasureArtist]]


; Formatting Functions ---------------------------------------------------------------


[MeasureActionTimer]
Measure=Plugin
Plugin=ActionTimer
IgnoreWarnings=1

; Marquee 1
ActionList1=Reset1 | Repeat Move1,#animationSpeed#,[MeasureTitleMarqueeOffset:] | Wait #marqueeWait# | DoOver1
Reset1=[!SetVariable titleMarquee1 0][!SetVariable titleMarquee2 [MeasureTitleMarqueeOffset:]][!UpdateMeasure MeasureActionTimer][!UpdateMeter MeterTitle1][!UpdateMeter MeterTitle2][!Redraw]
Move1=[!SetVariable titleMarquee1 "(#titleMarquee1# - 1)"][!SetVariable titleMarquee2 "(#titleMarquee2# - 1)"][!UpdateMeasure MeasureActionTimer][!UpdateMeter MeterTitle1][!UpdateMeter MeterTitle2][!Redraw]
DoOver1=[!CommandMeasure MeasureActionTimer "Execute 1"]

; Marquee 2
ActionList2=Reset2 | Repeat Move2,#animationSpeed#,[MeasureArtistMarqueeOffset:] | Wait #marqueeWait# | DoOver2
Reset2=[!SetVariable artistMarquee1 0][!SetVariable artistMarquee2 [MeasureArtistMarqueeOffset:]][!UpdateMeasure MeasureActionTimer][!UpdateMeter MeterArtist1][!UpdateMeter MeterArtist2][!Redraw]
Move2=[!SetVariable artistMarquee1 "(#artistMarquee1# - 1)"][!SetVariable artistMarquee2 "(#artistMarquee2#-1)"][!UpdateMeasure MeasureActionTimer][!UpdateMeter MeterArtist1][!UpdateMeter MeterArtist2][!Redraw]
DoOver2=[!CommandMeasure MeasureActionTimer "Execute 2"]

DynamicVariables=1

[TitleContainer]
Meter=Image
SolidColor=255,255,255,255
X=#btnSize#
Y=0
W=#width#
H=#btnSize#

[ArtistContainer]
Meter=Image
SolidColor=255,255,255,255
X=(#btnSize#*2+#width#)
Y=0
W=#width#
H=#btnSize#


; Meters ---------------------------------------------------------------------------


[MeterTitle1]
Meter=String
MeasureName=MeasureTitle
Container=TitleContainer
MeterStyle=StyleText
X=#titleMarquee1#
Y=0
Text=%1
SolidColor=0,0,0,1

[MeterTitle2]
Meter=String
MeasureName=MeasureTitle
Container=TitleContainer
MeterStyle=StyleText
X=#titleMarquee2#
Y=0
Text=%1
SolidColor=0,0,0,1

[MeterArtist1]
Meter=String
MeasureName=MeasureArtist
Container=ArtistContainer
MeterStyle=StyleText
X=#artistMarquee1#
Y=0
Text=%1
SolidColor=0,0,0,1

[MeterArtist2]
Meter=String
MeasureName=MeasureArtist
Container=ArtistContainer
MeterStyle=StyleText
X=#artistMarquee2#
Y=0
Text=%1
SolidColor=0,0,0,1


; Controls -------------------------------------------------------------------------


[PreviousButton]
Meter=IMAGE
ImageName=prev.png
X=0
Y=0
W=#btnSize#
H=#btnSize#
LeftMouseUpAction=[!CommandMeasure MeasureControls "Previous"]
AntiAlias=1

[PlayPauseButton]
Meter=IMAGE
ImageName=[MeasureControls].png
X=(#btnSize#+#width#)
Y=0
W=#btnSize#
H=#btnSize#
LeftMouseUpAction=[!CommandMeasure MeasureControls "PlayPause"][!Refresh][!Refresh]
DynamicVariables=1
AntiAlias=1

[NextButton]
Meter=IMAGE
ImageName=next.png
X=(#btnSize#*2+#width#*2)
Y=0
W=#btnSize#
H=#btnSize#
LeftMouseUpAction=[!CommandMeasure MeasureControls "Next"]
AntiAlias=1
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3536
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Scrolling text not updating correctly

eclectic-tech » September 7th, 2019, 4:53 pm

You completely removed the OnChangeAction!? ... That is probably why you are seeing the old info along with the new info.
I am not seeing that scenario. The title and artist are displayed twice, so the scroll brings the beginning of the second text to the starting position.

I don't know why you have 2 !Refresh commands in the Play/Pause button section??

All I changed is the [MeaureTitle] section by adding the OnChangeAction to refresh the entire skin when the title changes.

Code: Select all

[MeasureTitle]
Measure=NowPlaying
PlayerName=#playername#
PlayerType=Title
Substitute="":"#title#"
OnChangeAction=[!Refresh]
I tested using WinAmp player and see no issues.
scroll2.gif
Click Image to animate...
You do not have the required permissions to view the files attached to this post.
Cryden
Posts: 3
Joined: September 6th, 2019, 5:21 pm

Re: Scrolling text not updating correctly

Cryden » September 8th, 2019, 4:01 am

Crap, didn't realize I did that. Adding it back fixed it! Thanks eclectic!
I have 2 refreshes because Spotify doesn't update states correctly, so I have to force it to fully refresh by using 2. If you try with Spotify with just one, the play/pause button doesn't update.
Thanks again for the help!
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3536
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Scrolling text not updating correctly

eclectic-tech » September 8th, 2019, 4:17 am

Happy to help, glad you got it working! :great:
User avatar
balala
Rainmeter Sage
Posts: 8617
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Scrolling text not updating correctly

balala » September 8th, 2019, 2:28 pm

Although eclectic-tech offered a solution, this solution has a great disadvantage: if applied, the skin is refreshed many times, which isn't a good idea, because such refreshes are always quite destructive and should be avoided. This is why I always prefere not to refresh the skin, as long as it is possible. And in this case it is possible, so here is my solution.
First of all, take into account that the NowPlaying measures always have to have a parent - child structure. This means that one of the measures should be the parent measure and the others, which use the parent measure, would be the child measures. For instance in this case [MeasureTitle] should be the parent measure and the other two NowPlaying measures, being the child measures, should use the parent measure set as PlayerName. This means that you should keep the PlayerName=#playername# option on [MeasureTitle] and should replace it with PlayerName=[MeasureTitle] on [MeasureArtist] and [MeasureControls]:

Code: Select all

[MeasureTitle]
Measure=NowPlaying
PlayerName=#playername#
PlayerType=Title
Substitute="":"#title#"

[MeasureArtist]
Measure=NowPlaying
PlayerName=[MeasureTitle]
PlayerType=Artist
Substitute="":"#artist#"

[MeasureControls]
Measure=NowPlaying
PlayerName=[MeasureTitle]
PlayerType=State
Substitute="0":"play","1":"pause","2":"play"
Now as said, [MeasureTitle] became the parent measure, while [MeasureArtist] and [MeasureControls] are the child measures. This is the correct structure of these measures.
The next step is to add an appropriate OnChangeAction option to the [MeasureTitle] measure, which doesn't refreshes the skin whenever that title is changing. Add the following option: OnChangeAction=[!CommandMeasure MeasureActionTimer "Stop 1"][!UpdateMeter "MeterTitle1"][!UpdateMeter "MeterTitle2"][!UpdateMeasure "MeasureTitleMarqueeOffset"][!CommandMeasure MeasureActionTimer "Execute 1"].
And finally the last step is to update the [MeasureActionTimer] measure while the Move1 or Move2 options are executed. For this you have to add the appropriate bangs to these two options:

Code: Select all

[MeasureActionTimer]
...
Move1=[!SetVariable titleMarquee1 "(#titleMarquee1# - 1)"][!SetVariable titleMarquee2 "(#titleMarquee2# - 1)"][!UpdateMeasure "#CURRENTSECTION#"][!UpdateMeasure MeasureActionTimer][!UpdateMeter MeterTitle1][!UpdateMeter MeterTitle2][!Redraw]
...
Move2=[!SetVariable artistMarquee1 "(#artistMarquee1# - 1)"][!SetVariable artistMarquee2 "(#artistMarquee2#-1)"][!UpdateMeasure "#CURRENTSECTION#"][!UpdateMeasure MeasureActionTimer][!UpdateMeter MeterArtist1][!UpdateMeter MeterArtist2][!Redraw]
...
If you apply the above solution to the secondly posted code, this will avoid the continuous and undesired refresh of the skin.
Keep in mind what have been said about the structure of the NowPlaying measures: never use all measures of a code, as parent measures (as this time). This can give a lot of headache.