/[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 2695 - (hide annotations) (download) (as text)
Tue Jan 6 18:11:27 2015 UTC (9 years, 3 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 6013 byte(s)
* Sample Referenve View Dialog: Clicking on a reference in the list closes
  the dialog and jumps directly to the respective instrument, region and
  dimension region the respective sample reference is located at.

1 schoenebeck 1225 /* -*- c++ -*-
2 schoenebeck 2695 * Copyright (C) 2006-2015 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 persson 2169 #include "compat.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 schoenebeck 2695 void set_region(gig::Region* region);
77 schoenebeck 1225
78 schoenebeck 1654 void on_note_on_event(int key, int velocity);
79     void on_note_off_event(int key, int velocity);
80    
81 schoenebeck 1661 Gtk::HBox m_VirtKeybPropsBox;
82    
83 schoenebeck 1225 protected:
84 persson 2169 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
85 schoenebeck 1225 virtual bool on_expose_event(GdkEventExpose* e);
86 persson 2246 #else
87     virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
88 persson 2169 #endif
89 schoenebeck 1225 virtual bool on_button_press_event(GdkEventButton* event);
90     virtual bool on_button_release_event(GdkEventButton* event);
91     virtual bool on_motion_notify_event(GdkEventMotion* event);
92    
93     gig::Region* get_region(int key);
94    
95 persson 2169 Gdk::RGBA activeKeyColor, red, grey1, white, black;
96 schoenebeck 1225
97 persson 1261 sigc::signal<void> region_selected;
98     sigc::signal<void> instrument_changed;
99 schoenebeck 1225
100 schoenebeck 1322 sigc::signal<void, gig::Instrument*> instrument_struct_to_be_changed_signal;
101     sigc::signal<void, gig::Instrument*> instrument_struct_changed_signal;
102    
103     sigc::signal<void, gig::Region*> region_to_be_changed_signal;
104     sigc::signal<void, gig::Region*> region_changed_signal;
105    
106 schoenebeck 1660 sigc::signal<void, int/*key*/, int/*velocity*/> keyboard_key_hit_signal;
107     sigc::signal<void, int/*key*/, int/*velocity*/> keyboard_key_released_signal;
108    
109 schoenebeck 1225 gig::Instrument* instrument;
110     gig::Region* region;
111 persson 1623 SortedRegions regions;
112 schoenebeck 1225
113 schoenebeck 1654 bool is_black_key(int key);
114 persson 2246 void draw_keyboard(const Cairo::RefPtr<Cairo::Context>& cr,
115     int clip_low, int clip_high);
116     void draw_regions(const Cairo::RefPtr<Cairo::Context>& cr,
117     int clip_low, int clip_high);
118     void draw_key(const Cairo::RefPtr<Cairo::Context>& cr, int key);
119     void draw_digit(const Cairo::RefPtr<Cairo::Context>& cr, int key);
120 persson 1262 void motion_resize_region(int x, int y);
121     void motion_move_region(int x, int y);
122 persson 2246 void update_after_resize();
123     void update_after_move(int pos);
124     void invalidate_key(int key);
125 persson 1262
126 persson 2246 // returns the leftmost pixel of a key
127     int key_to_x(double k, int w) const {
128     return int(k * w / 128.0 + 0.5);
129     }
130    
131     // returns the key given a pixel
132     int x_to_key(double x, int w) const {
133     return int(x / w * 128.0);
134     }
135    
136     // returns the key given a pixel. If the pixel is the border
137     // between two keys, the key to the r�ght is always returned.
138     int x_to_key_right(double x, int w) const {
139     return int(ceil((x + 0.5) / w * 128.0)) - 1;
140     }
141    
142 schoenebeck 1225 // information needed during a resize
143     struct {
144     bool active;
145     enum {
146     undecided,
147     moving_high_limit,
148     moving_low_limit
149     } mode;
150     int pos;
151     int min;
152     int max;
153     gig::Region* region;
154     gig::Region* prev_region;
155     } resize;
156    
157 persson 1262 // information needed during a region move
158     struct {
159     bool active;
160 persson 2246 int offset;
161 persson 1262 } move;
162    
163 schoenebeck 1225 bool cursor_is_resize;
164     bool is_in_resize_zone(double x, double y);
165    
166     int h1;
167    
168     Gtk::Menu* popup_menu_inside_region;
169     Gtk::Menu* popup_menu_outside_region;
170     void show_region_properties();
171     void add_region();
172     void delete_region();
173     void manage_dimensions();
174     void on_dimension_manager_changed();
175     int new_region_pos;
176    
177     Glib::RefPtr<Gtk::ActionGroup> actionGroup;
178     Glib::RefPtr<Gtk::UIManager> uiManager;
179    
180 persson 2246 // properties of the virtual keyboard
181 schoenebeck 1661 ChoiceEntry<virt_keyboard_mode_t> m_VirtKeybModeChoice;
182     Gtk::Label m_VirtKeybVelocityLabelDescr;
183     Gtk::Label m_VirtKeybVelocityLabel;
184     Gtk::Label m_VirtKeybOffVelocityLabelDescr;
185     Gtk::Label m_VirtKeybOffVelocityLabel;
186     int currentActiveKey;
187 persson 2246 bool key_pressed[128];
188 schoenebeck 1661
189 schoenebeck 1225 DimensionManager dimensionManager;
190     };
191    
192     #endif

  ViewVC Help
Powered by ViewVC