It is currently March 29th, 2024, 2:25 pm

[BUG] Specific case caused by !Redraw if in Measure in IfCondition

Report bugs with the Rainmeter application and suggest features.
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

[BUG] Specific case caused by !Redraw if in Measure in IfCondition

Post by Active Colors »

So, this is quite simple. Let me walk you through the example.

I have a simple image background which looks like this:
1.PNG
This is the code:

Code: Select all

[Rainmeter]
Update=1000

[MsrCalc]
Measure=Calc
Formula=80

[ObjBase]
Meter=Image
ImageName=base.png
X=0
Y=0
W=220
H=(21+[MsrCalc])
ScaleMargins=15,15,15,15
AntiAlias=1
Hidden=0
DynamicVariables=1


Hovewer, when I have a condition in a measure which redraws the skin then the image appears like that:
2.PNG
This is the measure:

Code: Select all

[MsrCondition]
Measure=Calc
Formula=1
IfCondition=(MsrCondition = 1)
IfTrueAction=[!Redraw][!Log "Redraw happened" Notice]


I figured out that it is due to the height formula which uses the measure in the formula.
If I manually redraw the skin later hen the image meter shows up properly.
If I use just the number instead of the measure it shows properly of course.


Also, I noticed if there is some meter that is overlapping with the meter or placed further than the meter then the image meter shows up until the edge of that another meter:
3.PNG
4.PNG

Test skin:
TestRedraw.zip
You do not have the required permissions to view the files attached to this post.
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: [BUG] Specific case caused by !Redraw if in Measure in IfCondition

Post by Active Colors »

Also, this happens not only if you use a measure but also if the formula has something like:
H=(21+[OtherMeter:YH])
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [BUG] Specific case caused by !Redraw if in Measure in IfCondition

Post by jsmorley »

I don't understand the reasoning with using !Redraw without a corresponding !UpdateMeter?

Don't you mean...

Code: Select all

[MsrCondition]
Measure=Calc
Formula=1
IfCondition=(MsrCondition = 1)
IfTrueAction=[!UpdateMeter *][!Redraw]
!Redraw on its own actually does nothing.

https://docs.rainmeter.net/manual/bangs/#Redraw
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: [BUG] Specific case caused by !Redraw if in Measure in IfCondition

Post by Active Colors »

jsmorley wrote: July 24th, 2020, 10:46 pm I don't understand the reasoning with using !Redraw without a corresponding !UpdateMeter?

Don't you mean...

Code: Select all

[MsrCondition]
Measure=Calc
Formula=1
IfCondition=(MsrCondition = 1)
IfTrueAction=[!UpdateMeter *][!Redraw]
!Redraw on its own actually does nothing.

https://docs.rainmeter.net/manual/bangs/#Redraw
Oh, I have !UpdateMeter in my original skin but for this example I narrowed everything down to the basics to demonstrate the problem.

What you suggested works:

Code: Select all

IfTrueAction=[!UpdateMeter *][!Redraw]
But in my skin it does not work for some reason...

EDIT:
It works. I figured out that the position of this Redraw measure is important. In order to make it work properly it should be located in the skin after all the relevant meters and measures. If it is located before all of them then it will cause this chopping. It makes some sense I believe. I mark this as resolved. I didn't notice this detail in my original skin because of its complexity. Thank you jsmorley! Yet I am not sure if this chop effect should appeared, I will leave this to you ;-)
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [BUG] Specific case caused by !Redraw if in Measure in IfCondition

Post by jsmorley »

Good.

Yeah, that measure needs to come last, so that any / all dynamic changes to meter sizes has already happened before you do a final update and redraw to set the size of the background meter.

This is always going to be the case if you have a background meter, that by its nature needs to be "first" so it can be "behind" the other meters, but then its "size" is dependent on the meters that come "after" it.

