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> |
32 |
|
|
33 |
#include <gig.h> |
#include <gig.h> |
34 |
|
|
35 |
|
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 |
class RegionChooser : public Gtk::DrawingArea |
class RegionChooser : public Gtk::DrawingArea |
50 |
{ |
{ |
51 |
public: |
public: |
63 |
sigc::signal<void, gig::Region*>& signal_region_to_be_changed(); |
sigc::signal<void, gig::Region*>& signal_region_to_be_changed(); |
64 |
sigc::signal<void, gig::Region*>& signal_region_changed_signal(); |
sigc::signal<void, gig::Region*>& signal_region_changed_signal(); |
65 |
|
|
66 |
|
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 |
gig::Region* get_region() { return region; } |
gig::Region* get_region() { return region; } |
70 |
|
|
71 |
|
void on_note_on_event(int key, int velocity); |
72 |
|
void on_note_off_event(int key, int velocity); |
73 |
|
|
74 |
protected: |
protected: |
75 |
virtual void on_realize(); |
virtual void on_realize(); |
76 |
virtual bool on_expose_event(GdkEventExpose* e); |
virtual bool on_expose_event(GdkEventExpose* e); |
82 |
gig::Region* get_region(int key); |
gig::Region* get_region(int key); |
83 |
|
|
84 |
Glib::RefPtr<Gdk::GC> gc; |
Glib::RefPtr<Gdk::GC> gc; |
85 |
Gdk::Color blue, red, grey1; |
Gdk::Color activeKeyColor, red, grey1, white, black; |
|
|
|
|
void draw_region(int from, int to, const Gdk::Color& color); |
|
86 |
|
|
87 |
sigc::signal<void> region_selected; |
sigc::signal<void> region_selected; |
88 |
sigc::signal<void> instrument_changed; |
sigc::signal<void> instrument_changed; |
93 |
sigc::signal<void, gig::Region*> region_to_be_changed_signal; |
sigc::signal<void, gig::Region*> region_to_be_changed_signal; |
94 |
sigc::signal<void, gig::Region*> region_changed_signal; |
sigc::signal<void, gig::Region*> region_changed_signal; |
95 |
|
|
96 |
|
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 |
gig::Instrument* instrument; |
gig::Instrument* instrument; |
100 |
gig::Region* region; |
gig::Region* region; |
101 |
|
SortedRegions regions; |
102 |
|
|
103 |
|
bool is_black_key(int key); |
104 |
|
void draw_region(int from, int to, const Gdk::Color& color); |
105 |
|
void draw_digit(int key); |
106 |
void motion_resize_region(int x, int y); |
void motion_resize_region(int x, int y); |
107 |
void motion_move_region(int x, int y); |
void motion_move_region(int x, int y); |
108 |
|
|
134 |
bool is_in_resize_zone(double x, double y); |
bool is_in_resize_zone(double x, double y); |
135 |
|
|
136 |
int h1; |
int h1; |
|
int width; |
|
137 |
|
|
138 |
Gtk::Menu* popup_menu_inside_region; |
Gtk::Menu* popup_menu_inside_region; |
139 |
Gtk::Menu* popup_menu_outside_region; |
Gtk::Menu* popup_menu_outside_region; |