BEAST - Free Software Audio Synthesizer and Tracker  0.9.2
bstpatterncolumns.hh
Go to the documentation of this file.
1  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2 #ifndef __BST_PATTERN_COLUMNS_H__
3 #define __BST_PATTERN_COLUMNS_H__
4 
5 #include "bstutils.hh"
6 
7 G_BEGIN_DECLS
8 
9 /* --- enums --- */
10 typedef enum /*< skip >*/
11 {
12  BST_PATTERN_NONE = 0,
13  /* events */
14  BST_PATTERN_REMOVE_EVENTS,
15  BST_PATTERN_SET_NOTE, /* #note */
16  BST_PATTERN_SET_OCTAVE, /* #octave */
17  BST_PATTERN_NUMERIC_CHANGE, /* -32 .. +32 */
18  BST_PATTERN_SET_DIGIT, /* 0 .. +32 */
19  BST_PATTERN_MASK_ACTION = 0x000000ff,
20  /* base octave */
21  BST_PATTERN_SET_BASE_OCTAVE = 0x1 << 8,
22  BST_PATTERN_CHANGE_BASE_OCTAVE = 0x2 << 8,
23  BST_PATTERN_MASK_CONTROLS = 0x0000ff00,
24  /* focus movement */
25  BST_PATTERN_MOVE_LEFT = 0x1 << 16,
26  BST_PATTERN_MOVE_RIGHT = 0x2 << 16,
27  BST_PATTERN_MOVE_UP = 0x3 << 16,
28  BST_PATTERN_MOVE_DOWN = 0x4 << 16,
29  BST_PATTERN_PAGE_LEFT = 0x5 << 16,
30  BST_PATTERN_PAGE_RIGHT = 0x6 << 16,
31  BST_PATTERN_PAGE_UP = 0x7 << 16,
32  BST_PATTERN_PAGE_DOWN = 0x8 << 16,
33  BST_PATTERN_JUMP_LEFT = 0x9 << 16,
34  BST_PATTERN_JUMP_RIGHT = 0xa << 16,
35  BST_PATTERN_JUMP_TOP = 0xb << 16,
36  BST_PATTERN_JUMP_BOTTOM = 0xc << 16,
37  BST_PATTERN_MOVE_NEXT = 0xd << 16,
38  BST_PATTERN_SET_STEP_WIDTH = 0xe << 16,
39  BST_PATTERN_MASK_MOVEMENT = 0x00ff0000,
40 } BstPatternFunction;
41 typedef enum /*< skip >*/
42 {
43  BST_PATTERN_COLUMN_GC_TEXT0,
44  BST_PATTERN_COLUMN_GC_TEXT1,
45  BST_PATTERN_COLUMN_GC_VBAR,
46  BST_PATTERN_COLUMN_GC_LAST
47 } BstPatternColumnCellGcType;
48 typedef enum {
49  BST_PATTERN_LTYPE_SPACE,
50  BST_PATTERN_LTYPE_NOTE, /* plus #channel */
51  BST_PATTERN_LTYPE_OFFSET, /* plus #channel */
52  BST_PATTERN_LTYPE_LENGTH, /* plus #channel */
53  BST_PATTERN_LTYPE_VELOCITY, /* plus #channel */
54  BST_PATTERN_LTYPE_FINE_TUNE, /* plus #channel */
55  BST_PATTERN_LTYPE_CONTROL, /* plus #control */
56  BST_PATTERN_LTYPE_BAR,
57  BST_PATTERN_LTYPE_DBAR,
58 } BstPatternLType;
59 typedef enum {
60  BST_PATTERN_LFLAG_DIGIT_1 = 0 << 0,
61  BST_PATTERN_LFLAG_DIGIT_2 = 1 << 0,
62  BST_PATTERN_LFLAG_DIGIT_3 = 2 << 0,
63  BST_PATTERN_LFLAG_DIGIT_4 = 3 << 0,
64  BST_PATTERN_LFLAG_DIGIT_MASK = (3 << 0),
65  BST_PATTERN_LFLAG_DEC = 0 << 2,
66  BST_PATTERN_LFLAG_HEX = 1 << 2,
67  BST_PATTERN_LFLAG_NUM_MASK = (1 << 2),
68  BST_PATTERN_LFLAG_SIGNED = 1 << 5,
69  BST_PATTERN_LFLAG_LFOLD = 1 << 6,
70  BST_PATTERN_LFLAG_RFOLD = 1 << 7,
71  BST_PATTERN_LFLAG_COL1 = 0 << 8,
72  BST_PATTERN_LFLAG_COL2 = 1 << 8,
73  BST_PATTERN_LFLAG_COL3 = 2 << 8,
74  BST_PATTERN_LFLAG_COL4 = 3 << 8,
75  BST_PATTERN_LFLAG_COL_MASK = (3 << 8),
76 } BstPatternLFlags;
77 
78 /* --- typedefs & structures --- */
79 typedef struct _BstPatternView BstPatternView;
80 typedef struct _BstPatternColumn BstPatternColumn;
81 typedef struct _BstPatternColumnClass BstPatternColumnClass;
83 {
84  BstPatternColumnClass *klass;
85  gint num;
86  BstPatternLType ltype;
87  BstPatternLFlags lflags;
88  int n_focus_positions;
89  /* fields private to BstPatternView */
90  int x;
91  int width;
92  int focus_base;
93 };
95 {
96  int n_focus_positions;
97  guint instance_size;
98  void (*init) (BstPatternColumn *self);
99  PangoFontDescription* (*create_font_desc) (BstPatternColumn *self);
100  guint (*width_request) (BstPatternColumn *self,
101  BstPatternView *pview,
102  GdkWindow *drawable,
103  PangoLayout *pango_layout,
104  guint duration);
105  void (*draw_cell) (BstPatternColumn *self,
106  BstPatternView *pview,
107  GdkWindow *drawable,
108  PangoLayout *pango_layout,
109  guint tick,
110  guint duration,
111  GdkRectangle *cell_rect,
112  GdkRectangle *expose_area,
113  GdkGC *gcs[BST_PATTERN_COLUMN_GC_LAST]);
114  void (*get_focus_pos) (BstPatternColumn *self,
115  BstPatternView *pview,
116  GdkWindow *drawable,
117  PangoLayout *pango_layout,
118  guint tick,
119  guint duration,
120  GdkRectangle *cell_rect,
121  gint focus_pos,
122  gint *pos_x,
123  gint *pos_width);
124  guint collision_group;
125  gboolean (*key_event) (BstPatternColumn *self,
126  BstPatternView *pview,
127  GdkWindow *drawable,
128  PangoLayout *pango_layout,
129  guint tick,
130  guint duration,
131  GdkRectangle *cell_rect,
132  gint focus_pos,
133  guint keyval,
134  GdkModifierType modifier,
135  BstPatternFunction action,
136  gdouble param,
137  BstPatternFunction *movement);
138  void (*finalize) (BstPatternColumn *self);
139 };
140 
141 void bst_pattern_column_layouter_popup (BstPatternView *pview);
142 const gchar* bst_pattern_layout_parse_column (const gchar *string,
143  BstPatternLType *ltype,
144  gint *num,
145  BstPatternLFlags *flags);
146 BstPatternColumn* bst_pattern_column_create (BstPatternLType ltype,
147  gint num,
148  BstPatternLFlags lflags);
149 gboolean bst_pattern_column_has_notes (BstPatternColumn *column);
150 
151 G_END_DECLS
152 
153 // == Flags Enumeration Operators in C++ ==
154 #ifdef __cplusplus
155 constexpr BstPatternLFlags operator& (BstPatternLFlags s1, BstPatternLFlags s2) { return BstPatternLFlags (s1 & (long long unsigned) s2); }
156 inline BstPatternLFlags& operator&= (BstPatternLFlags &s1, BstPatternLFlags s2) { s1 = s1 & s2; return s1; }
157 constexpr BstPatternLFlags operator| (BstPatternLFlags s1, BstPatternLFlags s2) { return BstPatternLFlags (s1 | (long long unsigned) s2); }
158 inline BstPatternLFlags& operator|= (BstPatternLFlags &s1, BstPatternLFlags s2) { s1 = s1 | s2; return s1; }
159 constexpr BstPatternLFlags operator~ (BstPatternLFlags s1) { return BstPatternLFlags (~(long long unsigned) s1); }
160 constexpr BstPatternFunction operator& (BstPatternFunction s1, BstPatternFunction s2) { return BstPatternFunction (s1 & (long long unsigned) s2); }
161 inline BstPatternFunction& operator&= (BstPatternFunction &s1, BstPatternFunction s2) { s1 = s1 & s2; return s1; }
162 constexpr BstPatternFunction operator| (BstPatternFunction s1, BstPatternFunction s2) { return BstPatternFunction (s1 | (long long unsigned) s2); }
163 inline BstPatternFunction& operator|= (BstPatternFunction &s1, BstPatternFunction s2) { s1 = s1 | s2; return s1; }
164 constexpr BstPatternFunction operator~ (BstPatternFunction s1) { return BstPatternFunction (~(long long unsigned) s1); }
165 #endif // __cplusplus
166 #endif /* __BST_PATTERN_COLUMNS_H__ */
Definition: bstpatterncolumns.hh:94
Definition: bstpatternview.hh:44
Definition: bstpatterncolumns.hh:82