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.

165 lines
4.5KB

  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_draw.H>
  24. #include "Scalebar.H"
  25. /* FIXME: this class needs a lot of cleaning up. Too many public
  26. * members etc. */
  27. /* #include "Audio_File.H" // just for nframes_t */
  28. #include "types.h"
  29. #include <math.h>
  30. #include <assert.h>
  31. class Timeline;
  32. extern Timeline *timeline;
  33. #include "Track.H"
  34. class Tempo_Track;
  35. class Time_Track;
  36. class Ruler_Track;
  37. /* #include <list> */
  38. /* using std::list; */
  39. // disables double-buffering to make unnecessary redrawing more apparent
  40. // #define DEBUG_TIMELINE_DRAWING
  41. #ifndef DEBUG_TIMELINE_DRAWING
  42. #include <Fl/Fl_Overlay_Window.H>
  43. #else
  44. #include <FL/Fl_Single_Window.H>
  45. #define Fl_Overlay_Window Fl_Single_Window
  46. #define redraw_overlay()
  47. #endif
  48. struct Rectangle
  49. {
  50. int x;
  51. int y;
  52. int w;
  53. int h;
  54. Rectangle ( ) : x( 0 ), y( 0 ), w( 0 ), h( 0 ) {}
  55. Rectangle ( int X, int Y, int W, int H ) : x( X ), y( Y ), w( W ), h( H ) {}
  56. };
  57. class Engine;
  58. #include "RWLock.H"
  59. class Timeline : public Fl_Overlay_Window, public RWLock
  60. {
  61. static void draw_clip ( void * v, int X, int Y, int W, int H );
  62. int _old_xposition;
  63. int _old_yposition;
  64. Rectangle _selection;
  65. bool _enable_measure_lines;
  66. enum snap_flags_e {
  67. SNAP_TO_REGION,
  68. SNAP_TO_BAR,
  69. SNAP_TO_BEAT
  70. } snap_to;
  71. Fl_Scroll *scroll;
  72. Fl_Pack *tracks;
  73. Fl_Pack *rulers;
  74. Scalebar *hscroll;
  75. Fl_Scrollbar *vscroll;
  76. static void cb_scroll ( Fl_Widget *w, void *v );
  77. void cb_scroll ( Fl_Widget *w );
  78. float _fpp; /* frames per pixel */
  79. nframes_t _sample_rate;
  80. nframes_t _length;
  81. public:
  82. Tempo_Track *tempo_track;
  83. Time_Track *time_track;
  84. Ruler_Track *ruler_track;
  85. nframes_t xoffset;
  86. int _yposition;
  87. Timeline ( int X, int Y, int W, int H, const char *L=0 );
  88. float fpp ( void ) const { return _fpp; }
  89. nframes_t length ( void ) const { return _length; }
  90. nframes_t sample_rate ( void ) const { return _sample_rate; }
  91. int ts_to_x( nframes_t ts ) const { return ts / _fpp; }
  92. nframes_t x_to_ts ( int x ) const { return x * _fpp; }
  93. float beats_per_minute ( nframes_t when ) const;
  94. int beats_per_bar ( nframes_t when ) const;
  95. void beats_per_minute ( nframes_t when, float bpm );
  96. int nearest_line ( int ix );
  97. void draw_measure_lines ( int X, int Y, int W, int H, Fl_Color color );
  98. void draw_measure_BBT ( int X, int Y, int W, int H, Fl_Color color );
  99. void draw_measure ( int X, int Y, int W, int H, Fl_Color color, bool BBT );
  100. void xposition ( int X );
  101. void yposition ( int Y );
  102. void draw_playhead ( void );
  103. void redraw_playhead ( void );
  104. void draw ( void );
  105. void draw_overlay ( void );
  106. int handle ( int m );
  107. static void update_cb ( void *arg );
  108. void select( const Rectangle &r );
  109. private:
  110. friend class Engine; // FIXME: only Engine::process() needs to be friended.x
  111. /* Engine */
  112. nframes_t process ( nframes_t nframes );
  113. void seek ( nframes_t frame );
  114. int seek_pending ( void );
  115. };