useUndoManager. How does it work?



  • I noticed that theres a 'useUndoManager' setting in properties. Is it possible to make an undo button on the UI for effects plugins?



  • @SteveRiggs As simple as this 🙂

    HiseSnippet 1101.3ocsW8taaaCDmxIbsVYNncaeZ6KB8KyFq0P14OsE8CyyNICFcNwXtsnEEXELRz1DQhTUhJMFAAXOJ6QXuAaOJ6QXuAaGkjsnaccks2jALzcj2u6GOcG4w9gBGZTjHDYT9YSBnHiOGOXBWNtyXBii5dDxXWbORjjFZkpp8j.RTD0EYXr0OpTXTdaTxye+8sIdDtCMWEB8BAyg9SLelLWa+VOk44cBwk9Llu1r2uUWGAuivSDC7YKrMJf3bAYD8ThZZkvHiO6XWlTDNPRjzHjw1sEtSFLV7Nd57eAKhctGUIz.M..JU8IBOWEiUZQcFy7b6OccGg.T5mGE1JMJ7U3dLW1L84Qi6jLfUtE5wCiRKidM9zzydQzyPidamRu6hG3DxBj4in31N3tb3C0PB7IPmVoyEU5aKg6HfYvk08IWPOIDDlYQ0Cssuu0A110dREyzeLtGiSsFFycjLA2Rvi4th1RtBkPgWUGgeffC3ceqKIdwzZULuthoE7vFZUMUEnnrRyw7Q.X0UHTU4BktapXdC75TRMhJ6LEwp2KyW2qV8Hk9DO1g34cNjST88oxxHcHs.jt7GkwJyKFiybzGiwyyiZOQihmJjzy3UqYdsYYyaLsd+gFNbgikAkGMbgCqptBWlgU4w9mSCmFHlNQHMa973cJVdrSZTQahBdWNSdV.MSVuPb5pd5n1nYKVcU4qQcsIKsELsbUeXgDJ6qFTRc6roCSUlTPsaVAU6XoTvQLfikwoBMPIQG8M0Pqf4M2Ly2aELefGykFlX9svOkKNuwlXbyMw3hP66jYLTActns3pDy2AOUboje6TH9h47eenNKAjJ3bEyfAarKffKQRPFuFe390gmgem5+G2A9auy9uQFgdd2iTNA14MKgCRBCngRlpTx3H5kvIhoaiWFeDM5BoH.YXNaeDHDtjrhrMQPWoVPOv.glnd4afU16Xtxw4QqW0JhbIsKueHE1MRcL.KpmvGb.IDrwnDpfdLai1TO9GnLO90anGwEnt6pYX+mup0jbG8KshinOGnUOBG5NHb0wtoF1VuUC6VaN16ogcv0a.1KnbNGYzK0Qd3Fhrd732BzP9W2Tj0iFH8ng0nOAx2pf6RbkdhQN98eaKeRRNaYPhIo9P02WhaX1zbOy8MOv7PyGZ9HyGiJz5qPazjyjeWpwj+JXQqzOroNn0RgarGQNe+lplryF.N7dtF6TMuwiXxI5MguBMgZW3djKJcuKtOS5Ldw7szB3KrM4+27Mqk9J3iGNj5HyI613Sd451+9JPkeVDKY7Q8HxPlJg7zX+AvMbbn.S3bpWjJIsj5zsTYakrJxLfxcSD9G3IavFJYirAaLcPjOwIT7FmziGUWZ31IZ.NwSt6TY3RbfrU9ogX651He3tLuwwQEJd.v8EaSy0vl8VCa1eMr4f0vlCWCad3ZXyiVpMpqQ9CwRgeZYBnn+wI8MXXbLm.YYIYjn+k44YQH
    


  • @ustk So can this be used as A/B comparsion? How about using "redo button as A" and "undo button as B"?



  • @Fortune said in useUndoManager. How does it work?:

    @ustk So can this be used as A/B comparsion? How about using "redo button as A" and "undo button as B"?

    I don't think so, because:

    • undo/redo is about one parameter change at a time
    • A/B is about many changes at a time


  • @ustk Wow. Mega simple! Thanks man. Great example 🙂



  • @ustk said in useUndoManager. How does it work?:

    @Fortune said in useUndoManager. How does it work?:

    @ustk So can this be used as A/B comparsion? How about using "redo button as A" and "undo button as B"?

    I don't think so, because:

    • undo/redo is about one parameter change at a time
    • A/B is about many changes at a time

    No, it's not for one parameter. It's for all of the undo/redo enabled parameters. You can change multiple parameters with undo & redo. You can try it.



  • @Fortune For all enabled parameter of course (that's what I did in the snippet), but one by one.
    If you change knob1 value, then knob2 (so two changes), you'll need to click twice UNDO to recover the previous settings. Like any undo in any software, you need to click as many times as you want to go back in time... You cannot click only one time to change all parameters at once (that's what A/B aims to)



  • It does coallescate simultaneous events into one action, but using it for an A/B scheme is a nasty hack.



  • @Christoph-Hart said in useUndoManager. How does it work?:

    It does coallescate simultaneous events into one action, but using it for an A/B scheme is a nasty hack.

    So how would you do that? not for an A/B use, but I'm curious on how to undo/redo several parameters at once using these methods, that's counter-intuitive with general undo/redo behaviour 🤔
    In my (simple) snippet, it does it one by one...
    I can see a hack for A/B using undo/redo but it's nasty (certainly more than one of yours 😀 )



  • What it basically does is to run a timer that is executed every 500ms (or something like that) and coallescate undoable actions that appear in that time frame into one undoable action. Otherwise you would have to press Cmd+Z 20 times if you moved a slider.

    Normally this time is short enough to not coallescate different parameter changes.

    That's all done behind the scenes and is the same way the undo manager in script node and the interface designer works.



  • @Christoph-Hart Ok so that's useful for many values in one unique component (like sliderpacks), but obviously not for several components at once



  • If you think about it it still is: if you have some sort of macro button that isn't connected to the undo management system, but changes 8 parameters at the same time, you still would expect that they are being undoed with one Cmd+Z keypress.

    There's literally no scenario except for when you're monkeying around on your UI where this becomes an actual problem, but solves countless edge case things - believe me, it was implemented differently and it was buggy as hell.



  • @Christoph-Hart Yeah I believe you 🙂
    I was more thinking of the user moving parameters side than macro/behind the scene case



  • @Christoph-Hart For an A/B comparison, I was thinking of using preset save/load via script, but we are hitting the validation window problem as soon as you want to overwrite the A or B preset...
    Maybe an array containing all values combined with component.changed() would do it for an A/B?



  • @Fortune this snippet works as a compare A and B, but is only for those parameters you assign to the function, I have 2 buttons and 2 knobs in this example and it seems to work, but storing floating tiles values like the velocity etc in an arpeggiator it will be more complicated I guess
    And this is not comparing a preset from the preset manager and modified settings, but maybe it suits your purpose, I don't know.
    For comparing you have to press the "SnapShot" button and then start modifying the settings.
    With the Compare button" you will be able to flip between the A and B

    HiseSnippet 1324.3ocsX0saaaCElJIJswatXAX.6VNewfMZlibVa2.xxlicRFLZShwbVPABZ6Xjni4hDofDcSLBBPez1dS1ivdC1NThxR1VN9m05KB.4gmy4iemORcXZGHroggh.jwFmMvmhL9byNC3xdM6QXbTqCPFaZZK77IAT79XB2A2.0XfOILj5fLLV8WTKyXi0PQ+9metAwkvsooSgPmKX1zWw7XxzYaW+kLW2iHNzyXdYV8y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0GyLMY4dZ6o2ljISCGX33Y4fEIKSe+rPYYs4PVkln+1OSh9v0iDIy4QgcaVXNRnXgGK7f.QBfoMVIajeTbjKpi7qHWRciB7SxNSVZ+CWjI3.6LZAt9uOQA9mpKo2JUOsT2aZ0pUQKNF1YZb0hfguJg3ia5oitEH3EoS7BK3cdBm9tD4nO9S8hWsA395Qdkk5kT7PlbP1WDu.uHzZtev57B2MMayj18xGuqjCdgai9TiW86qKZdX2tvG3SA6ZlG85k8wzK.T9UQeU2NGSjALPQYdReuNPuu1T.IbN0MTc3dE086wisTiULSGJ2IZv+B+zFqoFanMVKwHxiXGHdmc7GHTuf+wQy.XhG8OxXCyiUiwIe8xvzzppExi4vdmsshJ9V.646yNKgOe2R3yyVBed9R3yKVBe99kvme3A8Q8+zY+9RgW7wDXh1GF84YCiC4DPkEoHQ+GuqzG+B
    


  • @Fortune I forgot to use the .changed() formula 🙂
    Here's an updated version

    HiseSnippet 1588.3ocsY80iSaDD2937URfTApUp8ws4gpDAjymK+ohqW4H2co5DbPZCE0JDP2XuIYKN65ZuginSmDeW52j9d+Nvi8w9Re95r9+NwNwD3LRP1c1Yledle63cV55xMIddbWE0JOYpCQQ8xZ8lxDi1aDlxTNbeE0uTaO9XGrKAceDlYgZibbIdDgR6oNXOOhkhp5E9A4pUqrth+y+du1XaLyjjLkhxS4TSxCoiohjY6t6Cn11cvVjmPGmZ02b2CM4r8317I.xtflthC17U3gjGgkKaMME0MNvhJ3t8DXAwSQc81bqo8FwOlEr9mR8n8sIxAaozCLTvzc31VRDKmUYuQTaqtQQ.OEvJcShGWHHd74ZGQsnwymDWthu.ThFoiGpqsH3sUZ3oWd3olBdqG.uqp0yzk5HRjHw1kzNjIHtCvPJHMrBVqxZe1kgjJrBln0X7qHcbgAwZz3155WGcKc8laWqZspPhvSfdM1E8.V+sdJ1dBAsCJR8gDgjdvYvfF0iWQcotYzzXoZZjmlsErk3y3ULulFKUyT9rV0M2DgtQxSZi0E6BLOH.839+NwT3A17YEG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X2oQ0CRr8mDX6Zg19g39DaeS+oomoXREalvBjdlMr786J64QdyVgGQtUqVq.FJlt8dfguH9xz7O3UuvigUN3bIs3FMKhP91eb4zjHrjoNZI8twrdOCI8816QUhi89EK16wsJV3lQqx680zTh5VCDtgxwmcVX00RBkEGH9PfxYgPY9656JZGwslXiEYuFR4cuFJ.9Nel66SdmdLOpXZ5udctb2jkEtWUqKUXNJe7tVN3E9R04MdCuo2ZZGLX.bfvDvttVme47+ZcU9I9D4gpOBKbo.gR6QSF2CXClD.ILFwVdVL00jryfw5xwxHSOByxe.vYNKT3VxwpgB2JRnxXroK+klAGdPdWxWzeF.SL+qTuh1Qxwn3S6noo2RWYL0h9RSSYn3F.1yWGiUPmuYEz4lqfN2ZEz41qfN2YEz4aWnNx+2Et+DAebv1DXhtG3ezMU0CXXfk4yHU9e.iud9y.
    


  • @ulrik Thank you! I really appreciate that. However it gives error in my system "API couldn't found" I am using the latest Hise build.



  • @Fortune hmm, strange...
    try this:

    HiseSnippet 1807.3ocuYssaaaDDkz1LMRNtIAnOzG2nGBjPhkoYykh35Xa4KEFINQsJMnEA4BE4JoMgZoJ4p33ZXf7Gzeg9sTj9ezm6S8OvcVt7xRJRIYYmxGDD2cmcNyLmY1KromqE1220SQszyNZ.VQ8JZsNhx5scOSBUY+cTT+Zssc6OvzCi1BYRsQMPC7v9XlRiiFX56isUTUm+64iVszBJAO+6FMLcLoV3jlTTdtKwB+XReBKo0la9Hhiydl13mQ5KM56r49VtzsccbGBHadMckAlVuyrK9Il7gMmlh5k10lvb8ZwLYXeE0EZ3ZeTqdtGREi+4DeRaGL+kUUZASjn48bcr4Hl2px18HN1Mi7.9JvrzLweLuve7UZGPrIwsm3WtVPGnDIj8GpyMN3spL7zmd3oJAuEDv65Zsr7HCXI8vw1hZ6SYXuNlPHPFVhwpLW0qBAUXDTV89luCumG7RrDUumt9sQ2UWu1ZKUdoxDpkyPab0JaC9dOylf8y9Q2gLBEW+s9UDCZoxP7xmgduoG5Qz1q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