elanhickler

user input class interface idea

Oct 4th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.76 KB | None | 0 0
  1. String Action_TestDialog()
  2. {
  3.     /* Declare a user input dialog */
  4.     UserInputDialog Dialog("CycleMarkFinder");
  5.  
  6.     /* Declare some user input fields */
  7.     UserInputField
  8.         Algorithm("Algorithm"),
  9.         Precision("Precision"),
  10.         Lofreq("Low Freq"),
  11.         HiFreq("High Freq");
  12.  
  13.     /* Delcare some user input buttons */
  14.     UserInputButton
  15.         Run("Run"),
  16.         DeleteMarkers("Delete Markers");
  17.  
  18.     /* Add the fields to dialog */
  19.     // Output a pointer from these functions
  20.     Dialog.addFields({
  21.         Algorithm.makeDropdown(0, {"Normal", "Refined"}), // default, menu items
  22.         Precision.makeField(8), // default
  23.         LoFreq.makeSlider(0.0, 10000.0, 20.0), // default/min/max
  24.         HiFreq.makeSlider(0.0, 10000.0, 1000.0), // default/min/max
  25.         // sliders are not crucial if it's too annoying right now
  26.         // also, is it possible to give sliders a callback so they,
  27.         // for example, run some code to update something in REAPER?
  28.     });
  29.  
  30.     /* Add buttons */
  31.     // just stack these horizontally at the bottom
  32.     Dialog.addButtons({
  33.         Run, DeleteMarkers,
  34.     });
  35.  
  36.     Run.setCallback([&]()
  37.     {
  38.         /* Xen, do you know how to determine type
  39.         by return type? I've done it before. Not crucial.
  40.         I think you have to do a new function for each return
  41.         type: double, int, string, bool */
  42.         int algo = Algorithm.getValue();
  43.         int precision = Precision.getVaue();
  44.         double lofreq = LoFreq.getValue();
  45.         double hiFreq = HiFreq.getValue();
  46.  
  47.         /* do stuff with values */
  48.  
  49.         return "status";
  50.     });
  51.  
  52.     DeleteMarkers.setCallback([&]()
  53.     {
  54.         /* do stuff */
  55.  
  56.         return "status";
  57.     });
  58.  
  59.     Dialog.runGUI();
  60. }
Advertisement
Add Comment
Please, Sign In to add comment