5 #include "playbackengine.h"
6 #include "playtransport.h"
7 #include "preferences.h"
9 #include "transportque.h"
14 PlayTransport::PlayTransport(MWindow *mwindow,
15 BC_WindowBase *subwindow,
19 this->subwindow = subwindow;
20 this->mwindow = mwindow;
28 PlayTransport::~PlayTransport()
31 delete frame_forward_play;
33 delete frame_reverse_play;
41 void PlayTransport::set_engine(PlaybackEngine *engine)
43 this->engine = engine;
46 void PlayTransport::set_slider(BC_Slider *slider)
48 this->slider = slider;
51 int PlayTransport::get_transport_width(MWindow *mwindow)
53 //printf("PlayTransport::get_transport_width %p\n", mwindow->theme->rewind_data);
54 return mwindow->theme->stop_data[0]->get_w() * 7 +
55 mwindow->theme->rewind_data[0]->get_w() * 2;
58 int PlayTransport::create_objects()
60 int x = this->x, y = this->y;
61 subwindow->add_subwindow(rewind_button = new RewindButton(mwindow, this, x, y));
62 x += rewind_button->get_w();
63 subwindow->add_subwindow(fast_reverse = new FastReverseButton(mwindow, this, x, y));
64 x += fast_reverse->get_w();
65 subwindow->add_subwindow(reverse_play = new ReverseButton(mwindow, this, x, y));
66 x += reverse_play->get_w();
67 subwindow->add_subwindow(frame_reverse_play = new FrameReverseButton(mwindow, this, x, y));
68 x += frame_reverse_play->get_w();
69 subwindow->add_subwindow(stop_button = new StopButton(mwindow, this, x, y));
70 x += stop_button->get_w();
71 subwindow->add_subwindow(frame_forward_play = new FramePlayButton(mwindow, this, x, y));
72 x += frame_forward_play->get_w();
73 subwindow->add_subwindow(forward_play = new PlayButton(mwindow, this, x, y));
74 x += forward_play->get_w();
75 subwindow->add_subwindow(fast_play = new FastPlayButton(mwindow, this, x, y));
76 x += fast_play->get_w();
77 subwindow->add_subwindow(end_button = new EndButton(mwindow, this, x, y));
78 x += end_button->get_w();
86 void PlayTransport::reposition_buttons(int x, int y)
90 rewind_button->reposition_window(x, y);
91 x += rewind_button->get_w();
92 fast_reverse->reposition_window(x, y);
93 x += fast_reverse->get_w();
94 reverse_play->reposition_window(x, y);
95 x += reverse_play->get_w();
96 frame_reverse_play->reposition_window(x, y);
97 x += frame_reverse_play->get_w();
98 stop_button->reposition_window(x, y);
99 x += stop_button->get_w();
100 frame_forward_play->reposition_window(x, y);
101 x += frame_forward_play->get_w();
102 forward_play->reposition_window(x, y);
103 x += forward_play->get_w();
104 fast_play->reposition_window(x, y);
105 x += fast_play->get_w();
106 end_button->reposition_window(x, y);
107 x += end_button->get_w();
110 int PlayTransport::get_w()
112 return end_button->get_x() + end_button->get_w() - rewind_button->get_x();
115 int PlayTransport::flip_vertical(int vertical, int &x, int &y)
119 rewind_button->reposition_window(x, y);
120 y += rewind_button->get_h();
121 fast_reverse->reposition_window(x, y);
122 y += fast_reverse->get_h();
123 reverse_play->reposition_window(x, y);
124 y += reverse_play->get_h();
125 frame_reverse_play->reposition_window(x, y);
126 y += frame_reverse_play->get_h();
127 stop_button->reposition_window(x, y);
128 y += stop_button->get_h();
129 frame_forward_play->reposition_window(x, y);
130 y += frame_forward_play->get_h();
131 forward_play->reposition_window(x, y);
132 y += forward_play->get_h();
133 fast_play->reposition_window(x, y);
134 y += fast_play->get_h();
135 end_button->reposition_window(x, y);
136 y += end_button->get_h();
140 rewind_button->reposition_window(x, y - 2);
141 x += rewind_button->get_w();
142 fast_reverse->reposition_window(x, y - 2);
143 x += fast_reverse->get_w();
144 reverse_play->reposition_window(x, y - 2);
145 x += reverse_play->get_w();
146 frame_reverse_play->reposition_window(x, y - 2);
147 x += frame_reverse_play->get_w();
148 stop_button->reposition_window(x, y - 2);
149 x += stop_button->get_w();
150 frame_forward_play->reposition_window(x, y - 2);
151 x += frame_forward_play->get_w();
152 forward_play->reposition_window(x, y - 2);
153 x += forward_play->get_w();
154 fast_play->reposition_window(x, y - 2);
155 x += fast_play->get_w();
156 end_button->reposition_window(x, y - 2);
157 x += end_button->get_w();
163 int PlayTransport::keypress_event()
166 if(subwindow->shift_down())
168 switch(subwindow->get_keypress())
171 subwindow->lock_window("PlayTransport::keypress_event 1");
174 subwindow->unlock_window();
177 subwindow->lock_window("PlayTransport::keypress_event 2");
180 subwindow->unlock_window();
186 subwindow->unlock_window();
187 switch(subwindow->get_keypress())
189 case KPPLUS: handle_transport(FAST_REWIND); result = 1; break;
190 case KP6: handle_transport(NORMAL_REWIND); result = 1; break;
191 case KP5: handle_transport(SLOW_REWIND); result = 1; break;
192 case KP4: handle_transport(SINGLE_FRAME_REWIND); result = 1; break;
193 case KP1: handle_transport(SINGLE_FRAME_FWD); result = 1; break;
194 case KP2: handle_transport(SLOW_FWD); result = 1; break;
195 case KP3: handle_transport(NORMAL_FWD); result = 1; break;
196 case KPENTER: handle_transport(FAST_FWD); result = 1; break;
197 case KPINS: handle_transport(STOP); result = 1; break;
198 case ' ': handle_transport(NORMAL_FWD); result = 1; break;
199 case 'k': handle_transport(STOP); result = 1; break;
201 subwindow->lock_window("PlayTransport::keypress_event 3");
204 subwindow->unlock_window();
207 subwindow->lock_window("PlayTransport::keypress_event 4");
210 subwindow->unlock_window();
214 subwindow->lock_window("PlayTransport::keypress_event 5");
220 void PlayTransport::goto_start()
222 handle_transport(REWIND, 1);
225 void PlayTransport::goto_end()
227 handle_transport(GOTO_END, 1);
232 void PlayTransport::handle_transport(int command, int wait_tracking)
234 //printf("PlayTransport::handle_transport 1\n");
235 if(!get_edl()) return;
236 //printf("PlayTransport::handle_transport 2 %d\n", command);
244 case SINGLE_FRAME_REWIND:
245 case SINGLE_FRAME_FWD:
250 //printf("PlayTransport::handle_transport 3 %d %d\n", engine->command->command, command);
251 if(engine->command->command == command &&
252 !engine->command->single_frame())
254 //printf("PlayTransport::handle_transport 4 %d\n", command);
255 engine->que->send_command(STOP,
259 engine->interrupt_playback(wait_tracking);
262 // Resume or change direction
263 if(engine->command->command != STOP &&
264 engine->command->command != COMMAND_NONE &&
265 engine->command->command != SINGLE_FRAME_FWD &&
266 engine->command->command != SINGLE_FRAME_REWIND)
268 //printf("PlayTransport::handle_transport 5 %d\n", command);
269 engine->que->send_command(STOP,
273 //printf("PlayTransport::handle_transport 3\n");
274 engine->interrupt_playback(wait_tracking);
275 //printf("PlayTransport::handle_transport 4\n");
276 engine->que->send_command(command,
281 //printf("PlayTransport::handle_transport 5\n");
284 // Start from scratch
286 //printf("PlayTransport::handle_transport 6 %d\n", command);
287 engine->que->send_command(command,
298 //printf("PlayTransport 1\n");
299 engine->que->send_command(STOP,
303 //printf("PlayTransport 1\n");
304 engine->interrupt_playback(wait_tracking);
307 //printf("PlayTransport::handle_transport 2\n");
310 EDL* PlayTransport::get_edl()
315 int PlayTransport::pause_transport()
317 if(active_button) active_button->set_mode(PLAY_MODE);
322 int PlayTransport::reset_transport()
324 fast_reverse->set_mode(PLAY_MODE);
325 reverse_play->set_mode(PLAY_MODE);
326 forward_play->set_mode(PLAY_MODE);
327 frame_reverse_play->set_mode(PLAY_MODE);
328 frame_forward_play->set_mode(PLAY_MODE);
329 fast_play->set_mode(PLAY_MODE);
333 PTransportButton::PTransportButton(MWindow *mwindow, PlayTransport *transport, int x, int y, VFrame **data)
334 : BC_Button(x, y, data)
336 this->mwindow = mwindow;
337 this->transport = transport;
340 PTransportButton::~PTransportButton()
344 int PTransportButton::set_mode(int mode)
351 RewindButton::RewindButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
352 : PTransportButton(mwindow, transport, x, y, mwindow->theme->rewind_data)
354 set_tooltip(_("Rewind ( Home )"));
356 int RewindButton::handle_event()
359 transport->goto_start();
364 FastReverseButton::FastReverseButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
365 : PTransportButton(mwindow, transport, x, y, mwindow->theme->fastrev_data)
367 set_tooltip(_("Fast reverse ( + )"));
369 int FastReverseButton::handle_event()
372 transport->handle_transport(FAST_REWIND);
373 lock_window("FastReverseButton::handle_event");
377 // Reverse playback normal speed
379 ReverseButton::ReverseButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
380 : PTransportButton(mwindow, transport, x, y, mwindow->theme->reverse_data)
382 set_tooltip(_("Normal reverse ( 6 )"));
384 int ReverseButton::handle_event()
387 transport->handle_transport(NORMAL_REWIND);
388 lock_window("ReverseButton::handle_event");
392 // Reverse playback one frame
394 FrameReverseButton::FrameReverseButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
395 : PTransportButton(mwindow, transport, x, y, mwindow->theme->framerev_data)
397 set_tooltip(_("Frame reverse ( 4 )"));
399 int FrameReverseButton::handle_event()
402 transport->handle_transport(SINGLE_FRAME_REWIND);
403 lock_window("FrameReverseButton::handle_event");
407 // forward playback normal speed
409 PlayButton::PlayButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
410 : PTransportButton(mwindow, transport, x, y, mwindow->theme->forward_data)
412 set_tooltip(_("Normal forward ( 3 )"));
414 int PlayButton::handle_event()
416 //printf("PlayButton::handle_event 1\n");
418 transport->handle_transport(NORMAL_FWD);
419 lock_window("PlayButton::handle_event");
420 //printf("PlayButton::handle_event 2\n");
426 // forward playback one frame
428 FramePlayButton::FramePlayButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
429 : PTransportButton(mwindow, transport, x, y, mwindow->theme->framefwd_data)
431 set_tooltip(_("Frame forward ( 1 )"));
433 int FramePlayButton::handle_event()
436 transport->handle_transport(SINGLE_FRAME_FWD);
437 lock_window("FramePlayButton::handle_event");
443 FastPlayButton::FastPlayButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
444 : PTransportButton(mwindow, transport, x, y, mwindow->theme->fastfwd_data)
446 set_tooltip(_("Fast forward ( Enter )"));
448 int FastPlayButton::handle_event()
451 transport->handle_transport(FAST_FWD);
452 lock_window("FastPlayButton::handle_event");
456 EndButton::EndButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
457 : PTransportButton(mwindow, transport, x, y, mwindow->theme->end_data)
459 set_tooltip(_("Jump to end ( End )"));
461 int EndButton::handle_event()
464 transport->goto_end();
469 StopButton::StopButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
470 : PTransportButton(mwindow, transport, x, y, mwindow->theme->stop_data)
472 set_tooltip(_("Stop ( 0 )"));
474 int StopButton::handle_event()
477 transport->handle_transport(STOP);
478 lock_window("StopButton::handle_event");