/[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 2151 - (hide annotations) (download) (as text)
Sun Nov 21 12:38:41 2010 UTC (13 years, 5 months ago) by persson
File MIME type: text/x-c++hdr
File size: 5008 byte(s)
* use Cairo instead of deprecated gdk drawing primitives
* avoid deprecated gtk methods when using newer gtk versions
* raised minimum supported gtkmm version to 2.8

1 schoenebeck 1225 /* -*- c++ -*-
2 persson 2151 * Copyright (C) 2006-2010 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 <gtkmm/uimanager.h>
27     #include <gdkmm/window.h>
28     #include <gtkmm/menu.h>
29    
30     #include "dimensionmanager.h"
31 schoenebeck 1661 #include "paramedit.h"
32 schoenebeck 1225
33     #include <gig.h>
34    
35 schoenebeck 1661 enum virt_keyboard_mode_t {
36     VIRT_KEYBOARD_MODE_NORMAL,
37     VIRT_KEYBOARD_MODE_CHORD
38     };
39    
40 persson 1623 class SortedRegions {
41     private:
42     std::vector<gig::Region*> regions;
43     std::vector<gig::Region*>::iterator region_iterator;
44    
45     public:
46     void update(gig::Instrument* instrument);
47     gig::Region* first();
48     gig::Region* next();
49     bool operator() (gig::Region* x, gig::Region* y) {
50     return x->KeyRange.low < y->KeyRange.low;
51     }
52     };
53    
54 schoenebeck 1225 class RegionChooser : public Gtk::DrawingArea
55     {
56     public:
57     RegionChooser();
58     virtual ~RegionChooser();
59    
60     void set_instrument(gig::Instrument* instrument);
61    
62 schoenebeck 1339 sigc::signal<void>& signal_region_selected();
63     sigc::signal<void>& signal_instrument_changed();
64 schoenebeck 1225
65 schoenebeck 1339 sigc::signal<void, gig::Instrument*>& signal_instrument_struct_to_be_changed();
66     sigc::signal<void, gig::Instrument*>& signal_instrument_struct_changed();
67 schoenebeck 1322
68 schoenebeck 1339 sigc::signal<void, gig::Region*>& signal_region_to_be_changed();
69     sigc::signal<void, gig::Region*>& signal_region_changed_signal();
70 schoenebeck 1322
71 schoenebeck 1660 sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_hit();
72     sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_released();
73    
74 schoenebeck 1225 gig::Region* get_region() { return region; }
75    
76 schoenebeck 1654 void on_note_on_event(int key, int velocity);
77     void on_note_off_event(int key, int velocity);
78    
79 schoenebeck 1661 Gtk::HBox m_VirtKeybPropsBox;
80    
81 schoenebeck 1225 protected:
82     virtual bool on_expose_event(GdkEventExpose* e);
83     virtual void on_size_request(GtkRequisition* requisition);
84     virtual bool on_button_press_event(GdkEventButton* event);
85     virtual bool on_button_release_event(GdkEventButton* event);
86     virtual bool on_motion_notify_event(GdkEventMotion* event);
87    
88     gig::Region* get_region(int key);
89    
90 schoenebeck 1654 Gdk::Color activeKeyColor, red, grey1, white, black;
91 schoenebeck 1225
92 persson 1261 sigc::signal<void> region_selected;
93     sigc::signal<void> instrument_changed;
94 schoenebeck 1225
95 schoenebeck 1322 sigc::signal<void, gig::Instrument*> instrument_struct_to_be_changed_signal;
96     sigc::signal<void, gig::Instrument*> instrument_struct_changed_signal;
97    
98     sigc::signal<void, gig::Region*> region_to_be_changed_signal;
99     sigc::signal<void, gig::Region*> region_changed_signal;
100    
101 schoenebeck 1660 sigc::signal<void, int/*key*/, int/*velocity*/> keyboard_key_hit_signal;
102     sigc::signal<void, int/*key*/, int/*velocity*/> keyboard_key_released_signal;
103    
104 schoenebeck 1225 gig::Instrument* instrument;
105     gig::Region* region;
106 persson 1623 SortedRegions regions;
107 schoenebeck 1225
108 schoenebeck 1654 bool is_black_key(int key);
109 persson 2151 void draw_key(int key, const Gdk::Color& color);
110 persson 1658 void draw_digit(int key);
111 persson 1262 void motion_resize_region(int x, int y);
112     void motion_move_region(int x, int y);
113    
114 schoenebeck 1225 // information needed during a resize
115     struct {
116     bool active;
117     enum {
118     undecided,
119     moving_high_limit,
120     moving_low_limit
121     } mode;
122     int pos;
123     int min;
124     int max;
125     gig::Region* region;
126     gig::Region* prev_region;
127     } resize;
128    
129 persson 1262 // information needed during a region move
130     struct {
131     bool active;
132     double from_x;
133     int pos;
134     bool touch_left;
135     bool touch_right;
136     } move;
137    
138 schoenebeck 1225 bool cursor_is_resize;
139     bool is_in_resize_zone(double x, double y);
140    
141     int h1;
142    
143     Gtk::Menu* popup_menu_inside_region;
144     Gtk::Menu* popup_menu_outside_region;
145     void show_region_properties();
146     void add_region();
147     void delete_region();
148     void manage_dimensions();
149     void on_dimension_manager_changed();
150     int new_region_pos;
151    
152     Glib::RefPtr<Gtk::ActionGroup> actionGroup;
153     Glib::RefPtr<Gtk::UIManager> uiManager;
154    
155 schoenebeck 1661 // properties of the virtaul keyboard
156     ChoiceEntry<virt_keyboard_mode_t> m_VirtKeybModeChoice;
157     Gtk::Label m_VirtKeybVelocityLabelDescr;
158     Gtk::Label m_VirtKeybVelocityLabel;
159     Gtk::Label m_VirtKeybOffVelocityLabelDescr;
160     Gtk::Label m_VirtKeybOffVelocityLabel;
161     int currentActiveKey;
162    
163 schoenebeck 1225 DimensionManager dimensionManager;
164     };
165    
166     #endif

  ViewVC Help
Powered by ViewVC