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.

75 lines
1.7KB

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