1 |
/* -*- c++ -*- |
2 |
* Copyright (C) 2006-2015 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 <gtkmm/uimanager.h> |
25 |
#include <gtkmm/menu.h> |
26 |
#include <gdkmm/window.h> |
27 |
|
28 |
#include "compat.h" |
29 |
|
30 |
#include <gig.h> |
31 |
|
32 |
#include <set> |
33 |
#include <map> |
34 |
|
35 |
class DimRegionChooser : public Gtk::DrawingArea |
36 |
{ |
37 |
public: |
38 |
DimRegionChooser(Gtk::Window& window); |
39 |
virtual ~DimRegionChooser(); |
40 |
|
41 |
void set_region(gig::Region* region); |
42 |
|
43 |
sigc::signal<void>& signal_dimregion_selected(); |
44 |
sigc::signal<void>& signal_region_changed(); |
45 |
|
46 |
gig::DimensionRegion* get_main_dimregion() const; |
47 |
void get_dimregions(const gig::Region* region, bool stereo, |
48 |
std::set<gig::DimensionRegion*>& dimregs) const; |
49 |
bool select_dimregion(gig::DimensionRegion* dimrgn); |
50 |
|
51 |
protected: |
52 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
53 |
virtual bool on_expose_event(GdkEventExpose* e); |
54 |
#else |
55 |
virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr); |
56 |
#endif |
57 |
virtual bool on_button_press_event(GdkEventButton* event); |
58 |
virtual bool on_button_release_event(GdkEventButton* event); |
59 |
virtual bool on_motion_notify_event(GdkEventMotion* event); |
60 |
virtual bool on_focus(Gtk::DirectionType direction); |
61 |
bool onKeyPressed(GdkEventKey* key); |
62 |
bool onKeyReleased(GdkEventKey* key); |
63 |
void refresh_all(); |
64 |
void split_dimension_zone(); |
65 |
void delete_dimension_zone(); |
66 |
void resetSelectedZones(); |
67 |
|
68 |
Gdk::RGBA red, black, white; |
69 |
|
70 |
gig::Instrument* instrument; |
71 |
gig::Region* region; |
72 |
|
73 |
sigc::signal<void> dimregion_selected; |
74 |
sigc::signal<void> region_changed; |
75 |
|
76 |
//std::set<gig::DimensionRegion*> dimregs; ///< Reflects which dimension regions are currently selected. |
77 |
int focus_line; |
78 |
std::map<gig::dimension_t, std::set<int> > dimzones; ///< Reflects which zone(s) of the individual dimension are currently selected. |
79 |
int label_width; |
80 |
bool labels_changed; |
81 |
int nbDimensions; |
82 |
|
83 |
// the "main" dimension region is the one that is used to i.e. evaluate the |
84 |
// precise custom velocity splits (could also be interpreted for focus stuff, |
85 |
// i.e. keyboard arrow key navigation) |
86 |
// NOTE: these may *not* necessarily currently be selected ! |
87 |
gig::dimension_t maindimtype; |
88 |
std::map<gig::dimension_t,int> maindimcase; |
89 |
int maindimregno; |
90 |
|
91 |
// information needed during a resize |
92 |
struct { |
93 |
bool active; |
94 |
enum { |
95 |
none, |
96 |
left, |
97 |
right |
98 |
} selected; |
99 |
int pos; |
100 |
int min; |
101 |
int max; |
102 |
int dimension; |
103 |
int offset; |
104 |
} resize; |
105 |
|
106 |
bool multiSelectKeyDown; |
107 |
|
108 |
bool cursor_is_resize; |
109 |
bool is_in_resize_zone(double x, double y); |
110 |
void update_after_resize(); |
111 |
|
112 |
int h; |
113 |
|
114 |
Glib::RefPtr<Gtk::ActionGroup> actionGroup; |
115 |
Glib::RefPtr<Gtk::UIManager> uiManager; |
116 |
Gtk::Menu* popup_menu_inside_dimregion; |
117 |
Gtk::Menu* popup_menu_outside_dimregion; |
118 |
}; |
119 |
|
120 |
#endif |