fast drag unselected edit, ctrl drag select in arrow mode
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / edithandles.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "cursors.h"
23 #include "edithandles.h"
24 #include "edithandles.inc"
25 #include "edit.h"
26 #include "edits.h"
27 #include "edl.h"
28 #include "mwindow.h"
29 #include "theme.h"
30 #include "track.h"
31 #include "tracks.h"
32 #include "trackcanvas.h"
33
34
35
36 EditHandle::EditHandle(MWindow *mwindow,
37                 TrackCanvas *trackcanvas,
38                 Edit *edit,
39                 int side,
40                 int x,
41                 int y)
42  : CanvasTool(mwindow,
43         trackcanvas,
44         edit,
45         x,
46         y,
47         side == EDIT_IN ? mwindow->theme->edithandlein_data : mwindow->theme->edithandleout_data)
48 {
49         this->side = side;
50 }
51
52 EditHandle::~EditHandle()
53 {
54 }
55
56 int EditHandle::handle_event()
57 {
58         return 0;
59 }
60
61
62
63
64
65 EditHandleIn::EditHandleIn(MWindow *mwindow,
66         TrackCanvas *trackcanvas,
67         Edit *edit,
68         int x,
69         int y)
70  : EditHandle(mwindow,
71                 trackcanvas,
72                 edit,
73                 EDIT_IN,
74                 x,
75                 y)
76 {
77 }
78
79 EditHandleIn::~EditHandleIn()
80 {
81 }
82
83
84 int EditHandleIn::handle_event()
85 {
86         return 1;
87 }
88
89
90
91
92
93
94
95
96 EditHandleOut::EditHandleOut(MWindow *mwindow,
97         TrackCanvas *trackcanvas,
98         Edit *edit,
99         int x,
100         int y)
101  : EditHandle(mwindow,
102                 trackcanvas,
103                 edit,
104                 EDIT_OUT,
105                 x,
106                 y)
107 {
108         this->mwindow = mwindow;
109         this->trackcanvas = trackcanvas;
110         this->edit = edit;
111         visible = 1;
112 }
113
114 EditHandleOut::~EditHandleOut()
115 {
116 }
117
118
119 int EditHandleOut::handle_event()
120 {
121         return 1;
122 }
123
124
125
126
127
128
129
130
131
132
133 EditHandles::EditHandles(MWindow *mwindow,
134                 TrackCanvas *trackcanvas)
135  : CanvasTools(mwindow, trackcanvas)
136 {
137 }
138
139 EditHandles::~EditHandles()
140 {
141 }
142
143 void EditHandles::update()
144 {
145         decrease_visible();
146
147         for(Track *current = mwindow->edl->tracks->first;
148                 current;
149                 current = NEXT)
150         {
151                 for(Edit *edit = current->edits->first; edit; edit = edit->next)
152                 {
153 // Test in point
154                         int64_t handle_x, handle_y, handle_w, handle_h;
155                         trackcanvas->get_handle_coords(edit, handle_x, handle_y, handle_w, handle_h, EDIT_IN);
156
157                         if(visible(handle_x, handle_y, handle_w, handle_h))
158                         {
159                                 int exists = 0;
160
161                                 for(int i = 0; i < total; i++)
162                                 {
163                                         EditHandle *handle = (EditHandle*)values[i];
164                                         if(handle->edit->id == edit->id && handle->side == EDIT_IN)
165                                         {
166                                                 handle->reposition_window(handle_x, handle_y);
167                                                 handle->raise_window();
168                                                 handle->draw_face();
169                                                 handle->visible = 1;
170                                                 exists = 1;
171                                                 break;
172                                         }
173                                 }
174
175                                 if(!exists)
176                                 {
177                                         EditHandle *handle = new EditHandle(mwindow,
178                                                 trackcanvas,
179                                                 edit,
180                                                 EDIT_IN,
181                                                 handle_x,
182                                                 handle_y);
183                                         trackcanvas->add_subwindow(handle);
184                                         handle->set_cursor(ARROW_CURSOR, 0, 0);
185                                         append(handle);
186                                 }
187                         }
188
189
190 // Test out point
191                         trackcanvas->get_handle_coords(edit, handle_x, handle_y, handle_w, handle_h, EDIT_OUT);
192
193                         if(visible(handle_x, handle_y, handle_w, handle_h))
194                         {
195                                 int exists = 0;
196
197                                 for(int i = 0; i < total; i++)
198                                 {
199                                         EditHandle *handle = (EditHandle*)values[i];
200                                         if(handle->edit->id == edit->id && handle->side == EDIT_OUT)
201                                         {
202                                                 handle->reposition_window(handle_x, handle_y);
203                                                 handle->raise_window();
204                                                 handle->draw_face();
205                                                 handle->visible = 1;
206                                                 exists = 1;
207                                                 break;
208                                         }
209                                 }
210
211                                 if(!exists)
212                                 {
213                                         EditHandle *handle = new EditHandle(mwindow,
214                                                 trackcanvas,
215                                                 edit,
216                                                 EDIT_OUT,
217                                                 handle_x,
218                                                 handle_y);
219                                         trackcanvas->add_subwindow(handle);
220                                         handle->set_cursor(ARROW_CURSOR, 0, 0);
221                                         append(handle);
222                                 }
223                         }
224                 }
225         }
226
227         delete_invisible();
228 }