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.

128 lines
3.3KB

  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 "Audio_Track.H"
  19. static
  20. void
  21. deurlify ( char *url )
  22. {
  23. char *r, *w;
  24. r = w = url;
  25. for ( ; *r; r++, w++ )
  26. {
  27. if ( *r == '%' )
  28. {
  29. char data[3] = { *(r + 1), *(r + 2), 0 };
  30. int c;
  31. sscanf( data, "%2X", &c );
  32. *w = c;
  33. r += 2;
  34. }
  35. else
  36. *w = *r;
  37. }
  38. *w = NULL;
  39. }
  40. /** event handler that supports DND of audio clips */
  41. int
  42. Audio_Track::handle ( int m )
  43. {
  44. switch ( m )
  45. {
  46. case FL_DND_DRAG:
  47. return Track::handle( m ) | 1;
  48. /* case FL_DND_ENTER: */
  49. /* case FL_DND_LEAVE: */
  50. case FL_DND_RELEASE:
  51. return 1;
  52. case FL_PASTE:
  53. {
  54. const char *text = Fl::event_text();
  55. if ( ! strcmp( text, "Region" ) )
  56. return 1;
  57. char *file;
  58. if ( ! sscanf( text, "file://%a[^\r\n]\n", &file ) )
  59. {
  60. printf( "invalid drop \"%s\"\n", text );
  61. return 0;
  62. }
  63. deurlify( file );
  64. printf( "pasted file \"%s\"\n", file );
  65. fl_cursor( FL_CURSOR_WAIT );
  66. Fl::check();
  67. Audio_File *c = Audio_File::from_file( file );
  68. fl_cursor( FL_CURSOR_DEFAULT );
  69. if ( ! c )
  70. {
  71. free( file );
  72. return 0;
  73. }
  74. Region *r = new Region( c, this, timeline->xoffset + timeline->x_to_ts( Fl::event_x() - x() ) );
  75. redraw();
  76. return 1;
  77. }
  78. default:
  79. return Track::handle( m );
  80. }
  81. }
  82. void
  83. Audio_Track::dump ( void )
  84. {
  85. printf( "1 \"%s\" {\n", /* name() */ "Track" );
  86. sort();
  87. for ( list <Track_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
  88. {
  89. printf( "\t" );
  90. ((Region*)(*r))->dump();
  91. }
  92. printf( "}\n" );
  93. }