It is currently March 28th, 2024, 7:53 pm

How to remove key=value from Meter (not blank it out)?

Get help with creating, editing & fixing problems with skins
MattNY177
Posts: 28
Joined: December 3rd, 2018, 1:15 am

How to remove key=value from Meter (not blank it out)?

Post by MattNY177 »

I have a custom skin that has a number of multi-level hideable sections/groups. I am using Meter Styles to track which groups are hidden, and using WriteKeyValue to toggle the Hidden attribute for each style. The issue arises when the child Meter(s) have "Hidden=0" but the parent(s) have "Hidden=1". In this case, the child Meter(s) key=value takes priority and so it remains visible even if the parent group is hidden.

For example:
  • The "Folders" parent group has two children: "Photos" and "Videos".
  • The "Photos" child group has two children: "Portait" and "Landscape".
  • The "Portrait" grandchild group has 10 meters that contain "MeterStyle = Style_Portrait | Style_Photos | Style_Folders"
To hide the "Portrait" Meters but keep everything else visible, the Meter Style attributes would be defined like this:

Code: Select all

[Style_Portrait]
Hidden=1

[Style_Photos]
Hidden=0

[Style_Folders]
Hidden=0
The problem is that the Style_Folders key/value always takes priority.
If we reverse the order of the MeterStyles, the opposite problem occurs (child group stays visible even if parent is hidden).
Since Hidden="" is the same as Hidden=0, blanking the key/value does not solve the problem.

From what I can tell, the only solution is to completely remove the "Hidden" key/value line from the parent(s) so the next MeterStyle will take effect instead of being overwritten by the parent Style. The desired outcome would be:

Code: Select all

[Style_Portrait]
Hidden=1

[Style_Photos]

[Style_Folders]
What is the best way to accomplish this?
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5382
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: How to remove key=value from Meter (not blank it out)?

Post by eclectic-tech »

You can not completely remove a keyword=option line; you can only change the option value.

I don't think MeterStyles is the best way to approach this; you should take a look at Groups to control what is displayed.

If you are using actual folders, FileView may be a better solution.

In order to help any further, we would need to see your code, sample folder structure, or more.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to remove key=value from Meter (not blank it out)?

Post by jsmorley »

eclectic-tech wrote: December 3rd, 2018, 2:54 am You can not completely remove a keyword=option line; you can only change the option value.
I would note that using !SetOption to dynamically set any option value to "" effectively removes the option, allowing it to to fall back to any default value it might have, or be controlled by an option in a MeterStyle. This has nothing to do with !WriteKeyValue of course, where you in fact cannot ever "remove" an option.

No idea if it applies here, since I don't understand the issue really, but you could do something clever with !WriteKeyValue where you write to a .inc file that simply has variables and a measure in it like:

[Variables]
1State=1
2State=""
3State=1
4State=""

[SetHidden]
Measure=Calc
UpdateDivider=-1
OnUpdateAction=[!SetOption MeterOne Hidden "#1State#"][!SetOption MeterTwo Hidden "#2State#"][!SetOption MeterThree Hidden "#3State#"][!SetOption MeterFour Hidden "#4State#"]

Then you just use !WriteKeyValue to change the variables in that .inc file, and refresh the skin.

With this approach, you can use the value of "", which has a different meaning in the context of !SetOption than it does when just set as the option value. FontSize="" will in fact fall back to any default value for the meter, but will not fall back to a MeterStyle, as it isn't the same as "not existing". !SetOption with "" in fact "removes" the option.
MattNY177
Posts: 28
Joined: December 3rd, 2018, 1:15 am

Re: How to remove key=value from Meter (not blank it out)?

Post by MattNY177 »

Thank you both for the replies, I will try the proposed solution and report back when I have tested it out.

Just out of curiosity, how difficult would it be to add something like !RemoveKeyValue in a future version? It just seems like that would be the simplest solution even if the suggested workaround does the same result.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to remove key=value from Meter (not blank it out)?

Post by jsmorley »

In order to deal with the "quotes" on things you might want something like:

Test.ini:

Code: Select all

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

[Variables]
@Include=#CURRENTPATH#Test.inc

[Style]
Hidden=1

[MeterOne]
Meter=String
MeterStyle=Style
FontSize=13
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=String One

[MeterTwo]
Meter=String
MeterStyle=Style
Y=5R
FontSize=13
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=String Two

[MeterThree]
Meter=String
MeterStyle=Style
Y=5R
FontSize=13
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=String Three

[MeterFour]
Meter=String
MeterStyle=Style
Y=5R
FontSize=13
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=String Four
Test.inc:

Code: Select all

[Variables]
1State=1
2State=[\34][\34]
3State=1
4State=[\34][\34]
 
[SetHidden]
Measure=Calc
UpdateDivider=-1
OnUpdateAction=[!SetOption MeterOne Hidden "#1State#"][!SetOption MeterTwo Hidden "#2State#"][!SetOption MeterThree Hidden "#3State#"][!SetOption MeterFour Hidden "#4State#"]
When you !WriteKeyValue to the .inc file use !WriteKeyValue Variables 1State "[\*34*][\*34*]" "#CURRENTPATH#Test.inc", so the Inline Character Reference variables are written as literals, and not resolved to "" in the bang. Turning into a bit of a Rube Goldberg...
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to remove key=value from Meter (not blank it out)?

Post by jsmorley »

MattNY177 wrote: December 3rd, 2018, 3:25 am Thank you both for the replies, I will try the proposed solution and report back when I have tested it out.

Just out of curiosity, how difficult would it be to add something like !RemoveKeyValue in a future version? It just seems like that would be the simplest solution even if the suggested workaround does the same result.
This is not likely, as it gets logically complicated. Position can matter in a Rainmeter skin, and if you remove an option, and add it back in later, it will be in the same section, but added at the very bottom of the section. This is ok most of the time, but not always. If we allow removing options, we would also have to allow removing sections, and that is very likely indeed to be an issue with position in the skin.
MattNY177
Posts: 28
Joined: December 3rd, 2018, 1:15 am

Re: How to remove key=value from Meter (not blank it out)?

Post by MattNY177 »

Thank you again for the quick reply. I understand and agree with your point about removing sections and the issues with positioning. The only part I'm not sure about is this:
If we allow removing options, we would also have to allow removing sections
I don't see what one has to do with the other... I think it would be totally fine to just strictly allow removing options but not sections, with the understanding that if you remove it then add it back later with !WriteKeyValue, it would be added to the bottom of the section.

Again this is just my 2 cents, but I'm sure this feature would have a more positive than negative impact if it's not too complicated to add.

Either way I appreciate your help and in the meantime I will continue trying to find other solutions.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to remove key=value from Meter (not blank it out)?

Post by jsmorley »

We are exploring this:
The issue is that if you use

!SetOption SomeMeter SomeKey ""

That in effect "removes" the entire key from the meter, and it will then fall back to something that may be defined in a MeterStyle

If however, you use

!WriteKeyValue SomeMeter SomeKey ""

It literally sets it to SomeKey="" in the skin.

MeterStyle is detecting that as a valid key name on the meter, and so it not using the value for SomeKey in the style.

That is wrong in my view. Since leading and trailing "quotes" are ignored when the options are parsed, that is really SomeKey= and should be treated as not existing. It in fact DOES treat it that way in order to determine if any "default" value for the option should be used, so for instance, FontSize="" is treated as not existing, and the default font size of 9 is used. But MeterStyle doesn't behave the same way, and it should.

We should change this so MeterStyle is looking for a "value" for an option, and not just the option name.
That should address your issue, without having to mess with !RemoveKey and such..
MattNY177
Posts: 28
Joined: December 3rd, 2018, 1:15 am

Re: How to remove key=value from Meter (not blank it out)?

Post by MattNY177 »

Ok so if I understand correctly, what you are saying is instead of MeterStyle recognizing Attribute="" to be the same as Attribute=0, instead it would treat it like it doesn't exist so it could fall back to the defined value of the MeterStyle attribute, is that correct?

If so, I would also add that this should be universal so it also applies when parsing multiple MeterStyles for a single Meter.

It sounds like that would solve the problem, since it's essentially the same as removing the key without actually removing it. Is this something that is going to be added/changed in a future version?
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to remove key=value from Meter (not blank it out)?

Post by jsmorley »

MattNY177 wrote: December 3rd, 2018, 6:39 am Ok so if I understand correctly, what you are saying is instead of MeterStyle recognizing Attribute="" to be the same as Attribute=0, instead it would treat it like it doesn't exist so it could fall back to the defined value of the MeterStyle attribute, is that correct?

If so, I would also add that this should be universal so it also applies when parsing multiple MeterStyles for a single Meter.

It sounds like that would solve the problem, since it's essentially the same as removing the key without actually removing it. Is this something that is going to be added/changed in a future version?
We are considering it. As always, we have to be careful of unintended consequences and backwards compatibility.