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.

151 lines
3.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. #include "Panner.H"
  19. /* 2D Panner widget. Supports various multichannel configurations. */
  20. /* multichannel layouts, in degrees */
  21. int Panner::_configs[][12] =
  22. {
  23. /* mono */
  24. { -1 },
  25. /* stereo */
  26. { 270, 90, -1 },
  27. /* quad */
  28. { 315, 45, 225, 135, -1 },
  29. /* 5.1 */
  30. { 315, 45, 225, 135, 0, -1 },
  31. /* 7.1 */
  32. { 315, 45, 225, 135, 0, 270, 90, -1 },
  33. };
  34. Panner::Point *
  35. Panner::event_point ( void )
  36. {
  37. int X, Y, W, H;
  38. bbox( X, Y, W, H );
  39. for ( int i = _ins; i--; )
  40. {
  41. Point *p = &_points[ i ];
  42. if ( Fl::event_inside( X + ((p->x * (W / 2)) + (W / 2)),
  43. Y + ((p->y * (H / 2)) + (H / 2)), pw(), ph() ) )
  44. return p;
  45. }
  46. return NULL;
  47. }
  48. void
  49. Panner::draw ( void )
  50. {
  51. draw_box();
  52. // draw_box( FL_FLAT_BOX, x(), y(), w(), h(), FL_BLACK );
  53. draw_label();
  54. int tw, th, tx, ty;
  55. bbox( tx, ty, tw, th );
  56. fl_color( FL_GRAY );
  57. switch ( _outs )
  58. {
  59. case 2: /* stereo */
  60. case 4: /* quad */
  61. fl_line( x(), y(), x()+ w(), y() + h() );
  62. fl_line( x() + w(), y(), x(), y() + h() );
  63. break;
  64. case 5: /* 5.1 */
  65. fl_line( x(), y(), x() + w(), y() + h() );
  66. fl_line( x() + w(), y(), x(), y() + h() );
  67. fl_line( x() + (w() / 2), y(), x() + (w() / 2), y() + (h() / 2) );
  68. break;
  69. }
  70. for ( int i = _ins; i--; )
  71. {
  72. Point *p = &_points[ i ];
  73. fl_color( (Fl_Color) 10 + i );
  74. const int bx = tx + ((tw / 2) * p->x + (tw / 2));
  75. const int by = ty + ((th / 2) * p->y + (th / 2));
  76. fl_rectf( bx, by, pw(), ph() );
  77. char pat[4];
  78. snprintf( pat, 4, "%d", i + 1 );
  79. fl_color( FL_BLACK );
  80. fl_font( FL_HELVETICA, ph() + 2 );
  81. fl_draw( pat, bx, by + ph() );
  82. }
  83. }
  84. int
  85. Panner::handle ( int m )
  86. {
  87. static Point *drag;
  88. switch ( m )
  89. {
  90. case FL_PUSH:
  91. if ( ( drag = event_point() ) )
  92. {
  93. printf( "bing\n" );
  94. return 1;
  95. }
  96. else
  97. return 0;
  98. case FL_RELEASE:
  99. drag = NULL;
  100. return 1;
  101. case FL_DRAG:
  102. {
  103. float X = Fl::event_x() - x();
  104. float Y = Fl::event_y() - y();
  105. drag->x = (float)(X / (w() / 2)) - 1.0f;
  106. drag->y = (float)(Y / (h() / 2)) - 1.0f;
  107. redraw();
  108. return 1;
  109. }
  110. }
  111. return 0;
  112. }