It is currently April 23rd, 2024, 8:54 am

Does Refresh include closing the skin?

Report bugs with the Rainmeter application and suggest features.
User avatar
Yincognito
Rainmeter Sage
Posts: 7148
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Does Refresh include closing the skin?

Post by Yincognito »

Test skin (let's say it's Test\Test.ini):

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
OnRefreshAction=[!Log "I was just refreshed"]
OnCloseAction=[!Log "I will be closed now"]

---Meters---

[DummyMeter]
Meter=STRING
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
Text="Dummy Stuff"
UpdateDivider=-1
DynamicVariables=1
The Log shows that when refreshing the skin, the OnCloseAction doesn't trigger. Is this normal? The manual says that !Refresh "reads the skin file and recreates the skin", but doesn't this require closing the skin before "recreating it"? If it doesn't, how can I replicate what OnCloseAction does, but right before !Refresh triggers in? Trying an alternate left click action attached to the meter:

Code: Select all

LeftMouseUpAction=[!DeactivateConfig][!ActivateConfig "Test" "Test.ini"]
to be able to use the OnCloseAction before reloading the skin doesn't work, since the Log writes that the "refresh" happened before "closing", aka the skin was loaded before being closed (is that even possible, logically?):
DeactivateAndActivate.jpg
Anyway, what I'm trying to do is !WriteKeyValue some variables just before a refresh (or, if it would be possible, an unload->reload sequence) happens. The values of those variables change very quickly while the skin is active (through on demand scrolling) so it would be overkill to save each of those variables every millisecond during such a scrolling sequence, hence leaving saving all of them just once before a !Refresh bang does its thing.

Hopefully I've been clear enough in my description. A minor suggestion of an OnSwitchAction (e.g. action to execute before refresh) would be feasible too, if you don't think messing with what OnCloseAction does is a good idea or it simply can't be done.
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Brian
Developer
Posts: 2681
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Does Refresh include closing the skin?

Post by Brian »

Yincognito wrote: June 27th, 2021, 1:31 am The Log shows that when refreshing the skin, the OnCloseAction doesn't trigger. Is this normal?
Yes, this is normal. The OnCloseAction is meant to trigger when the skin is completely closed (either unloaded or when Rainmeter exits) - or when the skin is completely destroyed. Refreshing a skin doesn't completely destroy the skin, it just re-creates all the components and starts its Update cycle over again.




Yincognito wrote: June 27th, 2021, 1:31 am The manual says that !Refresh "reads the skin file and recreates the skin", but doesn't this require closing the skin before "recreating it"?
To the user, it appears to completely close the skin then restart it. But internally that would require completely destroying things like the actual "window" and other backend objects - and then turn around and re-create those items again. It's a pointless operation for these backend objects.




Yincognito wrote: June 27th, 2021, 1:31 am If it doesn't, how can I replicate what OnCloseAction does, but right before !Refresh triggers in?
You could replicate this by sending the same bangs just before the !Refresh bang. Something like this:

Code: Select all

[Rainmeter]
OnCloseAction=#OnCloseAction#

[Variables]
OnCloseAction=[!WriteKeyValue ....]

[SomeMeter]
...
LeftMouseUpAction=#OnCloseAction#[!Refresh]
But this has 1 obviously flaw. If the user directly refreshes the skin manually in any manor other than using left click action in [SomeMeter], the #OnCloseAction# is never executed.


I see what you are trying to accomplish with this. Refreshing a skin resets any variables that were not manually written to the skin file before the refresh. OnCloseAction only works when unloading the skin or when exiting Rainmeter. There is no "pre refresh" bang that executes before the skin starts the refresh process.

I am not sure about executing OnCloseAction in another area of the code. I might be wrong, but this might break or produce different behavior in older skins. I could see skins wanting to "start over" in some way by refreshing....then having the OnCloseAction actually write the variables to save them for the next time the skin is loaded.

We will discuss this internally and weigh the pros and cons to this or adding a bang. Or we may not chose to do anything. :confused:

-Brian

PS -
Yincognito wrote: June 27th, 2021, 1:31 am to be able to use the OnCloseAction before reloading the skin doesn't work, since the Log writes that the "refresh" happened before "closing", aka the skin was loaded before being closed (is that even possible, logically?):
This happens because sometimes the main Rainmeter thread is busy when a skin unloads, so we move the unloaded skin to a "unmanaged" area to be completely destroyed later. Once Rainmeter is free, it deletes these "unmanaged skins" (and thus the OnCloseAction is executed).
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: Does Refresh include closing the skin?

Post by Active Colors »

Brian wrote: June 27th, 2021, 6:26 am But this has 1 obviously flaw. If the user directly refreshes the skin manually in any manor other than using left click action in [SomeMeter], the #OnCloseAction# is never executed.
Can't this be solved with OnRefreshAction? ;)
User avatar
Yincognito
Rainmeter Sage
Posts: 7148
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Does Refresh include closing the skin?

Post by Yincognito »

Thanks for the replies, guys. From my perspective, this conundrum has lost its urgency, as I found out it's much better to just save those variables at any time, on demand, not just before refreshing, by adding the needed context menu action (I already use it, so it fits nicely overall). It's still something to think of, of course, given my unorthodox "refresh" system in that skin (which is similar to choosing a skin variant, but from my custom skin actions, also in the context menu) and the inability to achieve exactly what has been described in my initial post, I'm just saying that from a practical point of view I have now chosen to do things a bit differently.

In other words, take your time and weigh in on this - no pressure. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth