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.

153 lines
3.7KB

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