Do be aware though, that the way you are doing this is not going to work as expected if in fact the size of the meters in front of the background are actually dynamic in size. Since the value of your measure is always going to be "1", it's only ever going to fire that action once, the first time the skin is loaded / refreshed.

In that case, you might want:

Code: Select all

[MsrCondition]
Measure=Calc
OnUpdateAction=[!UpdateMeter *][!Redraw]
While this will do one extra update of all meters and redraw of the screen on each update of the skin, it's one way to be sure your background isn't always "one update behind" in setting its size.
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: [BUG] Specific case caused by !Redraw if in Measure in IfCondition

Post by Active Colors »

Right, I considered that for the example skin but overlooked in my original skin.

Update:
Welp, it looks there are some more things to look at... it does not work as intended in my original skin even after placing the redraw measure at the very end of the skin. It is not very complex to overlook something but I believe I need to give myself a fresh thought to see if there are mistakes. Swapping the order of !UpdateMeterGroup with !Redraw works though:
[!Redraw][!UpdateMeterGroup GrpCmp]
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [BUG] Specific case caused by !Redraw if in Measure in IfCondition

Post by jsmorley »

Active Colors wrote: July 24th, 2020, 11:53 pm Right, I considered that for the example skin but overlooked in my original skin.

Update:
Welp, it looks there are some more things to look at... it does not work as intended in my original skin even after placing the redraw measure at the very end of the skin. It is not very complex to overlook something but I believe I need to give myself a fresh thought to see if there are mistakes. Swapping the order of !UpdateMeterGroup with !Redraw works though:
[!Redraw][!UpdateMeterGroup GrpCmp]
No, that doesn't make sense. As I said, !Redraw by itself doesn't do ANYTHING.

To be honest, I'm not sure the !Redraw makes any sense at all. If the measure is the last one in the skin, the very next thing Rainmeter is going to do after it is redraw the skin window anyway. It's redundant to do it twice. Just have the very last thing in the skin do [!UpdateMeter *] and that should do it.

The update cycle of a skin is basically:

Update all measures in the order they are in the skin
Update all meters in the order they are in the skin
Redraw the skin window
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: [BUG] Specific case caused by !Redraw if in Measure in IfCondition

Post by Active Colors »

jsmorley wrote: July 24th, 2020, 11:56 pm No, that doesn't make sense. As I said, !Redraw by itself doesn't do ANYTHING.
There are some bangs happening:

Code: Select all

[BatteryNotification]
Measure=Calc
Formula=1
IfCondition=(BatteryPluginPercent = 99) && (BatteryPluginStatus = 1)
IfTrueAction=[!SetOption BatteryState String "Battery is fully charged, unplug charger"][!UpdateMeasure BatteryState][!ShowMeterGroup GrpCmp][!UpdateMeterGroup GrpCmp][!Redraw]
Taking out [!Redraw] bangs works as intended, but having [!Redraw] causes the chop.
User avatar
Yincognito
Rainmeter Sage
Posts: 7030
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [BUG] Specific case caused by !Redraw if in Measure in IfCondition

Post by Yincognito »

Active Colors wrote: July 25th, 2020, 12:00 am There are some bangs happening:

Code: Select all

[BatteryNotification]
Measure=Calc
Formula=1
IfCondition=(BatteryPluginPercent = 99) && (BatteryPluginStatus = 1)
IfTrueAction=[!SetOption BatteryState String "Battery is fully charged, unplug charger"][!UpdateMeasure BatteryState][!ShowMeterGroup GrpCmp][!UpdateMeterGroup GrpCmp][!Redraw]
Taking out [!Redraw] bangs works as intended, but having [!Redraw] causes the chop.
Updating the meter group should come first here, followed by showing it and redrawing the skin. At least that's how I would do it.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: [BUG] Specific case caused by !Redraw if in Measure in IfCondition

Post by balala »

jsmorley wrote: July 24th, 2020, 10:46 pm !Redraw on its own actually does nothing.
Just consumes some resources, if I'm not mistaken.