It is currently April 19th, 2024, 12:28 am

Can I use a style as a template for another style?

Get help with creating, editing & fixing problems with skins
jn_meter
Posts: 136
Joined: December 27th, 2016, 12:04 pm

Can I use a style as a template for another style?

Post by jn_meter »

Dear all

I had some 'sections' that were styles, such that those sections duplicated each others lines:

Code: Select all

[style_vpn_fail]
FontColor=#col_red#
ToolTipIcon="Warning"
ToolTipText="Failed to curl (as reported by Lua script)."
ToolTipType=0
AntiAlias=1
FontSize=#font_size_smaller#
H=27
SolidColor=#col_transparent#
W=45
X=56r
Y=#y_pos#

[style_vpn_off]
FontColor=#col_grey#
ToolTipIcon="Warning"
ToolTipText="VPN is DISABLED."
ToolTipType=0
AntiAlias=1
FontSize=#font_size_smaller#
H=27
SolidColor=#col_transparent#
W=45
X=56r
Y=#y_pos#
I wanted to replace that code with the following - but the replacement does not work.

Code: Select all

[style_vpn]
AntiAlias=1
FontSize=#font_size_smaller#
H=27
SolidColor=#col_transparent#
W=45
X=56r
Y=#y_pos#

[style_vpn_fail]
FontColor=#col_red#
ToolTipIcon="Warning"
ToolTipText="Failed to curl (as reported by Lua script)."
ToolTipType=0
MeterStyle=style_vpn

[style_vpn_off]
FontColor=#col_grey#
ToolTipIcon="Warning"
ToolTipText="VPN is DISABLED."
ToolTipType=0
MeterStyle=style_vpn
The reason the replacement fails is that I am using MeterStyle in something that is not a meter. :Whistle But you get the idea. Can I implement that idea? If so, how? Thanks.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2603
Joined: March 23rd, 2015, 5:26 pm

Re: Can I use a style as a template for another style?

Post by SilverAzide »

jn_meter wrote: October 6th, 2022, 11:44 pm The reason the replacement fails is that I am using MeterStyle in something that is not a meter. :Whistle But you get the idea. Can I implement that idea? If so, how? Thanks.
No, unfortunately not. See the second bullet item in the MeterStyle docs. But you might be in luck anyway... did you know you can apply multiple styles to a meter? The manual chapter shows how to do this in the example. Styles can in effect be unioned together, if you are familiar with the concept of unions.

Here's a super simple example:

Code: Select all

[StyleBoldText]
FontWeight=700

[StyleRedText]
FontColor=255,0,0

[MeterText]
Meter=String
MeterStyle=StyleBoldText | StyleRedText
Text="This text is bold and red."
So all you need to do is adjust your styles slightly and then apply two or more styles to a single meter, which would have the net effect of being pretty much exactly what you are looking for.
Gadgets Wiki GitHub More Gadgets...
jn_meter
Posts: 136
Joined: December 27th, 2016, 12:04 pm

Re: Can I use a style as a template for another style?

Post by jn_meter »

SilverAzide - thank you! So I need a style definition that is, and that I use, as follows.

Code: Select all

[style_vpn_base]
; To be used in this sort of way, in the relevant meters (or in relevant bangs or lua scripts):
; MeterStyle=style_vpn_base | style_vpn_<particularStyle>

AntiAlias=1
FontSize=#font_size_smaller#
H=27
SolidColor=#col_transparent#
W=45
X=56r
Y=#y_pos#
And . . it works! Marvellous!