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.

64 lines
1.4KB

  1. #include <cmath>
  2. #include "Fl_Osc_TSlider.H"
  3. //Copyright (c) 2015 Christopher Oliver
  4. //License: GNU GPL version 2 or later
  5. static float identity_ts(float value)
  6. {
  7. return value;
  8. }
  9. Fl_Osc_TSlider::Fl_Osc_TSlider(int x, int y, int w, int h, const char *label)
  10. :Fl_Osc_Slider(x, y, w, h, label), transform(identity_ts)
  11. {
  12. Fl_Group *save = Fl_Group::current();
  13. tipwin = new TipWin();
  14. tipwin->hide();
  15. Fl_Group::current(save);
  16. tipwin->set_rounding();
  17. }
  18. Fl_Osc_TSlider::~Fl_Osc_TSlider()
  19. {
  20. if (tipwin)
  21. delete tipwin;
  22. }
  23. void Fl_Osc_TSlider::set_rounding(unsigned int digits)
  24. {
  25. tipwin->set_rounding(digits);
  26. }
  27. int Fl_Osc_TSlider::handle(int event)
  28. {
  29. int super = 1;
  30. super = Fl_Osc_Slider::handle(event);
  31. switch(event) {
  32. case FL_PUSH:
  33. case FL_MOUSEWHEEL:
  34. if (!Fl::event_inside(x(),y(),w(),h()))
  35. return(1);
  36. tipwin->position(Fl::event_x_root()-Fl::event_x()+x(),
  37. Fl::event_y_root()-Fl::event_y()+h()+y()+5);
  38. case FL_DRAG:
  39. tipwin->showValue(transform(value()));
  40. break;
  41. case FL_RELEASE:
  42. case FL_HIDE:
  43. case FL_LEAVE:
  44. if (tipwin)
  45. tipwin->hide();
  46. return 1;
  47. }
  48. return super;
  49. }
  50. void Fl_Osc_TSlider::set_transform(float (*transformer)(float))
  51. {
  52. transform = transformer;
  53. }