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.

48 lines
1.4KB

  1. #pragma once
  2. #include "Fl_Osc_Widget.H"
  3. #include <functional>
  4. #include <vector>
  5. #include <rtosc/rtosc.h>
  6. class Osc_ListModel:public Fl_Osc_Widget
  7. {
  8. public:
  9. Osc_ListModel(Fl_Osc_Interface *osc_)
  10. :Fl_Osc_Widget("", osc_), list_size(0)
  11. {
  12. assert(osc);
  13. }
  14. typedef std::vector<std::tuple<std::string, std::string, std::string>> list_t;
  15. list_t list;
  16. std::function<void(list_t)> callback;
  17. unsigned list_size;
  18. void update(std::string url)
  19. {
  20. if(!ext.empty())
  21. osc->removeLink(this);
  22. ext = url;
  23. oscRegister(ext.c_str());
  24. }
  25. //Raw messages
  26. virtual void OSC_raw(const char *msg)
  27. {
  28. std::string args = rtosc_argument_string(msg);
  29. if(args == "i") {
  30. list_size = rtosc_argument(msg, 0).i;
  31. list.clear();
  32. list.resize(list_size);
  33. } else if(args == "isss") {
  34. int idx = rtosc_argument(msg,0).i;
  35. std::get<0>(list[idx]) = rtosc_argument(msg,1).s;
  36. std::get<1>(list[idx]) = rtosc_argument(msg,2).s;
  37. std::get<2>(list[idx]) = rtosc_argument(msg,3).s;
  38. if(idx == (int)list_size-1 && callback)
  39. callback(list);
  40. }
  41. }
  42. };