It is currently April 27th, 2024, 8:23 am

Rainmeter reading font file on every update

Get help with creating, editing & fixing problems with skins
RicardoTM
Posts: 268
Joined: December 28th, 2022, 9:30 pm
Location: México

Re: Rainmeter reading font file on every update

Post by RicardoTM »

Yincognito wrote: February 9th, 2024, 8:53 pm Yep, the only thing you'll lose is the list moving in "real-time" after the gadget. As for optimizing, many of the things reside in very small details that are relatively hard to spot. It took me a while to optimize my skins after I wrote them for pretty much the same reasons.
Yup, I decided to merge both skins so no lost functionality there and I'll use Action Timer to open/close the list, it'll look better. By the way, speaking of the list, I was trying to set the Skin's Y anchor to the middle of the Gauge but it won't do anything. Only when I use percentages it has an effect, the problem with that is that when you open the list the Y anchor "moves", so the gauge goes up. I want to have the anchor fixed in the middle of the Gauge. I tried with AnchorX=50% and AnchorY=150 (the gauge is 300x300) but that doesn't work. Any idea why?

While optimizing I realized what's more cpu hungry on my case are the images and the mouse over actions. I won't get rid of any of them of course, but at least I can limit the image's update to save resources. I also noticed shapes are very GPU hungry.
Last edited by RicardoTM on February 10th, 2024, 5:35 am, edited 1 time in total.
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Rainmeter reading font file on every update

Post by Yincognito »

RicardoTM wrote: February 10th, 2024, 4:10 am Yup, I decided to merge both skins so no lost functionality there and I'll use Action Timer to open/close the list, it'll look better. By the way, speaking of the list, I was trying to set the Skin's Y anchor to the middle of the Gauge but it won't do anything. Only when I use percentages it has an effect, the problem with that is that when you open the list the Y anchor "moves", so the gauge goes up. I want to have the anchor fixed in the middle of the Gauge. I tried with AnchorX=50% and AnchorY=150 (the gauge is 300x300) but that doesn't work. Any idea why?

While optimizing I realized what's more cpu hungry on my case are the images and the mouse over actions. I won't get rid of any of them of course, but at least I can limit the image's update to save resources. I also noticed shapes are very GPU hungry.
It should work, but it depends on how, where and how often you do this. The skin has to be sufficiently large to include the anchor point at the moment of setting it. Typically you'd do a !SetWindowPosition or !SetAnchor in an OnRefreshAction in the [Rainmeter] section, since by then the skin is drawn and knows how large it is. Obviously, if needed, such a bang can be issued after opening the list as well, knowing that if you use percentages they will differ from the values with the list closed.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
RicardoTM
Posts: 268
Joined: December 28th, 2022, 9:30 pm
Location: México

Re: Rainmeter reading font file on every update

Post by RicardoTM »

Yincognito wrote: February 10th, 2024, 11:56 am It should work, but it depends on how, where and how often you do this. The skin has to be sufficiently large to include the anchor point at the moment of setting it. Typically you'd do a !SetWindowPosition or !SetAnchor in an OnRefreshAction in the [Rainmeter] section, since by then the skin is drawn and knows how large it is. Obviously, if needed, such a bang can be issued after opening the list as well, knowing that if you use percentages they will differ from the values with the list closed.
Yah I know, I did try SetAnchor on the ActionTimer but I can't manage to make a good transition. It doesn't look smooth at all. That's why I was thinking on just using a fixed value on pixels but that doesn't change anything. According to the docs it should accept values in pixels.

So, here's the problem:

With AnchorX=50% AnchorY=50% it resizes properly but it moves up when the list opens.
ezgif.com-video-to-gif-converter (5).gif
With AnchorX=50% AnchorY=0% the list opens properly but it moves up when resizes.
ezgif.com-video-to-gif-converter (4).gif
I want it to not move at all and keep the anchor right on the gauge's center.

This is my current ActionTimer measure to open the list:

Code: Select all

