1 |
schoenebeck |
1225 |
/* -*- c++ -*- |
2 |
|
|
* Copyright (C) 2006, 2007 Andreas Persson |
3 |
|
|
* |
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 |
|
|
#include <gtkmm/drawingarea.h> |
24 |
|
|
#include <gdkmm/colormap.h> |
25 |
|
|
#include <gtkmm/uimanager.h> |
26 |
|
|
#include <gdkmm/window.h> |
27 |
|
|
#include <gtkmm/menu.h> |
28 |
|
|
|
29 |
|
|
#include "dimensionmanager.h" |
30 |
|
|
|
31 |
|
|
#include <gig.h> |
32 |
|
|
|
33 |
|
|
class RegionChooser : public Gtk::DrawingArea |
34 |
|
|
{ |
35 |
|
|
public: |
36 |
|
|
RegionChooser(); |
37 |
|
|
virtual ~RegionChooser(); |
38 |
|
|
|
39 |
|
|
void set_instrument(gig::Instrument* instrument); |
40 |
|
|
|
41 |
persson |
1261 |
sigc::signal<void> signal_region_selected(); |
42 |
|
|
sigc::signal<void> signal_instrument_changed(); |
43 |
schoenebeck |
1225 |
|
44 |
schoenebeck |
1322 |
sigc::signal<void, gig::Instrument*> signal_instrument_struct_to_be_changed(); |
45 |
|
|
sigc::signal<void, gig::Instrument*> signal_instrument_struct_changed(); |
46 |
|
|
|
47 |
|
|
sigc::signal<void, gig::Region*> signal_region_to_be_changed(); |
48 |
|
|
sigc::signal<void, gig::Region*> signal_region_changed_signal(); |
49 |
|
|
|
50 |
schoenebeck |
1225 |
gig::Region* get_region() { return region; } |
51 |
|
|
|
52 |
|
|
protected: |
53 |
|
|
virtual void on_realize(); |
54 |
|
|
virtual bool on_expose_event(GdkEventExpose* e); |
55 |
|
|
virtual void on_size_request(GtkRequisition* requisition); |
56 |
|
|
virtual bool on_button_press_event(GdkEventButton* event); |
57 |
|
|
virtual bool on_button_release_event(GdkEventButton* event); |
58 |
|
|
virtual bool on_motion_notify_event(GdkEventMotion* event); |
59 |
|
|
|
60 |
|
|
gig::Region* get_region(int key); |
61 |
|
|
|
62 |
|
|
Glib::RefPtr<Gdk::GC> gc; |
63 |
persson |
1262 |
Gdk::Color blue, red, grey1; |
64 |
schoenebeck |
1225 |
|
65 |
|
|
void draw_region(int from, int to, const Gdk::Color& color); |
66 |
|
|
|
67 |
persson |
1261 |
sigc::signal<void> region_selected; |
68 |
|
|
sigc::signal<void> instrument_changed; |
69 |
schoenebeck |
1225 |
|
70 |
schoenebeck |
1322 |
sigc::signal<void, gig::Instrument*> instrument_struct_to_be_changed_signal; |
71 |
|
|
sigc::signal<void, gig::Instrument*> instrument_struct_changed_signal; |
72 |
|
|
|
73 |
|
|
sigc::signal<void, gig::Region*> region_to_be_changed_signal; |
74 |
|
|
sigc::signal<void, gig::Region*> region_changed_signal; |
75 |
|
|
|
76 |
schoenebeck |
1225 |
gig::Instrument* instrument; |
77 |
|
|
gig::Region* region; |
78 |
|
|
|
79 |
persson |
1262 |
void motion_resize_region(int x, int y); |
80 |
|
|
void motion_move_region(int x, int y); |
81 |
|
|
|
82 |
schoenebeck |
1225 |
// information needed during a resize |
83 |
|
|
struct { |
84 |
|
|
bool active; |
85 |
|
|
enum { |
86 |
|
|
undecided, |
87 |
|
|
moving_high_limit, |
88 |
|
|
moving_low_limit |
89 |
|
|
} mode; |
90 |
|
|
int pos; |
91 |
|
|
int min; |
92 |
|
|
int max; |
93 |
|
|
gig::Region* region; |
94 |
|
|
gig::Region* prev_region; |
95 |
|
|
} resize; |
96 |
|
|
|
97 |
persson |
1262 |
// information needed during a region move |
98 |
|
|
struct { |
99 |
|
|
bool active; |
100 |
|
|
double from_x; |
101 |
|
|
int pos; |
102 |
|
|
bool touch_left; |
103 |
|
|
bool touch_right; |
104 |
|
|
} move; |
105 |
|
|
|
106 |
schoenebeck |
1225 |
bool cursor_is_resize; |
107 |
|
|
bool is_in_resize_zone(double x, double y); |
108 |
|
|
|
109 |
|
|
int h1; |
110 |
|
|
int width; |
111 |
|
|
|
112 |
|
|
Gtk::Menu* popup_menu_inside_region; |
113 |
|
|
Gtk::Menu* popup_menu_outside_region; |
114 |
|
|
void show_region_properties(); |
115 |
|
|
void add_region(); |
116 |
|
|
void delete_region(); |
117 |
|
|
void manage_dimensions(); |
118 |
|
|
void on_dimension_manager_changed(); |
119 |
|
|
int new_region_pos; |
120 |
|
|
|
121 |
|
|
Glib::RefPtr<Gtk::ActionGroup> actionGroup; |
122 |
|
|
Glib::RefPtr<Gtk::UIManager> uiManager; |
123 |
|
|
|
124 |
|
|
DimensionManager dimensionManager; |
125 |
|
|
}; |
126 |
|
|
|
127 |
|
|
#endif |