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.

137 lines
3.6KB

  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_Scroll.H>
  20. #include <FL/Fl_Pack.H>
  21. #include <FL/Fl_Scrollbar.H>
  22. #include <FL/Fl_Widget.H>
  23. #include <Fl/Fl_Overlay_Window.H>
  24. #include "Scalebar.H"
  25. #include "Audio_File.H" // just for nframes_t
  26. #include <math.h>
  27. #include <assert.h>
  28. #include <FL/fl_draw.H>
  29. class Timeline;
  30. extern Timeline *timeline;
  31. #include "Track.H"
  32. // #include "Tempo_Track.H"
  33. class Tempo_Track;
  34. class Time_Track;
  35. // #include "Tempo_Point.H"
  36. // #include "Region.H"
  37. #include <list>
  38. using std::list;
  39. struct Rectangle
  40. {
  41. int x;
  42. int y;
  43. int w;
  44. int h;
  45. Rectangle ( ) : x( 0 ), y( 0 ), w( 0 ), h( 0 ) {}
  46. Rectangle ( int X, int Y, int W, int H ) : x( X ), y( Y ), w( W ), h( H ) {}
  47. };
  48. struct Timeline : public Fl_Overlay_Window
  49. {
  50. static void draw_clip ( void * v, int X, int Y, int W, int H );
  51. int _old_xposition;
  52. int _old_yposition;
  53. Rectangle _selection;
  54. bool _enable_measure_lines;
  55. enum snap_flags_e {
  56. SNAP_TO_REGION,
  57. SNAP_TO_BAR,
  58. SNAP_TO_BEAT
  59. } snap_to;
  60. Fl_Scroll *scroll;
  61. Fl_Pack *tracks;
  62. Fl_Pack *rulers;
  63. Scalebar *hscroll;
  64. Fl_Scrollbar *vscroll;
  65. Tempo_Track *tempo_track;
  66. Time_Track *time_track;
  67. float fpp; /* frames per pixel */
  68. // nframes_t fpp;
  69. nframes_t sample_rate;
  70. nframes_t xoffset;
  71. nframes_t length;
  72. int yposition;
  73. int _beats_per_bar;
  74. float _beats_per_minute;
  75. Timeline ( int X, int Y, int W, int H, const char *L=0 );
  76. int
  77. ts_to_x( nframes_t ts )
  78. {
  79. // assert( ts / fpp > 0 );
  80. return ts / fpp;
  81. }
  82. nframes_t
  83. x_to_ts ( int x )
  84. {
  85. return x * fpp;
  86. }
  87. /* #define FOR_CHILDREN_OF( name, ind ) \ */
  88. /* for ( int i = (name) ->children(); i-- && ( (ind) = (name) ->child( i ) ); ) */
  89. float beats_per_minute ( nframes_t when ) const;
  90. int beats_per_bar ( nframes_t when ) const;
  91. void beats_per_minute ( nframes_t when, float bpm );
  92. int nearest_line ( int ix );
  93. void draw_measure_lines ( int X, int Y, int W, int H, Fl_Color color );
  94. void position ( int X );
  95. void draw ( void );
  96. void draw_overlay ( void );
  97. int handle ( int m );
  98. void select( const Rectangle &r );
  99. };