1 |
/* -*- c++ -*- |
2 |
* Copyright (C) 2006-2011 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_DIMREGIONCHOOSER_H |
21 |
#define GIGEDIT_DIMREGIONCHOOSER_H |
22 |
|
23 |
#include <gtkmm/drawingarea.h> |
24 |
#include <gdkmm/window.h> |
25 |
|
26 |
#include "compat.h" |
27 |
|
28 |
#include <gig.h> |
29 |
|
30 |
#include <set> |
31 |
|
32 |
class DimRegionChooser : public Gtk::DrawingArea |
33 |
{ |
34 |
public: |
35 |
DimRegionChooser(); |
36 |
virtual ~DimRegionChooser(); |
37 |
|
38 |
void set_region(gig::Region* region); |
39 |
|
40 |
sigc::signal<void>& signal_dimregion_selected(); |
41 |
sigc::signal<void>& signal_region_changed(); |
42 |
|
43 |
gig::DimensionRegion* get_dimregion() const { return dimreg; } |
44 |
void get_dimregions(const gig::Region* region, bool stereo, |
45 |
std::set<gig::DimensionRegion*>& dimregs) const; |
46 |
|
47 |
protected: |
48 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
49 |
virtual bool on_expose_event(GdkEventExpose* e); |
50 |
#endif |
51 |
virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr); |
52 |
virtual bool on_button_press_event(GdkEventButton* event); |
53 |
virtual bool on_button_release_event(GdkEventButton* event); |
54 |
virtual bool on_motion_notify_event(GdkEventMotion* event); |
55 |
virtual bool on_focus(Gtk::DirectionType direction); |
56 |
|
57 |
Gdk::RGBA red, black, white; |
58 |
|
59 |
gig::Instrument* instrument; |
60 |
gig::Region* region; |
61 |
int dimregno; |
62 |
|
63 |
sigc::signal<void> dimregion_selected; |
64 |
sigc::signal<void> region_changed; |
65 |
|
66 |
gig::DimensionRegion* dimreg; |
67 |
int focus_line; |
68 |
int dimvalue[256]; |
69 |
int label_width; |
70 |
int nbDimensions; |
71 |
|
72 |
// information needed during a resize |
73 |
struct { |
74 |
bool active; |
75 |
enum { |
76 |
none, |
77 |
left, |
78 |
right |
79 |
} selected; |
80 |
int pos; |
81 |
int min; |
82 |
int max; |
83 |
int dimension; |
84 |
int offset; |
85 |
} resize; |
86 |
|
87 |
bool cursor_is_resize; |
88 |
bool is_in_resize_zone(double x, double y); |
89 |
|
90 |
int h; |
91 |
}; |
92 |
|
93 |
#endif |