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 |
|
|
gig::Region* get_region() { return region; } |
45 |
|
|
|
46 |
|
|
protected: |
47 |
|
|
virtual void on_realize(); |
48 |
|
|
virtual bool on_expose_event(GdkEventExpose* e); |
49 |
|
|
virtual void on_size_request(GtkRequisition* requisition); |
50 |
|
|
virtual bool on_button_press_event(GdkEventButton* event); |
51 |
|
|
virtual bool on_button_release_event(GdkEventButton* event); |
52 |
|
|
virtual bool on_motion_notify_event(GdkEventMotion* event); |
53 |
|
|
|
54 |
|
|
gig::Region* get_region(int key); |
55 |
|
|
|
56 |
|
|
Glib::RefPtr<Gdk::GC> gc; |
57 |
persson |
1262 |
Gdk::Color blue, red, grey1; |
58 |
schoenebeck |
1225 |
|
59 |
|
|
void draw_region(int from, int to, const Gdk::Color& color); |
60 |
|
|
|
61 |
persson |
1261 |
sigc::signal<void> region_selected; |
62 |
|
|
sigc::signal<void> instrument_changed; |
63 |
schoenebeck |
1225 |
|
64 |
|
|
gig::Instrument* instrument; |
65 |
|
|
gig::Region* region; |
66 |
|
|
|
67 |
persson |
1262 |
void motion_resize_region(int x, int y); |
68 |
|
|
void motion_move_region(int x, int y); |
69 |
|
|
|
70 |
schoenebeck |
1225 |
// information needed during a resize |
71 |
|
|
struct { |
72 |
|
|
bool active; |
73 |
|
|
enum { |
74 |
|
|
undecided, |
75 |
|
|
moving_high_limit, |
76 |
|
|
moving_low_limit |
77 |
|
|
} mode; |
78 |
|
|
int pos; |
79 |
|
|
int min; |
80 |
|
|
int max; |
81 |
|
|
gig::Region* region; |
82 |
|
|
gig::Region* prev_region; |
83 |
|
|
} resize; |
84 |
|
|
|
85 |
persson |
1262 |
// information needed during a region move |
86 |
|
|
struct { |
87 |
|
|
bool active; |
88 |
|
|
double from_x; |
89 |
|
|
int pos; |
90 |
|
|
bool touch_left; |
91 |
|
|
bool touch_right; |
92 |
|
|
} move; |
93 |
|
|
|
94 |
schoenebeck |
1225 |
bool cursor_is_resize; |
95 |
|
|
bool is_in_resize_zone(double x, double y); |
96 |
|
|
|
97 |
|
|
int h1; |
98 |
|
|
int width; |
99 |
|
|
|
100 |
|
|
Gtk::Menu* popup_menu_inside_region; |
101 |
|
|
Gtk::Menu* popup_menu_outside_region; |
102 |
|
|
void show_region_properties(); |
103 |
|
|
void add_region(); |
104 |
|
|
void delete_region(); |
105 |
|
|
void manage_dimensions(); |
106 |
|
|
void on_dimension_manager_changed(); |
107 |
|
|
int new_region_pos; |
108 |
|
|
|
109 |
|
|
Glib::RefPtr<Gtk::ActionGroup> actionGroup; |
110 |
|
|
Glib::RefPtr<Gtk::UIManager> uiManager; |
111 |
|
|
|
112 |
|
|
DimensionManager dimensionManager; |
113 |
|
|
}; |
114 |
|
|
|
115 |
|
|
#endif |