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-2012 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 AT1 {
  27. class RotaryGeom
  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. int cbind,
  47. RotaryGeom *rgeom,
  48. int xp,
  49. int yp);
  50. virtual ~RotaryCtl (void);
  51. enum { NOP = 200, PRESS, RELSE, DELTA };
  52. int cbind (void) { return _cbind; }
  53. int state (void) { return _state; }
  54. double value (void) { return _value; }
  55. virtual void set_state (int s);
  56. virtual void set_value (double v) = 0;
  57. virtual void get_string (char *p, int n) {}
  58. static void init (X_display *disp);
  59. static void fini (void);
  60. static int _wb_up;
  61. static int _wb_dn;
  62. protected:
  63. X_callback *_cbobj;
  64. int _cbind;
  65. RotaryGeom *_rgeom;
  66. int _state;
  67. int _count;
  68. int _range;
  69. double _value;
  70. double _angle;
  71. void render (void);
  72. void callback (int k) { _cbobj->handle_callb (k, this, 0); }
  73. static int _keymod;
  74. static int _button;
  75. static int _rcount;
  76. static int _rx;
  77. static int _ry;
  78. private:
  79. void handle_event (XEvent *E);
  80. void bpress (XButtonEvent *E);
  81. void brelse (XButtonEvent *E);
  82. void motion (XMotionEvent *E);
  83. virtual int handle_button (void) = 0;
  84. virtual int handle_motion (int dx, int dy) = 0;
  85. virtual int handle_mwheel (int dw) = 0;
  86. static cairo_t *_cairotype;
  87. static cairo_surface_t *_cairosurf;
  88. };
  89. }
  90. #endif