do most of the work related to adding new anchored trim cursors (but debugging/analys...
[ardour.git] / gtk2_ardour / mouse_cursors.cc
1 /*
2     Copyright (C) 2000-2010 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <gdkmm/cursor.h>
21 #include "utils.h"
22 #include "mouse_cursors.h"
23 #include "editor_xpms"
24
25 MouseCursors::MouseCursors ()
26         : cross_hair (0)
27         , trimmer (0)
28         , right_side_trim (0)
29         , anchored_right_side_trim (0)
30         , left_side_trim (0)
31         , anchored_left_side_trim (0)
32         , right_side_trim_left_only (0)
33         , left_side_trim_right_only (0)
34         , fade_in (0)
35         , fade_out (0)
36         , selector (0)
37         , grabber (0)
38         , grabber_note (0)
39         , grabber_edit_point (0)
40         , zoom_in (0)
41         , zoom_out (0)
42         , time_fx (0)
43         , fader (0)
44         , speaker (0)
45         , midi_pencil (0)
46         , midi_select (0)
47         , midi_resize (0)
48         , midi_erase (0)
49         , up_down (0)
50         , wait (0)
51         , timebar (0)
52         , transparent (0)
53         , resize_left (0)
54         , resize_top_left (0)
55         , resize_top (0)
56         , resize_top_right (0)
57         , resize_right (0)
58         , resize_bottom_right (0)
59         , resize_bottom (0)
60         , resize_bottom_left (0)
61         , move (0)
62         , expand_left_right (0)
63         , expand_up_down (0)
64 {
65 }
66
67 void
68 MouseCursors::drop_all ()
69 {
70         delete cross_hair; cross_hair = 0;
71         delete trimmer; trimmer = 0;
72         delete right_side_trim; right_side_trim = 0;
73         delete anchored_right_side_trim; anchored_right_side_trim = 0;
74         delete left_side_trim; left_side_trim = 0;
75         delete anchored_left_side_trim; anchored_left_side_trim = 0;
76         delete right_side_trim_left_only; right_side_trim_left_only = 0;
77         delete left_side_trim_right_only; left_side_trim_right_only = 0;
78         delete fade_in; fade_in = 0;
79         delete fade_out; fade_out = 0;
80         delete selector; selector = 0;
81         delete grabber; grabber = 0;
82         delete grabber_note; grabber_note = 0;
83         delete grabber_edit_point; grabber_edit_point = 0;
84         delete zoom_in; zoom_in = 0;
85         delete zoom_out; zoom_out = 0;
86         delete time_fx; time_fx = 0;
87         delete fader; fader = 0;
88         delete speaker; speaker = 0;
89         delete midi_pencil; midi_pencil = 0;
90         delete midi_select; midi_select = 0;
91         delete midi_resize; midi_resize = 0;
92         delete midi_erase; midi_erase = 0;
93         delete up_down; up_down = 0;
94         delete wait; wait = 0;
95         delete timebar; timebar = 0;
96         delete transparent; transparent = 0;
97         delete resize_left; resize_left = 0;
98         delete resize_top_left; resize_top_left = 0;
99         delete resize_top; resize_top = 0;
100         delete resize_top_right; resize_top_right = 0;
101         delete resize_right; resize_right = 0;
102         delete resize_bottom_right; resize_bottom_right = 0;
103         delete resize_bottom; resize_bottom = 0;
104         delete resize_bottom_left; resize_bottom_left = 0;
105         delete move; move = 0;
106         delete expand_left_right; expand_left_right = 0;
107         delete expand_up_down; expand_up_down = 0;
108 }
109
110 void
111 MouseCursors::set_cursor_set (const std::string& name)
112 {
113         using namespace Glib;
114         using namespace Gdk;
115         
116         drop_all ();
117         _cursor_set = name;
118
119         {
120                 RefPtr<Pixbuf> p (::get_icon ("zoom_in_cursor", _cursor_set));
121                 zoom_in = new Cursor (Display::get_default(), p, 10, 5);
122         }
123
124         {
125                 RefPtr<Pixbuf> p (::get_icon ("zoom_out_cursor", _cursor_set));
126                 zoom_out = new Cursor (Display::get_default(), p, 5, 5);
127         }
128
129         Color fbg ("#ffffff");
130         Color ffg ("#000000");
131
132         {
133                 RefPtr<Bitmap> source = Bitmap::create ((char const *) fader_cursor_bits, fader_cursor_width, fader_cursor_height);
134                 RefPtr<Bitmap> mask = Bitmap::create ((char const *) fader_cursor_mask_bits, fader_cursor_width, fader_cursor_height);
135                 fader = new Cursor (source, mask, ffg, fbg, fader_cursor_x_hot, fader_cursor_y_hot);
136         }
137
138         {
139                 RefPtr<Bitmap> source = Bitmap::create ((char const *) speaker_cursor_bits, speaker_cursor_width, speaker_cursor_height);
140                 RefPtr<Bitmap> mask = Bitmap::create ((char const *) speaker_cursor_mask_bits, speaker_cursor_width, speaker_cursor_height);
141                 speaker = new Cursor (source, mask, ffg, fbg, speaker_cursor_width >> 1, speaker_cursor_height >> 1);
142         }
143
144         {
145                 char pix[4] = { 0, 0, 0, 0 };
146                 RefPtr<Bitmap> bits = Bitmap::create (pix, 2, 2);
147                 Color c;
148                 transparent = new Cursor (bits, bits, c, c, 0, 0);
149         }
150
151         {
152                 char pix[4] = { 0, 0, 0, 0 };
153                 RefPtr<Bitmap> bits = Bitmap::create (pix, 2, 2);
154                 Color c;
155                 transparent = new Cursor (bits, bits, c, c, 0, 0);
156         }
157
158         {
159                 RefPtr<Pixbuf> p (::get_icon ("grabber", _cursor_set));
160                 grabber = new Cursor (Display::get_default(), p, 5, 0);
161         }
162
163         {
164                 RefPtr<Pixbuf> p (::get_icon ("grabber_note", _cursor_set));
165                 grabber_note = new Cursor (Display::get_default(), p, 5, 10);
166         }
167
168         {
169                 RefPtr<Pixbuf> p (::get_icon ("grabber_edit_point", _cursor_set));
170                 grabber_edit_point = new Cursor (Display::get_default(), p, 5, 17);
171         }
172
173         cross_hair = new Cursor (CROSSHAIR);
174         trimmer =  new Cursor (SB_H_DOUBLE_ARROW);
175
176         {
177                 RefPtr<Pixbuf> p (::get_icon ("trim_left_cursor", _cursor_set));
178                 left_side_trim = new Cursor (Display::get_default(), p, 5, 11);
179         }
180
181         {
182                 RefPtr<Pixbuf> p (::get_icon ("anchored_trim_left_cursor", _cursor_set));
183                 anchored_left_side_trim = new Cursor (Display::get_default(), p, 5, 11);
184         }
185
186         {
187                 RefPtr<Pixbuf> p (::get_icon ("trim_right_cursor", _cursor_set));
188                 right_side_trim = new Cursor (Display::get_default(), p, 23, 11);
189         }
190
191         {
192                 RefPtr<Pixbuf> p (::get_icon ("anchored_trim_right_cursor", _cursor_set));
193                 anchored_right_side_trim = new Cursor (Display::get_default(), p, 23, 11);
194         }
195
196         {
197                 RefPtr<Pixbuf> p (::get_icon ("trim_left_cursor_right_only", _cursor_set));
198                 left_side_trim_right_only = new Cursor (Display::get_default(), p, 5, 11);
199         }
200
201         {
202                 RefPtr<Pixbuf> p (::get_icon ("trim_right_cursor_left_only", _cursor_set));
203                 right_side_trim_left_only = new Cursor (Display::get_default(), p, 23, 11);
204         }
205
206         {
207                 RefPtr<Pixbuf> p (::get_icon ("fade_in_cursor", _cursor_set));
208                 fade_in = new Cursor (Display::get_default(), p, 0, 0);
209         }
210
211         {
212                 RefPtr<Pixbuf> p (::get_icon ("fade_out_cursor", _cursor_set));
213                 fade_out = new Cursor (Display::get_default(), p, 29, 0);
214         }
215
216         {
217                 RefPtr<Pixbuf> p (::get_icon ("resize_left_cursor", _cursor_set));
218                 resize_left = new Cursor (Display::get_default(), p, 3, 10);
219         }
220
221         {
222                 RefPtr<Pixbuf> p (::get_icon ("resize_top_left_cursor", _cursor_set));
223                 resize_top_left = new Cursor (Display::get_default(), p, 3, 3);
224         }
225
226         {
227                 RefPtr<Pixbuf> p (::get_icon ("resize_top_cursor", _cursor_set));
228                 resize_top = new Cursor (Display::get_default(), p, 10, 3);
229         }
230
231         {
232                 RefPtr<Pixbuf> p (::get_icon ("resize_top_right_cursor", _cursor_set));
233                 resize_top_right = new Cursor (Display::get_default(), p, 18, 3);
234         }
235
236         {
237                 RefPtr<Pixbuf> p (::get_icon ("resize_right_cursor", _cursor_set));
238                 resize_right = new Cursor (Display::get_default(), p, 24, 10);
239         }
240
241         {
242                 RefPtr<Pixbuf> p (::get_icon ("resize_bottom_right_cursor", _cursor_set));
243                 resize_bottom_right = new Cursor (Display::get_default(), p, 18, 18);
244         }
245
246         {
247                 RefPtr<Pixbuf> p (::get_icon ("resize_bottom_cursor", _cursor_set));
248                 resize_bottom = new Cursor (Display::get_default(), p, 10, 24);
249         }
250
251         {
252                 RefPtr<Pixbuf> p (::get_icon ("resize_bottom_left_cursor", _cursor_set));
253                 resize_bottom_left = new Cursor (Display::get_default(), p, 3, 18);
254         }
255
256         {
257                 RefPtr<Pixbuf> p (::get_icon ("move_cursor", _cursor_set));
258                 move = new Cursor (Display::get_default(), p, 11, 11);
259         }
260
261         {
262                 RefPtr<Pixbuf> p (::get_icon ("expand_left_right_cursor", _cursor_set));
263                 expand_left_right = new Cursor (Display::get_default(), p, 11, 4);
264         }
265
266         {
267                 RefPtr<Pixbuf> p (::get_icon ("expand_up_down_cursor", _cursor_set));
268                 expand_up_down = new Cursor (Display::get_default(), p, 4, 11);
269         }
270
271         {
272                 RefPtr<Pixbuf> p (::get_icon ("i_beam_cursor", _cursor_set));
273                 selector = new Cursor (Display::get_default(), p, 4, 11);
274         }
275
276         time_fx = new Cursor (SIZING);
277         wait = new Cursor (WATCH);
278         timebar = new Cursor(LEFT_PTR);
279         midi_pencil = new Cursor (PENCIL);
280         midi_select = new Cursor (CENTER_PTR);
281         midi_resize = new Cursor (SIZING);
282         midi_erase = new Cursor (DRAPED_BOX);
283         up_down = new Cursor (SB_V_DOUBLE_ARROW);
284 }