4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
27 #include "recordgui.h"
28 #include "recordtransport.h"
33 RecordTransport::RecordTransport(MWindow *mwindow, Record *record,
34 BC_WindowBase *window, int x, int y)
36 this->mwindow = mwindow;
37 this->record = record;
38 this->window = window;
45 void RecordTransport::create_objects()
47 int x = this->x, y = this->y;
49 window->add_subwindow(rewind_button = new RecordGUIRewind(this, x, y));
50 x += rewind_button->get_w(); y_end = y+rewind_button->get_h();
51 window->add_subwindow(record_button = new RecordGUIRec(this, x, y));
52 x += record_button->get_w(); y_end = max(y_end,y+record_button->get_h());
54 if(record->default_asset->video_data) {
55 window->add_subwindow(
56 record_frame = new RecordGUIRecFrame(this, x, y));
57 x += record_frame->get_w(); y_end = max(y_end,y+record_button->get_h());
59 window->add_subwindow(stop_button = new RecordGUIStop(this, x, y));
60 x += stop_button->get_w(); y_end = max(y_end,y+record_button->get_h());
61 // window->add_subwindow(pause_button = new RecordGUIPause(this, x, y));
62 // x += pause_button->get_w(); y_end = max(y_end,y+record_button->get_h());
66 x = this->x; y = y_end;
67 window->add_subwindow(back_button = new RecordGUIBack(this, x, y));
68 x += back_button->get_w(); x_end = max(x, x_end);
69 y_end = max(y + back_button->get_h(), y_end);
70 window->add_subwindow(play_button = new RecordGUIPlay(this, x, y));
71 x += play_button->get_w(); x_end = max(x, x_end);
72 y_end = max(y + play_button->get_h(), y_end);
73 window->add_subwindow(fwd_button = new RecordGUIFwd(this, x, y));
74 x += fwd_button->get_w(); x_end = max(x, x_end);
75 y_end = max(y + fwd_button->get_h(), y_end);
76 window->add_subwindow(end_button = new RecordGUIEnd(this, x, y));
77 x += end_button->get_w(); x_end = max(x, x_end);
78 y_end = max(y + end_button->get_h(), y_end);
80 x_end += xS(10); y_end += yS(10);
83 void RecordTransport::reposition_window(int x, int y)
85 this->x = x; this->y = y;
86 rewind_button->reposition_window(x, y);
87 x += rewind_button->get_w(); y_end = y+rewind_button->get_h();
88 record_button->reposition_window(x, y);
89 x += record_button->get_w(); y_end = max(y_end,y+record_button->get_h());
90 if(record->default_asset->video_data) {
91 record_frame->reposition_window(x, y);
92 x += record_frame->get_w(); y_end = max(y_end,y+record_button->get_h());
94 stop_button->reposition_window(x, y);
95 x += stop_button->get_w(); y_end = max(y_end,y+record_button->get_h());
96 // pause_button->reposition_window(x, y);
97 // x += pause_button->get_w(); y_end = max(y_end,y+record_button->get_h());
101 x = this->x; y = y_end;
102 back_button->reposition_window(x, y);
103 x += back_button->get_w(); x_end = max(x, x_end);
104 y_end = max(y + back_button->get_h(), y_end);
105 play_button->reposition_window(x, y);
106 x += play_button->get_w(); x_end = max(x, x_end);
107 y_end = max(y + play_button->get_h(), y_end);
108 fwd_button->reposition_window(x, y);
109 x += fwd_button->get_w(); x_end = max(x, x_end);
110 y_end = max(y + fwd_button->get_h(), y_end);
111 end_button->reposition_window(x, y);
112 x += end_button->get_w(); x_end = max(x, x_end);
113 y_end = max(y + end_button->get_h(), y_end);
115 x_end += xS(10); y_end += yS(10);
118 int RecordTransport::get_h()
123 int RecordTransport::get_w()
129 RecordTransport::~RecordTransport()
132 void RecordTransport::
133 start_writing_file(int single_frame)
135 if( !record->writing_file ) {
136 record->pause_input_threads();
137 record->update_position();
138 record->single_frame = single_frame;
139 record->start_writing_file();
140 record->resume_input_threads();
144 void RecordTransport::
147 record->stop_cron_thread(_("Interrupted"));
148 record->stop_writing();
151 int RecordTransport::keypress_event()
153 if( record->cron_active() > 0 ) return 0;
154 if( window->get_keypress() == ' ' ) {
155 //printf("RecordTransport::keypress_event 1\n");
156 if( record->writing_file ) {
157 window->unlock_window();
159 window->lock_window("RecordTransport::keypress_event 1");
162 window->unlock_window();
163 start_writing_file();
164 window->lock_window("RecordTransport::keypress_event 2");
166 //printf("RecordTransport::keypress_event 2\n");
173 RecordGUIRec::RecordGUIRec(RecordTransport *record_transport, int x, int y)
174 : BC_Button(x, y, record_transport->mwindow->theme->get_image_set("record"))
176 this->record_transport = record_transport;
177 set_tooltip(_("Start recording\nfrom current position"));
178 // *** CONTEXT_HELP ***
179 context_help_set_keyword("Recording Immediately to Capture");
182 RecordGUIRec::~RecordGUIRec()
186 int RecordGUIRec::handle_event()
188 if( record_transport->record->cron_active() > 0 ) return 0;
190 record_transport->start_writing_file();
191 lock_window("RecordGUIRec::handle_event");
195 int RecordGUIRec::keypress_event()
197 return context_help_check_and_show();
200 RecordGUIRecFrame::RecordGUIRecFrame(RecordTransport *record_transport, int x, int y)
201 : BC_Button(x, y, record_transport->mwindow->theme->get_image_set("recframe"))
203 this->record_transport = record_transport;
204 set_tooltip(_("RecordTransport single frame"));
205 // *** CONTEXT_HELP ***
206 context_help_set_keyword("Recording Immediately to Capture");
209 RecordGUIRecFrame::~RecordGUIRecFrame()
213 int RecordGUIRecFrame::handle_event()
215 if( record_transport->record->cron_active() > 0 ) return 0;
217 record_transport->start_writing_file(1);
218 lock_window("RecordGUIRecFrame::handle_event");
222 int RecordGUIRecFrame::keypress_event()
224 return context_help_check_and_show();
227 RecordGUIPlay::RecordGUIPlay(RecordTransport *record_transport, int x, int y)
228 : BC_Button(x, y, record_transport->mwindow->theme->get_image_set("play"))
230 this->record_transport = record_transport;
231 set_tooltip(_("Preview recording"));
234 RecordGUIPlay::~RecordGUIPlay()
238 int RecordGUIPlay::handle_event()
245 int RecordGUIPlay::keypress_event()
247 return context_help_check_and_show();
251 RecordGUIStop::RecordGUIStop(RecordTransport *record_transport, int x, int y)
252 : BC_Button(x, y, record_transport->mwindow->theme->get_image_set("stoprec"))
254 this->record_transport = record_transport;
255 set_tooltip(_("Stop operation"));
256 // *** CONTEXT_HELP ***
257 context_help_set_keyword("Recording Immediately to Capture");
260 RecordGUIStop::~RecordGUIStop()
264 int RecordGUIStop::handle_event()
267 record_transport->stop_writing();
268 lock_window("RecordGUIStop::handle_event");
272 int RecordGUIStop::keypress_event()
274 return context_help_check_and_show();
279 RecordGUIPause::RecordGUIPause(RecordTransport *record_transport, int x, int y)
280 : BC_Button(x, y, record_transport->mwindow->theme->get_image_set("pause"))
282 this->record_transport = record_transport;
283 set_tooltip(_("Pause"));
286 RecordGUIPause::~RecordGUIPause()
290 int RecordGUIPause::handle_event()
295 int RecordGUIPause::keypress_event()
297 return context_help_check_and_show();
302 RecordGUIRewind::RecordGUIRewind(RecordTransport *record_transport, int x, int y)
303 : BC_Button(x, y, record_transport->mwindow->theme->get_image_set("rewind"))
305 this->record_transport = record_transport;
306 set_tooltip(_("Start over"));
307 // *** CONTEXT_HELP ***
308 context_help_set_keyword("Recording Immediately to Capture");
311 RecordGUIRewind::~RecordGUIRewind()
315 int RecordGUIRewind::handle_event()
317 RecordGUI *record_gui = record_transport->record->record_gui;
318 if( !record_gui->startover_thread->running() )
319 record_gui->startover_thread->start();
323 int RecordGUIRewind::keypress_event()
325 return context_help_check_and_show();
330 RecordGUIBack::RecordGUIBack(RecordTransport *record_transport, int x, int y)
331 : BC_Button(x, y, record_transport->mwindow->theme->get_image_set("fastrev"))
333 this->record_transport = record_transport;
334 set_tooltip(_("Fast rewind"));
338 RecordGUIBack::~RecordGUIBack()
342 int RecordGUIBack::handle_event()
347 int RecordGUIBack::button_press()
352 int RecordGUIBack::button_release()
354 unset_repeat(repeat_id);
358 int RecordGUIBack::repeat_event()
364 int RecordGUIBack::keypress_event()
366 return context_help_check_and_show();
371 RecordGUIFwd::RecordGUIFwd(RecordTransport *record_transport, int x, int y)
372 : BC_Button(x, y, record_transport->mwindow->theme->get_image_set("fastfwd"))
374 this->record_transport = record_transport;
375 set_tooltip(_("Fast forward"));
379 RecordGUIFwd::~RecordGUIFwd()
383 int RecordGUIFwd::handle_event()
388 int RecordGUIFwd::button_press()
393 int RecordGUIFwd::button_release()
395 unset_repeat(repeat_id);
399 int RecordGUIFwd::repeat_event()
404 int RecordGUIFwd::keypress_event()
406 return context_help_check_and_show();
411 RecordGUIEnd::RecordGUIEnd(RecordTransport *record_transport, int x, int y)
412 : BC_Button(x, y, record_transport->mwindow->theme->get_image_set("end"))
414 this->record_transport = record_transport;
415 set_tooltip(_("Seek to end of recording"));
418 RecordGUIEnd::~RecordGUIEnd()
422 int RecordGUIEnd::handle_event()
427 int RecordGUIEnd::keypress_event()
429 return context_help_check_and_show();