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.

rotary.h 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // ----------------------------------------------------------------------
  2. //
  3. // Copyright (C) 2010-2012 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 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 int _wb_up;
  59. static int _wb_dn;
  60. protected:
  61. X_callback *_cbobj;
  62. int _cbind;
  63. RotaryGeom *_rgeom;
  64. int _state;
  65. int _count;
  66. int _range;
  67. double _value;
  68. double _angle;
  69. void render (void);
  70. void callback (int k) { _cbobj->handle_callb (k, this, 0); }
  71. static int _keymod;
  72. static int _button;
  73. static int _rcount;
  74. static int _rx;
  75. static int _ry;
  76. private:
  77. void handle_event (XEvent *E);
  78. void bpress (XButtonEvent *E);
  79. void brelse (XButtonEvent *E);
  80. void motion (XMotionEvent *E);
  81. virtual int handle_button (void) = 0;
  82. virtual int handle_motion (int dx, int dy) = 0;
  83. virtual int handle_mwheel (int dw) = 0;
  84. juce::SharedResourcePointer<x_cairo_t> _cairo;
  85. cairo_t *_cairotype;
  86. cairo_surface_t *_cairosurf;
  87. };
  88. }
  89. #endif