no longer need ffmpeg patch0 which was for Termux
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / vdeviceprefs.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2011 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #include "bcsignals.h"
23 #include "channeldb.h"
24 #include "channelpicker.h"
25 #include "clip.h"
26 #include "edl.h"
27 #include "edlsession.h"
28 #include "formattools.h"
29 #include "language.h"
30 #include "mwindow.h"
31 #include "mainsession.h"
32 #include "vdeviceprefs.h"
33 #include "videoconfig.h"
34 #include "videodevice.inc"
35 #include "overlayframe.inc"
36 #include "playbackconfig.h"
37 #include "preferences.h"
38 #include "preferencesthread.h"
39 #include "recordconfig.h"
40 #include "recordprefs.h"
41 #include "theme.h"
42 #include <string.h>
43
44
45 VDevicePrefs::VDevicePrefs(int x,
46         int y,
47         PreferencesWindow *pwindow,
48         PreferencesDialog *dialog,
49         VideoOutConfig *out_config,
50         VideoInConfig *in_config,
51         int mode)
52 {
53         this->pwindow = pwindow;
54         this->dialog = dialog;
55         this->driver = DEV_UNKNOWN;
56         this->mode = mode;
57         this->out_config = out_config;
58         this->in_config = in_config;
59         this->x = x;
60         this->y = y;
61         menu = 0;
62         reset_objects();
63
64 }
65
66 VDevicePrefs::~VDevicePrefs()
67 {
68         delete_objects();
69         if(menu) delete menu;
70         int config = -1;
71         switch( pwindow->thread->current_dialog ) {
72         case PreferencesThread::PLAYBACK_A:  config = 0;  break;
73         case PreferencesThread::PLAYBACK_B:  config = 1;  break;
74         }
75         if( config >= 0 )
76                 pwindow->mwindow->session->save_x11_host(config, out_config->x11_host);
77 }
78
79
80 void VDevicePrefs::reset_objects()
81 {
82         device_title = 0;
83         port_title = 0;
84         follow_video_config = 0;
85         dvb_adapter_title = 0;
86         dvb_adapter_device = 0;
87         channel_title = 0;
88         output_title = 0;
89         syt_title = 0;
90
91         device_text = 0;
92         firewire_port = 0;
93         firewire_channel = 0;
94         firewire_channels = 0;
95         firewire_syt = 0;
96         firewire_path = 0;
97         fields_title = 0;
98         device_fields = 0;
99         use_direct_x11 = 0;
100
101         channel_picker = 0;
102 }
103
104 int VDevicePrefs::initialize(int creation)
105 {
106         int *driver = 0;
107         delete_objects();
108
109         switch(mode)
110         {
111                 case MODEPLAY:
112                         driver = &out_config->driver;
113                         break;
114
115                 case MODERECORD:
116                         driver = &in_config->driver;
117                         break;
118         }
119         this->driver = *driver;
120
121         if(!menu)
122         {
123                 dialog->add_subwindow(menu = new VDriverMenu(x, y + yS(10),
124                                 this, (mode == MODERECORD), driver));
125                 menu->create_objects();
126                 menu->context_help_set_keyword("Video Out section");
127         }
128
129         switch(this->driver)
130         {
131                 case DEV_UNKNOWN:
132                         break;
133                 case VIDEO4LINUX2:
134                 case CAPTURE_JPEG_WEBCAM:
135                 case CAPTURE_YUYV_WEBCAM:
136                         create_v4l2_objs();
137                         break;
138                 case VIDEO4LINUX2JPEG:
139                         create_v4l2jpeg_objs();
140                         break;
141                 case VIDEO4LINUX2MPEG:
142                         create_v4l2mpeg_objs();
143                         break;
144                 case SCREENCAPTURE:
145                         create_screencap_objs();
146                         break;
147                 case PLAYBACK_X11:
148                 case PLAYBACK_X11_XV:
149                 case PLAYBACK_X11_GL:
150                         create_x11_objs();
151                         break;
152                 case PLAYBACK_DV1394:
153                 case PLAYBACK_FIREWIRE:
154                 case PLAYBACK_IEC61883:
155                 case CAPTURE_FIREWIRE:
156                 case CAPTURE_IEC61883:
157                         create_firewire_objs();
158                         break;
159                 case CAPTURE_DVB:
160                         create_dvb_objs();
161                         break;
162         }
163
164
165
166 // Update driver dependancies in file format
167         if(mode == MODERECORD && dialog && !creation)
168         {
169                 RecordPrefs *record_prefs = (RecordPrefs*)dialog;
170                 record_prefs->recording_format->update_driver(this->driver);
171         }
172
173         return 0;
174 }
175
176 int VDevicePrefs::delete_objects()
177 {
178         delete output_title;
179         delete channel_picker;
180         delete device_title;
181         delete device_text;
182         delete dvb_adapter_device;
183         delete follow_video_config;
184         delete dvb_adapter_title;
185         delete use_direct_x11;
186
187         delete port_title;
188
189         if(firewire_port) delete firewire_port;
190         if(channel_title) delete channel_title;
191         if(firewire_channel) delete firewire_channel;
192         if(firewire_path) delete firewire_path;
193         if(syt_title) delete syt_title;
194         if(firewire_syt) delete firewire_syt;
195         if(fields_title) delete fields_title;
196         if(device_fields) delete device_fields;
197
198         reset_objects();
199         driver = -1;
200         return 0;
201 }
202
203 int VDevicePrefs::get_h()
204 {
205         int margin = pwindow->mwindow->theme->widget_border;
206         return BC_Title::calculate_h(dialog, "X", MEDIUMFONT) + margin +
207                 BC_TextBox::calculate_h(dialog, MEDIUMFONT, 1, 1);
208 }
209
210 void VDevicePrefs::create_dvb_objs()
211 {
212         int x1 = x + menu->get_w() + xS(30);
213         int y1 = y + yS(10);
214         char *output_char = in_config->dvb_in_adapter;
215         int y2 = y1 - BC_Title::calculate_h(dialog, _("DVB Adapter:"), MEDIUMFONT) - yS(5);
216         BC_Resources *resources = BC_WindowBase::get_resources();
217         dvb_adapter_title = new BC_Title(x1, y2, _("DVB Adapter:"),
218                         MEDIUMFONT, resources->text_default);
219         dialog->add_subwindow(dvb_adapter_title);
220         dvb_adapter_title->context_help_set_keyword("Video Out section");
221         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y1, output_char));
222         device_text->context_help_set_keyword("Video Out section");
223         int x2 = x1 + device_text->get_w() + xS(5);
224         device_title = new BC_Title(x2, y2, _("dev:"),
225                         MEDIUMFONT, resources->text_default);
226         dialog->add_subwindow(device_title);
227         device_title->context_help_set_keyword("Video Out section");
228         int *output_int = &in_config->dvb_in_device;
229         dvb_adapter_device = new VDeviceTumbleBox(this, x2, y1, output_int, 0, 9, xS(20));
230         dvb_adapter_device->create_objects();
231         x1 += xS(64);  y1 += device_text->get_h() + yS(5);
232         follow_video_config = new BC_CheckBox(x1, y1,
233                         &in_config->follow_video, _("Follow video config"));
234         dialog->add_subwindow(follow_video_config);
235         follow_video_config->context_help_set_keyword("Video Out section");
236 }
237
238 int VDevicePrefs::create_firewire_objs()
239 {
240         int xs5 = xS(5), ys20 = yS(20);
241         int *output_int = 0;
242         char *output_char = 0;
243         int x1 = x + menu->get_w() + xS(5);
244         BC_Resources *resources = BC_WindowBase::get_resources();
245
246 // Firewire path
247         switch(mode)
248         {
249                 case MODEPLAY:
250                         if(driver == PLAYBACK_DV1394)
251                                 output_char = out_config->dv1394_path;
252                         else
253                         if(driver == PLAYBACK_FIREWIRE)
254                                 output_char = out_config->firewire_path;
255                         break;
256                 case MODERECORD:
257                         if(driver == CAPTURE_FIREWIRE)
258                                 output_char = in_config->firewire_path;
259                         break;
260         }
261
262         if(output_char)
263         {
264                 dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device Path:"), MEDIUMFONT, resources->text_default));
265                 device_title->context_help_set_keyword("Video Out section");
266                 dialog->add_subwindow(firewire_path = new VDeviceTextBox(x1, y + ys20, output_char));
267                 firewire_path->context_help_set_keyword("Video Out section");
268                 x1 += firewire_path->get_w() + xs5;
269         }
270
271 // Firewire port
272         switch(mode)
273         {
274                 case MODEPLAY:
275                         if(driver == PLAYBACK_DV1394)
276                                 output_int = &out_config->dv1394_port;
277                         else
278                                 output_int = &out_config->firewire_port;
279                         break;
280                 case MODERECORD:
281                         output_int = &in_config->firewire_port;
282                         break;
283         }
284         dialog->add_subwindow(port_title = new BC_Title(x1, y, _("Port:"), MEDIUMFONT, resources->text_default));
285         port_title->context_help_set_keyword("Video Out section");
286         dialog->add_subwindow(firewire_port = new VDeviceIntBox(x1, y + ys20, output_int));
287         firewire_port->context_help_set_keyword("Video Out section");
288         x1 += firewire_port->get_w() + xs5;
289
290 // Firewire channel
291         switch(mode)
292         {
293                 case MODEPLAY:
294                         if(driver == PLAYBACK_DV1394)
295                                 output_int = &out_config->dv1394_channel;
296                         else
297                                 output_int = &out_config->firewire_channel;
298                         break;
299                 case MODERECORD:
300                         output_int = &in_config->firewire_channel;
301                         break;
302         }
303
304         dialog->add_subwindow(channel_title = new BC_Title(x1, y, _("Channel:"), MEDIUMFONT, resources->text_default));
305         channel_title->context_help_set_keyword("Video Out section");
306         dialog->add_subwindow(firewire_channel = new VDeviceIntBox(x1, y + ys20, output_int));
307         firewire_channel->context_help_set_keyword("Video Out section");
308         x1 += firewire_channel->get_w() + xs5;
309
310
311 // Firewire syt
312         switch(mode)
313         {
314                 case MODEPLAY:
315                         if(driver == PLAYBACK_DV1394)
316                                 output_int = &out_config->dv1394_syt;
317                         else
318                         if(driver == PLAYBACK_FIREWIRE)
319                                 output_int = &out_config->firewire_syt;
320                         else
321                                 output_int = 0;
322                         break;
323                 case MODERECORD:
324                         output_int = 0;
325                         break;
326         }
327         if(output_int)
328         {
329                 dialog->add_subwindow(syt_title = new BC_Title(x1, y, _("Syt Offset:"), MEDIUMFONT, resources->text_default));
330                 syt_title->context_help_set_keyword("Video Out section");
331                 dialog->add_subwindow(firewire_syt = new VDeviceIntBox(x1, y + ys20, output_int));
332                 firewire_syt->context_help_set_keyword("Video Out section");
333         }
334
335         return 0;
336 }
337
338 int VDevicePrefs::create_v4l2_objs()
339 {
340         int xs5 = xS(5), ys20 = yS(20);
341         char *output_char;
342         BC_Resources *resources = BC_WindowBase::get_resources();
343         int x1 = x + menu->get_w() + xs5;
344         output_char = pwindow->thread->edl->session->vconfig_in->v4l2_in_device;
345         dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device path:"), MEDIUMFONT, resources->text_default));
346         device_title->context_help_set_keyword("Video Out section");
347         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + ys20, output_char));
348         device_text->context_help_set_keyword("Video Out section");
349
350         return 0;
351 }
352
353 int VDevicePrefs::create_v4l2jpeg_objs()
354 {
355         int xs5 = xS(5), ys20 = yS(20);
356         BC_Resources *resources = BC_WindowBase::get_resources();
357         int x1 = x + menu->get_w() + xs5;
358         char *output_char = &pwindow->thread->edl->session->vconfig_in->v4l2jpeg_in_device[0];
359         dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device path:"), MEDIUMFONT, resources->text_default));
360         device_title->context_help_set_keyword("Video Out section");
361         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + ys20, output_char));
362         device_text->context_help_set_keyword("Video Out section");
363         x1 += bmax(device_title->get_w(),device_text->get_w()) + xs5;
364         int *output_int = &pwindow->thread->edl->session->vconfig_in->v4l2jpeg_in_fields;
365         fields_title = new BC_Title(x1, y, _("Fields:"), MEDIUMFONT, resources->text_default);
366         dialog->add_subwindow(fields_title);
367         fields_title->context_help_set_keyword("Video Out section");
368         device_fields = new VDeviceTumbleBox(this, x1, y + ys20, output_int, 1, 2, xS(20));
369         device_fields->create_objects();
370         return 0;
371 }
372
373 int VDevicePrefs::create_v4l2mpeg_objs()
374 {
375         char *output_char;
376         BC_Resources *resources = BC_WindowBase::get_resources();
377         int x1 = x + menu->get_w() + xS(5);
378         output_char = pwindow->thread->edl->session->vconfig_in->v4l2mpeg_in_device;
379         dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Device path:"), MEDIUMFONT, resources->text_default));
380         device_title->context_help_set_keyword("Video Out section");
381         int y1 = y + yS(20);
382         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y1, output_char));
383         device_text->context_help_set_keyword("Video Out section");
384         x1 += xS(64);  y1 += device_text->get_h() + yS(5);
385         follow_video_config = new BC_CheckBox(x1, y1,
386                         &in_config->follow_video, _("Follow video config"));
387         dialog->add_subwindow(follow_video_config);
388         follow_video_config->context_help_set_keyword("Video Out section");
389         return 0;
390 }
391
392
393 int VDevicePrefs::create_screencap_objs()
394 {
395         char *output_char;
396         BC_Resources *resources = BC_WindowBase::get_resources();
397         int x1 = x + menu->get_w() + xS(5);
398         output_char = pwindow->thread->edl->session->vconfig_in->screencapture_display;
399         dialog->add_subwindow(device_title = new BC_Title(x1, y, _("Display:"), MEDIUMFONT, resources->text_default));
400         device_title->context_help_set_keyword("Video Out section");
401         dialog->add_subwindow(device_text = new VDeviceTextBox(x1, y + yS(20), output_char));
402         device_text->context_help_set_keyword("Video Out section");
403         return 0;
404 }
405
406 int VDevicePrefs::create_x11_objs()
407 {
408         char *output_char;
409         BC_Resources *resources = BC_WindowBase::get_resources();
410         output_char = out_config->x11_host;
411         const char *x11_display;
412         switch( pwindow->thread->current_dialog ) {
413         default:
414         case PreferencesThread::PLAYBACK_A:
415                 x11_display = _("Default A Display:");  break;
416                 break;
417         case PreferencesThread::PLAYBACK_B:
418                 x11_display = _("Default B Display:");  break;
419                 break;
420         }
421         int x1 = menu->get_x() + menu->get_w() + xS(10);
422         int y1 = menu->get_y();
423         if( driver == PLAYBACK_X11 ) y1 -= yS(10);
424         dialog->add_subwindow(device_title = new BC_Title(x1, y1+yS(4), x11_display,
425                         MEDIUMFONT, resources->text_default));
426         device_title->context_help_set_keyword("Video Out section");
427         int x2 = x1 + device_title->get_w() + xS(10), dy = device_title->get_h();
428         dialog->add_subwindow(device_text = new VDeviceTextBox(x2, y1, output_char));
429         device_text->context_help_set_keyword("Video Out section");
430         if( driver == PLAYBACK_X11 ) {
431                 int y2 = device_text->get_h();
432                 if( dy < y2 ) dy = y2;
433                 y1 += dy + yS(5);
434                 use_direct_x11 = new BC_CheckBox(x1, y1,
435                         &out_config->use_direct_x11, _("use direct x11 render if possible"));
436                 dialog->add_subwindow(use_direct_x11);
437                 use_direct_x11->context_help_set_keyword("Video Out section");
438         }
439         return 0;
440 }
441
442
443
444
445 VDriverMenu::VDriverMenu(int x, int y,
446         VDevicePrefs *device_prefs, int do_input, int *output)
447  : BC_PopupMenu(x, y, xS(200), driver_to_string(*output))
448 {
449         this->output = output;
450         this->do_input = do_input;
451         this->device_prefs = device_prefs;
452 }
453
454 VDriverMenu::~VDriverMenu()
455 {
456 }
457
458 char* VDriverMenu::driver_to_string(int driver)
459 {
460         switch(driver)
461         {
462                 case DEV_UNKNOWN:
463                         sprintf(string, DEV_UNKNOWN_TITLE);
464                         break;
465                 case VIDEO4LINUX2:
466                         sprintf(string, VIDEO4LINUX2_TITLE);
467                         break;
468                 case CAPTURE_JPEG_WEBCAM:
469                         sprintf(string, CAPTURE_JPEG_WEBCAM_TITLE);
470                         break;
471                 case CAPTURE_YUYV_WEBCAM:
472                         sprintf(string, CAPTURE_YUYV_WEBCAM_TITLE);
473                         break;
474                 case VIDEO4LINUX2JPEG:
475                         sprintf(string, VIDEO4LINUX2JPEG_TITLE);
476                         break;
477                 case VIDEO4LINUX2MPEG:
478                         sprintf(string, VIDEO4LINUX2MPEG_TITLE);
479                         break;
480                 case SCREENCAPTURE:
481                         sprintf(string, SCREENCAPTURE_TITLE);
482                         break;
483 #ifdef HAVE_FIREWIRE
484                 case CAPTURE_FIREWIRE:
485                         sprintf(string, CAPTURE_FIREWIRE_TITLE);
486                         break;
487                 case CAPTURE_IEC61883:
488                         sprintf(string, CAPTURE_IEC61883_TITLE);
489                         break;
490 #endif
491                 case CAPTURE_DVB:
492                         sprintf(string, CAPTURE_DVB_TITLE);
493                         break;
494                 case PLAYBACK_X11:
495                         sprintf(string, PLAYBACK_X11_TITLE);
496                         break;
497                 case PLAYBACK_X11_XV:
498                         sprintf(string, PLAYBACK_X11_XV_TITLE);
499                         break;
500                 case PLAYBACK_X11_GL:
501                         sprintf(string, PLAYBACK_X11_GL_TITLE);
502                         break;
503 #ifdef HAVE_FIREWIRE
504                 case PLAYBACK_FIREWIRE:
505                         sprintf(string, PLAYBACK_FIREWIRE_TITLE);
506                         break;
507                 case PLAYBACK_DV1394:
508                         sprintf(string, PLAYBACK_DV1394_TITLE);
509                         break;
510                 case PLAYBACK_IEC61883:
511                         sprintf(string, PLAYBACK_IEC61883_TITLE);
512                         break;
513 #endif
514                 default:
515                         string[0] = 0;
516         }
517         return string;
518 }
519
520 void VDriverMenu::create_objects()
521 {
522         if(do_input)
523         {
524 #ifdef HAVE_VIDEO4LINUX2
525                 add_item(new VDriverItem(this, VIDEO4LINUX2_TITLE, VIDEO4LINUX2));
526                 add_item(new VDriverItem(this, CAPTURE_JPEG_WEBCAM_TITLE, CAPTURE_JPEG_WEBCAM));
527                 add_item(new VDriverItem(this, CAPTURE_YUYV_WEBCAM_TITLE, CAPTURE_YUYV_WEBCAM));
528                 add_item(new VDriverItem(this, VIDEO4LINUX2JPEG_TITLE, VIDEO4LINUX2JPEG));
529                 add_item(new VDriverItem(this, VIDEO4LINUX2MPEG_TITLE, VIDEO4LINUX2MPEG));
530 #endif
531
532                 add_item(new VDriverItem(this, SCREENCAPTURE_TITLE, SCREENCAPTURE));
533 #ifdef HAVE_FIREWIRE
534                 add_item(new VDriverItem(this, CAPTURE_FIREWIRE_TITLE, CAPTURE_FIREWIRE));
535                 add_item(new VDriverItem(this, CAPTURE_IEC61883_TITLE, CAPTURE_IEC61883));
536 #endif
537 #ifdef HAVE_DVB
538                 add_item(new VDriverItem(this, CAPTURE_DVB_TITLE, CAPTURE_DVB));
539 #endif
540         }
541         else
542         {
543                 add_item(new VDriverItem(this, PLAYBACK_X11_TITLE, PLAYBACK_X11));
544 #ifdef HAVE_XV
545                 add_item(new VDriverItem(this, PLAYBACK_X11_XV_TITLE, PLAYBACK_X11_XV));
546 #endif
547 #ifdef HAVE_GL
548 // Check runtime glx version. pbuffer needs >= 1.3
549                 if(get_opengl_server_version() >= 103)
550                         add_item(new VDriverItem(this, PLAYBACK_X11_GL_TITLE, PLAYBACK_X11_GL));
551 #endif
552 #ifdef HAVE_FIREWIRE
553                 add_item(new VDriverItem(this, PLAYBACK_FIREWIRE_TITLE, PLAYBACK_FIREWIRE));
554                 add_item(new VDriverItem(this, PLAYBACK_DV1394_TITLE, PLAYBACK_DV1394));
555                 add_item(new VDriverItem(this, PLAYBACK_IEC61883_TITLE, PLAYBACK_IEC61883));
556 #endif
557         }
558 }
559
560
561 VDriverItem::VDriverItem(VDriverMenu *popup, const char *text, int driver)
562  : BC_MenuItem(text)
563 {
564         this->popup = popup;
565         this->driver = driver;
566 }
567
568 VDriverItem::~VDriverItem()
569 {
570 }
571
572 int VDriverItem::handle_event()
573 {
574         popup->set_text(get_text());
575         *(popup->output) = driver;
576         popup->device_prefs->initialize(0);
577         popup->device_prefs->pwindow->show_dialog();
578         return 1;
579 }
580
581
582
583
584 VDeviceTextBox::VDeviceTextBox(int x, int y, char *output)
585  : BC_TextBox(x, y, xS(200), 1, output)
586 {
587         this->output = output;
588 }
589
590 int VDeviceTextBox::handle_event()
591 {
592 // Suggestions
593         calculate_suggestions(0);
594
595         strcpy(output, get_text());
596         return 1;
597 }
598
599 VDeviceTumbleBox::VDeviceTumbleBox(VDevicePrefs *prefs,
600         int x, int y, int *output, int min, int max, int text_w)
601  : BC_TumbleTextBox(prefs->dialog, *output, min, max, x, y, text_w)
602 {
603         this->output = output;
604 }
605
606 int VDeviceTumbleBox::handle_event()
607 {
608         *output = atol(get_text());
609         return 1;
610 }
611
612
613
614
615
616
617 VDeviceIntBox::VDeviceIntBox(int x, int y, int *output)
618  : BC_TextBox(x, y, xS(60), 1, *output)
619 {
620         this->output = output;
621 }
622
623 int VDeviceIntBox::handle_event()
624 {
625         *output = atol(get_text());
626         return 1;
627 }
628
629
630
631
632
633 VDeviceCheckBox::VDeviceCheckBox(int x, int y, int *output, char *text)
634  : BC_CheckBox(x, y, *output, text)
635 {
636         this->output = output;
637 }
638 int VDeviceCheckBox::handle_event()
639 {
640         *output = get_value();
641         return 1;
642 }
643
644
645
646
647 VScalingItem::VScalingItem(VScalingEquation *popup, int interpolation)
648  : BC_MenuItem(popup->interpolation_to_string(interpolation))
649 {
650         this->popup = popup;
651         this->interpolation = interpolation;
652 }
653
654 VScalingItem::~VScalingItem()
655 {
656 }
657
658 int VScalingItem::handle_event()
659 {
660         popup->set_text(get_text());
661         *(popup->output) = interpolation;
662         return 1;
663 }
664
665
666 VScalingEquation::VScalingEquation(int x, int y, int *output)
667  : BC_PopupMenu(x, y, xS(240), interpolation_to_string(*output))
668 {
669         this->output = output;
670 }
671
672 VScalingEquation::~VScalingEquation()
673 {
674 }
675
676 const char *VScalingEquation::interpolation_to_string(int type)
677 {
678         switch( type ) {
679         case NEAREST_NEIGHBOR:  return _("Nearest Neighbor");
680         case CUBIC_CUBIC:       return _("BiCubic / BiCubic");
681         case CUBIC_LINEAR:      return _("BiCubic / BiLinear");
682         case LINEAR_LINEAR:     return _("BiLinear / BiLinear");
683         case LANCZOS_LANCZOS:   return _("Lanczos / Lanczos");
684         }
685         return _("Unknown");
686 }
687
688 void VScalingEquation::create_objects()
689 {
690         add_item(new VScalingItem(this, NEAREST_NEIGHBOR));
691         add_item(new VScalingItem(this, CUBIC_CUBIC));
692         add_item(new VScalingItem(this, CUBIC_LINEAR));
693         add_item(new VScalingItem(this, LINEAR_LINEAR));
694         add_item(new VScalingItem(this, LANCZOS_LANCZOS));
695 }
696