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.

181 lines
5.4KB

  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 : 8;
  26. unsigned char state : 4;
  27. unsigned char flags : 4;
  28. bool
  29. operator!= ( const cell_t &rhs )
  30. {
  31. return color != rhs.color || state != rhs.state || flags != rhs.flags;
  32. }
  33. };
  34. enum { LEFT, RIGHT, UP, DOWN, TO_PLAYHEAD, TO_NEXT_NOTE, TO_PREV_NOTE };
  35. class Canvas : public trackable
  36. {
  37. struct {
  38. int origin_x, origin_y;
  39. int width, height;
  40. int margin_left, margin_top;
  41. int div_w, div_h;
  42. int old_div_w, old_div_h;
  43. int maxh;
  44. bool ruler_drawn;
  45. bool mapping_drawn;
  46. bool grid_drawn;
  47. int playhead; /* where the playhead is for this canvas. only used for display. */
  48. enum { PATTERN, SEQUENCE } mode;
  49. Grid *grid; /* grid currently connected to this canvas */
  50. size_t size;
  51. cell_t **current, **previous;
  52. bool draw; /* really drawing, or just checking size? */
  53. int rule;
  54. bool row_compact; /* use row-compaction? */
  55. /* tables used for row-compaction */
  56. int rtn[128]; /* row-to-note */
  57. int ntr[128]; /* note-to-row */
  58. int shape;
  59. Viewport *vp;
  60. int w, h;
  61. uint p1, p2; /* range cursors */
  62. uint p3, p4; /* row cursors */
  63. } m;
  64. int rtn ( int r ) const;
  65. int ntr ( int n ) const;
  66. void _update_row_mapping ( void );
  67. cell_t ** _alloc_array ( void );
  68. void redraw_ruler ( void );
  69. void redraw_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 draw_line ( int x, int flags );
  76. void update_mapping ( void );
  77. public:
  78. enum { OFF, ON, TOGGLE };
  79. signal <void> signal_settings_change;
  80. signal <void> signal_draw;
  81. signal <void> signal_resize;
  82. signal <void> signal_pan;
  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 can_scroll ( int *left, int *right, int *up, int *down );
  114. void h_zoom ( float n );
  115. void v_zoom ( float n );
  116. void v_zoom_fit ( void );
  117. void notes ( char *s );
  118. char * notes ( void );
  119. void randomize_row ( int y );
  120. int playhead_moved ( void );
  121. void start_cursor ( int x, int y );
  122. void end_cursor ( int x, int y );
  123. void delete_time ( void );
  124. void insert_time ( void );
  125. void move_selected ( int dir, int n );
  126. };
  127. inline int
  128. Canvas::rtn ( int r ) const
  129. {
  130. return m.row_compact ? m.rtn[ r ] : r;
  131. }
  132. inline int
  133. Canvas::ntr ( int n ) const
  134. {
  135. return m.row_compact ? m.ntr[ n ] : n;
  136. }