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.

177 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. /* /\* these are in logical units, not pixels *\/ */
  51. /* int w, h; /\* viewport *\/ */
  52. /* int x, y; /\* pan position *\/ */
  53. enum { PATTERN, SEQUENCE } mode;
  54. Grid *grid; /* grid currently connected to this canvas */
  55. size_t size;
  56. cell_t **current, **previous;
  57. bool draw; /* really drawing, or just checking size? */
  58. int rule;
  59. bool row_compact; /* use row-compaction? */
  60. /* tables used for row-compaction */
  61. int rtn[128]; /* row-to-note */
  62. int ntr[128]; /* note-to-row */
  63. int shape;
  64. Viewport *vp;
  65. int w, h;
  66. uint p1, p2; /* cursors */
  67. } m;
  68. int rtn ( int r ) const;
  69. int ntr ( int n ) const;
  70. void _update_row_mapping ( void );
  71. cell_t ** _alloc_array ( void );
  72. void redraw_ruler ( void );
  73. void redraw_mapping ( void );
  74. void draw_mapping ( void );
  75. void draw_ruler ( void );
  76. void _reset ( void );
  77. void _lr ( void );
  78. bool viewable_x ( int x );
  79. void draw_line ( int x, int flags );
  80. public:
  81. enum { OFF, ON, TOGGLE };
  82. signal <void> signal_settings_change;
  83. signal <void> signal_draw;
  84. signal <void> signal_resize;
  85. Canvas ( );
  86. void handle_event_change ( void );
  87. void set ( int x, int y );
  88. void grid ( Grid *g );
  89. void changed_mapping ( void );
  90. Grid * grid ( void );
  91. void resize ( void );
  92. void resize_grid ( void );
  93. void resize ( int x, int y, int w, int h );
  94. void copy ( void );
  95. void clear ( void );
  96. void flip ( void );
  97. void draw_row_name ( int y, const char *name, int color );
  98. void draw_shape ( int x, int y, int shape, int state, int color, bool selected );
  99. void draw_dash ( int x, int y, int l, int shape, int color, bool selected );
  100. int draw_playhead ( void );
  101. void draw ( void );
  102. void redraw ( void );
  103. bool grid_pos ( int *x, int *y ) const;
  104. int is_row_name ( int x, int y );
  105. void unset ( int x, int y );
  106. void adj_color ( int x, int y, int n );
  107. void adj_length ( int x, int y, int n );
  108. void select ( int x, int y );
  109. void select_range ( void );
  110. void duplicate_range ( void );
  111. void crop ( void );
  112. void row_compact ( int n );
  113. void pan ( int dir, int n );
  114. void h_zoom ( float n );
  115. void v_zoom ( float n );
  116. void notes ( char *s );
  117. char * notes ( void );
  118. void randomize_row ( int y );
  119. void delete_time ( void );
  120. void insert_time ( void );
  121. void move_selected ( int dir, int n );
  122. };
  123. inline int
  124. Canvas::rtn ( int r ) const
  125. {
  126. return m.row_compact ? m.rtn[ r ] : r;
  127. }
  128. inline int
  129. Canvas::ntr ( int n ) const
  130. {
  131. return m.row_compact ? m.ntr[ n ] : n;
  132. }