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.

180 lines
5.3KB

  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 "gui/draw.H"
  21. #include <sigc++/sigc++.h>
  22. using namespace sigc;
  23. class Mapping;
  24. struct cell_t {
  25. unsigned char color;
  26. unsigned char shape : 4;
  27. unsigned char state : 4;
  28. unsigned char flags : 4;
  29. bool
  30. operator!= ( const cell_t &rhs )
  31. {
  32. return color != rhs.color || shape != rhs.shape || state != rhs.state || flags != rhs.flags;
  33. }
  34. };
  35. enum { LEFT, RIGHT, UP, DOWN, TO_PLAYHEAD, TO_NEXT_NOTE, TO_PREV_NOTE };
  36. class Canvas : public trackable
  37. {
  38. struct {
  39. int origin_x, origin_y;
  40. int width, height;
  41. int margin_left, margin_top;
  42. int div_w, div_h;
  43. int border_w;
  44. int old_div_w, old_div_h;
  45. int maxh;
  46. bool ruler_drawn;
  47. bool mapping_drawn;
  48. bool grid_drawn;
  49. int playhead; /* where the playhead is for this canvas. only used for display. */
  50. enum { PATTERN, SEQUENCE } mode;
  51. Grid *grid; /* grid currently connected to this canvas */
  52. size_t size;
  53. cell_t **current, **previous;
  54. bool draw; /* really drawing, or just checking size? */
  55. int rule;
  56. bool row_compact; /* use row-compaction? */
  57. /* tables used for row-compaction */
  58. int rtn[128]; /* row-to-note */
  59. int ntr[128]; /* note-to-row */
  60. int shape;
  61. Viewport *vp;
  62. int w, h;
  63. uint p1, p2; /* range cursors */
  64. uint p3, p4; /* row cursors */
  65. } m;
  66. int rtn ( int r ) const;
  67. int ntr ( int n ) const;
  68. void _update_row_mapping ( void );
  69. cell_t ** _alloc_array ( void );
  70. void redraw_ruler ( void );
  71. void redraw_mapping ( void );
  72. void draw_mapping ( void );
  73. void draw_ruler ( void );
  74. void _reset ( void );
  75. void _lr ( void );
  76. bool viewable_x ( int x );
  77. void draw_line ( int x, int flags );
  78. public:
  79. enum { OFF, ON, TOGGLE };
  80. signal <void> signal_settings_change;
  81. signal <void> signal_draw;
  82. signal <void> signal_resize;
  83. Canvas ( );
  84. void handle_event_change ( void );
  85. void set ( int x, int y );
  86. void grid ( Grid *g );
  87. void changed_mapping ( void );
  88. Grid * grid ( void );
  89. void resize ( void );
  90. void resize_grid ( void );
  91. void resize ( int x, int y, int w, int h );
  92. void copy ( void );
  93. void clear ( void );
  94. void flip ( void );
  95. void draw_row_name ( int y, const char *name, int color );
  96. void draw_shape ( int x, int y, int shape, int state, int color, bool selected );
  97. void draw_dash ( int x, int y, int l, int shape, int color, bool selected );
  98. int draw_playhead ( void );
  99. void draw ( void );
  100. void redraw ( void );
  101. bool grid_pos ( int *x, int *y ) const;
  102. int is_row_name ( int x, int y );
  103. void unset ( int x, int y );
  104. void adj_color ( int x, int y, int n );
  105. void adj_length ( int x, int y, int n );
  106. void select ( int x, int y );
  107. void select_range ( void );
  108. void invert_selection ( void );
  109. void duplicate_range ( void );
  110. void crop ( void );
  111. void row_compact ( int n );
  112. void pan ( int dir, int n );
  113. void h_zoom ( float n );
  114. void v_zoom ( float n );
  115. void v_zoom_fit ( void );
  116. void notes ( char *s );
  117. char * notes ( void );
  118. void randomize_row ( int y );
  119. void start_cursor ( int x, int y );
  120. void end_cursor ( int x, int y );
  121. void delete_time ( void );
  122. void insert_time ( void );
  123. void move_selected ( int dir, int n );
  124. };
  125. inline int
  126. Canvas::rtn ( int r ) const
  127. {
  128. return m.row_compact ? m.rtn[ r ] : r;
  129. }
  130. inline int
  131. Canvas::ntr ( int n ) const
  132. {
  133. return m.row_compact ? m.ntr[ n ] : n;
  134. }