67b569603c9b205ae9d2420c99f656f3cf709d68
[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          max_ticks;     /* in ticks */
72   gfloat         hzoom;
73
74   /* last drag state */
75   guint          start_tick;
76   gint           start_note;
77   guint          start_valid : 1;
78
79   guint          draw_qn_grid : 1;
80   guint          draw_qqn_grid : 1;
81
82   /* slight hack */
83   guint          release_closes_toplevel : 1;
84
85   /* selection rectangle */
86   guint          selection_tick;
87   guint          selection_duration;
88   gint           selection_min_note;
89   gint           selection_max_note;
90 };
91 struct _BstPianoRollClass
92 {
93   GxkScrollCanvasClass parent_class;
94
95   void          (*canvas_drag)                  (BstPianoRoll     *self,
96                                                  BstPianoRollDrag *drag);
97   void          (*canvas_clicked)               (BstPianoRoll     *proll,
98                                                  guint             button,
99                                                  guint             tick_position,
100                                                  gint              note,
101                                                  GdkEvent         *event);
102   void          (*piano_drag)                   (BstPianoRoll     *self,
103                                                  BstPianoRollDrag *drag);
104   void          (*piano_clicked)                (BstPianoRoll     *proll,
105                                                  guint             button,
106                                                  gint              note,
107                                                  GdkEvent         *event);
108 };
109
110
111 /* --- prototypes --- */
112 GType   bst_piano_roll_get_type                 (void);
113 void    bst_piano_roll_set_proxy                (BstPianoRoll   *self,
114                                                  SfiProxy        proxy);
115 gfloat  bst_piano_roll_set_hzoom                (BstPianoRoll   *self,
116                                                  gfloat          hzoom);
117 gfloat  bst_piano_roll_set_vzoom                (BstPianoRoll   *self,
118                                                  gfloat          vzoom);
119 void    bst_piano_roll_set_view_selection       (BstPianoRoll   *self,
120                                                  guint           tick,
121                                                  guint           duration,
122                                                  gint            min_note,
123                                                  gint            max_note);
124 gint    bst_piano_roll_get_vpanel_width         (BstPianoRoll   *self);
125 void    bst_piano_roll_get_paste_pos            (BstPianoRoll   *self,
126                                                  guint          *tick_p,
127                                                  gint           *note_p);
128 void    bst_piano_roll_set_marker               (BstPianoRoll          *self,
129                                                  guint                  mark_index,
130                                                  guint                  position,
131                                                  BstPianoRollMarkerType mtype);
132
133      
134 G_END_DECLS
135
136 #endif /* __BST_PIANO_ROLL_H__ */