It is currently July 12th, 2020, 3:25 am

Dynamically changing StringAlign on a meter doesn't change the alignment when the meter has multiple lines.

Report bugs with the Rainmeter application and suggest features.
User avatar
JelleDekkers
Posts: 58
Joined: September 27th, 2017, 6:32 pm

Dynamically changing StringAlign on a meter doesn't change the alignment when the meter has multiple lines.

Post by JelleDekkers »

Hey there, fellow Rainmeterers! I think I might have found a bug in the StringAlign option.

Whenever you change the StringAlign option in a meter dinamically, either using SetOption or SetVariable + DynamicVariables, the anchor point of the string meter does change, but the actual alignment doesn't change from the initial value (which is either the initial value of the variable used or the set value for the StringAlign option of that meter).

Here's the initial setup:
Image

Now I use a custom context option to change the alignment of the string meters:
Image

The code for that context option is the following:

Code: Select all

ContextTitle4=Right align
ContextAction4=[!SetVariable TextHorizontalAlignment Right] [!UpdateMeter *] [!UpdateMeter *] [!Redraw]
The result is the following:
Image
As you can see, the anchor point changes like it should, but the actual alignment of the string meter with multiple lines doesn't change.

Is it just a bug or am I forgetting something? Before you reply, please check the code of the skin. I've attached it with this post.
You do not have the required permissions to view the files attached to this post.
Last edited by JelleDekkers on January 8th, 2020, 10:46 pm, edited 2 times in total.
User avatar
jsmorley
Developer
Posts: 21014
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Dinamically changing StringAlign on a meter doesn't change the alignment when the meter has multiple lines.

Post by jsmorley »

I think there may be a bug with this indeed. What seems to be happening is that when StringAlign is dynamically changed, that change is just ignored if the Text option, or the value of the measure bound with MeasureName on the String meter is not also changed.

And yes, The X option of the meter would need to be changed at the same time to have this work as expected, but that's not the issue here.

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeterLeft]
Meter=String
X=0
W=100
FontSize=11
FontWeight=400
FontColor=255,255,255,255
AntiAlias=1
StringAlign=Left
Text=I'm Left

[MeterCenter]
Meter=String
X=50
Y=0R
W=100
FontSize=11
FontWeight=400
FontColor=255,255,255,255
AntiAlias=1
StringAlign=Center
Text=I'm Center

[MeterRight]
Meter=String
X=100
Y=0R
W=100
FontSize=11
FontWeight=400
FontColor=255,255,255,255
AntiAlias=1
StringAlign=Right
Text=I'm Right

[MeterBox]
Meter=Image
X=0
Y=5R
W=50
H=50
SolidColor=47,47,47,255
LeftMouseUpAction=[!SetOption MeterRight StringAlign "Center"][!SetOption MeterRight X "50"][!UpdateMeter *][!Redraw]
MiddleMouseUpAction=[!SetOption MeterRight StringAlign "Center"][!SetOption MeterRight X "50"][!SetOption MeterRight Text "I've Changed"][!UpdateMeter *][!Redraw]

We will poke around in this and see what we can find.
User avatar
JelleDekkers
Posts: 58
Joined: September 27th, 2017, 6:32 pm

Re: Dinamically changing StringAlign on a meter doesn't change the alignment when the meter has multiple lines.

Post by JelleDekkers »

jsmorley wrote:
December 28th, 2019, 12:03 pm
I think there may be a bug with this indeed. What seems to be happening is that when StringAlign is dynamically changed, that change is just ignored if the Text option, or the value of the measure bound with MeasureName on the String meter is not also changed.
That does seem to be the issue here, yeah. Adding a SetOption to change the text as well seems to work fine, unless the text parameter is the same for both bangs. In that case, it seems to work the first time, but not the second time.

so this (notice the 1 and 2 to make the text parameters unique)

Code: Select all

ContextTitle3=Left align
ContextAction3=[!SetVariable TextHorizontalAlignment Left] [!SetOption Title Text "Sample text goes#*CRLF*#Here1"] [!UpdateMeter *] [!UpdateMeter *] [!Redraw]
ContextTitle4=Right align
ContextAction4=[!SetVariable TextHorizontalAlignment Right] [!SetOption Title Text "Sample text goes#*CRLF*#Here2"] [!UpdateMeter *] [!UpdateMeter *] [!Redraw]
works fine, whereas this (identical text parameters)

Code: Select all

