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