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.

121 lines
2.9KB

  1. // ----------------------------------------------------------------------
  2. //
  3. // Copyright (C) 2010 Fons Adriaensen <fons@linuxaudio.org>
  4. // Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
  5. //
  6. // This program is free software; you can redistribute it and/or modify
  7. // it under the terms of the GNU General Public License as published by
  8. // the Free Software Foundation; either version 2 of the License, or
  9. // (at your option) any later version.
  10. //
  11. // This program is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU General Public License
  17. // along with this program; if not, write to the Free Software
  18. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. //
  20. // ----------------------------------------------------------------------
  21. #ifndef __ROTARY_H
  22. #define __ROTARY_H
  23. #include <cairo/cairo.h>
  24. #include <cairo/cairo-xlib.h>
  25. #include <clxclient.h>
  26. namespace BLS1 {
  27. class RotaryImg
  28. {
  29. public:
  30. XftColor *_backg;
  31. XImage *_image [4];
  32. char _lncol [4];
  33. int _x0;
  34. int _y0;
  35. int _dx;
  36. int _dy;
  37. double _xref;
  38. double _yref;
  39. double _rad;
  40. };
  41. class RotaryCtl : public X_window
  42. {
  43. public:
  44. RotaryCtl (X_window *parent,
  45. X_callback *cbobj,
  46. RotaryImg *image,
  47. int xp, int yp,
  48. int cbind = 0);
  49. virtual ~RotaryCtl (void);
  50. enum { NOP = 200, PRESS, RELSE, DELTA };
  51. int cbind (void) { return _cbind; }
  52. int state (void) { return _state; }
  53. double value (void) { return _value; }
  54. int keymod (void) { return _keymod; }
  55. int button (void) { return _button; }
  56. virtual void set_state (int s);
  57. virtual void set_value (double v) = 0;
  58. virtual void get_string (char *p, int n) {}
  59. static void init (X_display *disp);
  60. static void fini (void);
  61. static int _wb_up;
  62. static int _wb_dn;
  63. protected:
  64. X_callback *_cbobj;
  65. int _cbind;
  66. RotaryImg *_image;
  67. int _state;
  68. int _count;
  69. int _range;
  70. double _value;
  71. double _angle;
  72. void render (void);
  73. void callback (int k) { _cbobj->handle_callb (k, this, 0); }
  74. static int _keymod;
  75. static int _button;
  76. static int _rcount;
  77. static int _rx;
  78. static int _ry;
  79. private:
  80. void handle_event (XEvent *E);
  81. void bpress (XButtonEvent *E);
  82. void brelse (XButtonEvent *E);
  83. void motion (XMotionEvent *E);
  84. virtual int handle_button (void) = 0;
  85. virtual int handle_motion (int dx, int dy) = 0;
  86. virtual int handle_mwheel (int dw) = 0;
  87. static cairo_t *_cairotype;
  88. static cairo_surface_t *_cairosurf;
  89. };
  90. }
  91. #endif