1 |
/* -*- c++ -*- |
/* -*- c++ -*- |
2 |
* Copyright (C) 2006, 2007 Andreas Persson |
* Copyright (C) 2006-2008 Andreas Persson |
3 |
* |
* |
4 |
* This program is free software; you can redistribute it and/or |
* This program is free software; you can redistribute it and/or |
5 |
* modify it under the terms of the GNU General Public License as |
* modify it under the terms of the GNU General Public License as |
20 |
#ifndef GIGEDIT_REGIONCHOOSER_H |
#ifndef GIGEDIT_REGIONCHOOSER_H |
21 |
#define GIGEDIT_REGIONCHOOSER_H |
#define GIGEDIT_REGIONCHOOSER_H |
22 |
|
|
23 |
|
#include <vector> |
24 |
|
|
25 |
#include <gtkmm/drawingarea.h> |
#include <gtkmm/drawingarea.h> |
26 |
#include <gdkmm/colormap.h> |
#include <gdkmm/colormap.h> |
27 |
#include <gtkmm/uimanager.h> |
#include <gtkmm/uimanager.h> |
29 |
#include <gtkmm/menu.h> |
#include <gtkmm/menu.h> |
30 |
|
|
31 |
#include "dimensionmanager.h" |
#include "dimensionmanager.h" |
32 |
|
#include "paramedit.h" |
33 |
|
|
34 |
#include <gig.h> |
#include <gig.h> |
35 |
|
|
36 |
|
enum virt_keyboard_mode_t { |
37 |
|
VIRT_KEYBOARD_MODE_NORMAL, |
38 |
|
VIRT_KEYBOARD_MODE_CHORD |
39 |
|
}; |
40 |
|
|
41 |
|
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 |
class RegionChooser : public Gtk::DrawingArea |
class RegionChooser : public Gtk::DrawingArea |
56 |
{ |
{ |
57 |
public: |
public: |
69 |
sigc::signal<void, gig::Region*>& signal_region_to_be_changed(); |
sigc::signal<void, gig::Region*>& signal_region_to_be_changed(); |
70 |
sigc::signal<void, gig::Region*>& signal_region_changed_signal(); |
sigc::signal<void, gig::Region*>& signal_region_changed_signal(); |
71 |
|
|
72 |
|
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 |
gig::Region* get_region() { return region; } |
gig::Region* get_region() { return region; } |
76 |
|
|
77 |
|
void on_note_on_event(int key, int velocity); |
78 |
|
void on_note_off_event(int key, int velocity); |
79 |
|
|
80 |
|
Gtk::HBox m_VirtKeybPropsBox; |
81 |
|
|
82 |
protected: |
protected: |
83 |
virtual void on_realize(); |
virtual void on_realize(); |
84 |
virtual bool on_expose_event(GdkEventExpose* e); |
virtual bool on_expose_event(GdkEventExpose* e); |
90 |
gig::Region* get_region(int key); |
gig::Region* get_region(int key); |
91 |
|
|
92 |
Glib::RefPtr<Gdk::GC> gc; |
Glib::RefPtr<Gdk::GC> gc; |
93 |
Gdk::Color blue, red, grey1; |
Gdk::Color activeKeyColor, red, grey1, white, black; |
|
|
|
|
void draw_region(int from, int to, const Gdk::Color& color); |
|
94 |
|
|
95 |
sigc::signal<void> region_selected; |
sigc::signal<void> region_selected; |
96 |
sigc::signal<void> instrument_changed; |
sigc::signal<void> instrument_changed; |
101 |
sigc::signal<void, gig::Region*> region_to_be_changed_signal; |
sigc::signal<void, gig::Region*> region_to_be_changed_signal; |
102 |
sigc::signal<void, gig::Region*> region_changed_signal; |
sigc::signal<void, gig::Region*> region_changed_signal; |
103 |
|
|
104 |
|
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 |
gig::Instrument* instrument; |
gig::Instrument* instrument; |
108 |
gig::Region* region; |
gig::Region* region; |
109 |
|
SortedRegions regions; |
110 |
|
|
111 |
|
bool is_black_key(int key); |
112 |
|
void draw_region(int from, int to, const Gdk::Color& color); |
113 |
|
void draw_digit(int key); |
114 |
void motion_resize_region(int x, int y); |
void motion_resize_region(int x, int y); |
115 |
void motion_move_region(int x, int y); |
void motion_move_region(int x, int y); |
116 |
|
|
142 |
bool is_in_resize_zone(double x, double y); |
bool is_in_resize_zone(double x, double y); |
143 |
|
|
144 |
int h1; |
int h1; |
|
int width; |
|
145 |
|
|
146 |
Gtk::Menu* popup_menu_inside_region; |
Gtk::Menu* popup_menu_inside_region; |
147 |
Gtk::Menu* popup_menu_outside_region; |
Gtk::Menu* popup_menu_outside_region; |
155 |
Glib::RefPtr<Gtk::ActionGroup> actionGroup; |
Glib::RefPtr<Gtk::ActionGroup> actionGroup; |
156 |
Glib::RefPtr<Gtk::UIManager> uiManager; |
Glib::RefPtr<Gtk::UIManager> uiManager; |
157 |
|
|
158 |
|
// 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 |
DimensionManager dimensionManager; |
DimensionManager dimensionManager; |
167 |
}; |
}; |
168 |
|
|