ContextTitle3=Left align
ContextAction3=[!SetVariable TextHorizontalAlignment Left] [!SetOption Title Text "Sample text goes#*CRLF*#Here"] [!UpdateMeter *] [!UpdateMeter *] [!Redraw]
ContextTitle4=Right align
ContextAction4=[!SetVariable TextHorizontalAlignment Right] [!SetOption Title Text "Sample text goes#*CRLF*#Here"] [!UpdateMeter *] [!UpdateMeter *] [!Redraw]
does not. It only works once.

PS: The X values are accounted for using conditionals and nested variables. This is purely about the StringAlign.
User avatar
jsmorley
Developer
Posts: 21014
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Dinamically changing StringAlign on a meter doesn't change the alignment when the meter has multiple lines.

Post by jsmorley »

JelleDekkers wrote:
December 28th, 2019, 12:11 pm
That does seem to be the issue here, yeah. Adding a SetOption to change the text as well seems to work fine, unless the text parameter is the same for both bangs. In that case, it seems to work the first time, but not the second time.

so this (notice the 1 and 2 to make the text parameters unique)

Code: Select all

ContextTitle3=Left align
ContextAction3=[!SetVariable TextHorizontalAlignment Left] [!SetOption Title Text "Sample text goes#*CRLF*#Here1"] [!UpdateMeter *] [!UpdateMeter *] [!Redraw]
ContextTitle4=Right align
ContextAction4=[!SetVariable TextHorizontalAlignment Right] [!SetOption Title Text "Sample text goes#*CRLF*#Here2"] [!UpdateMeter *] [!UpdateMeter *] [!Redraw]
works fine, whereas this (identical text parameters)

Code: Select all

ContextTitle3=Left align
ContextAction3=[!SetVariable TextHorizontalAlignment Left] [!SetOption Title Text "Sample text goes#*CRLF*#Here"] [!UpdateMeter *] [!UpdateMeter *] [!Redraw]
ContextTitle4=Right align
ContextAction4=[!SetVariable TextHorizontalAlignment Right] [!SetOption Title Text "Sample text goes#*CRLF*#Here"] [!UpdateMeter *] [!UpdateMeter *] [!Redraw]
does not. It only works once.
Right. The Text Option / value has to actually "change" for it to work. This is unfortunate behavior that we will look into.
User avatar
jsmorley
Developer
Posts: 21014
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Dinamically changing StringAlign on a meter doesn't change the alignment when the meter has multiple lines.

Post by jsmorley »

The only temporary work-around I have found is ugly, but it works..

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeterLeft]
Meter=String
X=0
W=100
FontSize=11
FontWeight=400
FontColor=255,255,255,255
AntiAlias=1
StringAlign=Left
Text=I'm Left

[MeterCenter]
Meter=String
X=50
Y=0R
W=100
FontSize=11
FontWeight=400
FontColor=255,255,255,255
AntiAlias=1
StringAlign=Center
Text=I'm Center

[MeterRight]
Meter=String
X=100
Y=0R
W=100
FontSize=11
FontWeight=400
FontColor=255,255,255,255
AntiAlias=1
StringAlign=Right
Text=I'm Right

[MeterBox]
Meter=Image
X=0
Y=5R
W=50
H=50
SolidColor=47,47,47,255
LeftMouseUpAction=[!SetOption MeterRight StringAlign "Center"][!SetOption MeterRight Text ""][!UpdateMeter *][!Redraw][!SetOption MeterRight Text "I'm Right"][!SetOption MeterRight X "50"][!UpdateMeter *][!Redraw]
So you have to change the Text, poke the meter, change the Text back, poke the meter...
User avatar
JelleDekkers
Posts: 58
Joined: September 27th, 2017, 6:32 pm

Re: Dinamically changing StringAlign on a meter doesn't change the alignment when the meter has multiple lines.

Post by JelleDekkers »

jsmorley wrote:
December 28th, 2019, 12:20 pm
The only temporary work-around I have found is ugly, but it works..

<code>

So you have to change the Text, poke the meter, change the Text back, poke the meter...
Seems it doesn't work without a !Redraw in between either. Weird bug. I guess I'll just stick with refreshing my Album Art Generator for now, but I found this issue trying to make it without !Refresh bangs.
User avatar
jsmorley
Developer
Posts: 21014
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Dynamically changing StringAlign on a meter doesn't change the alignment when the meter has multiple lines.

Post by jsmorley »

This has been corrected and will be in the next beta soon.