GUI: use quantization setting to choose grid to draw
[stwbeast.git] / beast-gtk / bstpianoroll.h
1 /* BEAST - Better Audio System
2  * Copyright (C) 2002-2004 Tim Janik
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * A copy of the GNU Lesser General Public License should ship along
15  * with this library; if not, see http://www.gnu.org/copyleft/.
16  */
17 #ifndef __BST_PIANO_ROLL_H__
18 #define __BST_PIANO_ROLL_H__
19
20 #include        "bstutils.h"
21
22 G_BEGIN_DECLS
23
24 /* --- type macros --- */
25 #define BST_TYPE_PIANO_ROLL              (bst_piano_roll_get_type ())
26 #define BST_PIANO_ROLL(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), BST_TYPE_PIANO_ROLL, BstPianoRoll))
27 #define BST_PIANO_ROLL_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), BST_TYPE_PIANO_ROLL, BstPianoRollClass))
28 #define BST_IS_PIANO_ROLL(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), BST_TYPE_PIANO_ROLL))
29 #define BST_IS_PIANO_ROLL_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), BST_TYPE_PIANO_ROLL))
30 #define BST_PIANO_ROLL_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BST_TYPE_PIANO_ROLL, BstPianoRollClass))
31
32
33 /* --- typedefs & enums --- */
34 typedef struct _BstPianoRoll        BstPianoRoll;
35 typedef struct _BstPianoRollClass   BstPianoRollClass;
36 typedef enum    /*< skip >*/
37 {
38   BST_PIANO_ROLL_MARKER_NONE,
39   BST_PIANO_ROLL_MARKER_POINTER,
40   BST_PIANO_ROLL_MARKER_SELECT
41 } BstPianoRollMarkerType;
42
43
44 /* --- structures & typedefs --- */
45 typedef struct {
46   GXK_SCROLL_CANVAS_DRAG_FIELDS;
47   guint         start_tick;
48   gint          start_note;
49   guint         start_valid : 1;        /* note out of range or non-existant black key */
50   guint         current_tick;
51   gint          current_note;
52   guint         current_valid : 1;      /* note out of range or non-existant black key */
53   /* convenience: */
54   BstPianoRoll *proll;
55 } BstPianoRollDrag;
56 struct _BstPianoRoll
57 {
58   GxkScrollCanvas parent_instance;
59
60   SfiProxy       proxy;
61   SfiProxy       song;
62   BsePartLinkSeq*plinks;
63   gint           min_note;
64   gint           max_note;
65   guint          vzoom;
66
67   /* horizontal layout */
68   guint          tpqn;          /* ticks per quarter note */
69   guint          ppb;           /* parts per beat */
70   guint          bpt;           /* beats per tact */
71   guint          quant;         /* quantization */
72   guint          quant_ticks;   /* ticks per quantization step */
73   guint          max_ticks;     /* in ticks */
74   gfloat         hzoom;
75
76   /* last drag state */
77   guint          start_tick;
78   gint           start_note;
79   guint          start_valid : 1;
80
81   guint          draw_beat_grid : 1;
82   guint          draw_quant_grid : 1;
83
84   /* slight hack */
85   guint          release_closes_toplevel : 1;
86
87   /* selection rectangle */
88   guint          selection_tick;
89   guint          selection_duration;
90   gint           selection_min_note;
91   gint           selection_max_note;
92 };
93 struct _BstPianoRollClass
94 {
95   GxkScrollCanvasClass parent_class;
96
97   void          (*canvas_drag)                  (BstPianoRoll     *self,
98                                                  BstPianoRollDrag *drag);
99   void          (*canvas_clicked)               (BstPianoRoll     *proll,
100                                                  guint             button,
101                                                  guint             tick_position,
102                                                  gint              note,
103                                                  GdkEvent         *event);
104   void          (*piano_drag)                   (BstPianoRoll     *self,
105                                                  BstPianoRollDrag *drag);
106   void          (*piano_clicked)                (BstPianoRoll     *proll,
107                                                  guint             button,
108                                                  gint              note,
109                                                  GdkEvent         *event);
110 };
111
112
113 /* --- prototypes --- */
114 GType   bst_piano_roll_get_type                 (void);
115 void    bst_piano_roll_set_proxy                (BstPianoRoll   *self,
116                                                  SfiProxy        proxy);
117 gfloat  bst_piano_roll_set_hzoom                (BstPianoRoll   *self,
118                                                  gfloat          hzoom);
119 gfloat  bst_piano_roll_set_vzoom                (BstPianoRoll   *self,
120                                                  gfloat          vzoom);
121 void    bst_piano_roll_set_view_selection       (BstPianoRoll   *self,
122                                                  guint           tick,
123                                                  guint           duration,
124                                                  gint            min_note,
125                                                  gint            max_note);
126 gint    bst_piano_roll_get_vpanel_width         (BstPianoRoll   *self);
127 void    bst_piano_roll_get_paste_pos            (BstPianoRoll   *self,
128                                                  guint          *tick_p,
129                                                  gint           *note_p);
130 void    bst_piano_roll_set_marker               (BstPianoRoll          *self,
131                                                  guint                  mark_index,
132                                                  guint                  position,
133                                                  BstPianoRollMarkerType mtype);
134 void    bst_piano_roll_set_quant                (BstPianoRoll          *self,
135                                                  guint                  quant);
136
137      
138 G_END_DECLS
139
140 #endif /* __BST_PIANO_ROLL_H__ */