It is currently April 27th, 2024, 12:31 am

[Meter] ImageName or ButtonImage improvement

Report bugs with the Rainmeter application and suggest features.
User avatar
ShadowDragon
Posts: 44
Joined: January 28th, 2021, 4:30 pm

[Meter] ImageName or ButtonImage improvement

Post by ShadowDragon »

While Still struggling to get my ButtonImage to work correctly from a variable settings. I try to Explain
what I mean with ImageName or ButtonImage Improvement as feature (there might be work arounds.

This is a sample setup (so this DOES NOT WORK) so dont copy paste blindly!

Code: Select all

[MeasureMS1L]
Measure=Calc
Formula=#MS1L#
IfCondition=(#CURRENTSECTION#>=1)
IfTrueAction=[!ShowMeterGroup "L1"][!SetVariable MS2L "0"]{.......][!Redraw]
IfFalseAction=[!HideMeterGroup "L1"][!Redraw]
DynamicVariables=1
The above code is a measure with "IfTrueAction" and "IfFalseAction" but here is the thing.
let check the Meter section:

Code: Select all

[MS1L]
Meter=BUTTON
ButtonImage=#L1Sub#
X=670
Y=0
Hidden=1
DynamicVariables=1
LeftMouseUpAction=[!SetVariable MS1L "(1-#MS1L#)"][!SetVariable MS2L "0"][.....][!Redraw]
SolidColor=0,0,0,1
on 1 side, this works, but it has a downside, before I what he downside is, lets check the next measure

Code: Select all

[MeasureMS1Lp]
Measure=Calc
Formula=(([MeasureMS1L] < 1 ) ? 1 : 0)
IfCondition=(#CURRENTSECTION#>=1)
IfTrueAction=[!SetOption MS1L ButtonImage "#L1SubA#"][!UpdateMeter "MS1L"][!Redraw]
IfFalseAction=[!SetOption MS1L ButtonImage "#L1Sub#"][!UpdateMeter "MS1L"][!Redraw]
DynamicVariables=1
This basicly target the measure I have previosly, but the variable name to change the ButtonImage DOES NOT WORK.
while the variable Exist, the part now is, when the condition is FALSE, it shows the active buttonimage (which is wrong)
insert it directly works, but it DOES NOT reversed when FALSE.

so what improvement feature is usefull?
Instead of a second measure or meter to read this nicely, I hope for the following code for ImageName or ButtonImage
when a measure TRUE or FALSE is presented like this:

Code: Select all

[MS1L]
Meter=BUTTON
ButtonImage=#L1Sub# : #L1SubA#
X=670
Y=0
Hidden=1
DynamicVariables=1
LeftMouseUpAction=[!SetVariable MS1L "(1-#MS1L#)"][!SetVariable MS2L "0"][.....][!Redraw]
SolidColor=0,0,0,1
see how ButtonImage has 2 values? this should only work if TRUE and FALSE exist, else ignored.
so basicly it would read around this:

Code: Select all

ButtonImage=#L1Sub#
---- this read as normal and active (even when TRUE and FALSE actions are there)

Code: Select all

ButtonImage=#L1SUB# : #L1SubA#
---- this read FALSE else TRUE, when not activated, its false, when activated, it's true.

while this is in a variable, I don't get it to work, unless this MUST be hardcoded which I want to avoid.
while this might be doable in .lua, I got no knowledge of it, but this might be a easy way to control images easy and smoothly.
specially if you have a bunch to control, and also save some extra coding.

Do you think this is a nice feature to control ButtonImage easier if measure exist?
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Meter] ImageName or ButtonImage improvement

Post by jsmorley »

I don't know that I entirely follow your examples, but at a high level, it should be understood that there is no "true / false" value can is or can be passed to a meter based on an IfCondition or IfMatch on some measure. Those "tests" are entirely independent, and the "actions" that arise from them, based on their "true / false" results are up to you to define using just a ton of different "bangs" that can impact all kinds of things. If you have an IfCondition for instance, and based on the IfTrueAction and / or IfFalseAction, you use !SetOption to set the ImageName or ButtonImage of a meter, that certainly works. I don't see that anything more than that adds any real value to things.

Code: Select all

[MeasureToggleButtonImage]
Measure=Calc
Formula=1-MeasureCalc
UpdateDivider=5
IfCondition=MeasureCalc = 0
IfTrueAction=[!SetOption MeterButton ButtonImage "#@#Buttons\ButtonImage0.png"][!UpdateMeter MeterButton][!Redraw]
IfFalseAction=[!SetOption MeterButton ButtonImage "#@#Buttons\ButtonImage1.png"][!UpdateMeter MeterButton][!Redraw]

[MeterButton]
Meter=Button
A meter does not, and cannot, "know" the result of an IfCondition test...

I suspect that your issue arises from how you are passing all this through various dynamic variables. You need to be sure that DynamicVariables=1 is set anywhere you "use" them, and you are going to want to add an !UpdateMeter before any !Redraw bang, as !Redraw by itself does exactly nothing.

https://docs.rainmeter.net/manual/bangs/#Redraw

Code: Select all

[Variables]
Button0=#@#Buttons\ButtonImage0.png
Button1=#@#Buttons\ButtonImage1.png
CurrentButton=#Button0#

[MeasureCalc]
Measure=Calc
Formula=1-MeasureCalc
UpdateDivider=5
IfCondition=MeasureCalc = 0
IfTrueAction=[!SetVariable CurrentButton "#Button0#"][!UpdateMeter MeterButton][!Redraw]
IfFalseAction=[!SetVariable CurrentButton "#Button1#"][!UpdateMeter MeterButton][!Redraw]

[MeterButton]
Meter=Button
DynamicVariables=1
ButtonImage=#CurrentButton#
User avatar
ShadowDragon
Posts: 44
Joined: January 28th, 2021, 4:30 pm

Re: [Meter] ImageName or ButtonImage improvement

Post by ShadowDragon »

While playing around more, and place it "again" in the main measure, it does work, but I cannot
tell why it didn't work before.

I personally thing, if a true action and false action are use to control a meter image,
imageName: varA : varB can be used to update that meter instantly when a calc is used, without to much
more coding added.

my variables are controlled in the VariableSettings.inc so any name can be taken what they placed.
I still dont know why it didn't work before, or the formula how they exacly as, how calc know when
a button is pressed , when normal (0) and when activated (1).

while the formula is still complex, I learned a couple of things, specially the measure and meter combined
to work smoothly, this also avoid alot of extra coding that I had to a much simple (but a huge bangs).

but there are 2 other questions, unrelated, if you dont mind me to PM, because there is no answer to find on those.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Meter] ImageName or ButtonImage improvement

Post by jsmorley »

ShadowDragon wrote: February 17th, 2021, 6:22 pm While playing around more, and place it "again" in the main measure, it does work, but I cannot
tell why it didn't work before.

I personally thing, if a true action and false action are use to control a meter image,
imageName: varA : varB can be used to update that meter instantly when a calc is used, without to much
more coding added.

my variables are controlled in the VariableSettings.inc so any name can be taken what they placed.
I still dont know why it didn't work before, or the formula how they exacly as, how calc know when
a button is pressed , when normal (0) and when activated (1).

while the formula is still complex, I learned a couple of things, specially the measure and meter combined
to work smoothly, this also avoid alot of extra coding that I had to a much simple (but a huge bangs).

but there are 2 other questions, unrelated, if you dont mind me to PM, because there is no answer to find on those.
I never respond to private messages, sorry. All the help I do here is in public posts, so potentially everyone can weigh in, and everyone can benefit.