It is currently March 28th, 2024, 3:34 pm

Which code should I choose?

Get help with creating, editing & fixing problems with skins
Post Reply
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Which code should I choose?

Post by kyriakos876 »

So, I have 2 options:

1)

Code: Select all

[Icon0A]
Meter=Image
ImageName=#ImagePath0A#
ImageAlpha=#Alpha#
LeftMouseUpAction=#Command0A# #Close#
MouseOverAction=[!SetOption #CURRENTSECTION# ImageAlpha "255"][!UpdateMeter  #CURRENTSECTION#][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# ImageAlpha "#Alpha#"][!UpdateMeter  #CURRENTSECTION#][!Redraw]
X=#IconX#
Y=#IconY#
W=#IconW#
H=#IconH#
AntiAlias=1
2)

Code: Select all

[Icon0A]
Meter=Image
ImageName=#ImagePath0A#
ImageAlpha=#Alpha#
LeftMouseUpAction=#Command0A# #Close#
MouseOverAction=[!SetOption #CURRENTSECTION# ImageAlpha "255"][!Update ]
MouseLeaveAction=[!SetOption #CURRENTSECTION# ImageAlpha "#Alpha#"][!Update ]
X=#IconX#
Y=#IconY#
W=#IconW#
H=#IconH#
AntiAlias=1
DynamicVariables=1
Supposing I have ~100 of those meters in a skin. (This means I get a "lag time", until the change of the alpha is displayed, that time increases when I add more meters as redrawing everything is a hard job for the CPU)
In the first case I update only one meter but redraw everything, while in the second, I update everything but change (not exactly redraw I think) only the updated meter.

Which solution would be more CPU friendly? (Is there gonna be any difference to being with?)
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Which code should I choose?

Post by balala »

kyriakos876 wrote:In the first case I update only one meter but redraw everything, while in the second, I update everything but change (not exactly redraw I think) only the updated meter.
Not exactly. When an !Update bang is applied, a redraw of the whole skin is automatically done. That's why the !Update bang doesn't require the !Redraw bang, as !UpdateMeter (or !UpdateMeterGroup) does. So, even the second code does a redraw.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Which code should I choose?

Post by kyriakos876 »

balala wrote:Not exactly. When an !Update bang is applied, a redraw of the whole skin is automatically done. That's why the !Update bang doesn't require the !Redraw bang, as !UpdateMeter (or !UpdateMeterGroup) does. So, even the second code does a redraw.
I understand that both do a redraw but I find the [!Redraw] alone is heavier than the [!Update] in this case (Could be very easily be wrong). That's why I'm asking.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Which code should I choose?

Post by balala »

kyriakos876 wrote:I find the [!Redraw] alone is heavier than the [!Update] in this case (Could be very easily be wrong). That's why I'm asking.
However neither I'm not very sure, I wouldn't think it would be, because, as far as I know, the !Update bang also does a regular redraw. Read the second paragraph of the Meters section below: https://forum.rainmeter.net/viewtopic.php?p=126084#p126084
Probably jsmorley will come with some clarifications (I hope).
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Which code should I choose?

Post by kyriakos876 »

balala wrote:However neither I'm not very sure, I wouldn't think it would be, because, as far as I know, the !Update bang also does a regular redraw. Read the second paragraph of the Meters section below: https://forum.rainmeter.net/viewtopic.php?p=126084#p126084
Probably jsmorley will come with some clarifications (I hope).
Yeah, this is a bit weird. I'll hope with your for his reply :D
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Which code should I choose?

Post by jsmorley »

There is no reason to think that using [!UpdateMeter SomeMeter][!Redraw] is more resource intensive than [!Update], in fact in almost all cases it would be the opposite.

The analogy for !Update step by step would be:

[!UpdateMeasure *][!UpdateMeter *][!Redraw]

And in fact !Update would do just a bit more than that, although that is most of it.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Which code should I choose?

Post by kyriakos876 »

jsmorley wrote:There is no reason to think that using [!UpdateMeter SomeMeter][!Redraw] is more resource intensive than [!Update], in fact in almost all cases it would be the opposite.

The analogy for !Update step by step would be:

[!UpdateMeasure *][!UpdateMeter *][!Redraw]

And in fact !Update would do just a bit more than that, although that is most of it.
Great. That answers my question. Thanks ;)
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Which code should I choose?

Post by kyriakos876 »

kyriakos876 wrote:So, I have 2 options:

1)

Code: Select all

[Icon0A]
Meter=Image
ImageName=#ImagePath0A#
ImageAlpha=#Alpha#
LeftMouseUpAction=#Command0A# #Close#
MouseOverAction=[!SetOption #CURRENTSECTION# ImageAlpha "255"][!UpdateMeter  #CURRENTSECTION#][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# ImageAlpha "#Alpha#"][!UpdateMeter  #CURRENTSECTION#][!Redraw]
X=#IconX#
Y=#IconY#
W=#IconW#
H=#IconH#
AntiAlias=1
2)

Code: Select all

[Icon0A]
Meter=Image
ImageName=#ImagePath0A#
ImageAlpha=#Alpha#
LeftMouseUpAction=#Command0A# #Close#
MouseOverAction=[!SetOption #CURRENTSECTION# ImageAlpha "255"][!Update ]
MouseLeaveAction=[!SetOption #CURRENTSECTION# ImageAlpha "#Alpha#"][!Update ]
X=#IconX#
Y=#IconY#
W=#IconW#
H=#IconH#
AntiAlias=1
DynamicVariables=1
Supposing I have ~100 of those meters in a skin. (This means I get a "lag time", until the change of the alpha is displayed, that time increases when I add more meters as redrawing everything is a hard job for the CPU)
In the first case I update only one meter but redraw everything, while in the second, I update everything but change (not exactly redraw I think) only the updated meter.

Which solution would be more CPU friendly? (Is there gonna be any difference to being with?)
Post Reply