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_Check.cpp 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "Fl_Osc_Check.H"
  2. #include "Fl_Osc_Interface.h"
  3. #include "Fl_Osc_Pane.H"
  4. #include <cstdlib>
  5. #include <cstring>
  6. #include <cmath>
  7. #include <cassert>
  8. #include <sstream>
  9. Fl_Osc_Check::Fl_Osc_Check(int X, int Y, int W, int H, const char *label)
  10. :Fl_Check_Button(X,Y,W,H,label), Fl_Osc_Widget(this), is_osc(false), cb_data(NULL, NULL)
  11. {
  12. Fl_Check_Button::callback(Fl_Osc_Check::_cb);
  13. }
  14. Fl_Osc_Check::~Fl_Osc_Check(void)
  15. {}
  16. void Fl_Osc_Check::OSC_value(bool v)
  17. {
  18. value(v);
  19. is_osc = true;
  20. if(cb_data.first)
  21. cb_data.first(this, cb_data.second);
  22. is_osc = false;
  23. }
  24. void Fl_Osc_Check::init(std::string path, char type)
  25. {
  26. this->ext = path;
  27. this->type = type;
  28. oscRegister(path.c_str());
  29. }
  30. void Fl_Osc_Check::cb(void)
  31. {
  32. //Order is significant for takeback style callbacks
  33. if(cb_data.first)
  34. cb_data.first(this, cb_data.second);
  35. if(type == 'T')
  36. oscWrite(ext, value() ? "T" : "F");
  37. else {
  38. if(type=='c')
  39. fprintf(stderr, "invalid `c' from checkbox %s%s, using `i'\n", loc.c_str(), ext.c_str());
  40. oscWrite(ext, "i", value());
  41. }
  42. }
  43. void Fl_Osc_Check::callback(Fl_Callback *cb, void *p)
  44. {
  45. cb_data.first = cb;
  46. cb_data.second = p;
  47. }
  48. void Fl_Osc_Check::_cb(Fl_Widget *w, void *)
  49. {
  50. static_cast<Fl_Osc_Check*>(w)->cb();
  51. }