It is currently March 28th, 2024, 4:22 pm

Question on DynamicVariables=1

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: Question on DynamicVariables=1

Post by jsmorley »

Ok. I still don't follow, but I don't really need to. Keep in mind that a single option being dynamically resolved with DynamicVariables=-1 takes extra CPU time that is likely measured in 10's if not 100's of thousandth's of a second. While I'm not in favor of using DynamicVariables indiscriminately, as more efficient is always better than less efficient, even if only in spirit, I also don't dwell too much on it, as at the end of the day it's a tiny, tiny difference.
User avatar
Yincognito
Rainmeter Sage
Posts: 7025
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Question on DynamicVariables=1

Post by Yincognito »

Ok, disregard following what I just said, LOL - I was even more confusing than before.
Question: is setting DynamicVariables from 1 to 0 on some random skin elements gonna retain the last value of the variables that were previously dynamic? Or will those variables reset to 0/"" and lose the last dynamic change on them?
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Question on DynamicVariables=1

Post by jsmorley »

Yincognito wrote: February 4th, 2019, 3:58 am Ok, disregard following what I just said, LOL - I was even more confusing than before.
Question: is setting DynamicVariables from 1 to 0 on some random skin elements gonna retain the last value of the variables that were previously dynamic? Or will those variables reset to 0/"" and lose the last dynamic change on them?
Changing DynamicVariables won't change or "forget" any option values. It will simply make the options either static or dynamic on subsequent updates. If it was set with DynamicVariables set to "1" and ended up changing from "Alpha" to "Beta" based on some changing variable or section variable or even a !SetOption, and you change DynamicVariables to "0", the option value will remain forever as "Beta", unless you again set it to DynamicVariables=1, or use !SetOption to change it.

Timing matters though, as using !SetOption to change a measure or meter from dynamic to not dynamic will in fact FORCE it to be dynamic for one more, the next, update. From then on, it will be not dynamic, and keep whatever value it has.

What you cannot do is take a measure or meter that is dynamically reacting to a change in an option value on every update, and use !SetOption to change DynamicVariables and have that freeze the value that it is during that current update. It will still change one more time, as it is forced to be dynamic for one subsequent update.

BTW, the earlier tip that you could make a measure or meter dynamic for one update without actually changing any specific thing is a reasonable one, as long as you do it right. You need to use !SetOption and set "", on some option that doesn't exist on the measure or meter, or even better, some option name like "Dummy" that doesn't exist at all. That will ignore the change to the option, since it is invalid, while still making the measure or meter dynamic for one update. Alternatively, you can use !SetOption to just change something to the same value it already has. Like AntiAlias from "1" to "1".

Remember that setting an existing option to "" with !SetOption does NOT change the value to "", but REMOVES the option entirely from the measure or meter, and entirely forgets any previous value it had.
User avatar
Yincognito
Rainmeter Sage
Posts: 7025
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Question on DynamicVariables=1

Post by Yincognito »

Thanks. That suits my needs, in the (unlikely) case that I would want to use static variables for all but the first update. All this with a single !SetOptionGroup on DynamicVariables, instead of lots of different !SetOptionGroup in a long long line, on all the variables involved. ;-)

EDIT: Well, yeah, I want to use !SetOption to change DynamicVariables and have that freeze the value of variables (or better said, freeze the dynamic changes on them), but since after the first update the said variables stay on the same values, having them stay on the value from the last update isn't going to be a problem (I think). I need to time this just after the first dynamic change, I guess.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Question on DynamicVariables=1

Post by jsmorley »

I don't know, we are going down some rabbit hole here that feels like a solution looking for a problem to me.

The only way I can think of to "freeze" the Text value (for instance) of a dynamically changing meter, and have it keep the current value it had at that exact point, is something like:

Code: Select all

[Loop]
Measure=Loop
StartValue=1
EndValue=5

[MeterOne]
Meter=String
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
DynamicVariables=1
Text=[Loop]
LeftMouseUpAction=[!SetOption MeterOne Text "[Loop]"][!SetOption MeterOne DynamicVariables "0"][!UpdateMeter *][!Redraw]
RightMouseUpAction=[!SetOption MeterOne Text "[*Loop*]"][!SetOption MeterOne DynamicVariables "1"][!UpdateMeter *][!Redraw]
So you are first changing the Text option from the [Loop] section variable to the literal, current value of the measure [Loop], since that will be resolved and set to the numeric value by the bang. Then you are making the meter not dynamic, although I'm not sure why. The fact that it will actually be dynamic for one more update doesn't matter, since there is nothing in it that can change. In the second action, you are putting the Text value back to being the [Loop] section variable, and making the meter dynamic again.

Anyway, you have lost me on this one. I can only tell you how things work. What you do with that is up to you.
User avatar
Brian
Developer
Posts: 2673
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Question on DynamicVariables=1

Post by Brian »

jsmorley wrote: February 4th, 2019, 4:55 amBTW, the earlier tip that you could make a measure or meter dynamic for one update without actually changing any specific thing is a reasonable one, as long as you do it right. You need to use !SetOption and set "", on some option that doesn't exist on the measure or meter, or even better, some option name like "Dummy" that doesn't exist at all. That will ignore the change to the option, since it is invalid, while still making the measure or meter dynamic for one update. Alternatively, you can use !SetOption to just change something to the same value it already has. Like AntiAlias from "1" to "1".
In "production" skins, what I like to do is instead of using a "dummy" option to force a one-time dynamic reading of options, is to use the DynamicVariables option itself.
[!SetOption SomeSection DynamicVariables "0"]