[ListOpener]
measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat SlideUp, 20, 25
SlideUp=[!SetVariable ListState "(Clamp((#ListState#-1),0,20))"][!SetVariable ListHeight "(Trunc((300-300*(1-1/(2048**(0.05*#ListState#))))))"][!UpdateMeasure [#CURRENTSECTION]][!UpdateMeterGroup List][!Redraw]
ActionList2=Repeat SlideDown, 20, 25
SlideDown=[!SetVariable ListState "(Clamp((#ListState#+0.8),0,20))"][!SetVariable ListHeight "(Trunc((300-300*(1-1/(512**(0.05*#ListState#))))))"][!UpdateMeasure [#CURRENTSECTION]][!UpdateMeterGroup List][!Redraw]
DynamicVariables=1
You do not have the required permissions to view the files attached to this post.
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Rainmeter reading font file on every update

Post by Yincognito »

RicardoTM wrote: February 10th, 2024, 4:33 pm Yah I know, I did try SetAnchor on the ActionTimer but I can't manage to make a good transition. It doesn't look smooth at all. That's why I was thinking on just using a fixed value on pixels but that doesn't change anything. According to the docs it should accept values in pixels.
This would normally belong in its own thread, but anyway...
I've written this before you added the GIF and the code, but should make it clear that using combined values (e.g. percents with pixels and such) works:

Code: Select all

[Variables]
ListAction=2
ListHeight=0
FullHeight=450
SizerSteps=45
SizerDelay=10

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
OnRefreshAction=[!SetWindowPosition "50%" "25%" "50%" "150"]

---Measures---

[Sizer]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat SizeUp,#SizerDelay#,#SizerSteps#
ActionList2=Repeat SizeDn,#SizerDelay#,#SizerSteps#
SizeUp=[!SetVariable ListHeight (Clamp(#ListHeight#+#FullHeight#/#SizerSteps#,0,#FullHeight#))][!UpdateMeasure Sizer][!UpdateMeter List][!Redraw]
SizeDn=[!SetVariable ListHeight (Clamp(#ListHeight#-#FullHeight#/#SizerSteps#,0,#FullHeight#))][!UpdateMeasure Sizer][!UpdateMeter List][!Redraw]
UpdateDivider=-1
DynamicVariables=1

---Meters---

[Gauge]
Meter=Image
X=50
Y=0
W=300
H=300
SolidColor=255,0,0,128
LeftMouseUpAction=[!SetVariable ListAction (3-[#ListAction])][!CommandMeasure Sizer "Stop 1"][!CommandMeasure Sizer "Stop 2"][!CommandMeasure Sizer "Execute [#ListAction]"]
DynamicVariables=1

[List]
Meter=Image
X=0
Y=300
W=400
H=#ListHeight#
SolidColor=0,255,0,128
DynamicVariables=1
P.S. Didn't know if you were using a container to move the whole contents up and down via the Y of the list, so I wrote the above to change the list's height instead. It turns out it's roughly similar to what you were doing.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Rainmeter reading font file on every update

Post by Yincognito »

RicardoTM wrote: February 10th, 2024, 4:33 pm With AnchorX=50% AnchorY=0% the list opens properly but it moves up when resizes.
I want it to not move at all and keep the anchor right on the gauge's center.
I added scaling and used !SetAnchor, compared to the earlier version:

Code: Select all

[Variables]
ListAction=2
ListHeight=0
FullHeight=450
SizerSteps=10
SizerDelay=10
GaugeScale=1
GaugeSteps=0.05

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
OnRefreshAction=[!SetAnchor "50%" "(300/2*[#GaugeScale])"]

---Measures---

[Sizer]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat SizeUp,#SizerDelay#,#SizerSteps#
ActionList2=Repeat SizeDn,#SizerDelay#,#SizerSteps#
SizeUp=[!SetVariable ListHeight (Clamp([#ListHeight]+#FullHeight#/#SizerSteps#,0,#FullHeight#))][!UpdateMeasure Sizer][!UpdateMeter *][!Redraw]
SizeDn=[!SetVariable ListHeight (Clamp([#ListHeight]-#FullHeight#/#SizerSteps#,0,#FullHeight#))][!UpdateMeasure Sizer][!UpdateMeter *][!Redraw]
UpdateDivider=-1
DynamicVariables=1

---Meters---

[Gauge]
Meter=Image
X=((400-300)/2*[#GaugeScale])
Y=0
W=(300*[#GaugeScale])
H=(300*[#GaugeScale])
SolidColor=255,0,0,128
MouseScrollUpAction=[!SetVariable GaugeScale (Clamp([#GaugeScale]+#GaugeSteps#,#GaugeSteps#*1,#GaugeSteps#*40))][!UpdateMeter *][!Redraw][!SetAnchor "50%" "(300/2*[#GaugeScale])"]
MouseScrollDownAction=[!SetVariable GaugeScale (Clamp([#GaugeScale]-#GaugeSteps#,#GaugeSteps#*1,#GaugeSteps#*40))][!UpdateMeter *][!Redraw][!SetAnchor "50%" "(300/2*[#GaugeScale])"]
LeftMouseUpAction=[!SetVariable ListAction (3-[#ListAction])][!CommandMeasure Sizer "Stop 1"][!CommandMeasure Sizer "Stop 2"][!CommandMeasure Sizer "Execute [#ListAction]"]
DynamicVariables=1

[List]
Meter=Image
X=0
Y=0R
W=(400*[#GaugeScale])
H=([#ListHeight]*[#GaugeScale])
SolidColor=0,255,0,128
DynamicVariables=1
I think such an approach does what you want. It moves a bit after scaling and dragging it to a different location, but I guess that's just some minor rounding effect or something.

EDIT: Replaced the standard syntax for variables with the nested one just to be sure, and it looks like it's no rounding effect and isn't dependent on scaling. It seems more of an effect of Rainmeter updating or setting the skin position stuff (on / from the disk?), something that seems to be at times not synchronized with releasing the mouse button to end the dragging. :???:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
RicardoTM
Posts: 268
Joined: December 28th, 2022, 9:30 pm
Location: México

Re: Rainmeter reading font file on every update

Post by RicardoTM »

Yincognito wrote: February 10th, 2024, 6:19 pm This would normally belong in its own thread, but anyway...
I know, but I won't tell anyone, don't worry. :Whistle
Yincognito wrote: February 10th, 2024, 7:04 pm I added scaling and used !SetAnchor, compared to the earlier version:

Code: Select all

MouseScrollUpAction=[!SetVariable GaugeScale (Clamp([#GaugeScale]+#GaugeSteps#,#GaugeSteps#*1,#GaugeSteps#*40))][!UpdateMeter *][!Redraw][!SetAnchor "50%" "(300/2*[#GaugeScale])"]
MouseScrollDownAction=[!SetVariable GaugeScale (Clamp([#GaugeScale]-#GaugeSteps#,#GaugeSteps#*1,#GaugeSteps#*40))][!UpdateMeter *][!Redraw][!SetAnchor "50%" "(300/2*[#GaugeScale])"]
I think such an approach does what you want. It moves a bit after scaling and dragging it to a different location, but I guess that's just some minor rounding effect or something.

EDIT: Replaced the standard syntax for variables with the nested one just to be sure, and it looks like it's no rounding effect and isn't dependent on scaling. It seems more of an effect of Rainmeter updating or setting the skin position stuff (on / from the disk?), something that seems to be at times not synchronized with releasing the mouse button to end the dragging. :???:
Yup, that works,thank you. It doesn't move as you said after moving it but it kind of jumps while scrolling, which your example doesn't do for some reason.
ezgif.com-video-to-gif-converter (6).gif
Pretty much the same:

Code: Select all

MouseScrollDownAction=[!SetOptionGroup Resize DynamicVariables 0][!WriteKeyValue Variables Scaler "(Clamp(([#Scaler]-[#MouseIncrement]),[#MinSize],[#MaxSize]))" "[#vSettingsPath]"][!SetVariable Scaler (Clamp(([#Scaler]-[#MouseIncrement]),[#MinSize],[#MaxSize]))][!UpdateMeter *][!Redraw][!SetAnchor "50%" "([#StatesHeight]/2*[#Scaler])"]
MouseScrollUpAction=[!SetOptionGroup Resize DynamicVariables 0][!WriteKeyValue Variables Scaler "(Clamp(([#Scaler]+[#MouseIncrement]),[#MinSize],[#MaxSize]))" "[#vSettingsPath]"][!SetVariable Scaler (Clamp(([#Scaler]+[#MouseIncrement]),[#MinSize],[#MaxSize]))][!UpdateMeter *][!Redraw][!SetAnchor "50%" "([#StatesHeight]/2*[#Scaler])"]
At first I thought it was because mine was using measures to compute the formula but after removing those measures and putting the formula directly on the bang (like the code above) it does exactly the same thing. The outcome is a little different if I move the SetAnchor bang but putting it last does the best job. Also moving the WriteKey bang after the SetVar bang makes it move after a refresh, so it has to be first to avoid that. Anyway I'm happy with the result. Thanks again Yin.

I'm pretty close to a release state now, I just need to find a solution for some problem with changing the list's height and the ActionTimer animation and a way to disable unused sensor measures (I had a way but I found a little (big tbh) caveat so I need to find another solution).

By the way, to answer your question:
Yincognito wrote: February 10th, 2024, 6:19 pm P.S. Didn't know if you were using a container to move the whole contents up and down via the Y of the list, so I wrote the above to change the list's height instead. It turns out it's roughly similar to what you were doing.
I'm using a container yes, the ActionTimer changes its height instead of moving the meters' Y position. And to change the Height of the list I use a MouseDrag action.
You do not have the required permissions to view the files attached to this post.
Last edited by RicardoTM on February 11th, 2024, 11:13 am, edited 1 time in total.
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Rainmeter reading font file on every update

Post by Yincognito »

RicardoTM wrote: February 11th, 2024, 9:28 am The outcome is a little different if I move the SetAnchor bang but putting it last does the best job. Also moving the WriteKey bang after the SetVar bang makes it move after a refresh, so it has to be first to avoid that. Anyway I'm happy with the result. Thanks again Yin.
You're welcome - glad it helped. Yes, the order of bangs is sometimes important. In my unreleased Screen Ruler skin, I also have a case where !Move and !Redraw must be written in a certain order, otherwise the "frame" of the Shape I use to mark the measured area "wobbles".
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth