Old 04-26-2015, 12:05 PM   #1
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 3,964
Default Scripts (EEL): Prevent UI Refresh for Custom Actions

Hi !

Have you ever build some custom actions (main section, not MIDI editor) that are not fluid (jumpy cursor, jumpy item editing, track insertion or things like that) ?

I have a solution for you!

Video Demo/Tutorial:
http://take.ms/CQ9w2

Notes:
To do that, I use two scripts:
  • Prevent UI Refresh.eel
  • Prevent UI Refresh Restore.eel
They are in my scripts collection, in Various scripts folder( link in my signature).


This was simple (it is one function/one effective line scripts), but I'm pretty sure it can be useful with some custom actions, or other particular cases.
When my Lua functions break, I used to restart REAPER everytime. Not need anymore: I just have to execute the Prevent UI Refresh Restore script


Cheers !


(note: for the custom action in the demo, that for sure, it will be better in full script. In fact, I rarely use it, I don't even remember when I needed that).

Last edited by X-Raym; 05-18-2015 at 01:01 AM.
X-Raym is offline   Reply With Quote
Old 04-26-2015, 04:47 PM   #2
Triode
Human being with feelings
 
Triode's Avatar
 
Join Date: Jan 2012
Posts: 323
Default

Works a charm

Thanks for curing the jitters!
__________________
Brush and Beater Drums Online: www.outoftheboxdrums.co.uk
Triode is offline   Reply With Quote
Old 04-26-2015, 05:08 PM   #3
Triode
Human being with feelings
 
Triode's Avatar
 
Join Date: Jan 2012
Posts: 323
Default

It doesn't work on some of my scripts. For instance this one:

Prevent UI Refresh
SWS: Save current track selection
Track: Select All Tracks
SWS: Vertical zoom to selected track(s), minimize others
SWS: Restore saved track selection
Prevent UI Refresh Restore


Also what happens if you use this pair of scripts in nested scripts so that you get two Prevents occurring and then two restores? I think I might be seeing some strange partial restore behaviour.
__________________
Brush and Beater Drums Online: www.outoftheboxdrums.co.uk
Triode is offline   Reply With Quote
Old 04-26-2015, 05:26 PM   #4
Breeder
Human being with feelings
 
Join Date: Nov 2010
Posts: 1,809
Default

Quote:
Originally Posted by Triode View Post
Also what happens if you use this pair of scripts in nested scripts so that you get two Prevents occurring and then two restores? I think I might be seeing some strange partial restore behaviour.
And that's why I believe this function (PreventUIRefresh) uses integer instead of boolean.

So calling PreventUIRefresh(1) twice will work all right if you call PreventUIRefresh(-1) twice (or PreventUIRefresh(-2) once ) after that. It seems that the important thing is that you set internal counter back to 0 after you're done with it (consequently, UI will not refresh until that counter is set to 0)

Quote:
Originally Posted by Triode View Post
It doesn't work on some of my scripts. For instance this one:
Prevent UI Refresh
SWS: Save current track selection
Track: Select All Tracks
SWS: Vertical zoom to selected track(s), minimize others
SWS: Restore saved track selection
Prevent UI Refresh Restore
I think that's purely due to the way these SWS actions work (I guess SWS: Vertical zoom to selected track(s), minimize others is at fault here)...nothing you can do about it really except find the action at fault, report it on our GitHub issue tracker and hope someone takes a look

Last edited by Breeder; 04-26-2015 at 05:33 PM.
Breeder is offline   Reply With Quote
Old 04-26-2015, 06:39 PM   #5
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 3,964
Default

@Breeder
Thank you for you support
I would have thought it was a problem with my scripts, and I wouldn't be able to debug that.
A one line script with a problem... that would be a shame ^^


@Triode

Hi, thank you for your comments
I guess Breeder gave you satisfying answers, with even more SWS related precisions than I could provide :P

Some notes :
  • Quote:
    It doesn't work on some of my scripts.
    Actually, this is not a script, it is just a custom action (aka macro)
  • If you want PreventUIRefresh inside a script (not a custom action / macro), you may just add PreventUIRefresh(1) and (-1) at the top and bottom of your script, rather than create a custom actions that encapsulate the script with my PreventUIRefresh script.
  • I didn't test it with a lot of custom actions as there is not a lot of things to test, let us know if you have any other problems.
X-Raym is offline   Reply With Quote
Old 04-27-2015, 02:08 PM   #6
Triode
Human being with feelings
 
Triode's Avatar
 
Join Date: Jan 2012
Posts: 323
Default

ah yes I mean it doesn't work in all my macros.
Ta breeder yes that makes sense.
If there was a script that did the job of my macro above then maybe it would be possible to circumvent the SWS issue. Is it easy for those in the know? ¿
__________________
Brush and Beater Drums Online: www.outoftheboxdrums.co.uk
Triode is offline   Reply With Quote
Old 06-06-2016, 10:49 AM   #7
EpicSounds
Human being with feelings
 
EpicSounds's Avatar
 
Join Date: Jul 2009
Posts: 3,982
Default

is there a trick to getting this working with cycle actions?
__________________
REAPER Video Tutorials, Tips & Tricks and more at The REAPER Blog
EpicSounds is offline   Reply With Quote
Old 06-06-2016, 11:10 AM   #8
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 3,964
Default

This doesn't work anymore since a recent REAPER update.
X-Raym is offline   Reply With Quote
Old 12-03-2016, 01:07 AM   #9
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,011
Default

Has the PreventUIRefresh function itself been broken?

(I experimented a bit with PreventUIRefresh in Lua but it doesn't seem to do anything.)
juliansader is online now   Reply With Quote
Old 12-03-2016, 06:42 AM   #10
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 3,964
Default

These scripts doesn't work because a post 5.0 REAPER updates put a prevention system for "orphelin" prevent UI refresh not resolve in a scripts (for eg, if you script broke before the PreventUIRefresh(-1) call, the interface will be buggy, untill you call PreventUIRefresh(-1) yourself. The fix aims to prevent that.
X-Raym is offline   Reply With Quote
Old 12-04-2016, 05:50 AM   #11
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 3,964
Default

@TonE
I just said it can't work anymore. :/
X-Raym is offline   Reply With Quote
Old 06-12-2017, 10:00 AM   #12
Triode
Human being with feelings
 
Triode's Avatar
 
Join Date: Jan 2012
Posts: 323
Default

My recent thoughts on this. I'm now finding Prevent UI Refresh (off and on) works even with SWS actions *if I'm in playback*. I wonder if it's possible to tweak the script (without calling playback but something else) so that the conditions are similar to make this script work again...
__________________
Brush and Beater Drums Online: www.outoftheboxdrums.co.uk
Triode is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:58 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.