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