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.

Fl_Osc_ListView.cpp 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #include "Fl_Osc_ListView.H"
  2. #include <cstdio>
  3. #include <rtosc/rtosc.h>
  4. Fl_Osc_ListView::Fl_Osc_ListView(int x,int y, int w, int h, const char *label)
  5. :Fl_Browser(x,y,w,h,label), data(0)
  6. {}
  7. Fl_Osc_ListView::~Fl_Osc_ListView(void)
  8. {
  9. delete data;
  10. };
  11. void Fl_Osc_ListView::init(const char *path_)
  12. {
  13. Fl_Osc_Pane *pane = fetch_osc_pane(this);
  14. assert(pane);
  15. osc = pane->osc;
  16. loc = pane->base;
  17. assert(osc);
  18. path = path_;
  19. data = new Osc_SimpleListModel(osc);
  20. data->callback = [this](Osc_SimpleListModel::list_t l){this->doUpdate(l);};
  21. data->update(loc+path_);
  22. }
  23. void Fl_Osc_ListView::doUpdate(Osc_SimpleListModel::list_t l)
  24. {
  25. this->clear();
  26. for(int i=0; i<(int)l.size(); ++i) {
  27. this->add(l[i].c_str());
  28. }
  29. }
  30. void Fl_Osc_ListView::update(void)
  31. {
  32. data->update(loc+path);
  33. }
  34. void Fl_Osc_ListView::insert(std::string s, int offset)
  35. {
  36. assert(offset);
  37. data->list.insert(data->list.begin()+offset-1, s);
  38. data->apply();
  39. //fprintf(stderr, "UNIMPLEMENTED\n");
  40. }
  41. void Fl_Osc_ListView::append(std::string s)
  42. {
  43. data->list.push_back(s);
  44. data->apply();
  45. }
  46. void Fl_Osc_ListView::doMove(int i, int j)
  47. {
  48. assert(i);
  49. assert(j);
  50. auto &list = data->list;
  51. std::string value = list[j-1];
  52. list.erase(list.begin()+j-1);
  53. list.insert(list.begin()+i-1, value);
  54. //std::swap(data->list[i-1], data->list[j-1]);
  55. data->apply();
  56. }
  57. void Fl_Osc_ListView::doRemove(int offset)
  58. {
  59. assert(offset);
  60. data->list.erase(data->list.begin()+offset-1);
  61. data->apply();
  62. }
  63. void Fl_Osc_ListView::sendUpdate() const
  64. {
  65. }