BEAST/BSE - Better Audio System and Sound Engine  0.8.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
bstpatterncolumns.hh
Go to the documentation of this file.
00001  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
00002 #ifndef __BST_PATTERN_COLUMNS_H__
00003 #define __BST_PATTERN_COLUMNS_H__
00004 
00005 #include "bstutils.hh"
00006 
00007 G_BEGIN_DECLS
00008 
00009 /* --- enums --- */
00010 typedef enum /*< skip >*/
00011 {
00012   BST_PATTERN_NONE                = 0,
00013   /* events */
00014   BST_PATTERN_REMOVE_EVENTS,
00015   BST_PATTERN_SET_NOTE,           /* #note */
00016   BST_PATTERN_SET_OCTAVE,         /* #octave */
00017   BST_PATTERN_NUMERIC_CHANGE,     /* -32 .. +32 */
00018   BST_PATTERN_SET_DIGIT,          /* 0 .. +32 */
00019   BST_PATTERN_MASK_ACTION         = 0x000000ff,
00020   /* base octave */
00021   BST_PATTERN_SET_BASE_OCTAVE     = 0x1 << 8,
00022   BST_PATTERN_CHANGE_BASE_OCTAVE  = 0x2 << 8,
00023   BST_PATTERN_MASK_CONTROLS       = 0x0000ff00,
00024   /* focus movement */
00025   BST_PATTERN_MOVE_LEFT           = 0x1 << 16,
00026   BST_PATTERN_MOVE_RIGHT          = 0x2 << 16,
00027   BST_PATTERN_MOVE_UP             = 0x3 << 16,
00028   BST_PATTERN_MOVE_DOWN           = 0x4 << 16,
00029   BST_PATTERN_PAGE_LEFT           = 0x5 << 16,
00030   BST_PATTERN_PAGE_RIGHT          = 0x6 << 16,
00031   BST_PATTERN_PAGE_UP             = 0x7 << 16,
00032   BST_PATTERN_PAGE_DOWN           = 0x8 << 16,
00033   BST_PATTERN_JUMP_LEFT           = 0x9 << 16,
00034   BST_PATTERN_JUMP_RIGHT          = 0xa << 16,
00035   BST_PATTERN_JUMP_TOP            = 0xb << 16,
00036   BST_PATTERN_JUMP_BOTTOM         = 0xc << 16,
00037   BST_PATTERN_MOVE_NEXT           = 0xd << 16,
00038   BST_PATTERN_SET_STEP_WIDTH      = 0xe << 16,
00039   BST_PATTERN_MASK_MOVEMENT       = 0x00ff0000,
00040 } BstPatternFunction;
00041 typedef enum /*< skip >*/
00042 {
00043   BST_PATTERN_COLUMN_GC_TEXT0,
00044   BST_PATTERN_COLUMN_GC_TEXT1,
00045   BST_PATTERN_COLUMN_GC_VBAR,
00046   BST_PATTERN_COLUMN_GC_LAST
00047 } BstPatternColumnCellGcType;
00048 typedef enum {
00049   BST_PATTERN_LTYPE_SPACE,
00050   BST_PATTERN_LTYPE_NOTE,       /* plus #channel */
00051   BST_PATTERN_LTYPE_OFFSET,     /* plus #channel */
00052   BST_PATTERN_LTYPE_LENGTH,     /* plus #channel */
00053   BST_PATTERN_LTYPE_VELOCITY,   /* plus #channel */
00054   BST_PATTERN_LTYPE_FINE_TUNE,  /* plus #channel */
00055   BST_PATTERN_LTYPE_CONTROL,    /* plus #control */
00056   BST_PATTERN_LTYPE_BAR,
00057   BST_PATTERN_LTYPE_DBAR,
00058 } BstPatternLType;
00059 typedef enum {
00060   BST_PATTERN_LFLAG_DIGIT_1     = 0 << 0,
00061   BST_PATTERN_LFLAG_DIGIT_2     = 1 << 0,
00062   BST_PATTERN_LFLAG_DIGIT_3     = 2 << 0,
00063   BST_PATTERN_LFLAG_DIGIT_4     = 3 << 0,
00064   BST_PATTERN_LFLAG_DIGIT_MASK  = (3 << 0),
00065   BST_PATTERN_LFLAG_DEC         = 0 << 2,
00066   BST_PATTERN_LFLAG_HEX         = 1 << 2,
00067   BST_PATTERN_LFLAG_NUM_MASK    = (1 << 2),
00068   BST_PATTERN_LFLAG_SIGNED      = 1 << 5,
00069   BST_PATTERN_LFLAG_LFOLD       = 1 << 6,
00070   BST_PATTERN_LFLAG_RFOLD       = 1 << 7,
00071   BST_PATTERN_LFLAG_COL1        = 0 << 8,
00072   BST_PATTERN_LFLAG_COL2        = 1 << 8,
00073   BST_PATTERN_LFLAG_COL3        = 2 << 8,
00074   BST_PATTERN_LFLAG_COL4        = 3 << 8,
00075   BST_PATTERN_LFLAG_COL_MASK    = (3 << 8),
00076 } BstPatternLFlags;
00077 
00078 /* --- typedefs & structures --- */
00079 typedef struct _BstPatternView        BstPatternView;
00080 typedef struct _BstPatternColumn      BstPatternColumn;
00081 typedef struct _BstPatternColumnClass BstPatternColumnClass;
00082 struct _BstPatternColumn
00083 {
00084   BstPatternColumnClass *klass;
00085   gint                   num;
00086   BstPatternLType        ltype;
00087   BstPatternLFlags       lflags;
00088   int                    n_focus_positions;
00089   /* fields private to BstPatternView */
00090   int                    x;
00091   int                    width;
00092   int                    focus_base;
00093 };
00094 struct _BstPatternColumnClass
00095 {
00096   int                     n_focus_positions;
00097   guint                   instance_size;
00098   void                  (*init)                 (BstPatternColumn       *self);
00099   PangoFontDescription* (*create_font_desc)     (BstPatternColumn       *self);
00100   guint                 (*width_request)        (BstPatternColumn       *self,
00101                                                  BstPatternView         *pview,
00102                                                  GdkWindow              *drawable,
00103                                                  PangoLayout            *pango_layout,
00104                                                  guint                   duration);
00105   void                  (*draw_cell)            (BstPatternColumn       *self,
00106                                                  BstPatternView         *pview,
00107                                                  GdkWindow              *drawable,
00108                                                  PangoLayout            *pango_layout,
00109                                                  guint                   tick,
00110                                                  guint                   duration,
00111                                                  GdkRectangle           *cell_rect,
00112                                                  GdkRectangle           *expose_area,
00113                                                  GdkGC                  *gcs[BST_PATTERN_COLUMN_GC_LAST]);
00114   void                  (*get_focus_pos)        (BstPatternColumn       *self,
00115                                                  BstPatternView         *pview,
00116                                                  GdkWindow              *drawable,
00117                                                  PangoLayout            *pango_layout,
00118                                                  guint                   tick,
00119                                                  guint                   duration,
00120                                                  GdkRectangle           *cell_rect,
00121                                                  gint                    focus_pos,
00122                                                  gint                   *pos_x,
00123                                                  gint                   *pos_width);
00124   guint                   collision_group;
00125   gboolean              (*key_event)            (BstPatternColumn       *self,
00126                                                  BstPatternView         *pview,
00127                                                  GdkWindow              *drawable,
00128                                                  PangoLayout            *pango_layout,
00129                                                  guint                   tick,
00130                                                  guint                   duration,
00131                                                  GdkRectangle           *cell_rect,
00132                                                  gint                    focus_pos,
00133                                                  guint                   keyval,
00134                                                  GdkModifierType         modifier,
00135                                                  BstPatternFunction      action,
00136                                                  gdouble                 param,
00137                                                  BstPatternFunction     *movement);
00138   void                  (*finalize)             (BstPatternColumn       *self);
00139 };
00140 
00141 void              bst_pattern_column_layouter_popup (BstPatternView   *pview);
00142 const gchar*      bst_pattern_layout_parse_column   (const gchar      *string,
00143                                                      BstPatternLType  *ltype,
00144                                                      gint             *num,
00145                                                      BstPatternLFlags *flags);
00146 BstPatternColumn* bst_pattern_column_create         (BstPatternLType   ltype,
00147                                                      gint              num,
00148                                                      BstPatternLFlags  lflags);
00149 gboolean          bst_pattern_column_has_notes      (BstPatternColumn *column);
00150 
00151 G_END_DECLS
00152 
00153 // == Flags Enumeration Operators in C++ ==
00154 #ifdef __cplusplus
00155 constexpr BstPatternLFlags  operator&  (BstPatternLFlags  s1, BstPatternLFlags s2) { return BstPatternLFlags (s1 & (long long unsigned) s2); }
00156 inline    BstPatternLFlags& operator&= (BstPatternLFlags &s1, BstPatternLFlags s2) { s1 = s1 & s2; return s1; }
00157 constexpr BstPatternLFlags  operator|  (BstPatternLFlags  s1, BstPatternLFlags s2) { return BstPatternLFlags (s1 | (long long unsigned) s2); }
00158 inline    BstPatternLFlags& operator|= (BstPatternLFlags &s1, BstPatternLFlags s2) { s1 = s1 | s2; return s1; }
00159 constexpr BstPatternLFlags  operator~  (BstPatternLFlags  s1)                      { return BstPatternLFlags (~(long long unsigned) s1); }
00160 constexpr BstPatternFunction  operator&  (BstPatternFunction  s1, BstPatternFunction s2) { return BstPatternFunction (s1 & (long long unsigned) s2); }
00161 inline    BstPatternFunction& operator&= (BstPatternFunction &s1, BstPatternFunction s2) { s1 = s1 & s2; return s1; }
00162 constexpr BstPatternFunction  operator|  (BstPatternFunction  s1, BstPatternFunction s2) { return BstPatternFunction (s1 | (long long unsigned) s2); }
00163 inline    BstPatternFunction& operator|= (BstPatternFunction &s1, BstPatternFunction s2) { s1 = s1 | s2; return s1; }
00164 constexpr BstPatternFunction  operator~  (BstPatternFunction  s1)                      { return BstPatternFunction (~(long long unsigned) s1); }
00165 #endif // __cplusplus
00166 #endif /* __BST_PATTERN_COLUMNS_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines