1 /* GSequencer - Advanced GTK Sequencer
2  * Copyright (C) 2005-2019 Joël Krähemann
3  *
4  * This file is part of GSequencer.
5  *
6  * GSequencer is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * GSequencer is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with GSequencer.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef __AGS_NOTATION_EDIT_H__
21 #define __AGS_NOTATION_EDIT_H__
22 
23 #include <glib.h>
24 #include <glib-object.h>
25 
26 #include <gtk/gtk.h>
27 
28 #include <ags/libags.h>
29 #include <ags/libags-audio.h>
30 #include <ags/libags-gui.h>
31 
32 G_BEGIN_DECLS
33 
34 #define AGS_TYPE_NOTATION_EDIT                (ags_notation_edit_get_type ())
35 #define AGS_NOTATION_EDIT(obj)                (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_NOTATION_EDIT, AgsNotationEdit))
36 #define AGS_NOTATION_EDIT_CLASS(class)        (G_TYPE_CHECK_CLASS_CAST((class), AGS_TYPE_NOTATION_EDIT, AgsNotationEditClass))
37 #define AGS_IS_NOTATION_EDIT(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AGS_TYPE_NOTATION_EDIT))
38 #define AGS_IS_NOTATION_EDIT_CLASS(class)     (G_TYPE_CHECK_CLASS_TYPE ((class), AGS_TYPE_NOTATION_EDIT))
39 #define AGS_NOTATION_EDIT_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), AGS_TYPE_NOTATION_EDIT, AgsNotationEditClass))
40 
41 #define AGS_NOTATION_EDIT_DEFAULT_CONTROL_WIDTH (64)
42 #define AGS_NOTATION_EDIT_DEFAULT_CONTROL_HEIGHT (14)
43 
44 #define AGS_NOTATION_EDIT_DEFAULT_CONTROL_MARGIN_X (0)
45 #define AGS_NOTATION_EDIT_DEFAULT_CONTROL_MARGIN_Y (2)
46 
47 #define AGS_NOTATION_EDIT_DEFAULT_CURSOR_POSITION_X (0)
48 #define AGS_NOTATION_EDIT_DEFAULT_CURSOR_POSITION_Y (0)
49 
50 #define AGS_NOTATION_EDIT_DEFAULT_SELECTED_NOTE_BORDER (2)
51 
52 #define AGS_NOTATION_EDIT_DEFAULT_FADER_WIDTH (3)
53 
54 #define AGS_NOTATION_EDIT_MIN_ZOOM (1.0 / 16.0)
55 #define AGS_NOTATION_EDIT_MAX_ZOOM (4.0)
56 #define AGS_NOTATION_EDIT_MAX_ZOOM_CONTROL_WIDTH (64.0 * AGS_NOTATION_EDIT_DEFAULT_CONTROL_WIDTH)
57 
58 typedef struct _AgsNotationEdit AgsNotationEdit;
59 typedef struct _AgsNotationEditClass AgsNotationEditClass;
60 
61 typedef enum{
62   AGS_NOTATION_EDIT_CONNECTED             = 1,
63   AGS_NOTATION_EDIT_AUTO_SCROLL           = 1 <<  1,
64   AGS_NOTATION_EDIT_SHOW_RULER            = 1 <<  2,
65   AGS_NOTATION_EDIT_SHOW_VSCROLLBAR       = 1 <<  3,
66   AGS_NOTATION_EDIT_SHOW_HSCROLLBAR       = 1 <<  4,
67 }AgsNotationEditFlags;
68 
69 typedef enum{
70   AGS_NOTATION_EDIT_NO_EDIT_MODE,
71   AGS_NOTATION_EDIT_POSITION_CURSOR,
72   AGS_NOTATION_EDIT_ADD_NOTE,
73   AGS_NOTATION_EDIT_DELETE_NOTE,
74   AGS_NOTATION_EDIT_SELECT_NOTE,
75 }AgsNotationEditMode;
76 
77 typedef enum{
78   AGS_NOTATION_EDIT_BUTTON_1            = 1,
79 }AgsNotationEditButtonMask;
80 
81 typedef enum{
82   AGS_NOTATION_EDIT_KEY_L_CONTROL       = 1,
83   AGS_NOTATION_EDIT_KEY_R_CONTROL       = 1 <<  1,
84   AGS_NOTATION_EDIT_KEY_L_SHIFT         = 1 <<  2,
85   AGS_NOTATION_EDIT_KEY_R_SHIFT         = 1 <<  3,
86 }AgsNotationEditKeyMask;
87 
88 struct _AgsNotationEdit
89 {
90   GtkTable table;
91 
92   guint flags;
93   guint mode;
94 
95   guint button_mask;
96   guint key_mask;
97 
98   guint note_offset;
99   guint note_offset_absolute;
100 
101   guint control_width;
102   guint control_height;
103 
104   guint control_margin_x;
105   guint control_margin_y;
106 
107   guint cursor_position_x;
108   guint cursor_position_y;
109 
110   guint selected_note_border;
111 
112   guint selection_x0;
113   guint selection_x1;
114   guint selection_y0;
115   guint selection_y1;
116 
117   AgsNote *current_note;
118 
119   AgsRuler *ruler;
120 
121   GtkDrawingArea *drawing_area;
122 
123   GtkVScrollbar *vscrollbar;
124   GtkHScrollbar *hscrollbar;
125 };
126 
127 struct _AgsNotationEditClass
128 {
129   GtkTableClass table;
130 };
131 
132 GType ags_notation_edit_get_type(void);
133 
134 void ags_notation_edit_reset_vscrollbar(AgsNotationEdit *notation_edit);
135 void ags_notation_edit_reset_hscrollbar(AgsNotationEdit *notation_edit);
136 
137 void ags_notation_edit_draw_segment(AgsNotationEdit *notation_edit, cairo_t *cr);
138 void ags_notation_edit_draw_position(AgsNotationEdit *notation_edit, cairo_t *cr);
139 
140 void ags_notation_edit_draw_cursor(AgsNotationEdit *notation_edit, cairo_t *cr);
141 void ags_notation_edit_draw_selection(AgsNotationEdit *notation_edit, cairo_t *cr);
142 
143 void ags_notation_edit_draw_note(AgsNotationEdit *notation_edit,
144 				 AgsNote *note,
145 				 cairo_t *cr,
146 				 gdouble opacity);
147 void ags_notation_edit_draw_notation(AgsNotationEdit *notation_edit, cairo_t *cr);
148 
149 void ags_notation_edit_draw(AgsNotationEdit *notation_edit, cairo_t *cr);
150 
151 AgsNotationEdit* ags_notation_edit_new();
152 
153 G_END_DECLS
154 
155 #endif /*__AGS_NOTATION_EDIT_H__*/
156