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.

129 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. class 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. static void cb_scroll ( Fl_Widget *w, void *v );
  68. void cb_scroll ( Fl_Widget *w );
  69. float _fpp; /* frames per pixel */
  70. nframes_t _sample_rate;
  71. nframes_t _length;
  72. public:
  73. nframes_t xoffset;
  74. int _yposition;
  75. Timeline ( int X, int Y, int W, int H, const char *L=0 );
  76. float fpp ( void ) const { return _fpp; }
  77. nframes_t length ( void ) const { return _length; }
  78. nframes_t sample_rate ( void ) const { return _sample_rate; }
  79. int ts_to_x( nframes_t ts ) const { return ts / _fpp; }
  80. nframes_t x_to_ts ( int x ) const { return x * _fpp; }
  81. float beats_per_minute ( nframes_t when ) const;
  82. int beats_per_bar ( nframes_t when ) const;
  83. void beats_per_minute ( nframes_t when, float bpm );
  84. int nearest_line ( int ix );
  85. void draw_measure_lines ( int X, int Y, int W, int H, Fl_Color color );
  86. void xposition ( int X );
  87. void yposition ( int Y );
  88. void draw ( void );
  89. void draw_overlay ( void );
  90. int handle ( int m );
  91. void select( const Rectangle &r );
  92. };