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.

120 lines
2.8KB

  1. // ----------------------------------------------------------------------
  2. //
  3. // Copyright (C) 2010 Fons Adriaensen <fons@linuxaudio.org>
  4. // Modified by falkTX on Jan 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 REV1 {
  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. virtual void set_state (int s);
  55. virtual void set_value (double v) = 0;
  56. virtual void get_string (char *p, int n) {}
  57. static void init (X_display *disp);
  58. static void fini (void);
  59. static int _wb_up;
  60. static int _wb_dn;
  61. protected:
  62. X_callback *_cbobj;
  63. int _cbind;
  64. RotaryImg *_image;
  65. int _state;
  66. int _count;
  67. int _range;
  68. double _value;
  69. double _angle;
  70. void render (void);
  71. void callback (int k) { _cbobj->handle_callb (k, this, 0); }
  72. static int _keymod;
  73. static int _button;
  74. static int _rcount;
  75. static int _rx;
  76. static int _ry;
  77. private:
  78. void handle_event (XEvent *E);
  79. void bpress (XButtonEvent *E);
  80. void brelse (XButtonEvent *E);
  81. void motion (XMotionEvent *E);
  82. virtual int handle_button (void) = 0;
  83. virtual int handle_motion (int dx, int dy) = 0;
  84. virtual int handle_mwheel (int dw) = 0;
  85. static cairo_t *_cairotype;
  86. static cairo_surface_t *_cairosurf;
  87. };
  88. }
  89. #endif