Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
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.

95 lines
2.9KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2008 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. #pragma once
  19. #include <FL/Fl_Widget.H>
  20. #include <FL/fl_draw.H>
  21. #include <FL/Fl.H>
  22. #include <math.h>
  23. #include <vector>
  24. using namespace std;
  25. class Panner : public Fl_Widget
  26. {
  27. struct Point
  28. {
  29. /* axes */
  30. float x, y;
  31. Point ( ) : x( 0.0f ), y( 0.0f ) { }
  32. Point ( float X, float Y ) : x( X ), y( Y ) { }
  33. /* return the distance between the point and that referenced by /p/ */
  34. float
  35. distance ( const Point &p )
  36. {
  37. return sqrt( pow( x - p.x, 2 ) + pow( y - p.y, 2 ) );
  38. }
  39. };
  40. /* channel configuration */
  41. int _ins,
  42. _outs;
  43. vector <Point> _points;
  44. static int pw ( void ) { return 6; }
  45. static int ph ( void ) { return 6; }
  46. static int _configs[][12];
  47. void bbox ( int &X, int &Y, int &W, int &H )
  48. {
  49. W = w() - Fl::box_dw( box() );
  50. H = h() - Fl::box_dh( box() );
  51. X = x() + Fl::box_dx( box() );
  52. Y = y() + Fl::box_dy( box() );
  53. }
  54. Point * event_point ( void );
  55. Point angle_to_axes ( float a );
  56. public:
  57. Panner ( int X, int Y, int W, int H, const char *L = 0 ) :
  58. Fl_Widget( X, Y, W, H, L )
  59. {
  60. _ins = _outs = 4;
  61. _points.push_back( Point( -1, -1 ) );
  62. _points.push_back( Point( 1, 1 ) );
  63. _points.push_back( Point( -1, 1 ) );
  64. _points.push_back( Point( 1, -1 ) );
  65. _outs = 5;
  66. }
  67. virtual ~Panner ( ) { }
  68. virtual void draw ( void );
  69. virtual int handle ( int );
  70. };