4 #include "localsession.h"
6 #include "playbackengine.h"
7 #include "playtransport.h"
8 #include "preferences.h"
10 #include "transportque.h"
12 #include "localsession.h"
16 PlayTransport::PlayTransport(MWindow *mwindow,
17 BC_WindowBase *subwindow,
21 this->subwindow = subwindow;
22 this->mwindow = mwindow;
30 PlayTransport::~PlayTransport()
33 delete frame_forward_play;
35 delete frame_reverse_play;
43 void PlayTransport::set_engine(PlaybackEngine *engine)
45 this->engine = engine;
48 void PlayTransport::set_slider(BC_Slider *slider)
50 this->slider = slider;
53 int PlayTransport::get_transport_width(MWindow *mwindow)
55 return mwindow->theme->get_image_set("stop")[0]->get_w() * 7 +
56 mwindow->theme->get_image_set("rewind")[0]->get_w() * 2;
59 int PlayTransport::create_objects()
61 int x = this->x, y = this->y;
62 subwindow->add_subwindow(rewind_button = new RewindButton(mwindow, this, x, y));
63 x += rewind_button->get_w();
64 subwindow->add_subwindow(fast_reverse = new FastReverseButton(mwindow, this, x, y));
65 x += fast_reverse->get_w();
66 subwindow->add_subwindow(reverse_play = new ReverseButton(mwindow, this, x, y));
67 x += reverse_play->get_w();
68 subwindow->add_subwindow(frame_reverse_play = new FrameReverseButton(mwindow, this, x, y));
69 x += frame_reverse_play->get_w();
70 subwindow->add_subwindow(stop_button = new StopButton(mwindow, this, x, y));
71 x += stop_button->get_w();
72 subwindow->add_subwindow(frame_forward_play = new FramePlayButton(mwindow, this, x, y));
73 x += frame_forward_play->get_w();
74 subwindow->add_subwindow(forward_play = new PlayButton(mwindow, this, x, y));
75 x += forward_play->get_w();
76 subwindow->add_subwindow(fast_play = new FastPlayButton(mwindow, this, x, y));
77 x += fast_play->get_w();
78 subwindow->add_subwindow(end_button = new EndButton(mwindow, this, x, y));
79 x += end_button->get_w();
87 void PlayTransport::reposition_buttons(int x, int y)
91 rewind_button->reposition_window(x, y);
92 x += rewind_button->get_w();
93 fast_reverse->reposition_window(x, y);
94 x += fast_reverse->get_w();
95 reverse_play->reposition_window(x, y);
96 x += reverse_play->get_w();
97 frame_reverse_play->reposition_window(x, y);
98 x += frame_reverse_play->get_w();
99 stop_button->reposition_window(x, y);
100 x += stop_button->get_w();
101 frame_forward_play->reposition_window(x, y);
102 x += frame_forward_play->get_w();
103 forward_play->reposition_window(x, y);
104 x += forward_play->get_w();
105 fast_play->reposition_window(x, y);
106 x += fast_play->get_w();
107 end_button->reposition_window(x, y);
108 x += end_button->get_w();
111 int PlayTransport::get_w()
113 return end_button->get_x() + end_button->get_w() - rewind_button->get_x();
116 int PlayTransport::flip_vertical(int vertical, int &x, int &y)
120 rewind_button->reposition_window(x, y);
121 y += rewind_button->get_h();
122 fast_reverse->reposition_window(x, y);
123 y += fast_reverse->get_h();
124 reverse_play->reposition_window(x, y);
125 y += reverse_play->get_h();
126 frame_reverse_play->reposition_window(x, y);
127 y += frame_reverse_play->get_h();
128 stop_button->reposition_window(x, y);
129 y += stop_button->get_h();
130 frame_forward_play->reposition_window(x, y);
131 y += frame_forward_play->get_h();
132 forward_play->reposition_window(x, y);
133 y += forward_play->get_h();
134 fast_play->reposition_window(x, y);
135 y += fast_play->get_h();
136 end_button->reposition_window(x, y);
137 y += end_button->get_h();
141 rewind_button->reposition_window(x, y - 2);
142 x += rewind_button->get_w();
143 fast_reverse->reposition_window(x, y - 2);
144 x += fast_reverse->get_w();
145 reverse_play->reposition_window(x, y - 2);
146 x += reverse_play->get_w();
147 frame_reverse_play->reposition_window(x, y - 2);
148 x += frame_reverse_play->get_w();
149 stop_button->reposition_window(x, y - 2);
150 x += stop_button->get_w();
151 frame_forward_play->reposition_window(x, y - 2);
152 x += frame_forward_play->get_w();
153 forward_play->reposition_window(x, y - 2);
154 x += forward_play->get_w();
155 fast_play->reposition_window(x, y - 2);
156 x += fast_play->get_w();
157 end_button->reposition_window(x, y - 2);
158 x += end_button->get_w();
164 int PlayTransport::keypress_event()
167 if(subwindow->shift_down())
169 switch(subwindow->get_keypress())
172 subwindow->lock_window("PlayTransport::keypress_event 1");
175 subwindow->unlock_window();
178 subwindow->lock_window("PlayTransport::keypress_event 2");
181 subwindow->unlock_window();
187 // Set playback range to in/out points if CTRL is down
189 if(subwindow->ctrl_down())
193 subwindow->unlock_window();
196 switch(subwindow->get_keypress())
198 case KPPLUS: handle_transport(FAST_REWIND, 0, use_inout); result = 1; break;
199 case KP6: handle_transport(NORMAL_REWIND, 0, use_inout); result = 1; break;
200 case KP5: handle_transport(SLOW_REWIND, 0, use_inout); result = 1; break;
201 case KP4: handle_transport(SINGLE_FRAME_REWIND, 0, use_inout); result = 1; break;
202 case KP1: handle_transport(SINGLE_FRAME_FWD, 0, use_inout); result = 1; break;
203 case KP2: handle_transport(SLOW_FWD, 0, use_inout); result = 1; break;
204 case KP3: handle_transport(NORMAL_FWD, 0, use_inout); result = 1; break;
205 case KPENTER: handle_transport(FAST_FWD, 0, use_inout); result = 1; break;
206 case KPINS: handle_transport(STOP, 0, use_inout); result = 1; break;
207 case ' ': handle_transport(NORMAL_FWD, 0, use_inout); result = 1; break;
208 case 'k': handle_transport(STOP, 0, use_inout); result = 1; break;
210 subwindow->lock_window("PlayTransport::keypress_event 3");
213 subwindow->unlock_window();
216 subwindow->lock_window("PlayTransport::keypress_event 4");
219 subwindow->unlock_window();
223 subwindow->lock_window("PlayTransport::keypress_event 5");
229 void PlayTransport::goto_start()
231 handle_transport(REWIND, 1, 0);
234 void PlayTransport::goto_end()
236 handle_transport(GOTO_END, 1, 0);
241 void PlayTransport::handle_transport(int command,
245 if(!get_edl()) return;
252 // Commands that play back
256 case SINGLE_FRAME_REWIND:
257 case SINGLE_FRAME_FWD:
262 if(engine->command->command == command &&
263 !engine->command->single_frame())
265 engine->que->send_command(STOP,
271 engine->interrupt_playback(wait_tracking);
274 // Resume or change direction
275 if(engine->command->command != STOP &&
276 engine->command->command != COMMAND_NONE &&
277 engine->command->command != SINGLE_FRAME_FWD &&
278 engine->command->command != SINGLE_FRAME_REWIND)
280 engine->que->send_command(STOP,
286 engine->interrupt_playback(wait_tracking);
287 engine->que->send_command(command,
295 // Start from scratch
297 engine->que->send_command(command,
306 // Commands that stop
310 engine->que->send_command(STOP,
316 engine->interrupt_playback(wait_tracking);
321 EDL* PlayTransport::get_edl()
326 int PlayTransport::pause_transport()
328 if(active_button) active_button->set_mode(PLAY_MODE);
333 int PlayTransport::reset_transport()
335 fast_reverse->set_mode(PLAY_MODE);
336 reverse_play->set_mode(PLAY_MODE);
337 forward_play->set_mode(PLAY_MODE);
338 frame_reverse_play->set_mode(PLAY_MODE);
339 frame_forward_play->set_mode(PLAY_MODE);
340 fast_play->set_mode(PLAY_MODE);
344 PTransportButton::PTransportButton(MWindow *mwindow, PlayTransport *transport, int x, int y, VFrame **data)
345 : BC_Button(x, y, data)
347 this->mwindow = mwindow;
348 this->transport = transport;
351 PTransportButton::~PTransportButton()
355 int PTransportButton::set_mode(int mode)
362 RewindButton::RewindButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
363 : PTransportButton(mwindow, transport, x, y, mwindow->theme->get_image_set("rewind"))
365 set_tooltip(_("Rewind ( Home )"));
367 int RewindButton::handle_event()
370 transport->goto_start();
375 FastReverseButton::FastReverseButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
376 : PTransportButton(mwindow, transport, x, y, mwindow->theme->get_image_set("fastrev"))
378 set_tooltip(_("Fast reverse ( + )"));
380 int FastReverseButton::handle_event()
383 transport->handle_transport(FAST_REWIND, 0, ctrl_down());
384 lock_window("FastReverseButton::handle_event");
388 // Reverse playback normal speed
390 ReverseButton::ReverseButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
391 : PTransportButton(mwindow, transport, x, y, mwindow->theme->get_image_set("reverse"))
393 set_tooltip(_("Normal reverse ( 6 )"));
395 int ReverseButton::handle_event()
398 transport->handle_transport(NORMAL_REWIND, 0, ctrl_down());
399 lock_window("ReverseButton::handle_event");
403 // Reverse playback one frame
405 FrameReverseButton::FrameReverseButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
406 : PTransportButton(mwindow, transport, x, y, mwindow->theme->get_image_set("framerev"))
408 set_tooltip(_("Frame reverse ( 4 )"));
410 int FrameReverseButton::handle_event()
413 transport->handle_transport(SINGLE_FRAME_REWIND, 0, ctrl_down());
414 lock_window("FrameReverseButton::handle_event");
418 // forward playback normal speed
420 PlayButton::PlayButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
421 : PTransportButton(mwindow, transport, x, y, mwindow->theme->get_image_set("play"))
423 set_tooltip(_("Normal forward ( 3 )"));
425 int PlayButton::handle_event()
428 transport->handle_transport(NORMAL_FWD, 0, ctrl_down());
429 lock_window("PlayButton::handle_event");
435 // forward playback one frame
437 FramePlayButton::FramePlayButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
438 : PTransportButton(mwindow, transport, x, y, mwindow->theme->get_image_set("framefwd"))
440 set_tooltip(_("Frame forward ( 1 )"));
442 int FramePlayButton::handle_event()
445 transport->handle_transport(SINGLE_FRAME_FWD, 0, ctrl_down());
446 lock_window("FramePlayButton::handle_event");
452 FastPlayButton::FastPlayButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
453 : PTransportButton(mwindow, transport, x, y, mwindow->theme->get_image_set("fastfwd"))
455 set_tooltip(_("Fast forward ( Enter )"));
457 int FastPlayButton::handle_event()
460 transport->handle_transport(FAST_FWD, 0, ctrl_down());
461 lock_window("FastPlayButton::handle_event");
465 EndButton::EndButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
466 : PTransportButton(mwindow, transport, x, y, mwindow->theme->get_image_set("end"))
468 set_tooltip(_("Jump to end ( End )"));
470 int EndButton::handle_event()
473 transport->goto_end();
478 StopButton::StopButton(MWindow *mwindow, PlayTransport *transport, int x, int y)
479 : PTransportButton(mwindow, transport, x, y, mwindow->theme->get_image_set("stop"))
481 set_tooltip(_("Stop ( 0 )"));
483 int StopButton::handle_event()
486 transport->handle_transport(STOP, 0, 0);
487 lock_window("StopButton::handle_event");