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_VSlider.cpp 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include <FL/Fl.H>
  2. #include <FL/fl_draw.H>
  3. #include "Fl_Osc_VSlider.H"
  4. #include "Fl_Osc_Interface.h"
  5. #include "Fl_Osc_Pane.H"
  6. #include <cstdlib>
  7. #include <cstring>
  8. #include <cmath>
  9. #include <cassert>
  10. #include <sstream>
  11. Fl_Osc_VSlider::Fl_Osc_VSlider(int X, int Y, int W, int H, const char *label)
  12. :Fl_Osc_Slider(X,Y,W,H,label)
  13. {
  14. //bounds(0.0f,1.0f);
  15. Fl_Slider::callback(Fl_Osc_Slider::_cb);
  16. textfont_ = FL_HELVETICA;
  17. textsize_ = 10;
  18. textcolor_ = FL_FOREGROUND_COLOR;
  19. }
  20. Fl_Osc_VSlider::~Fl_Osc_VSlider(void)
  21. {}
  22. void Fl_Osc_VSlider::init(std::string path_, char type_)
  23. {
  24. Fl_Osc_Slider::init(path_, type_);
  25. }
  26. void Fl_Osc_VSlider::draw() {
  27. int sxx = x(), syy = y(), sww = w(), shh = h();
  28. int bxx = x(), byy = y(), bww = w(), bhh = h();
  29. if (horizontal()) {
  30. bww = 35; sxx += 35; sww -= 35;
  31. } else {
  32. syy += 25; bhh = 25; shh -= 25;
  33. }
  34. if (damage()&FL_DAMAGE_ALL) draw_box(box(),sxx,syy,sww,shh,color());
  35. Fl_Osc_Slider::draw(sxx+Fl::box_dx(box()),
  36. syy+Fl::box_dy(box()),
  37. sww-Fl::box_dw(box()),
  38. shh-Fl::box_dh(box()));
  39. draw_box(box(),bxx,byy,bww,bhh,color());
  40. char buf[128];
  41. format(buf);
  42. fl_font(textfont(), textsize());
  43. fl_color(active_r() ? textcolor() : fl_inactive(textcolor()));
  44. fl_draw(buf, bxx, byy, bww, bhh, FL_ALIGN_CLIP);
  45. }
  46. int Fl_Osc_VSlider::handle(int ev)
  47. {
  48. if (ev == FL_PUSH && Fl::visible_focus()) {
  49. Fl::focus(this);
  50. redraw();
  51. }
  52. int sxx = x(), syy = y(), sww = w(), shh = h();
  53. if (horizontal()) {
  54. sxx += 35; sww -= 35;
  55. } else {
  56. syy += 25; shh -= 25;
  57. }
  58. return Fl_Osc_Slider::handle(ev,
  59. sxx+Fl::box_dx(box()),
  60. syy+Fl::box_dy(box()),
  61. sww-Fl::box_dw(box()),
  62. shh-Fl::box_dh(box()));
  63. }