Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.7KB

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. Osc_ListModel.h - OSC List View
  4. Copyright (C) 2016 Mark McCurry
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. */
  10. #pragma once
  11. #include "Fl_Osc_Widget.H"
  12. #include <functional>
  13. #include <vector>
  14. #include <rtosc/rtosc.h>
  15. class Osc_ListModel:public Fl_Osc_Widget
  16. {
  17. public:
  18. Osc_ListModel(Fl_Osc_Interface *osc_)
  19. :Fl_Osc_Widget("", osc_), list_size(0)
  20. {
  21. assert(osc);
  22. }
  23. typedef std::vector<std::tuple<std::string, std::string, std::string>> list_t;
  24. list_t list;
  25. std::function<void(list_t)> callback;
  26. unsigned list_size;
  27. void doUpdate(std::string url)
  28. {
  29. if(!ext.empty())
  30. osc->removeLink(this);
  31. ext = url;
  32. oscRegister(ext.c_str());
  33. }
  34. //Raw messages
  35. virtual void OSC_raw(const char *msg)
  36. {
  37. std::string args = rtosc_argument_string(msg);
  38. if(args == "i") {
  39. list_size = rtosc_argument(msg, 0).i;
  40. list.clear();
  41. list.resize(list_size);
  42. } else if(args == "isss") {
  43. int idx = rtosc_argument(msg,0).i;
  44. std::get<0>(list[idx]) = rtosc_argument(msg,1).s;
  45. std::get<1>(list[idx]) = rtosc_argument(msg,2).s;
  46. std::get<2>(list[idx]) = rtosc_argument(msg,3).s;
  47. if(idx == (int)list_size-1 && callback)
  48. callback(list);
  49. }
  50. }
  51. };