It is currently April 18th, 2024, 10:09 pm

ActionTimer

Share and get help with Plugins and Addons
cfixd
Posts: 31
Joined: September 1st, 2014, 1:38 am

Re: ActionTimer 0.1 [Beta]

Post by cfixd »

I know the worry about the CPU usage, after all you need think more about all the authors...

Actually I want to use this plugin to keep the balance of CPU usage and better animations.
In my mind, only two "thread" needed in those skins which tend to better animation, one (the original rainmeter update rate, in a low speed) for collect information and record (since it can't be stopped and changed), the other to play the animation freely, which may be realized by this plugin. That's why I want a "stop all other actionlist except one" command, for I want to jump one actionlist from another, and sure just one quick "redraw" in one skin.This may lead to more calc measure and "if condition" in animation of several items, but I think it's better than lots of redraw.
I think "endless" repeat is necessary in this situation for it takes over the redraw work, however there may be losts of "useless" redraw in the original rainmeter update rate, so I often write "Update=-1" in skins like dock.

Maybe I've asked for too much, and just small part of authors care about the CPU usage. :)
Whatever the plugin will be, I think it will make the rainmeter better under your leading.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ActionTimer 0.1 [Beta]

Post by jsmorley »

There is every chance that I don't follow you correctly at all, but I think the sense I get from that is an attempt to turn off the normal skin update entirely, using Update=-1 in [Rainmeter] and then have the entire skin controlled by one or more ActionTimer plugin measures running in an endless loop. The idea I suppose is that you can avoid all measure and meter updates and redraws of the skin window in the context of the update cycle, and only have them done "on demand" by the plugin actions.

In a sense "replacing" the update cycle with a loop of your own creation, with an eye toward minimizing any extra work you don't specifically "ask for".

While intriguing, that isn't the intent of the plugin, and I'm not sure we are going to introduce the risk of misbehavior that endless loops bring, in order to support what is a very unusual and complicated approach.

I'm sure Brian will want to chew on the idea though when he gets back to town.
User avatar
lysy1993lbn
Posts: 291
Joined: July 25th, 2011, 9:53 am
Location: Lublin, Poland

Re: ActionTimer 0.1 [Beta]

Post by lysy1993lbn »

@ jsmorley can you please upload those skins for more reference?

I'm struggling to get simple dock slide up/down transition

Or if you could pont me what am I doing wrong
[Variables]
@include=#@#var.cfg
@include2=#@#$Themes\#theme#\settings.cfg
PlayerName=Aimp
PlayerPath="#SOFT#AIMP3\AIMP3.exe"
Position=5

[ActionTimer1]
Measure=Plugin
Plugin=ActionTimer
ActionList1=[!SetVariable Posiition 5][!UpdateMeter Dock][!Redraw]

[ActionTimer2]
Measure=Plugin
Plugin=ActionTimer
ActionList1=[!SetVariable Posiition 68][!UpdateMeter Dock][!Redraw]

[Trigger]
Meter=Image
MeterStyle=Style1
SolidColor=0,0,0,200
;255,255,255,200
;MouseOverAction=!ZPos 2 "woodock"
;MouseOverAction=[!ShowFade "woodock"][!Hide "woodock\$widgets\position"]
H=1
W=410
;MouseOverAction=[!CommandMeasure Transition "MoveToY('Dock', 5)"]
MouseOverAction=[!CommandMeasure ActionTimer1 "Execute 1"]
Y=68
DynamicVariables=1

[Dock]
Meter=Image
MeterStyle=Style1
Imagename=#@#$Themes\#theme#\dock
MiddleMouseUpAction=["#USB#"]
;MouseLeaveAction=!ZPos 0 "woodock"
;MouseLeaveAction=[!HideFade "woodock"][!Show "woodock\$widgets\position"]
SolidColor=0,0,0,1
;MouseLeaveAction=[!CommandMeasure Transition "MoveToY('dock', 68)"]
MouseLeaveAction=[!CommandMeasure ActionTimer2 "Execute 1"]
Y=#Position#
DynamicVariables=1
"Never argue with an idiot, he will drag you down to his level and beat you with experience."
my deviantART | Alternative Rainmeter tray icons
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ActionTimer 0.1 [Beta]

Post by jsmorley »

lysy1993lbn wrote:@ jsmorley can you please upload those skins for more reference?

I'm struggling to get simple dock slide up/down transition

Or if you could pont me what am I doing wrong
[Variables]
@include=#@#var.cfg
@include2=#@#$Themes\#theme#\settings.cfg
PlayerName=Aimp
PlayerPath="#SOFT#AIMP3\AIMP3.exe"
Position=5

[ActionTimer1]
Measure=Plugin
Plugin=ActionTimer
ActionList1=[!SetVariable Posiition 5][!UpdateMeter Dock][!Redraw]

[ActionTimer2]
Measure=Plugin
Plugin=ActionTimer
ActionList1=[!SetVariable Posiition 68][!UpdateMeter Dock][!Redraw]

[Trigger]
Meter=Image
MeterStyle=Style1
SolidColor=0,0,0,200
;255,255,255,200
;MouseOverAction=!ZPos 2 "woodock"
;MouseOverAction=[!ShowFade "woodock"][!Hide "woodock\$widgets\position"]
H=1
W=410
;MouseOverAction=[!CommandMeasure Transition "MoveToY('Dock', 5)"]
MouseOverAction=[!CommandMeasure ActionTimer1 "Execute 1"]
Y=68
DynamicVariables=1

[Dock]
Meter=Image
MeterStyle=Style1
Imagename=#@#$Themes\#theme#\dock
MiddleMouseUpAction=["#USB#"]
;MouseLeaveAction=!ZPos 0 "woodock"
;MouseLeaveAction=[!HideFade "woodock"][!Show "woodock\$widgets\position"]
SolidColor=0,0,0,1
;MouseLeaveAction=[!CommandMeasure Transition "MoveToY('dock', 68)"]
MouseLeaveAction=[!CommandMeasure ActionTimer2 "Execute 1"]
Y=#Position#
DynamicVariables=1
The skins are in the .rmskin in the first post.
User avatar
lysy1993lbn
Posts: 291
Joined: July 25th, 2011, 9:53 am
Location: Lublin, Poland

Re: ActionTimer 0.1 [Beta]

Post by lysy1993lbn »

jsmorley wrote: The skins are in the .rmskin in the first post.
Oh.. didn't notice them. sorry :oops:

Though still can't get it to work. Perhaps I'm too dumb for this

If you'd like to take a look, there's an rmskin

Set skin position as following to see what am I trying to accomplish

Code: Select all

WindowX=50%
AnchorX=50%
WindowY=69B
KeepOnScreen=0
You do not have the required permissions to view the files attached to this post.
"Never argue with an idiot, he will drag you down to his level and beat you with experience."
my deviantART | Alternative Rainmeter tray icons
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ActionTimer 0.1 [Beta]

Post by jsmorley »

lysy1993lbn,

Overview

The ActionTimer plugin itself is pretty easy. It is simply "do something, wait, do something, wait, do something."

The trick is first defining:

- What is it I want it to do? In a sense you want to say "at the start I want these things set this way, and and the end I want them set that way." Define a goal. A beginning and an end.

- What actions will I need to change those settings from the beginning state to the end state in steps? Define the !SetVariable or !SetOption commands you would need to change from the beginning state to the end state.

- How many "steps" do I want this to have?

- How "fast" do I want this to happen?

Those last two are actually related. Just as with any "animation", the effect is a combination of how many "frames" you have in the animation, and how quickly you change from frame to frame. The more "frames" you have the more "smooth" the effect is, but you then need to balance the speed so "smooth" doesn't cause "slow".

So you might need to play with it to get the right balance of "steps", "size of each change", and "length of the waits" so you get the desired result.

Example

I'm not going to wade through your skin, as it's just more complicated than I think is useful for a demonstration that can help everyone. I am starting with the "concept" you have in mind however, and you should be able to adapt this to your needs.

So let's start by defining that "What do I want it to do?" question...

The goal here is to have a "toolbar" of icons, that behave much like the "auto hide" feature of the taskbar in Windows. They should be "hidden" as a starting state, and then "slide up" when the mouse is moved over the bar, and "slide down" when the mouse moves off.

While I want the "slide up" effect to happen as soon as I move the mouse over it, I find it pleasing to have a short "pause" before the "slide down" effect starts when I move the mouse off.

So I want an end result like this:
slide.gif
So let's start with a skin that does that, but without any ActionTimer "transition effect". Let's just get it working as a "starting" and "ending" state.

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1

[Variables]
UnCropH=0
SlideH=0
IconY=48
DownPause=1000
W=5
U=[!UpdateMeterGroup Sliders][!Redraw]

[MeterSkinBack]
Meter=Image
W=116
H=50
SolidColor=0,0,0,1
MouseOverAction=[!SetVariable IconY "0"][!SetVariable SlideH "50"][!SetVariable UnCropH 48"]#U#
MouseLeaveAction=[!SetVariable IconY "48"][!SetVariable SlideH "0"][!SetVariable UnCropH "0"]#U#

[MeterSlideBack]
Meter=Image
Group=Sliders
W=116
H=#SlideH#
Y=#IconY#
SolidColor=15,55,79,255
DynamicVariables=1

[MeterBottomBar]
Meter=Image
W=116
H=2
Y=50
SolidColor=155,171,249,255

[MeterIcon1]
Meter=Image
Group=Sliders
X=5
Y=#IconY#
ImageName=#@#Images\DriveC.png
ImageTint=200,200,200,255
ImageCrop=0,0,48,#UnCropH#,1
DynamicVariables=1
MouseOverAction=[!SetOption #CURRENTSECTION# ImageTint ""]#U#
MouseLeaveAction=[!SetOption #CURRENTSECTION# ImageTint "200,200,200,255"]#U#
LeftMouseUpAction=["C:"]

[MeterIcon2]
Meter=Image
Group=Sliders
X=10R
Y=#IconY#
ImageName=#@#Images\ControlPanel.png
ImageTint=200,200,200,255
ImageCrop=0,0,48,#UnCropH#,1
DynamicVariables=1
MouseOverAction=[!SetOption #CURRENTSECTION# ImageTint ""]#U#
MouseLeaveAction=[!SetOption #CURRENTSECTION# ImageTint "200,200,200,255"]#U#
LeftMouseUpAction=["Control"]


Hold on a sec, we need to stop here for a minute to touch on something that has nothing to do with ActionTimer as such, but is important for this.

I sorta hate the approach of just having the icons be "off the screen" at the bottom, and then sliding them up "on to the screen" as the effect. While this can work if you put the skin at the very bottom of the screen, it is not going to work even as a concept if you want to change it around to slide out from the top or sides. It also means you are going to get in a fight with the Windows taskbar, which WILL insist on being "in front" at all times.

So what I do instead is use the ImageCrop option to crop and uncrop the images at the same time as I slide them up and down. That way I'm not playing games with the edge of the screen to get the effect, and the skin can be anywhere.

Ok, back to it. Le't look at that code, and the result:

What I am doing is creating an invisible background meter that will define the overall size of the skin, and be the place where I put the mouse "over" and "leave" actions to trigger the effect.

Then I create meters for my two icons. I initially set their "Y" option so they are being displayed outside the skin, and at the same time using ImageCrop to crop their height to "nothing". So they are invisible. Images that are set outside the skin will still display, so we use ImageCrop to overcome that behavior. I use ImageCrop rather than W and H, as the goal is not to "resize" them, but literally to "crop" them.

Now in our MouseOverAction, we just change the "Y" option to move the images up to the top of the skin, and at the same time remove that ImageCrop, so the entire image is displayed.

That gives us something like this:
pop.gif
Good! That's the "result" I want to end up with, now we just need to add the "transition effect".

Code: Select all

[Rainmeter]
Update=1000

[Variables]
UnCropH=0
SlideH=0
IconY=48
DownPause=1000
W=5
U=[!UpdateMeasureGroup Sliders][!UpdateMeterGroup Sliders][!Redraw]

[MeterSkinBack]
Meter=Image
W=116
H=50
SolidColor=0,0,0,1
MouseOverAction=[!CommandMeasure MeasureSliders "Stop 2"][!CommandMeasure MeasureSliders "Execute 1"]
MouseLeaveAction=[!CommandMeasure MeasureSliders "Stop 1"][!CommandMeasure MeasureSliders "Execute 2"]

[MeasureSliders]
Measure=Plugin
Plugin=ActionTimer
Group=Sliders
ActionList1=SlideUp|Wait #W#|SlideUp|Wait #W#|SlideUp|Wait #W#|SlideUp|Wait #W#|SlideUp|Wait #W#|SlideUp|Wait #W#|SlideUp|Wait #W#|SlideUp|Wait #W#|SlideUp|Wait #W#|SlideUp|Wait #W#|SlideUp|Wait #W#|SlideUp|Wait #W#|SlideUp|Wait #W#|SlideUp|Wait #W#|SlideUp|Wait #W#|SlideUp|Wait #W#|SlideUp|Wait #W#|SlideUp|Wait #W#|SlideUp|Wait #W#|SlideUp
SlideUp=[!SetVariable IconY "(Clamp(#IconY#-3,0,48))"][!SetVariable SlideH "(Clamp(#SlideH#+3,0,50))"][!SetVariable UnCropH "(Clamp(#UnCropH#+3,0,48))"]#U#
ActionList2=Wait #DownPause#|SlideDown|Wait #W#|SlideDown|Wait #W#|SlideDown|Wait #W#|SlideDown|Wait #W#|SlideDown|Wait #W#|SlideDown|Wait #W#|SlideDown|Wait #W#|SlideDown|Wait #W#|SlideDown|Wait #W#|SlideDown|Wait #W#|SlideDown|Wait #W#|SlideDown|Wait #W#|SlideDown|Wait #W#|SlideDown|Wait #W#|SlideDown|Wait #W#|SlideDown|Wait #W#|SlideDown|Wait #W#|SlideDown|Wait #W#|SlideDown|Wait #W#|SlideDown
SlideDown=[!SetVariable IconY "(Clamp(#IconY#+3,0,48))"][!SetVariable SlideH "(Clamp(#SlideH#-3,0,50))"][!SetVariable UnCropH "(Clamp(#UnCropH#-3,0,48))"]#U#
DynamicVariables=1
UpdateDivider=-1
IgnoreWarnings=1

[MeterSlideBack]
Meter=Image
Group=Sliders
W=116
H=#SlideH#
Y=#IconY#
SolidColor=15,55,79,255
DynamicVariables=1

[MeterBottomBar]
Meter=Image
W=116
H=2
Y=50
SolidColor=155,171,249,255

[MeterIcon1]
Meter=Image
Group=Sliders
X=5
Y=#IconY#
ImageName=#@#Images\DriveC.png
ImageTint=200,200,200,255
ImageCrop=0,0,48,#UnCropH#,1
DynamicVariables=1
MouseOverAction=[!SetOption #CURRENTSECTION# ImageTint ""]#U#
MouseLeaveAction=[!SetOption #CURRENTSECTION# ImageTint "200,200,200,255"]#U#
LeftMouseUpAction=["C:"]

[MeterIcon2]
Meter=Image
Group=Sliders
X=10R
Y=#IconY#
ImageName=#@#Images\ControlPanel.png
ImageTint=200,200,200,255
ImageCrop=0,0,48,#UnCropH#,1
DynamicVariables=1
MouseOverAction=[!SetOption #CURRENTSECTION# ImageTint ""]#U#
MouseLeaveAction=[!SetOption #CURRENTSECTION# ImageTint "200,200,200,255"]#U#
LeftMouseUpAction=["Control"]
So first, I changed the MouseOverAction and MouseLeaveAction options on the background meter so they trigger one of the two ActionTimer effects I want. "Slide up and show", or "Slide down and hide".

Then I created the ActionTimer Measure [MeasureSliders] with two ActionListN options. The First, ActionList1 will slide the toolbar up, and the second, ActionList2 will slide the bar down.

The plugin measure itself is pretty simple. I decided it worked pretty well with 20 "steps" and a "wait" of 5 milliseconds between each "step" of 3 pixels. So there are 20 instances of "SlideUp" and "SlideDown" in the measure, and #W# is set to "5".

Each step simply increases or decreases variables for the "Y" of the icons and the sliding background I decided I wanted, and at the same time changes variables for the ImageCrop settings. I use "Clamp" so I don't have to be "exact" with the number of steps and how many pixels each step changes things. You can't ever define "half a pixel", so rather than fight to get things exact, I can just use Clamp to enforce the lower and upper bounds.

I decided on these settings by looking at how many pixels of total change would be required (50 pixels) and just guessing that 20 steps would make for a nice transition. If I divide 50 by 20, I get 2.5. I can't use half-pixels, so I just made the increment +-3, and let the Clamp function take care of any overrun. I ran it once and then tweaked #W# to get the final effect I liked.

At a high level, you want to ask "how long do I want the entire change to take?" If you want the transition to get from the "beginning" to the "end" in say 200 milliseconds, then you need to use settings so that the total of all "waits" in the ActionList adds up to 200 milliseconds or less. Factor in a millisecond or two for each "action" Rainmeter takes as well. Note that this will never be "exact", as there can be some tiny, impossible to quantify "delays" that happen between actions if Rainmeter is "busy" doing something else at that precise instant.

The goal is to have enough "steps" to be as "smooth" as possible, while also being as "fast" as desired. Don't assume that to "move" or "change" something 200 units (pixels, color, whatever) means you need 200 "steps". First, getting that to be "fast" enough is going to be hard and relatively "CPU expensive", and second, the human eye really doesn't need tons and tons of incremental changes to see it as "smooth". Don't forget that an actual movie is only 24 frames per second, a good video game maxes out around 60 frames per second, and those work perfectly well.


I added an initial "pause" of one second before the "slide down" effect starts, and made sure my #U# "update" variable also updates the ActionTimer measure as well as the meters, so the ActionTimer measure always has the most current value for variables as it is doing those formulas.

Now I end up with my desired:
slide.gif
I have added this example skin to the .rmskin in the first post of this thread
You do not have the required permissions to view the files attached to this post.
User avatar
exper1mental
Posts: 269
Joined: January 9th, 2013, 7:52 pm
Location: Clemson University

Re: ActionTimer 0.1 [Beta]

Post by exper1mental »

I manually installed the plugin and demo skins on Rainmeter 3.2.1 and they are running like a charm! :D

This plugin makes me feel like its Christmas in July :p I look forward to "playing" with my new toy and applying to my WIPs.
Image
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ActionTimer 0.1 [Beta]

Post by jsmorley »

exper1mental wrote:I manually installed the plugin and demo skins on Rainmeter 3.2.1 and they are running like a charm! :D

This plugin makes me feel like its Christmas in July :p I look forward to "playing" with my new toy and applying to my WIPs.
Ah, I'm glad you caught that. There is no need to require Rainmeter 3.3 to use the plugin, and I have fixed the .rmskin in the first post.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: ActionTimer 0.1 [Beta]

Post by moshi »

just gave it a first try.

it's nice, but imho it should only be used with mouse actions. i noticed when i have the ImageFade example running, that during the fading Rainmeter does not respond.

for most people it's probably not an issue, but i interact with my skins (mouse-over, click, etc.) and a permantly running ActionTimer skin would be pretty annoying in my setup.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ActionTimer 0.1 [Beta]

Post by jsmorley »

moshi wrote:just gave it a first try.

it's nice, but imho it should only be used with mouse actions. i noticed when i have the ImageFade example running, that during the fading Rainmeter does not respond.

for most people it's probably not an issue, but i interact with my skins (mouse-over, click, etc.) and a permantly running ActionTimer skin would be pretty annoying in my setup.
I agree moshi. I think it is quite useful for "transitions" when some value changes or a value target is matched in a skin, or for short animations on a mouse action, but I think it will be both annoying and relatively "expensive" to do constant animations in a skin.

As you noted, one of the more "expensive" things you can do is to hammer Rainmeter with skin "redraws" when you are doing a transition (a fade or whatever) on a large image. Resizing images when W and H is set on an image meter is done on each redraw of the skin, and while this plugin is never literally "blocking", it can "monopolize" the message queue Rainmeter uses, and cause some lag in reacting to other messages from the OS, like mouse clicks. While it is going to be very tempting to do "sideshow" skins using this, doing a slideshow with transitions using large wallpaper size images is going to be tricky to keep light and responsive.

Almost nothing else in Rainmeter is as expensive as hammering the skin with redraws every few milliseconds when you are manipulating an image of 1920 pixels and displaying it at 300 pixels. Rainmeter will work insanely hard to keep up with that. While that is fine once in a while, having a skin that is constantly fighting that battle is going to perform poorly.

As an aside, another thing to keep in mind is that while this will likely mostly be used for transitions and animations, where the goal is to run something "faster" than the skin update cycle, it can also be used as a way to have a "delay" between actions of some kind. You can't always depend on it being easy to use UpdateDivider and the values of counter measures and such to drive "timing" for things, and this is another arrow in the quiver. There will be times when it might be useful to say "do this, then wait 15 seconds, then do that". Think of the elusive "sleep" for Rainmeter...