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.

81 lines
2.3KB

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