~ubuntu-branches/ubuntu/utopic/ardour3/utopic

« back to all changes in this revision

Viewing changes to gtk2_ardour/gtk_pianokeyboard.h

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler
  • Date: 2013-09-21 19:05:02 UTC
  • Revision ID: package-import@ubuntu.com-20130921190502-8gsftrku6jnzhd7v
Tags: upstream-3.4~dfsg
ImportĀ upstreamĀ versionĀ 3.4~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (C) 2012 Paul Davis 
 
3
 
 
4
    This program is free software; you can redistribute it and/or modify
 
5
    it under the terms of the GNU General Public License as published by
 
6
    the Free Software Foundation; either version 2 of the License, or
 
7
    (at your option) any later version.
 
8
 
 
9
    This program 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
 
12
    GNU General Public License for more details.
 
13
 
 
14
    You should have received a copy of the GNU General Public License
 
15
    along with this program; if not, write to the Free Software
 
16
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
17
 
 
18
*/
 
19
 
 
20
#ifndef __PIANO_KEYBOARD_H__
 
21
#define __PIANO_KEYBOARD_H__
 
22
 
 
23
#include <glib.h>
 
24
#include <gtk/gtkdrawingarea.h>
 
25
 
 
26
G_BEGIN_DECLS
 
27
 
 
28
#define TYPE_PIANO_KEYBOARD                     (piano_keyboard_get_type ())
 
29
#define PIANO_KEYBOARD(obj)                     (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PIANO_KEYBOARD, PianoKeyboard))
 
30
#define PIANO_KEYBOARD_CLASS(klass)             (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PIANO_KEYBOARD, PianoKeyboardClass))
 
31
#define IS_PIANO_KEYBOARD(obj)                  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PIANO_KEYBOARD))
 
32
#define IS_PIANO_KEYBOARD_CLASS(klass)          (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PIANO_KEYBOARD))
 
33
#define PIANO_KEYBOARD_GET_CLASS(obj)           (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PIANO_KEYBOARD, PianoKeyboardClass))
 
34
 
 
35
typedef struct  _PianoKeyboard                  PianoKeyboard;
 
36
typedef struct  _PianoKeyboardClass             PianoKeyboardClass;
 
37
 
 
38
#define NNOTES                  127
 
39
 
 
40
#define OCTAVE_MIN      -1
 
41
#define OCTAVE_MAX      7
 
42
 
 
43
struct Note {
 
44
        int                     pressed;                /* 1 if key is in pressed down state. */
 
45
        int                     sustained;              /* 1 if note is sustained. */
 
46
        int                     x;                      /* Distance between the left edge of the key
 
47
                                                         * and the left edge of the widget, in pixels. */
 
48
        int                     w;                      /* Width of the key, in pixels. */
 
49
        int                     h;                      /* Height of the key, in pixels. */
 
50
        int                     white;                  /* 1 if key is white; 0 otherwise. */
 
51
};
 
52
 
 
53
struct _PianoKeyboard
 
54
{
 
55
        GtkDrawingArea          da;
 
56
        int                     maybe_stop_sustained_notes;
 
57
        int                     sustain_new_notes;
 
58
        int                     enable_keyboard_cue;
 
59
        int                     octave;
 
60
        int                     widget_margin;
 
61
        int                     note_being_pressed_using_mouse;
 
62
        volatile struct Note    notes[NNOTES];
 
63
        /* Table used to translate from PC keyboard character to MIDI note number. */
 
64
        GHashTable              *key_bindings;
 
65
};
 
66
 
 
67
struct _PianoKeyboardClass
 
68
{
 
69
        GtkDrawingAreaClass     parent_class;
 
70
};
 
71
 
 
72
GType           piano_keyboard_get_type         (void) G_GNUC_CONST;
 
73
GtkWidget*      piano_keyboard_new              (void);
 
74
void            piano_keyboard_sustain_press    (PianoKeyboard *pk);
 
75
void            piano_keyboard_sustain_release  (PianoKeyboard *pk);
 
76
void            piano_keyboard_set_note_on      (PianoKeyboard *pk, int note);
 
77
void            piano_keyboard_set_note_off     (PianoKeyboard *pk, int note);
 
78
void            piano_keyboard_set_keyboard_cue (PianoKeyboard *pk, int enabled);
 
79
void            piano_keyboard_set_octave (PianoKeyboard *pk, int octave);
 
80
gboolean        piano_keyboard_set_keyboard_layout (PianoKeyboard *pk, const char *layout);
 
81
 
 
82
G_END_DECLS
 
83
 
 
84
#endif /* __PIANO_KEYBOARD_H__ */
 
85