It is currently March 28th, 2024, 1:01 pm

Trying to show / hide base on content

Get help with creating, editing & fixing problems with skins
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Trying to show / hide base on content

Post by jsmorley »

nodiaque wrote: September 16th, 2019, 2:28 pm Hello,

I tried some logic like that in the past and it didn't worked, but I just tried with yours. Now, it shows 2 empty line
Show me the values in About / Skins.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Trying to show / hide base on content

Post by jsmorley »

I'm seriously betting that the string values for these registry entries are not "numeric" when they are filled. So the number values are just always zero.

If so, something like this will work:

Code: Select all

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

[MeasureProfile]
Measure=String
String=Some String

[MeasureRole]
Measure=String
String=Some Other String

[MeasureProfileRole]
Measure=String
String=[MeasureProfile];[MeasureRole]
IfMatch=.+;
IfMatchAction=[!ShowMeterGroup "Profile"][!HideMeterGroup "Role"]
IfMatch2=^;.+
IfMatchAction2=[!ShowMeterGroup "Role"][!HideMeterGroup "Profile"]
IfMatch3=^;$
IfMatchAction3=[!HideMeterGroup "Profile"][!HideMeterGroup "Role"]
DynamicVariables=1

[MeterProfile]
Meter=String
Group=Profile
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Profile

[MeterRole]
Meter=String
Group=Role
Y=0R
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Role
Note that I'm concatenating those two string values together and separating them with a static ; character, so I can test what is on the left and right (or not) of the ; character.

IfMatch cannot compare the string value of two separate measures at once, as it only acts on the string value of the measure it is actually on, unlike IfCondition, with is explicitly "told" which measure value(s) to act on. That's why I create a third measure to concatenate the string values together.

The test(s) are more or less the same. I'm testing the "states" of:

MeasureProfile has a text value
MeasureProfile does not have a text value and MeasureRole has a text value
Both MeasureProfile and MeasureRole do not have text values

Once again, one and only one of these can be true.

1.jpg
nodiaque
Posts: 9
Joined: September 16th, 2019, 11:04 am

Re: Trying to show / hide base on content

Post by nodiaque »

It is string since it's from the registry. 0 is the current value for the MeasureProfile while MeasureRole have a value. So it should show only the MeterRole with it's value. I tried match in the past, didn't work.
nodiaque
Posts: 9
Joined: September 16th, 2019, 11:04 am

Re: Trying to show / hide base on content

Post by nodiaque »

Just tried again with the "new" method. Now, it show 0 and an empty string. But I understand why the empty line, it's because this is not there anymore:

[!SetOption meterLabelProfile Y 0r]

Which lower the line.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Trying to show / hide base on content

Post by jsmorley »

So it's all working as you want now?
nodiaque
Posts: 9
Joined: September 16th, 2019, 11:04 am

Re: Trying to show / hide base on content

Post by nodiaque »

With my update, I get now 0 as showed because the Registry Value exist, but is empty. This return 0. They are of type registry

Code: Select all

[MeasureProfileRole]
Measure=String
String=[MeasureProfile];[MeasureRole]
IfMatch=.+;
IfMatchAction=[!ShowMeterGroup "Profile"][!HideMeterGroup "Role"][!SetOption meterLabelProfile Y 25r][!SetOption meterLabelRole Y 0r]
IfMatch2=^;.+
IfMatchAction2=[!ShowMeterGroup "Role"][!HideMeterGroup "Profile"][!SetOption meterLabelProfile Y 0r][!SetOption meterLabelRole Y 25r]
IfMatch3=^;$
IfMatchAction3=[!HideMeterGroup "Profile"][!HideMeterGroup "Role"][!SetOption meterLabelProfile Y 0r][!SetOption meterLabelRole Y 0r]
Image
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Trying to show / hide base on content

Post by jsmorley »

nodiaque wrote: September 16th, 2019, 2:57 pm With my update, I get now 0 as showed because the Registry Value exist, but is empty. This return 0. They are of type registry

Code: Select all

[MeasureProfileRole]
Measure=String
String=[MeasureProfile];[MeasureRole]
IfMatch=.+;
IfMatchAction=[!ShowMeterGroup "Profile"][!HideMeterGroup "Role"][!SetOption meterLabelProfile Y 25r][!SetOption meterLabelRole Y 0r]
IfMatch2=^;.+
IfMatchAction2=[!ShowMeterGroup "Role"][!HideMeterGroup "Profile"][!SetOption meterLabelProfile Y 0r][!SetOption meterLabelRole Y 25r]
IfMatch3=^;$
IfMatchAction3=[!HideMeterGroup "Profile"][!HideMeterGroup "Role"][!SetOption meterLabelProfile Y 0r][!SetOption meterLabelRole Y 0r]
Image
So is that "yes" or "no" to my question?
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Trying to show / hide base on content

Post by jsmorley »

You need DynamicVariables=1 on the string measure with the IfMatch(s) on it.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Trying to show / hide base on content

Post by jsmorley »

I think I see what is happening.

If the Registry measure does not find the entry at all, it returns "0" as both the number and string values. Our IfMatch(s) are looking for an empty string, and not a value of zero, so this is giving you trouble.

Try this:

Code: Select all

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

[MeasureProfile]
Measure=String
String=Some String

[MeasureRole]
Measure=String
String=Some Other String

[MeasureProfileRole]
Measure=String
String=[MeasureProfile];[MeasureRole]
RegExpSubstitute=1
Substitute="^0;0$":";","(.+);0$":"\1;","^0;(.+)":";\1"
IfMatch=.+;
IfMatchAction=[!ShowMeterGroup "Profile"][!HideMeterGroup "Role"]
IfMatch2=^;.+
IfMatchAction2=[!ShowMeterGroup "Role"][!HideMeterGroup "Profile"]
IfMatch3=^;$
IfMatchAction3=[!HideMeterGroup "Profile"][!HideMeterGroup "Role"]
DynamicVariables=1

[MeterProfile]
Meter=String
Group=Profile
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Profile

[MeterRole]
Meter=String
Group=Role
Y=0R
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Role
That will replace any "0" only values in either measure with an empty string, allowing our IfMatch(s) to work as expected.
nodiaque
Posts: 9
Joined: September 16th, 2019, 11:04 am

Re: Trying to show / hide base on content

Post by nodiaque »

Oh wow, that worked! Was trickier then I though, I'm not very good with reg expr. Thanks a lot! I bet you could optimize my overall skin with your skill!
Post Reply