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.

116 lines
2.8KB

  1. // ----------------------------------------------------------------------
  2. //
  3. // Copyright (C) 2010 Fons Adriaensen <fons@linuxaudio.org>
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation; either version 2 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. //
  19. // ----------------------------------------------------------------------
  20. #ifndef __ROTARY_H
  21. #define __ROTARY_H
  22. #include <cairo/cairo.h>
  23. #include <cairo/cairo-xlib.h>
  24. #include <clxclient.h>
  25. class RotaryImg
  26. {
  27. public:
  28. XftColor *_backg;
  29. XImage *_image [4];
  30. char _lncol [4];
  31. int _x0;
  32. int _y0;
  33. int _dx;
  34. int _dy;
  35. double _xref;
  36. double _yref;
  37. double _rad;
  38. };
  39. class RotaryCtl : public X_window
  40. {
  41. public:
  42. RotaryCtl (X_window *parent,
  43. X_callback *cbobj,
  44. RotaryImg *image,
  45. int xp, int yp,
  46. int cbind = 0);
  47. virtual ~RotaryCtl (void);
  48. enum { NOP = 200, PRESS, RELSE, DELTA };
  49. int cbind (void) { return _cbind; }
  50. int state (void) { return _state; }
  51. double value (void) { return _value; }
  52. int keymod (void) { return _keymod; }
  53. int button (void) { return _button; }
  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. #endif