1 |
schoenebeck |
1225 |
/* -*- c++ -*- |
2 |
schoenebeck |
3068 |
* Copyright (C) 2006-2017 Andreas Persson |
3 |
schoenebeck |
1225 |
* |
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 |
schoenebeck |
2556 |
#include <gtkmm/menu.h> |
25 |
schoenebeck |
1225 |
#include <gdkmm/window.h> |
26 |
|
|
|
27 |
persson |
2169 |
#include "compat.h" |
28 |
|
|
|
29 |
schoenebeck |
3068 |
#ifdef LIBGIG_HEADER_FILE |
30 |
|
|
# include LIBGIG_HEADER_FILE(gig.h) |
31 |
|
|
#else |
32 |
|
|
# include <gig.h> |
33 |
|
|
#endif |
34 |
schoenebeck |
1225 |
|
35 |
schoenebeck |
3364 |
#if USE_GTKMM_BUILDER |
36 |
|
|
# include <gtkmm/builder.h> |
37 |
|
|
#else |
38 |
|
|
# include <gtkmm/uimanager.h> // deprecated in gtkmm >= 3.21.4 |
39 |
|
|
#endif |
40 |
|
|
|
41 |
persson |
1533 |
#include <set> |
42 |
schoenebeck |
2626 |
#include <map> |
43 |
persson |
1533 |
|
44 |
schoenebeck |
3123 |
#include "global.h" |
45 |
|
|
|
46 |
schoenebeck |
1225 |
class DimRegionChooser : public Gtk::DrawingArea |
47 |
|
|
{ |
48 |
|
|
public: |
49 |
schoenebeck |
2626 |
DimRegionChooser(Gtk::Window& window); |
50 |
schoenebeck |
1225 |
virtual ~DimRegionChooser(); |
51 |
|
|
|
52 |
|
|
void set_region(gig::Region* region); |
53 |
|
|
|
54 |
schoenebeck |
1339 |
sigc::signal<void>& signal_dimregion_selected(); |
55 |
|
|
sigc::signal<void>& signal_region_changed(); |
56 |
schoenebeck |
1225 |
|
57 |
schoenebeck |
2626 |
gig::DimensionRegion* get_main_dimregion() const; |
58 |
persson |
1533 |
void get_dimregions(const gig::Region* region, bool stereo, |
59 |
|
|
std::set<gig::DimensionRegion*>& dimregs) const; |
60 |
schoenebeck |
2695 |
bool select_dimregion(gig::DimensionRegion* dimrgn); |
61 |
schoenebeck |
3134 |
void select_next_dimzone(bool add = false); |
62 |
|
|
void select_prev_dimzone(bool add = false); |
63 |
schoenebeck |
3123 |
void select_next_dimension(); |
64 |
|
|
void select_prev_dimension(); |
65 |
schoenebeck |
1225 |
|
66 |
schoenebeck |
3089 |
// those 3 are ATM only relevant when resizing custom dimension region zones |
67 |
schoenebeck |
3148 |
// and for painting those auto selected zones with gray hatched pattern |
68 |
schoenebeck |
3089 |
void setModifyBothChannels(bool b); |
69 |
|
|
void setModifyAllDimensionRegions(bool b); |
70 |
|
|
void setModifyAllRegions(bool b); |
71 |
|
|
|
72 |
schoenebeck |
1225 |
protected: |
73 |
persson |
2169 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
74 |
schoenebeck |
1225 |
virtual bool on_expose_event(GdkEventExpose* e); |
75 |
persson |
2246 |
#else |
76 |
|
|
virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr); |
77 |
persson |
2169 |
#endif |
78 |
schoenebeck |
1225 |
virtual bool on_button_press_event(GdkEventButton* event); |
79 |
|
|
virtual bool on_button_release_event(GdkEventButton* event); |
80 |
|
|
virtual bool on_motion_notify_event(GdkEventMotion* event); |
81 |
|
|
virtual bool on_focus(Gtk::DirectionType direction); |
82 |
schoenebeck |
3364 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
83 |
|
|
bool onKeyPressed(Gdk::EventKey& key); |
84 |
|
|
bool onKeyReleased(Gdk::EventKey& key); |
85 |
|
|
#else |
86 |
schoenebeck |
2626 |
bool onKeyPressed(GdkEventKey* key); |
87 |
|
|
bool onKeyReleased(GdkEventKey* key); |
88 |
schoenebeck |
3364 |
#endif |
89 |
schoenebeck |
2556 |
void refresh_all(); |
90 |
|
|
void split_dimension_zone(); |
91 |
|
|
void delete_dimension_zone(); |
92 |
schoenebeck |
2695 |
void resetSelectedZones(); |
93 |
schoenebeck |
3134 |
void select_dimzone_by_dir(int dir, bool add = false); |
94 |
schoenebeck |
3305 |
void drawIconsFor(gig::dimension_t dimension, uint zone, |
95 |
|
|
const Cairo::RefPtr<Cairo::Context>& cr, |
96 |
|
|
int x, int y, int w, int h); |
97 |
schoenebeck |
1225 |
|
98 |
schoenebeck |
3131 |
Gdk::RGBA red, blue, black, white; |
99 |
|
|
Glib::RefPtr<Gdk::Pixbuf> blueHatchedPatternARGB; |
100 |
|
|
Cairo::RefPtr<Cairo::SurfacePattern> blueHatchedSurfacePattern; |
101 |
schoenebeck |
3286 |
Glib::RefPtr<Gdk::Pixbuf> blueHatchedPattern2ARGB; |
102 |
|
|
Cairo::RefPtr<Cairo::SurfacePattern> blueHatchedSurfacePattern2; |
103 |
schoenebeck |
3147 |
Glib::RefPtr<Gdk::Pixbuf> grayBlueHatchedPatternARGB; |
104 |
|
|
Cairo::RefPtr<Cairo::SurfacePattern> grayBlueHatchedSurfacePattern; |
105 |
schoenebeck |
1225 |
|
106 |
|
|
gig::Instrument* instrument; |
107 |
|
|
gig::Region* region; |
108 |
|
|
|
109 |
persson |
1261 |
sigc::signal<void> dimregion_selected; |
110 |
|
|
sigc::signal<void> region_changed; |
111 |
schoenebeck |
1225 |
|
112 |
schoenebeck |
3089 |
// those 3 are ATM only relevant when resizing custom dimension region zones |
113 |
schoenebeck |
3148 |
// and for painting those auto selected zones with gray hatched pattern |
114 |
schoenebeck |
3089 |
bool modifybothchannels; |
115 |
|
|
bool modifyalldimregs; |
116 |
|
|
bool modifyallregions; |
117 |
|
|
|
118 |
schoenebeck |
1225 |
int focus_line; |
119 |
schoenebeck |
2626 |
std::map<gig::dimension_t, std::set<int> > dimzones; ///< Reflects which zone(s) of the individual dimension are currently selected. |
120 |
schoenebeck |
1225 |
int label_width; |
121 |
persson |
2246 |
bool labels_changed; |
122 |
schoenebeck |
1225 |
int nbDimensions; |
123 |
|
|
|
124 |
schoenebeck |
2626 |
// the "main" dimension region is the one that is used to i.e. evaluate the |
125 |
|
|
// precise custom velocity splits (could also be interpreted for focus stuff, |
126 |
|
|
// i.e. keyboard arrow key navigation) |
127 |
|
|
// NOTE: these may *not* necessarily currently be selected ! |
128 |
|
|
gig::dimension_t maindimtype; |
129 |
schoenebeck |
3123 |
DimensionCase maindimcase; |
130 |
schoenebeck |
2626 |
int maindimregno; |
131 |
schoenebeck |
2556 |
|
132 |
schoenebeck |
1225 |
// information needed during a resize |
133 |
|
|
struct { |
134 |
|
|
bool active; |
135 |
|
|
enum { |
136 |
|
|
none, |
137 |
|
|
left, |
138 |
|
|
right |
139 |
|
|
} selected; |
140 |
|
|
int pos; |
141 |
|
|
int min; |
142 |
|
|
int max; |
143 |
|
|
int dimension; |
144 |
schoenebeck |
3089 |
gig::dimension_def_t dimensionDef; |
145 |
|
|
int zone; |
146 |
schoenebeck |
1225 |
} resize; |
147 |
|
|
|
148 |
schoenebeck |
2626 |
bool multiSelectKeyDown; |
149 |
schoenebeck |
3131 |
bool primaryKeyDown; // on Mac: Cmd key, on all other OSs: Ctrl key |
150 |
|
|
bool shiftKeyDown; |
151 |
schoenebeck |
2626 |
|
152 |
schoenebeck |
1225 |
bool cursor_is_resize; |
153 |
|
|
bool is_in_resize_zone(double x, double y); |
154 |
persson |
2246 |
void update_after_resize(); |
155 |
schoenebeck |
1225 |
|
156 |
|
|
int h; |
157 |
schoenebeck |
2556 |
|
158 |
schoenebeck |
3364 |
Glib::RefPtr<ActionGroup> actionGroup; |
159 |
|
|
#if USE_GTKMM_BUILDER |
160 |
|
|
Glib::RefPtr<Gtk::Builder> uiManager; |
161 |
|
|
#else |
162 |
schoenebeck |
2556 |
Glib::RefPtr<Gtk::UIManager> uiManager; |
163 |
schoenebeck |
3364 |
#endif |
164 |
schoenebeck |
2556 |
Gtk::Menu* popup_menu_inside_dimregion; |
165 |
|
|
Gtk::Menu* popup_menu_outside_dimregion; |
166 |
schoenebeck |
3105 |
|
167 |
|
|
private: |
168 |
schoenebeck |
3364 |
Glib::RefPtr<Action> actionDeleteDimZone; |
169 |
|
|
Glib::RefPtr<Action> actionSplitDimZone; |
170 |
schoenebeck |
1225 |
}; |
171 |
|
|
|
172 |
|
|
#endif |