This way you can still understand "why" you placed that there at a later time when the skin isn't so fresh in your mind. Or if you happen to distribute the skin, other users can attempt to understand what you are doing. [!SetOption Something Dummy ""] isn't going to make a lot of sense to most users, and might even throw you for a loop 2 years later when updating your skin.

-Brian
User avatar
Yincognito
Rainmeter Sage
Posts: 7025
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Question on DynamicVariables=1

Post by Yincognito »

Well, I don't want to to lose you, you're a valuable Rainmeter team member... :D
The process in my case is "relatively" simple:

Code: Select all

[Variables]
SkinBevelWidth=0.5

TextPaddingTop=0
TextPaddingLeft=2
TextPaddingBottom=0
TextPaddingRight=2

SmallRowHeight=[MT_SmallRow:H]
SmallColWidth=[MT_SmallCol:W]
LargeColWidth=[MT_LargeCol:W]

SkinWidth=(#SkinBevelWidth#*2+(#TextPaddingLeft#+#TextPaddingRight#)*4+#SmallColWidth#*2+#LargeColWidth#*2)
SkinHeight=(#SkinBevelWidth#*2+(#TextPaddingTop#+#TextPaddingBottom#)*1+#SmallRowHeight#)

[Rainmeter]

...the usual stuff, accurate text and dynamic window size

[Styles]

...a couple of meter style having X,Y,W and H set on formulas using the variables above...

---Measures---

...some measures...

---Meters---

[MT_SmallRow]
Meter=STRING
MeterStyle=sometransparentmeterstyle
Text="bp"
UpdateDivider=-1

[MT_SmallCol]
Meter=STRING
MeterStyle=someothertransparentmeterstyle
Text="DK.W#CRLF#ram.P#CRLF#000 °C#CRLF#00-bit"
InlineSetting=Weight | 700
InlinePattern=(DK\.W|ram\.P)
UpdateDivider=-1

[MT_LargeCol]
Meter=STRING
MeterStyle=someanothertransparentmeterstyle
Text="0000.0 MBs#CRLF#0000.0 MHz"
UpdateDivider=-1

[MT_Background]
...some nicely filled background rectangle and a custom width bevel (all shapes made with formulas using the values in the [Variables] section)...

[ActualMeterOne]
Group=AllMetersGroup
MeterStyle=style having X,Y,W and H set to formulas using the values in the [Variables] section
DynamicVariables=1

[ActualMeterTwo]
Group=AllMetersGroup
MeterStyle=style having X,Y,W and H set to formulas using the values in the [Variables] section
DynamicVariables=1

[ActualMeterThree]
Group=AllMetersGroup
MeterStyle=style having X,Y,W and H set to formulas using the values in the [Variables] section
DynamicVariables=1
Basically, the [MT_...] meters set the dimensions/positions for the subsequent meters. So, I'm thinking that if I use something like OnUpdateAction=[!SetOptionGroup AllMetersGroup DynamicVariables 0] on [ActualMeterThree] (i.e. the last meter), that's going to turn the variables used by meters into static variables ... after that first/initial change in the first update (the one that sets X,Y,W, and H of the meters to the formulas using the values in the [Variables] section).

I don't know if I was clear this time, but maybe my basic code schema helps in understading things better...

P.S. When you said that setting something like AntiAlias from "1" to "1" triggers an update/dynamic variables change, I immediately thought that it's a bit redundant/pointless if this thing happens every time we (willingly/knowingly or not) "update" something to the same value. Like !HideMeter when the meter is already hidden, that kind of stuff. Just saying...
User avatar
Brian
Developer
Posts: 2673
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Question on DynamicVariables=1

Post by Brian »

Yincognito wrote: February 4th, 2019, 6:30 am OnUpdateAction=[!SetOptionGroup AllMetersGroup DynamicVariables 0]
This isn't going to do what you think....

OnUpdateAction is going to fire on every update cycle. Every single one.

Using !SetOptionGroup to set an option on every meter in the group will cause EACH meter to re-read ALL of its options on the NEXT update cycle.

This will be the exact same things as leaving DynamicVariables=1 on all the meters in the group.

I would suggest using something other than OnUpdateAction to solve this.

-Brian
User avatar
Yincognito
Rainmeter Sage
Posts: 7025
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Question on DynamicVariables=1

Post by Yincognito »

Brian wrote: February 4th, 2019, 6:54 am This isn't going to do what you think....

OnUpdateAction is going to fire on every update cycle. Every single one.

Using !SetOptionGroup to set an option on every meter in the group will cause EACH meter to re-read ALL of its options on the NEXT update cycle.

This will be the exact same things as leaving DynamicVariables=1 on all the meters in the group.

I would suggest using something other than OnUpdateAction to solve this.

-Brian
Yeah, my bad. What about triggering !SetOptionGroup from the last meter, on all the meters except the last one, where the last one is a dummy meter that has UpdateDivider=-1 set on it? Would that correct my previous method, right? To be clear, the last meter would be an additional one, like [DummyMeterFour].
User avatar
Brian
Developer
Posts: 2673
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Question on DynamicVariables=1

Post by Brian »

Yeah, UpdateDivider=-1 will only update on the first update cycle, so the OnUpdateAction for that meter should only fire once.

-Brian
Post Reply