/[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 1654 - (hide annotations) (download) (as text)
Wed Jan 30 02:20:48 2008 UTC (16 years, 2 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 4298 byte(s)
* first step to make the virtual keyboard interactive: active keys of the
  sampler (in live-mode only of course) are highlighted on the virtual
  keyboard - NOTE: yet inaccurate draw of the keys and this mechanism
  yet only works on the first gigedit invocation by the sampler process,
  so this still has to be fixed

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    
33     #include <gig.h>
34    
35 persson 1623 class SortedRegions {
36     private:
37     std::vector<gig::Region*> regions;
38     std::vector<gig::Region*>::iterator region_iterator;
39    
40     public:
41     void update(gig::Instrument* instrument);
42     gig::Region* first();
43     gig::Region* next();
44     bool operator() (gig::Region* x, gig::Region* y) {
45     return x->KeyRange.low < y->KeyRange.low;
46     }
47     };
48    
49 schoenebeck 1225 class RegionChooser : public Gtk::DrawingArea
50     {
51     public:
52     RegionChooser();
53     virtual ~RegionChooser();
54    
55     void set_instrument(gig::Instrument* instrument);
56    
57 schoenebeck 1339 sigc::signal<void>& signal_region_selected();
58     sigc::signal<void>& signal_instrument_changed();
59 schoenebeck 1225
60 schoenebeck 1339 sigc::signal<void, gig::Instrument*>& signal_instrument_struct_to_be_changed();
61     sigc::signal<void, gig::Instrument*>& signal_instrument_struct_changed();
62 schoenebeck 1322
63 schoenebeck 1339 sigc::signal<void, gig::Region*>& signal_region_to_be_changed();
64     sigc::signal<void, gig::Region*>& signal_region_changed_signal();
65 schoenebeck 1322
66 schoenebeck 1225 gig::Region* get_region() { return region; }
67    
68 schoenebeck 1654 void on_note_on_event(int key, int velocity);
69     void on_note_off_event(int key, int velocity);
70    
71 schoenebeck 1225 protected:
72     virtual void on_realize();
73     virtual bool on_expose_event(GdkEventExpose* e);
74     virtual void on_size_request(GtkRequisition* requisition);
75     virtual bool on_button_press_event(GdkEventButton* event);
76     virtual bool on_button_release_event(GdkEventButton* event);
77     virtual bool on_motion_notify_event(GdkEventMotion* event);
78    
79     gig::Region* get_region(int key);
80    
81     Glib::RefPtr<Gdk::GC> gc;
82 schoenebeck 1654 Gdk::Color activeKeyColor, red, grey1, white, black;
83 schoenebeck 1225
84 persson 1261 sigc::signal<void> region_selected;
85     sigc::signal<void> instrument_changed;
86 schoenebeck 1225
87 schoenebeck 1322 sigc::signal<void, gig::Instrument*> instrument_struct_to_be_changed_signal;
88     sigc::signal<void, gig::Instrument*> instrument_struct_changed_signal;
89    
90     sigc::signal<void, gig::Region*> region_to_be_changed_signal;
91     sigc::signal<void, gig::Region*> region_changed_signal;
92    
93 schoenebeck 1225 gig::Instrument* instrument;
94     gig::Region* region;
95 persson 1623 SortedRegions regions;
96 schoenebeck 1225
97 schoenebeck 1654 bool is_black_key(int key);
98     void draw_region(int from, int to, const Gdk::Color& color);
99 persson 1262 void motion_resize_region(int x, int y);
100     void motion_move_region(int x, int y);
101    
102 schoenebeck 1225 // information needed during a resize
103     struct {
104     bool active;
105     enum {
106     undecided,
107     moving_high_limit,
108     moving_low_limit
109     } mode;
110     int pos;
111     int min;
112     int max;
113     gig::Region* region;
114     gig::Region* prev_region;
115     } resize;
116    
117 persson 1262 // information needed during a region move
118     struct {
119     bool active;
120     double from_x;
121     int pos;
122     bool touch_left;
123     bool touch_right;
124     } move;
125    
126 schoenebeck 1225 bool cursor_is_resize;
127     bool is_in_resize_zone(double x, double y);
128    
129     int h1;
130    
131     Gtk::Menu* popup_menu_inside_region;
132     Gtk::Menu* popup_menu_outside_region;
133     void show_region_properties();
134     void add_region();
135     void delete_region();
136     void manage_dimensions();
137     void on_dimension_manager_changed();
138     int new_region_pos;
139    
140     Glib::RefPtr<Gtk::ActionGroup> actionGroup;
141     Glib::RefPtr<Gtk::UIManager> uiManager;
142    
143     DimensionManager dimensionManager;
144     };
145    
146     #endif

  ViewVC Help
Powered by ViewVC