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.

202 lines
6.0KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2007-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 "grid.H"
  20. #include <FL/Fl_Group.H>
  21. #include <sigc++/sigc++.h>
  22. using namespace sigc;
  23. class Mapping;
  24. enum { LEFT, RIGHT, UP, DOWN, TO_PLAYHEAD, TO_NEXT_NOTE, TO_PREV_NOTE };
  25. class Fl_Scrollbar;
  26. class Fl_Slider;
  27. class Canvas : public Fl_Group, public trackable
  28. {
  29. class Canvas_Panzoomer;
  30. struct SelectionRect {
  31. int x1,y1,x2,y2;
  32. };
  33. SelectionRect _selection_rect;
  34. int _selection_mode;
  35. bool _move_mode;
  36. Canvas_Panzoomer *panzoomer;
  37. Fl_Slider *vzoom;
  38. /* these are grid coords, not pixels */
  39. int _old_scroll_x;
  40. int _old_scroll_y;
  41. struct {
  42. int origin_x, origin_y;
  43. int width, height;
  44. int margin_left, margin_top;
  45. int div_w, div_h;
  46. int old_div_w, old_div_h;
  47. int maxh;
  48. bool ruler_drawn;
  49. bool mapping_drawn;
  50. bool grid_drawn;
  51. int playhead; /* where the playhead is for this canvas. only used for display. */
  52. enum { PATTERN, SEQUENCE } mode;
  53. Grid *grid; /* grid currently connected to this canvas */
  54. size_t size;
  55. bool draw; /* really drawing, or just checking size? */
  56. int rule;
  57. bool row_compact; /* use row-compaction? */
  58. /* tables used for row-compaction */
  59. int rtn[128]; /* row-to-note */
  60. int ntr[128]; /* note-to-row */
  61. Viewport *vp;
  62. int w, h;
  63. uint p1, p2; /* range cursors */
  64. uint p3, p4; /* row cursors */
  65. } m;
  66. bool is_ruler_click ( void ) const;
  67. int rtn ( int r ) const;
  68. int ntr ( int n ) const;
  69. void _update_row_mapping ( void );
  70. void draw_mapping ( void );
  71. void draw_ruler ( void );
  72. void _reset ( void );
  73. void _lr ( void );
  74. bool viewable_x ( int x );
  75. void update_mapping ( void );
  76. static void cb_scroll ( Fl_Widget *w, void *v );
  77. void cb_scroll ( Fl_Widget *w );
  78. static void draw_clip ( void *v, int X, int Y, int W, int H );
  79. void draw_clip ( int X, int Y, int W, int H );
  80. enum {
  81. SELECT_NONE = 0,
  82. SELECT_RECTANGLE,
  83. SELECT_RANGE
  84. };
  85. public:
  86. bool selection_mode ( void ) const { return _selection_mode; }
  87. void selection_mode ( bool b )
  88. {
  89. _selection_mode = b ? SELECT_RECTANGLE : SELECT_NONE;
  90. }
  91. enum { OFF, ON, TOGGLE };
  92. signal <void> signal_settings_change;
  93. Canvas ( int X, int Y, int W, int H, const char *L=0 );
  94. virtual ~Canvas ( );
  95. void cut ( void );
  96. void paste ( void );
  97. void redraw_playhead ( void );
  98. void handle_event_change ( void );
  99. void set ( int x, int y );
  100. void grid ( Grid *g );
  101. void changed_mapping ( void );
  102. Grid * grid ( void );
  103. void adj_size ( void );
  104. void resize_grid ( void );
  105. void resize ( int x, int y, int w, int h );
  106. void copy ( void );
  107. void draw_row_name ( int y, const char *name, int color );
  108. // void draw_shape ( int x, int y, int w, int color );
  109. static void draw_dash ( tick_t x, int y, tick_t l, int color, int selected, void *userdata );
  110. void draw_dash ( tick_t x, int y, tick_t w, int color, int selected ) const;
  111. void damage_grid ( tick_t x, int y, tick_t w, int h );
  112. void draw_overlay ( void );
  113. void draw_playhead ( void );
  114. void draw ( void );
  115. bool grid_pos ( int *x, int *y ) const;
  116. int is_row_press ( void ) const;
  117. void unset ( int x, int y );
  118. void adj_color ( int x, int y, int n );
  119. void adj_length ( int x, int y, int n );
  120. void set_end ( int x, int y, int n );
  121. void select ( int x, int y );
  122. void select_range ( void );
  123. void invert_selection ( void );
  124. void duplicate_range ( void );
  125. void crop ( void );
  126. void row_compact ( int n );
  127. void pan ( int dir, int n );
  128. void can_scroll ( int *left, int *right, int *up, int *down );
  129. void h_zoom ( float n );
  130. void v_zoom ( float n );
  131. void v_zoom_fit ( void );
  132. void notes ( char *s );
  133. char * notes ( void );
  134. int playhead_moved ( void );
  135. void start_cursor ( int x, int y );
  136. void end_cursor ( int x, int y );
  137. void delete_time ( void );
  138. void insert_time ( void );
  139. void move_selected ( int dir, int n );
  140. void selected_velocity ( int v );
  141. virtual int handle ( int m );
  142. };
  143. inline int
  144. Canvas::rtn ( int r ) const
  145. {
  146. return m.row_compact ? m.rtn[ r ] : r;
  147. }
  148. inline int
  149. Canvas::ntr ( int n ) const
  150. {
  151. return m.row_compact ? m.ntr[ n ] : n;
  152. }