It is currently March 28th, 2024, 12:00 pm

How to center variable width String Meter?

Tips and Tricks from the Rainmeter Community
Post Reply
NewStorm
Posts: 4
Joined: February 13th, 2023, 2:06 pm

How to center variable width String Meter?

Post by NewStorm »

Okay I'm super new in this, so sorry if this is a stupid/badly explained question 🙈
So I've got a String Meter - it's text input is variable (i.e. changes automatically from, say, 40 to 60 characters every 5min), meaning that the length of the string changes, too.
What I want is that "X" coordinate is always centered automatically (in regards to other meters), whenever string's length changes?ALL WHILE TEXT REMAINS ALIGNED TO THE LEFT - i.e. if I do "StringAlign=Center", all of the string text gets centred. I assume this would require to put string inside a shape that is always centered while the string inside remains aligned to the left. But then the question is how to adjust the shape's width and/or height automatically in order to match that of the string inside? Something like this, hopefully it makes sense 😭:
text.jpg
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: How to center variable width String Meter?

Post by ikarus1969 »

NewStorm wrote: February 20th, 2023, 7:01 pm Okay I'm super new in this, so sorry if this is a stupid/badly explained question 🙈
So I've got a String Meter - it's text input is variable (i.e. changes automatically from, say, 40 to 60 characters every 5min), meaning that the length of the string changes, too.
What I want is that "X" coordinate is always centered automatically (in regards to other meters), whenever string's length changes?ALL WHILE TEXT REMAINS ALIGNED TO THE LEFT - i.e. if I do "StringAlign=Center", all of the string text gets centred. I assume this would require to put string inside a shape that is always centered while the string inside remains aligned to the left. But then the question is how to adjust the shape's width and/or height automatically in order to match that of the string inside? Something like this, hopefully it makes sense 😭:
text.jpg
Assuming 500 is the position for centering the left-aligned text you have to code on the text-meter a x-position like that:
X=(500 - 0.5 * [[#CURRENTSECTION]:W])

edit

Code: Select all

[Meter_To_Center_Left_Aligned]
Meter=STRING
Text=#VARIABLE_WITH_CONTENT#
X=(500 - 0.5 * [[#CURRENTSECTION]:W])
Y=10
StringAlign=LEFT
AntiAlias=1
DynamicVariables=1
NewStorm
Posts: 4
Joined: February 13th, 2023, 2:06 pm

Re: How to center variable width String Meter?

Post by NewStorm »

It worked! Thank you!!
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: How to center variable width String Meter?

Post by ikarus1969 »

NewStorm wrote: February 21st, 2023, 7:42 am It worked! Thank you!!
You're welcome!
Post Reply