/[svn]/gigedit/trunk/src/gigedit/dimregionchooser.h
ViewVC logotype

Contents of /gigedit/trunk/src/gigedit/dimregionchooser.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3123 - (show annotations) (download) (as text)
Tue Apr 25 20:45:54 2017 UTC (6 years, 11 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 4477 byte(s)
* Implemented fast navigation through regions by keyboard accelerator
  Ctrl+Left and Ctrl+Right (on Mac: Cmd+Left and Cmd+Right).
* Implemented fast navigation through dimension region zones of currently
  selected region by keyboard accelerator Alt+Left, Alt+Right, Alt+Up,
  Alt+Down, as well as simply using the arrow keys alone if the dimension
  region chooser got focus (i.e. when it was selected by mouse previously).
* Bumped version (1.0.0.svn29).

1 /* -*- c++ -*-
2 * Copyright (C) 2006-2017 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 #ifdef LIBGIG_HEADER_FILE
31 # include LIBGIG_HEADER_FILE(gig.h)
32 #else
33 # include <gig.h>
34 #endif
35
36 #include <set>
37 #include <map>
38
39 #include "global.h"
40
41 class DimRegionChooser : public Gtk::DrawingArea
42 {
43 public:
44 DimRegionChooser(Gtk::Window& window);
45 virtual ~DimRegionChooser();
46
47 void set_region(gig::Region* region);
48
49 sigc::signal<void>& signal_dimregion_selected();
50 sigc::signal<void>& signal_region_changed();
51
52 gig::DimensionRegion* get_main_dimregion() const;
53 void get_dimregions(const gig::Region* region, bool stereo,
54 std::set<gig::DimensionRegion*>& dimregs) const;
55 bool select_dimregion(gig::DimensionRegion* dimrgn);
56 void select_next_dimzone();
57 void select_prev_dimzone();
58 void select_next_dimension();
59 void select_prev_dimension();
60
61 // those 3 are ATM only relevant when resizing custom dimension region zones
62 void setModifyBothChannels(bool b);
63 void setModifyAllDimensionRegions(bool b);
64 void setModifyAllRegions(bool b);
65
66 protected:
67 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
68 virtual bool on_expose_event(GdkEventExpose* e);
69 #else
70 virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
71 #endif
72 virtual bool on_button_press_event(GdkEventButton* event);
73 virtual bool on_button_release_event(GdkEventButton* event);
74 virtual bool on_motion_notify_event(GdkEventMotion* event);
75 virtual bool on_focus(Gtk::DirectionType direction);
76 bool onKeyPressed(GdkEventKey* key);
77 bool onKeyReleased(GdkEventKey* key);
78 void refresh_all();
79 void split_dimension_zone();
80 void delete_dimension_zone();
81 void resetSelectedZones();
82 void select_dimzone_by_dir(int dir);
83
84 Gdk::RGBA red, black, white;
85
86 gig::Instrument* instrument;
87 gig::Region* region;
88
89 sigc::signal<void> dimregion_selected;
90 sigc::signal<void> region_changed;
91
92 // those 3 are ATM only relevant when resizing custom dimension region zones
93 bool modifybothchannels;
94 bool modifyalldimregs;
95 bool modifyallregions;
96
97 int focus_line;
98 std::map<gig::dimension_t, std::set<int> > dimzones; ///< Reflects which zone(s) of the individual dimension are currently selected.
99 int label_width;
100 bool labels_changed;
101 int nbDimensions;
102
103 // the "main" dimension region is the one that is used to i.e. evaluate the
104 // precise custom velocity splits (could also be interpreted for focus stuff,
105 // i.e. keyboard arrow key navigation)
106 // NOTE: these may *not* necessarily currently be selected !
107 gig::dimension_t maindimtype;
108 DimensionCase maindimcase;
109 int maindimregno;
110
111 // information needed during a resize
112 struct {
113 bool active;
114 enum {
115 none,
116 left,
117 right
118 } selected;
119 int pos;
120 int min;
121 int max;
122 int dimension;
123 gig::dimension_def_t dimensionDef;
124 int zone;
125 } resize;
126
127 bool multiSelectKeyDown;
128
129 bool cursor_is_resize;
130 bool is_in_resize_zone(double x, double y);
131 void update_after_resize();
132
133 int h;
134
135 Glib::RefPtr<Gtk::ActionGroup> actionGroup;
136 Glib::RefPtr<Gtk::UIManager> uiManager;
137 Gtk::Menu* popup_menu_inside_dimregion;
138 Gtk::Menu* popup_menu_outside_dimregion;
139
140 private:
141 Glib::RefPtr<Gtk::Action> actionDeleteDimZone;
142 Glib::RefPtr<Gtk::Action> actionSplitDimZone;
143 };
144
145 #endif

  ViewVC Help
Powered by ViewVC