5 #include "channeledit.h"
6 #include "channelpicker.h"
7 #include "chantables.h"
10 #include "edlsession.h"
15 #include "playbackconfig.h"
16 #include "preferencesthread.h"
18 #include "recordgui.h"
19 #include "recordmonitor.h"
21 #include "vdevicebuz.h"
22 #include "vdeviceprefs.h"
23 #include "videodevice.h"
25 RecordChannelPicker::RecordChannelPicker(MWindow *mwindow,
27 RecordMonitor *record_monitor,
28 BC_WindowBase *parent_window,
32 : ChannelPicker(channeldb,
37 this->mwindow = mwindow;
38 this->record = record;
39 this->record_monitor = record_monitor;
42 RecordChannelPicker::~RecordChannelPicker()
46 int RecordChannelPicker::use_select()
51 Channel* RecordChannelPicker::get_master_channel()
53 return record->master_channel;
56 void RecordChannelPicker::handle_channel_edit(int result)
60 record->record_gui->lock_window("RecordChannelPicker::handle_channel_edit 1");
61 record->record_gui->update_batch_sources();
63 record->set_channel(current_channel);
64 record->record_gui->unlock_window();
65 record->save_defaults();
66 VideoDevice::save_channeldb(record->channeldb,
67 mwindow->edl->session->vconfig_in);
71 record->record_gui->lock_window("RecordChannelPicker::handle_channel_edit 2");
72 record->set_channel(record->get_editing_batch()->channel);
73 record->record_gui->unlock_window();
76 mwindow->save_defaults();
79 void RecordChannelPicker::load_scan_defaults(Channel *scan_params)
81 scan_params->load_defaults(mwindow->defaults);
84 void RecordChannelPicker::save_scan_defaults(Channel *scan_params)
86 scan_params->save_defaults(mwindow->defaults);
89 BC_Theme* RecordChannelPicker::get_theme()
91 return mwindow->theme;
95 Channel* RecordChannelPicker::get_current_channel_struct()
97 return record->get_current_channel_struct();
100 int RecordChannelPicker::get_current_channel_number()
102 return record->get_editing_channel();
105 ArrayList<Channel*>* RecordChannelPicker::get_video_inputs()
107 return record->get_video_inputs();
110 Channel* RecordChannelPicker::get_channel_usage()
112 return record->master_channel;
115 void RecordChannelPicker::set_channel_number(int number)
117 record->set_channel(number);
120 int RecordChannelPicker::set_brightness(int value)
124 record->picture->brightness = value;
125 record->set_video_picture();
130 int RecordChannelPicker::set_hue(int value)
134 record->picture->hue = value;
135 record->set_video_picture();
140 int RecordChannelPicker::set_color(int value)
144 record->picture->color = value;
145 record->set_video_picture();
150 int RecordChannelPicker::set_contrast(int value)
154 record->picture->contrast = value;
155 record->set_video_picture();
160 int RecordChannelPicker::set_whiteness(int value)
164 record->picture->whiteness = value;
165 record->set_video_picture();
170 int RecordChannelPicker::set_picture(int device_id, int value)
174 record->picture->set_item(device_id, value);
175 record->set_video_picture();
181 int RecordChannelPicker::get_brightness()
183 if(record) return record->picture->brightness;
187 int RecordChannelPicker::get_hue()
189 if(record) return record->picture->hue;
193 int RecordChannelPicker::get_color()
195 if(record) return record->picture->color;
199 int RecordChannelPicker::get_contrast()
201 if(record) return record->picture->contrast;
205 int RecordChannelPicker::get_whiteness()
207 if(record) return record->picture->whiteness;
211 int RecordChannelPicker::get_controls()
213 if(record) return record->picture->controls.total;
217 PictureItem* RecordChannelPicker::get_control(int i)
219 if(record) return record->picture->controls.values[i];
223 PictureConfig* RecordChannelPicker::get_picture_usage()
225 if(record) return record->picture;
231 void RecordChannelPicker::set_channel(Channel *channel)
233 record->set_channel(channel);
236 int RecordChannelPicker::has_signal()
238 return record->has_signal();
249 PrefsChannelPicker::PrefsChannelPicker(MWindow *mwindow,
251 ChannelDB *channeldb,
254 : ChannelPicker(channeldb,
259 // printf("PrefsChannelPicker::PrefsChannelPicker 1\n");
260 this->mwindow = mwindow;
262 VDeviceBUZ::get_inputs(&input_sources);
265 PrefsChannelPicker::~PrefsChannelPicker()
267 input_sources.remove_all_objects();
270 void PrefsChannelPicker::load_scan_defaults(Channel *scan_params)
272 scan_params->load_defaults(mwindow->defaults);
275 void PrefsChannelPicker::save_scan_defaults(Channel *scan_params)
277 scan_params->save_defaults(mwindow->defaults);
280 void PrefsChannelPicker::handle_channel_edit(int result)
282 mwindow->save_defaults();
285 BC_Theme* PrefsChannelPicker::get_theme()
287 return mwindow->theme;
291 Channel* PrefsChannelPicker::get_current_channel_struct()
293 int number = get_current_channel_number();
295 if(number >= 0 && number < channeldb->size())
297 return channeldb->get(number);
302 int PrefsChannelPicker::get_current_channel_number()
304 return prefs->out_config->buz_out_channel;
307 ArrayList<Channel*>* PrefsChannelPicker::get_video_inputs()
309 return &input_sources;
312 Channel* PrefsChannelPicker::get_channel_usage()
318 void PrefsChannelPicker::set_channel(Channel *channel)
321 channel_text->update(channel->title);
324 void PrefsChannelPicker::set_channel_number(int number)
326 CLAMP(number, 0, channeldb->size() - 1);
327 prefs->out_config->buz_out_channel = number;
328 set_channel(get_current_channel_struct());
331 int PrefsChannelPicker::has_signal()
336 int PrefsChannelPicker::set_brightness(int value)
338 prefs->out_config->brightness = value;
341 int PrefsChannelPicker::set_hue(int value)
343 prefs->out_config->hue = value;
346 int PrefsChannelPicker::set_color(int value)
348 prefs->out_config->color = value;
351 int PrefsChannelPicker::set_contrast(int value)
353 prefs->out_config->contrast = value;
356 int PrefsChannelPicker::set_whiteness(int value)
358 prefs->out_config->whiteness = value;
361 int PrefsChannelPicker::get_brightness()
363 return prefs->out_config->brightness;
366 int PrefsChannelPicker::get_hue()
368 return prefs->out_config->hue;
371 int PrefsChannelPicker::get_color()
373 return prefs->out_config->color;
376 int PrefsChannelPicker::get_contrast()
378 return prefs->out_config->contrast;
381 int PrefsChannelPicker::get_whiteness()
383 return prefs->out_config->whiteness;
391 ChannelPicker::ChannelPicker(ChannelDB *channeldb,
394 BC_WindowBase *parent_window)
396 this->parent_window = parent_window;
399 this->channeldb = channeldb;
400 current_channel = new Channel;
405 update_channel_list();
408 ChannelPicker::~ChannelPicker()
411 delete channel_select;
412 delete channel_button;
413 delete current_channel;
414 channel_listitems.remove_all_objects();
417 void ChannelPicker::update_channel_list()
419 channel_listitems.remove_all_objects();
420 for(int i = 0; i < channeldb->size(); i++)
422 channel_listitems.append(new BC_ListBoxItem(channeldb->get(i)->title));
426 channel_text->update_list(&channel_listitems);
436 BC_WindowBase* ChannelPicker::get_subwindow()
438 return parent_window;
448 int ChannelPicker::create_objects()
451 update_channel_list();
452 channel_text = new ChannelText(this, x, y);
453 channel_text->create_objects();
454 x += channel_text->get_w();
455 get_subwindow()->add_subwindow(channel_select = new ChannelTumbler(this,
458 x += channel_select->get_w() + 5;
459 get_subwindow()->add_subwindow(channel_button = new ChannelButton(this,
465 int ChannelPicker::reposition()
467 channel_text->reposition_window(channel_text->get_x(),
468 channel_text->get_y());
469 channel_select->reposition_window(channel_select->get_x(),
470 channel_select->get_y());
471 channel_button->reposition_window(channel_button->get_x(),
472 channel_button->get_y());
476 int ChannelPicker::close_threads()
478 channel_button->thread->close_threads();
482 char* ChannelPicker::get_source_name(Channel *channel)
484 if(channel->entry < chanlists[channel->freqtable].count)
485 return chanlists[channel->freqtable].list[channel->entry].name;
487 return chanlists[channel->freqtable].list[0].name;
490 char* ChannelPicker::current_channel_name()
492 if(get_current_channel_struct())
494 return get_current_channel_struct()->title;
500 int ChannelPicker::channel_down()
502 int number = get_current_channel_number() - 1;
503 if(number < 0) number = 0;
504 CLAMP(number, 0, channeldb->size() - 1);
505 set_channel_number(number);
509 int ChannelPicker::channel_up()
511 int number = get_current_channel_number() + 1;
512 if(number >= channeldb->size()) number = channeldb->size() - 1;
513 CLAMP(number, 0, channeldb->size() - 1);
514 set_channel_number(number);
520 ChannelButton::ChannelButton(ChannelPicker *channel_picker,
525 channel_picker->get_theme() ?
526 channel_picker->get_theme()->get_image_set("channel") :
529 this->channel_picker = channel_picker;
530 thread = new ChannelEditThread(channel_picker,
531 channel_picker->channeldb);
532 set_tooltip(_("Edit channels"));
535 ChannelButton::~ChannelButton()
540 int ChannelButton::handle_event()
547 ChannelText::ChannelText(ChannelPicker *channel_picker,
550 : BC_PopupTextBox(channel_picker->get_subwindow(),
551 &channel_picker->channel_listitems,
552 channel_picker->current_channel_name(),
559 this->channel_picker = channel_picker;
562 ChannelText::~ChannelText()
566 int ChannelText::handle_event()
568 channel_picker->set_channel_number(get_number());
575 ChannelList::ChannelList(ChannelPicker *channel_picker, int x, int y)
580 LISTBOX_TEXT, // Display text list or icons
581 &channel_picker->channel_listitems, // Each column has an ArrayList of BC_ListBoxItems.
582 0, // Titles for columns. Set to 0 for no titles
583 0, // width of each column
585 0, // Pixel of top of window.
586 1) // If this listbox is a popup window
588 this->channel_picker = channel_picker;
591 ChannelList::~ChannelList()
595 int ChannelList::handle_event()
602 ChannelTumbler::ChannelTumbler(ChannelPicker *channel_picker,
607 this->channel_picker = channel_picker;
609 ChannelTumbler::~ChannelTumbler()
612 int ChannelTumbler::handle_up_event()
614 channel_picker->channel_up();
617 int ChannelTumbler::handle_down_event()
619 channel_picker->channel_down();
622 int ChannelTumbler::keypress_event()
624 if(get_keypress() == PGUP)
630 if(get_keypress() == PGDN)