It is currently April 27th, 2024, 11:21 am

Align static text based on dynamic text

Get help with creating, editing & fixing problems with skins
paul1965
Posts: 11
Joined: March 7th, 2024, 4:44 pm

Align static text based on dynamic text

Post by paul1965 »

The last change I'm making to the awesome Weather Time Bar is to add some static text that will display next to the current condition. However, I'm having a hard time getting the spacing to react dynamically so there's no large gaps or overlapping of text. I've replaced the location value with static text "Right now, it's". Then on the next line is the current condition, with static text "and", then the next line is the current temp. "and" is the text that needs to be spaced dynamically to the right of whatever the current condition is. I thought I had it working using Padding, but as soon as the skin updated from "Sunny" to "Fair", the spacing failed and resulted in a large gap. What is the best way to handle this scenario? Here's the code I've got so far:

Code: Select all

[MeterLocation]
Meter=String
MeasureName=MeasureCity
MeasureName2=MeasureAdminDistrictCode
X=(#size#*260)
Y=(#size#*50)
W=(#size#*300)
H=(#size#*50)
FontColor=#FontColor#
FontSize=(#size#*12)
StringStyle=normal
StringEffect=SHADOW
FontFace=#FontFace#
StringAlign=Left
FontEffectColor=0,0,0,50
AntiAlias=1
ClipString=1
Text=Right now, it's  


[MeterTempText]
Meter=String
MeasureName=MeasureTempText
X=(#size#*290)
Y=(#size#*82)
W=(#size#*120)
H=(#size#*40)
;FontColor=[#TempColor[&MeasureColor#TempFormat#]]
SolidColor=125,125,125,0
FontColor=#FontColor#
StringStyle=normal
StringEffect=SHADOW
FontFace=#FontFace#
StringAlign=LeftCenter
;FontEffectColor=168,168,168
FontEffectColor=0,0,0,50
AntiAlias=1
ClipString=1
FontSize=(#size#*12)
Padding=20,0,0,0
Text=and
;DynamicVariables=1

[MeterTemp]
Meter=String
MeasureName=MeasureTemp
X=(#size#*260)
Y=(#size#*109)
W=(#size#*120)
H=(#size#*40)
;FontColor=[#TempColor[&MeasureColor#TempFormat#]]
FontColor=#FontColor#
StringStyle=normal
StringEffect=SHADOW
FontFace=#FontFace#
StringAlign=LeftCenter
;FontEffectColor=168,168,168
FontEffectColor=0,0,0,50
AntiAlias=1
ClipString=1
FontSize=(#size#*25)
Text= %1°
DynamicVariables=1
User avatar
xenium
Posts: 868
Joined: January 4th, 2018, 9:52 pm

Re: Align static text based on dynamic text

Post by xenium »

paul1965 wrote: March 10th, 2024, 9:18 pm The last change I'm making to the awesome Weather Time Bar is to add some static text that will display next to the current condition. However, I'm having a hard time getting the spacing to react dynamically so there's no large gaps or overlapping of text. I've replaced the location value with static text "Right now, it's". Then on the next line is the current condition, with static text "and", then the next line is the current temp. "and" is the text that needs to be spaced dynamically to the right of whatever the current condition is. I thought I had it working using Padding, but as soon as the skin updated from "Sunny" to "Fair", the spacing failed and resulted in a large gap. What is the best way to handle this scenario? Here's the code I've got so far:

Code: Select all

[MeterLocation]
Meter=String
MeasureName=MeasureCity
MeasureName2=MeasureAdminDistrictCode
X=(#size#*260)
Y=(#size#*50)
W=(#size#*300)
H=(#size#*50)
FontColor=#FontColor#
FontSize=(#size#*12)
StringStyle=normal
StringEffect=SHADOW
FontFace=#FontFace#
StringAlign=Left
FontEffectColor=0,0,0,50
AntiAlias=1
ClipString=1
Text=Right now, it's  


[MeterTempText]
Meter=String
MeasureName=MeasureTempText
X=(#size#*290)
Y=(#size#*82)
W=(#size#*120)
H=(#size#*40)
;FontColor=[#TempColor[&MeasureColor#TempFormat#]]
SolidColor=125,125,125,0
FontColor=#FontColor#
StringStyle=normal
StringEffect=SHADOW
FontFace=#FontFace#
StringAlign=LeftCenter
;FontEffectColor=168,168,168
FontEffectColor=0,0,0,50
AntiAlias=1
ClipString=1
FontSize=(#size#*12)
Padding=20,0,0,0
Text=and
;DynamicVariables=1

[MeterTemp]
Meter=String
MeasureName=MeasureTemp
X=(#size#*260)
Y=(#size#*109)
W=(#size#*120)
H=(#size#*40)
;FontColor=[#TempColor[&MeasureColor#TempFormat#]]
FontColor=#FontColor#
StringStyle=normal
StringEffect=SHADOW
FontFace=#FontFace#
StringAlign=LeftCenter
;FontEffectColor=168,168,168
FontEffectColor=0,0,0,50
AntiAlias=1
ClipString=1
FontSize=(#size#*25)
Text= %1°
DynamicVariables=1
To display text on separate lines use #CRLF#
https://docs.rainmeter.net/manual/variables/built-in-variables/#CRLF
Replace in your code [MeterLocation], [MeterTempText] and [MeterTemp] with the code below:

Code: Select all

[MeterDisplayWeatherInfo]
Meter=String
MeasureName=MeasureCondition
MeasureName2=MeasureTemp
X=(#size#*260)
Y=(#size#*50)
W=(#size#*300)
H=(#size#*150)
FontColor=#FontColor#
FontSize=(#size#*12)
StringStyle=normal
StringEffect=SHADOW
FontFace=#FontFace#
StringAlign=left
FontEffectColor=0,0,0,50
AntiAlias=1
ClipString=1
Text=Right now, it's#CRLF#%1 and#CRLF#%2°
paul1965
Posts: 11
Joined: March 7th, 2024, 4:44 pm

Re: Align static text based on dynamic text

Post by paul1965 »

Thanks! That works great, it's simpler and much cleaner. But with that code, I can't set a separate font for the temp (to 25) like I have for the clock. However, this looks like it work, I'll just keep an eye on it as the conditions update through-out the day. Thanks again xenium, great work!

Code: Select all

[MeterDisplayWeatherInfo]
Meter=String
MeasureName=MeasureCondition
MeasureName2=MeasureTemp
X=(#size#*260)
Y=(#size#*50)
W=(#size#*300)
H=(#size#*150)
FontColor=#FontColor#
FontSize=(#size#*12)
StringStyle=normal
StringEffect=SHADOW
FontFace=#FontFace#
StringAlign=left
FontEffectColor=0,0,0,50
AntiAlias=1
ClipString=1
Text=Right now, it's#CRLF#%1 and

[MeterTemp]
Meter=String
MeasureName=MeasureTemp
X=(#size#*260)
Y=(#size#*109)
W=(#size#*120)
H=(#size#*40)
FontColor=[#TempColor[&MeasureColor#TempFormat#]]
FontColor=#FontColor#
StringStyle=normal
StringEffect=SHADOW
FontFace=#FontFace#
StringAlign=LeftCenter
FontEffectColor=168,168,168
FontEffectColor=0,0,0,50
AntiAlias=1
ClipString=1
FontSize=(#size#*25)
Text= %1°
User avatar
xenium
Posts: 868
Joined: January 4th, 2018, 9:52 pm

Re: Align static text based on dynamic text

Post by xenium »

paul1965 wrote: March 11th, 2024, 11:04 am But with that code, I can't set a separate font for the temp (to 25) like I have for the clock.
For this, the Inline option is used:
https://docs.rainmeter.net/manual/meters/string/inline/
Adding the Inline option, the code will look like this

Code: Select all

[MeterDisplayWeatherInfo]
Meter=String
MeasureName=MeasureCondition
MeasureName2=MeasureTemp
X=(#size#*260)
Y=(#size#*50)
W=(#size#*300)
H=(#size#*150)
FontColor=#FontColor#
FontSize=(#size#*12)
StringStyle=normal
StringEffect=SHADOW
FontFace=#FontFace#
StringAlign=left
FontEffectColor=0,0,0,50
AntiAlias=1
ClipString=1
Text=Right now, it's#CRLF#%1 and#CRLF#%2°
InlineSetting=Size | (#size#*25)
InlinePattern=[MeasureTemp:0]°
DynamicVariables=1
paul1965
Posts: 11
Joined: March 7th, 2024, 4:44 pm

Re: Align static text based on dynamic text

Post by paul1965 »

Oh, perfect. Thanks again!