It is currently April 19th, 2024, 10:08 pm

Trying to show / hide base on content

Get help with creating, editing & fixing problems with skins
nodiaque
Posts: 9
Joined: September 16th, 2019, 11:04 am

Trying to show / hide base on content

Post by nodiaque »

Hello,

I have a little skin that I'm trying to dynamically show or hide depending on if there's a value. Right now, I manage to show both or none of them, but I want to show the first one if there's value. If not, hide it and show the other one if there's a value for it. It's based on a registry value. The key can exist but empty, not exist or exist with value.

Code: Select all

[MeasureProfile]
Measure=Registry
RegHKey=HKEY_LOCAL_MACHINE
RegKey=Software\ASDF\OSD
RegValue=Profile
UpdateDivider=-1
IfCondition=([MeasureProfile] = 0)
IfTrueAction=[!SetOption meterLabelProfile Y 0r][!SetOptionGroup "Profile" Hidden 1]
IfFalseAction=[!SetOption meterLabelProfile Y 25r][!SetOptionGroup "Profile" Hidden 0]
DynamicVariables=1

[MeasureRole]
Measure=Registry
RegHKey=HKEY_LOCAL_MACHINE
RegKey=Software\ASDF\OSD
RegValue=Role
UpdateDivider=-1
IfCondition=([MeasureProfile] <> 0)
IfTrueAction=[!SetOption meterLabelRole Y 0r][!SetOptionGroup "Role" Hidden 1]
IfCondition2=([MeasureRole] = 0)
IfFalseAction=[!SetOption meterLabelRole Y 25r][!SetOptionGroup "Role" Hidden 0]
DynamicVariables=1
This only work on hidding it if one of them is empty, but not on hidding the second one if the first one have value or showing only the second if the first one have value and first is empty.

Thank you
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Trying to show / hide base on content

Post by jsmorley »

Try adding DynamicVariables=1 to each of the measures.
nodiaque
Posts: 9
Joined: September 16th, 2019, 11:04 am

Re: Trying to show / hide base on content

Post by nodiaque »

It's already there if you look at the code, but thanks ;)
User avatar
jsmorley
Developer
Posts: 22629
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, 11:21 am It's already there if you look at the code, but thanks ;)
Argh. Sorry, my bad.

Gimmie a minute to look at the logic of this.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Trying to show / hide base on content

Post by jsmorley »

Can you clarify a bit what behavior you are looking for?

I'm not sure I entirely follow these:
I want to show the first one if there's value. If not, hide it and show the other one if there's a value for it.

This only work on hiding it if one of them is empty, but not on hiding the second one if the first one have value or showing only the second if the first one have value and first is empty.
Remember that IfCondition / IfMatch tests are either "true" or "false". They are all evaluated, and there is no "if / then / elseif / else" construct. You need to be careful that the IfFalseAction of one doesn't conflict with or override the IfTrueAction of another.
nodiaque
Posts: 9
Joined: September 16th, 2019, 11:04 am

Re: Trying to show / hide base on content

Post by nodiaque »

The iftrue iffalse was a test, in the end it did the samething that I achieved from another way.

What I want is I have 2 meter, MeasureProfile and MeasureRole. Both of them read 2 different registry key value. This key can exist or not, and can be empty or not. When it's empty, it return 0 from my test.

Now, I want MeasureProfile to show if there's a value and I want to MeasureRole to show only if it has a value and MeasureProfile is hidden (in short, it's looking for a backup registry value in case the first one is not there. If there'S a way to do it with only one measure, I can use that too).
User avatar
jsmorley
Developer
Posts: 22629
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, 11:42 am The iftrue iffalse was a test, in the end it did the samething that I achieved from another way.

What I want is I have 2 meter, MeasureProfile and MeasureRole. Both of them read 2 different registry key value. This key can exist or not, and can be empty or not. When it's empty, it return 0 from my test.

Now, I want MeasureProfile to show if there's a value and I want to MeasureRole to show only if it has a value and MeasureProfile is hidden (in short, it's looking for a backup registry value in case the first one is not there. If there'S a way to do it with only one measure, I can use that too).
So to be clear, you have two METERS, presumably called MeterProfile and MeterRole?
nodiaque
Posts: 9
Joined: September 16th, 2019, 11:04 am

Re: Trying to show / hide base on content

Post by nodiaque »

Yup,

Code: Select all

[meterProfile]
Meter=String
Group=Profile
MeasureName=MeasureProfile
MeterStyle=styleLeftText
X=10
Y=25r
Text=%1
Hidden=0

[meterRole]
Meter=String
Group=Role
MeasureName=MeasureRole
MeterStyle=styleLeftText
X=10
Y=25r
Text=%1
Hidden=0
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Trying to show / hide base on content

Post by jsmorley »

Wouldn't this logic work?

Code: Select all

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

;Now, I want MeasureProfile to show if there's a value and I want to MeasureRole to show only if it has a value and MeasureProfile is hidden (in short, it's looking for a backup registry value in case the first one is not there. If there'S a way to do it with only one measure, I can use that too).

[MeasureProfile]
Measure=String
String=0

[MeasureRole]
Measure=String
String=1
IfCondition=MeasureProfile > 0
IfTrueAction=[!ShowMeterGroup "Profile"][!HideMeterGroup "Role"]
IfCondition2=(MeasureProfile = 0 ) && (MeasureRole > 0)
IfTrueAction2=[!ShowMeterGroup "Role"][!HideMeterGroup "Profile"]
IfCondition3=(MeasureProfile = 0 ) && (MeasureRole = 0)
IfTrueAction3=[!HideMeterGroup "Profile"][!HideMeterGroup "Role"]

[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
You will find that using IfFalseAction is generally going to cause logic complexity when you have a set of conditions that can have more than two "states". In this case you have three:

MeasureProfile is true
MeasureProfile is false and MeasureRole is true
Both MeasureProfile and MeasureRole are false

So the simplest logic is to have three "positive" tests for those three conditions. One and only one of those three "states" must be true. There is no way that all three can be false, and there is no way more than one can be true.



This assumes that both MeasureProfile and MeasureRole return numeric string values not equal to 0 if they are populated. If they return a textual string value and a number value of 0, then we would need to use IfMatch instead of IfCondition, (IfCondition ONLY acts on the number value of a measure) and the logic will be very different based on the behavior of IfMatch vs. IfCondition. The easiest way to know is to use About/Skins to look at the number and string values being returned:


1.jpg
You do not have the required permissions to view the files attached to this post.
nodiaque
Posts: 9
Joined: September 16th, 2019, 11:04 am

Re: Trying to show / hide base on content

Post by nodiaque »

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