/[svn]/gigedit/trunk/src/gigedit/regionchooser.h
ViewVC logotype

Annotation of /gigedit/trunk/src/gigedit/regionchooser.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1661 - (hide annotations) (download) (as text)
Sun Feb 3 14:10:47 2008 UTC (16 years, 2 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 5109 byte(s)
* implemented alternative behavior for the virtual MIDI keyboard
  (selectable by combobox below the keyboard)
* show absolute velocity value of note-on & note-off events below
  the virtual MIDI keyboard

1 schoenebeck 1225 /* -*- c++ -*-
2 persson 1623 * Copyright (C) 2006-2008 Andreas Persson
3 schoenebeck 1225 *
4     * This program is free software; you can redistribute it and/or
5     * modify it under the terms of the GNU General Public License as
6     * published by the Free Software Foundation; either version 2, or (at
7     * your option) any later version.
8     *
9     * This program is distributed in the hope that it will be useful, but
10     * WITHOUT ANY WARRANTY; without even the implied warranty of
11     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12     * General Public License for more details.
13     *
14     * You should have received a copy of the GNU General Public License
15     * along with program; see the file COPYING. If not, write to the Free
16     * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17     * 02110-1301 USA.
18     */
19    
20     #ifndef GIGEDIT_REGIONCHOOSER_H
21     #define GIGEDIT_REGIONCHOOSER_H
22    
23 persson 1623 #include <vector>
24    
25 schoenebeck 1225 #include <gtkmm/drawingarea.h>
26     #include <gdkmm/colormap.h>
27     #include <gtkmm/uimanager.h>
28     #include <gdkmm/window.h>
29     #include <gtkmm/menu.h>
30    
31     #include "dimensionmanager.h"
32 schoenebeck 1661 #include "paramedit.h"
33 schoenebeck 1225
34     #include <gig.h>
35    
36 schoenebeck 1661 enum virt_keyboard_mode_t {
37     VIRT_KEYBOARD_MODE_NORMAL,
38     VIRT_KEYBOARD_MODE_CHORD
39     };
40    
41 persson 1623 class SortedRegions {
42     private:
43     std::vector<gig::Region*> regions;
44     std::vector<gig::Region*>::iterator region_iterator;
45    
46     public:
47     void update(gig::Instrument* instrument);
48     gig::Region* first();
49     gig::Region* next();
50     bool operator() (gig::Region* x, gig::Region* y) {
51     return x->KeyRange.low < y->KeyRange.low;
52     }
53     };
54    
55 schoenebeck 1225 class RegionChooser : public Gtk::DrawingArea
56     {
57     public:
58     RegionChooser();
59     virtual ~RegionChooser();
60    
61     void set_instrument(gig::Instrument* instrument);
62    
63 schoenebeck 1339 sigc::signal<void>& signal_region_selected();
64     sigc::signal<void>& signal_instrument_changed();
65 schoenebeck 1225
66 schoenebeck 1339 sigc::signal<void, gig::Instrument*>& signal_instrument_struct_to_be_changed();
67     sigc::signal<void, gig::Instrument*>& signal_instrument_struct_changed();
68 schoenebeck 1322
69 schoenebeck 1339 sigc::signal<void, gig::Region*>& signal_region_to_be_changed();
70     sigc::signal<void, gig::Region*>& signal_region_changed_signal();
71 schoenebeck 1322
72 schoenebeck 1660 sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_hit();
73     sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_released();
74    
75 schoenebeck 1225 gig::Region* get_region() { return region; }
76    
77 schoenebeck 1654 void on_note_on_event(int key, int velocity);
78     void on_note_off_event(int key, int velocity);
79    
80 schoenebeck 1661 Gtk::HBox m_VirtKeybPropsBox;
81    
82 schoenebeck 1225 protected:
83     virtual void on_realize();
84     virtual bool on_expose_event(GdkEventExpose* e);
85     virtual void on_size_request(GtkRequisition* requisition);
86     virtual bool on_button_press_event(GdkEventButton* event);
87     virtual bool on_button_release_event(GdkEventButton* event);
88     virtual bool on_motion_notify_event(GdkEventMotion* event);
89    
90     gig::Region* get_region(int key);
91    
92     Glib::RefPtr<Gdk::GC> gc;
93 schoenebeck 1654 Gdk::Color activeKeyColor, red, grey1, white, black;
94 schoenebeck 1225
95 persson 1261 sigc::signal<void> region_selected;
96     sigc::signal<void> instrument_changed;
97 schoenebeck 1225
98 schoenebeck 1322 sigc::signal<void, gig::Instrument*> instrument_struct_to_be_changed_signal;
99     sigc::signal<void, gig::Instrument*> instrument_struct_changed_signal;
100    
101     sigc::signal<void, gig::Region*> region_to_be_changed_signal;
102     sigc::signal<void, gig::Region*> region_changed_signal;
103    
104 schoenebeck 1660 sigc::signal<void, int/*key*/, int/*velocity*/> keyboard_key_hit_signal;
105     sigc::signal<void, int/*key*/, int/*velocity*/> keyboard_key_released_signal;
106    
107 schoenebeck 1225 gig::Instrument* instrument;
108     gig::Region* region;
109 persson 1623 SortedRegions regions;
110 schoenebeck 1225
111 schoenebeck 1654 bool is_black_key(int key);
112     void draw_region(int from, int to, const Gdk::Color& color);
113 persson 1658 void draw_digit(int key);
114 persson 1262 void motion_resize_region(int x, int y);
115     void motion_move_region(int x, int y);
116    
117 schoenebeck 1225 // information needed during a resize
118     struct {
119     bool active;
120     enum {
121     undecided,
122     moving_high_limit,
123     moving_low_limit
124     } mode;
125     int pos;
126     int min;
127     int max;
128     gig::Region* region;
129     gig::Region* prev_region;
130     } resize;
131    
132 persson 1262 // information needed during a region move
133     struct {
134     bool active;
135     double from_x;
136     int pos;
137     bool touch_left;
138     bool touch_right;
139     } move;
140    
141 schoenebeck 1225 bool cursor_is_resize;
142     bool is_in_resize_zone(double x, double y);
143    
144     int h1;
145    
146     Gtk::Menu* popup_menu_inside_region;
147     Gtk::Menu* popup_menu_outside_region;
148     void show_region_properties();
149     void add_region();
150     void delete_region();
151     void manage_dimensions();
152     void on_dimension_manager_changed();
153     int new_region_pos;
154    
155     Glib::RefPtr<Gtk::ActionGroup> actionGroup;
156     Glib::RefPtr<Gtk::UIManager> uiManager;
157    
158 schoenebeck 1661 // properties of the virtaul keyboard
159     ChoiceEntry<virt_keyboard_mode_t> m_VirtKeybModeChoice;
160     Gtk::Label m_VirtKeybVelocityLabelDescr;
161     Gtk::Label m_VirtKeybVelocityLabel;
162     Gtk::Label m_VirtKeybOffVelocityLabelDescr;
163     Gtk::Label m_VirtKeybOffVelocityLabel;
164     int currentActiveKey;
165    
166 schoenebeck 1225 DimensionManager dimensionManager;
167     };
168    
169     #endif

  ViewVC Help
Powered by ViewVC