r870: Merge 2.1:
[cinelerra_cv.git] / cinelerra / edithandles.C
blob2b6005332a999a89d6568634f1479b497562f879
1 #include "cursors.h"
2 #include "edithandles.h"
3 #include "edithandles.inc"
4 #include "edit.h"
5 #include "edits.h"
6 #include "edl.h"
7 #include "mwindow.h"
8 #include "theme.h"
9 #include "track.h"
10 #include "tracks.h"
11 #include "trackcanvas.h"
15 EditHandle::EditHandle(MWindow *mwindow, 
16                 TrackCanvas *trackcanvas, 
17                 Edit *edit, 
18                 int side, 
19                 int x, 
20                 int y)
21  : CanvasTool(mwindow,
22         trackcanvas,
23         edit, 
24         x,
25         y, 
26         side == EDIT_IN ? mwindow->theme->edithandlein_data : mwindow->theme->edithandleout_data)
28         this->side = side;
31 EditHandle::~EditHandle()
35 int EditHandle::handle_event()
37         return 0;
44 EditHandleIn::EditHandleIn(MWindow *mwindow, 
45         TrackCanvas *trackcanvas,
46         Edit *edit,
47         int x,
48         int y)
49  : EditHandle(mwindow, 
50                 trackcanvas, 
51                 edit, 
52                 EDIT_IN, 
53                 x, 
54                 y)
58 EditHandleIn::~EditHandleIn()
63 int EditHandleIn::handle_event()
65         return 1;
75 EditHandleOut::EditHandleOut(MWindow *mwindow, 
76         TrackCanvas *trackcanvas,
77         Edit *edit,
78         int x,
79         int y)
80  : EditHandle(mwindow, 
81                 trackcanvas, 
82                 edit, 
83                 EDIT_OUT, 
84                 x, 
85                 y)
87         this->mwindow = mwindow;
88         this->trackcanvas = trackcanvas;
89         this->edit = edit;
90         visible = 1;
93 EditHandleOut::~EditHandleOut()
98 int EditHandleOut::handle_event()
100         return 1;
112 EditHandles::EditHandles(MWindow *mwindow, 
113                 TrackCanvas *trackcanvas)
114  : CanvasTools(mwindow, trackcanvas)
118 EditHandles::~EditHandles()
122 void EditHandles::update()
124         decrease_visible();
126         for(Track *current = mwindow->edl->tracks->first;
127                 current;
128                 current = NEXT)
129         {
130                 for(Edit *edit = current->edits->first; edit; edit = edit->next)
131                 {
132 // Test in point
133                         int64_t handle_x, handle_y, handle_w, handle_h;
134                         trackcanvas->get_handle_coords(edit, handle_x, handle_y, handle_w, handle_h, EDIT_IN);
136                         if(visible(handle_x, handle_y, handle_w, handle_h))
137                         {
138                                 int exists = 0;
139                                 
140                                 for(int i = 0; i < total; i++)
141                                 {
142                                         EditHandle *handle = (EditHandle*)values[i];
143                                         if(handle->edit->id == edit->id && handle->side == EDIT_IN)
144                                         {
145                                                 handle->reposition_window(handle_x, handle_y);
146                                                 handle->raise_window();
147                                                 handle->draw_face();
148                                                 handle->visible = 1;
149                                                 exists = 1;
150                                                 break;
151                                         }
152                                 }
153                                 
154                                 if(!exists)
155                                 {
156                                         EditHandle *handle = new EditHandle(mwindow, 
157                                                 trackcanvas, 
158                                                 edit, 
159                                                 EDIT_IN, 
160                                                 handle_x, 
161                                                 handle_y);
162                                         trackcanvas->add_subwindow(handle);
163                                         handle->set_cursor(ARROW_CURSOR);
164                                         append(handle);
165                                 }
166                         }
169 // Test out point
170                         trackcanvas->get_handle_coords(edit, handle_x, handle_y, handle_w, handle_h, EDIT_OUT);
172                         if(visible(handle_x, handle_y, handle_w, handle_h))
173                         {
174                                 int exists = 0;
175                                 
176                                 for(int i = 0; i < total; i++)
177                                 {
178                                         EditHandle *handle = (EditHandle*)values[i];
179                                         if(handle->edit->id == edit->id && handle->side == EDIT_OUT)
180                                         {
181                                                 handle->reposition_window(handle_x, handle_y);
182                                                 handle->raise_window();
183                                                 handle->draw_face();
184                                                 handle->visible = 1;
185                                                 exists = 1;
186                                                 break;
187                                         }
188                                 }
189                                 
190                                 if(!exists)
191                                 {
192                                         EditHandle *handle = new EditHandle(mwindow, 
193                                                 trackcanvas, 
194                                                 edit, 
195                                                 EDIT_OUT, 
196                                                 handle_x, 
197                                                 handle_y);
198                                         trackcanvas->add_subwindow(handle);
199                                         handle->set_cursor(ARROW_CURSOR);
200                                         append(handle);
201                                 }
202                         }
203                 }
204         }
206         delete_invisible();