Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Feature Requests

Reply
 
Thread Tools Display Modes
Old 05-15-2020, 02:51 AM   #1
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default API to get what was changed with the last action (better GetProjectStateChangeCount)

EDIT: Old title:
API: GetProjectStateChangeCount to return undo flags

It would be super-useful to know not only if something got changed in the project but also a hint to what it was (if not exactly what it was).

So, a second return value to show the flags for undo:
Code:
1: track configurations
2: track FX
4: track items
8: project states
16: freeze states

integer, flags = reaper.GetProjectStateChangeCount(ReaProject proj)
returns an integer that changes when the project state changes, and the undo flags associated with the change
Edit: New proposal at post #5
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 08-30-2020 at 04:25 PM. Reason: changed title
amagalma is offline   Reply With Quote
Old 05-15-2020, 07:57 AM   #2
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,629
Default

I would prefer to enumerate the last x undostates, like

Code:
integer undoflags, string descchangename, string undo_statechunk_snippet =  reaper.Undo_GetState(integer idx)

parameters:
integer idx - the index of the undostate with 1 for the most recent

retvals:
integer undoflags - the undoflags set for this undostate
string descchangename - the "name" of the undostate, as shown in the undo-list/set by descchange in Undo_EndBlock
string undo_state_information - the change made by this undo-state, as shown by the context menu "Undo state information" in the Undo history-list.
This would be more versatile, especially, as you would probably want to know other undostates as well.

It would also allow us writing scripts, who analyze the undo-states and get all undostate-names, so Undo_OnStateChangeEx2 would benefit from it as well.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 05-16-2020, 10:36 AM   #3
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

This would be super! Especially the Undo Differences snippet!

I would prefer the enumeration to start with 0 for the last undo. 1 for the previous one, 2 for the previous before the previous etc
We might require a CountUndoStates function too..

But really, I would only care for the last undo. A function that returned the flags and the changed chunk snippet would be super for me! The name of the undo we can get it already with Undo_CanUndo2.

So, something like this would be super efficient for my needs:
Code:
integer undoflags, string undo_statechunk_snippet = reaper.Undo_GetLastUndoState(ReaProject proj)
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-16-2020, 04:25 PM   #4
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,629
Default

But sometimes, scripts produce numerous undo-states, as per behavior of some functions. So if your script creates one undo-state you're interested in and after that another one, getting the last undo-state would only give you the other one, not the one you were interested in. Getting more undo-states would give you full control, so some kind of index would be needed for that. Even if it's only optional with nil being the last one.

Code:
integer undoflags, string undo_statechunk_snippet = reaper.Undo_GetLastUndoState(ReaProject proj, optional integer undoindex)
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 08-13-2020, 05:01 AM   #5
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

I am still thinking about this.. I am trying to create a Track Edit Groups script like in Pro Tools and I greatly need this to speed up things..

Would something like this make sense? :

Code:
integer changed_objects_count = reaper.CountLastUndoChanges(ReaProject proj)
returns the number of reaper objects that changed in the last undo
Code:
*void pointer, string "ctypename", string str = reaper.GetLastUndoChangeDetails(ReaProject proj, integer idx)

returns the pointer and type of object that changed with the last action, associated with the idx number.
Supported types are: "MediaTrack*", "MediaItem*", "MediaItem_Take*", "TrackEnvelope*" and "PCM_source*"
str holds the relative RPPXMLstate line(s) that changed
What do you think?
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 08-13-2020 at 05:07 AM.
amagalma is offline   Reply With Quote
Old 02-26-2021, 09:12 AM   #6
vitalker
Human being with feelings
 
vitalker's Avatar
 
Join Date: Dec 2012
Posts: 13,333
Default

+1 from me
vitalker 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 03:00 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.