/[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 1660 - (hide annotations) (download) (as text)
Sun Feb 3 00:19:55 2008 UTC (16 years, 2 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 4654 byte(s)
* call it virtually baby: the keyboard finally can trigger notes on
  sampler side (only in live-mode of course)
* added a red cross on top of the detached-mode icon to make
  it more obvious

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 1660 sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_hit();
67     sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_released();
68    
69 schoenebeck 1225 gig::Region* get_region() { return region; }
70    
71 schoenebeck 1654 void on_note_on_event(int key, int velocity);
72     void on_note_off_event(int key, int velocity);
73    
74 schoenebeck 1225 protected:
75     virtual void on_realize();
76     virtual bool on_expose_event(GdkEventExpose* e);
77     virtual void on_size_request(GtkRequisition* requisition);
78     virtual bool on_button_press_event(GdkEventButton* event);
79     virtual bool on_button_release_event(GdkEventButton* event);
80     virtual bool on_motion_notify_event(GdkEventMotion* event);
81    
82     gig::Region* get_region(int key);
83    
84     Glib::RefPtr<Gdk::GC> gc;
85 schoenebeck 1654 Gdk::Color activeKeyColor, red, grey1, white, black;
86 schoenebeck 1225
87 persson 1261 sigc::signal<void> region_selected;
88     sigc::signal<void> instrument_changed;
89 schoenebeck 1225
90 schoenebeck 1322 sigc::signal<void, gig::Instrument*> instrument_struct_to_be_changed_signal;
91     sigc::signal<void, gig::Instrument*> instrument_struct_changed_signal;
92    
93     sigc::signal<void, gig::Region*> region_to_be_changed_signal;
94     sigc::signal<void, gig::Region*> region_changed_signal;
95    
96 schoenebeck 1660 sigc::signal<void, int/*key*/, int/*velocity*/> keyboard_key_hit_signal;
97     sigc::signal<void, int/*key*/, int/*velocity*/> keyboard_key_released_signal;
98    
99 schoenebeck 1225 gig::Instrument* instrument;
100     gig::Region* region;
101 persson 1623 SortedRegions regions;
102 schoenebeck 1225
103 schoenebeck 1654 bool is_black_key(int key);
104     void draw_region(int from, int to, const Gdk::Color& color);
105 persson 1658 void draw_digit(int key);
106 persson 1262 void motion_resize_region(int x, int y);
107     void motion_move_region(int x, int y);
108    
109 schoenebeck 1225 // information needed during a resize
110     struct {
111     bool active;
112     enum {
113     undecided,
114     moving_high_limit,
115     moving_low_limit
116     } mode;
117     int pos;
118     int min;
119     int max;
120     gig::Region* region;
121     gig::Region* prev_region;
122     } resize;
123    
124 persson 1262 // information needed during a region move
125     struct {
126     bool active;
127     double from_x;
128     int pos;
129     bool touch_left;
130     bool touch_right;
131     } move;
132    
133 schoenebeck 1225 bool cursor_is_resize;
134     bool is_in_resize_zone(double x, double y);
135    
136     int h1;
137    
138     Gtk::Menu* popup_menu_inside_region;
139     Gtk::Menu* popup_menu_outside_region;
140     void show_region_properties();
141     void add_region();
142     void delete_region();
143     void manage_dimensions();
144     void on_dimension_manager_changed();
145     int new_region_pos;
146    
147     Glib::RefPtr<Gtk::ActionGroup> actionGroup;
148     Glib::RefPtr<Gtk::UIManager> uiManager;
149    
150     DimensionManager dimensionManager;
151     };
152    
153     #endif

  ViewVC Help
Powered by ViewVC