label edit deadlock, build openexr cfg option, code cleanup
[goodguy/history.git] / cinelerra-5.1 / cinelerra / assetedit.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2010 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 "asset.h"
23 #include "assetedit.h"
24 #include "awindow.h"
25 #include "awindowgui.h"
26 #include "bcprogressbox.h"
27 #include "bcsignals.h"
28 #include "bitspopup.h"
29 #include "cache.h"
30 #include "clip.h"
31 #include "cplayback.h"
32 #include "cwindow.h"
33 #include "edl.h"
34 #include "edlsession.h"
35 #include "file.h"
36 #include "filempeg.h"
37 #include "fileffmpeg.h"
38 #include "filesystem.h"
39 #include "indexable.h"
40 #include "indexfile.h"
41 #include "indexstate.h"
42 #include "language.h"
43 #include "mainindexes.h"
44 #include "mwindow.h"
45 #include "mwindowgui.h"
46 #include "theme.h"
47 #include "new.h"
48 #include "preferences.h"
49 #include "resizetrackthread.h"
50 #include "removefile.h"
51 #include "theme.h"
52 #include "transportque.h"
53 #include "interlacemodes.h"
54 #include "edl.h"
55 #include "edlsession.h"
56
57 #include <string.h>
58
59
60
61 AssetEdit::AssetEdit(MWindow *mwindow)
62  : BC_DialogThread()
63 {
64         this->mwindow = mwindow;
65         indexable = 0;
66         window = 0;
67         changed_params = new Asset;
68         //set_synchronous(0);
69 }
70
71
72 AssetEdit::~AssetEdit()
73 {
74         close_window();
75         changed_params->remove_user();
76 }
77
78
79 void AssetEdit::edit_asset(Indexable *indexable, int x, int y)
80 {
81         close_window();
82         this->indexable = indexable;
83         this->indexable->add_user();
84         this->x = x;  this->y = y;
85
86 // Copy asset parameters into temporary storage for editing.
87         if( indexable->is_asset ) {
88                 changed_params->copy_from((Asset*)indexable, 0);
89         }
90         else {
91                 EDL *nested_edl = (EDL*)indexable;
92                 strcpy(changed_params->path, nested_edl->path);
93                 changed_params->sample_rate = nested_edl->session->sample_rate;
94                 changed_params->channels = nested_edl->session->audio_channels;
95
96 //printf("AssetEdit::edit_asset %d %f\n", __LINE__, nested_edl->session->frame_rate);
97                 changed_params->frame_rate = nested_edl->session->frame_rate;
98                 changed_params->width = nested_edl->session->output_w;
99                 changed_params->height = nested_edl->session->output_h;
100         }
101
102         BC_DialogThread::start();
103 }
104
105 void AssetEdit::handle_done_event(int result)
106 {
107 }
108
109 void AssetEdit::handle_close_event(int result)
110 {
111         if( !result ) {
112                 int changed = 0;
113                 Asset *asset = 0;
114                 EDL *nested_edl = 0;
115
116                 if( indexable->is_asset ) {
117                         asset = (Asset*)indexable;
118                         if( !changed_params->equivalent(*asset, 1, 1, mwindow->edl) )
119                                 changed = 1;
120                 }
121                 else {
122                         nested_edl = (EDL*)indexable;
123                         if( strcmp(changed_params->path, nested_edl->path)
124 //                              || changed_params->sample_rate != nested_edl->session->sample_rate
125 //                              || !EQUIV(changed_params->frame_rate, nested_edl->session->frame_rate
126                         )
127                                 changed = 1;
128                 }
129                 if( changed ) {
130                         mwindow->gui->lock_window();
131 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
132
133 // Omit index status from copy since an index rebuild may have been
134 // happening when new_asset was created but not be happening anymore.
135                         if( asset ) {
136                                 mwindow->remove_asset_from_caches(asset);
137 //printf("AssetEdit::handle_close_event %d %f\n", __LINE__, asset->get_frame_rate());
138                                 asset->copy_from(changed_params, 0);
139 //printf("AssetEdit::handle_close_event %d %d %d\n", __LINE__, changed_params->bits, asset->bits);
140                         }
141                         else {
142                                 strcpy(nested_edl->path, changed_params->path);
143 // Other parameters can't be changed because they're defined in the other EDL
144 //              nested_edl->session->frame_rate = changed_params->frame_rate;
145 //              nested_edl->session->sample_rate = changed_params->sample_rate;
146                         }
147 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
148
149                         mwindow->gui->update(0, 2, 0, 0, 0, 0, 0);
150 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
151
152 // Start index rebuilding
153                         if( (asset && asset->audio_data) || nested_edl) {
154                                 char source_filename[BCTEXTLEN];
155                                 char index_filename[BCTEXTLEN];
156                                 IndexFile::get_index_filename(source_filename,
157                                         mwindow->preferences->index_directory,
158                                         index_filename,
159                                         indexable->path);
160                                 remove_file(index_filename);
161                                 indexable->index_state->index_status = INDEX_NOTTESTED;
162                                 mwindow->mainindexes->add_next_asset(0, indexable);
163                                 mwindow->mainindexes->start_build();
164                         }
165                         mwindow->gui->unlock_window();
166 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
167                         mwindow->awindow->gui->update_picon(indexable);
168                         mwindow->awindow->gui->async_update_assets();
169
170                         mwindow->restart_brender();
171                         mwindow->sync_parameters(CHANGE_ALL);
172 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
173                 }
174         }
175
176         this->indexable->remove_user();
177         this->indexable = 0;
178 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
179 }
180
181 BC_Window* AssetEdit::new_gui()
182 {
183         window = new AssetEditWindow(mwindow, this);
184         window->create_objects();
185         return window;
186 }
187
188 int AssetEdit::window_height()
189 {
190         int h = 128 + 64;
191         if( indexable->have_audio() )
192                 h += 180;
193         if( indexable->have_video() ) {
194                 h += 200;
195                 if( indexable->is_asset ) {
196                         Asset *asset = (Asset *)indexable;
197                         if( asset->format == FILE_MPEG ||
198                             asset->format == FILE_FFMPEG ) {
199                                 h += 40;
200                         }
201                 }
202         }
203         return h;
204 }
205
206 AssetEditWindow::AssetEditWindow(MWindow *mwindow, AssetEdit *asset_edit)
207  : BC_Window(_(PROGRAM_NAME ": Asset Info"),
208         asset_edit->x - 450/2, asset_edit->y - asset_edit->window_height()/2,
209         450, asset_edit->window_height(), 0, 0, 1)
210 {
211         this->mwindow = mwindow;
212         this->asset_edit = asset_edit;
213         bitspopup = 0;
214         path_text = 0;
215         path_button = 0;
216         hilo = 0;
217         lohi = 0;
218         allow_edits = 0;
219         detail_dialog = 0;
220         win_width = 0;
221         win_height = 0;
222 }
223
224
225
226
227
228 AssetEditWindow::~AssetEditWindow()
229 {
230         lock_window("AssetEditWindow::~AssetEditWindow");
231         delete bitspopup;
232         delete detail_dialog;
233         unlock_window();
234 }
235
236
237
238
239 void AssetEditWindow::create_objects()
240 {
241         int y = 10, x = 10, x1 = 10, x2 = 190;
242         char string[BCTEXTLEN];
243         int vmargin;
244         FileSystem fs;
245         BC_Title *title;
246         BC_TextBox  *textboxw;
247         BC_ListBox  *listboxw;
248         Interlaceautofix *ilacefixoption_chkboxw;
249         Asset *asset = 0;
250         EDL *nested_edl = 0;
251
252         if( asset_edit->indexable->is_asset )
253                 asset = (Asset*)asset_edit->indexable;
254         else
255                 nested_edl = (EDL*)asset_edit->indexable;
256
257         if( asset && asset->format == FILE_PCM )
258                 allow_edits = 1;
259         else
260                 allow_edits = 0;
261
262         lock_window("AssetEditWindow::create_objects");
263         if( allow_edits )
264                 vmargin = 30;
265         else
266                 vmargin = 20;
267
268         add_subwindow(path_text = new AssetEditPathText(this, y));
269         add_subwindow(path_button = new AssetEditPath(mwindow, this,
270                 path_text, y, asset_edit->indexable->path,
271                 _(PROGRAM_NAME ": Asset path"),
272                 _("Select a file for this asset:")));
273         y += 30;
274
275         if( asset ) {
276                 add_subwindow(new BC_Title(x, y, _("File format:")));
277                 x = x2;
278                 add_subwindow(new BC_Title(x, y, File::formattostr(mwindow->plugindb,
279                                 asset->format),
280                         MEDIUMFONT,
281                         mwindow->theme->assetedit_color));
282                 x = x1;
283                 y += 20;
284
285                 int64_t bytes = fs.get_size(asset->path);
286                 add_subwindow(new BC_Title(x, y, _("Bytes:")));
287                 sprintf(string, "%jd", bytes);
288                 Units::punctuate(string);
289
290
291                 add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
292                 if( asset->format == FILE_MPEG || asset->format == FILE_FFMPEG ) {
293                         detail_dialog = new DetailAssetDialog(mwindow);
294                         BC_GenericButton *detail = new DetailAssetButton(this, x2+120, y);
295                         add_subwindow(detail);
296                 }
297
298                 y += 20;
299                 x = x1;
300
301                 double length = 0.;
302                 y += 20;
303                 x = x1;
304
305                 if( asset->audio_length > 0 )
306                         length = (double)asset->audio_length / asset->sample_rate;
307                 if( asset->video_length > 0 )
308                         length = MAX(length, (double)asset->video_length / asset->frame_rate);
309                 int64_t bitrate;
310                 if( !EQUIV(length, 0) )
311                         bitrate = (int64_t)(bytes * 8 / length);
312                 else
313                         bitrate = bytes;
314                 add_subwindow(new BC_Title(x, y, _("Bitrate (bits/sec):")));
315                 sprintf(string, "%jd", bitrate);
316
317                 Units::punctuate(string);
318                 add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
319
320                 y += 30;
321                 x = x1;
322         }
323
324         if( (asset && asset->audio_data) || nested_edl ) {
325                 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
326                 y += 5;
327
328                 add_subwindow(new BC_Title(x, y, _("Audio:"), LARGEFONT, RED));
329
330                 y += 30;
331
332                 if( asset ) {
333                         if( asset->get_compression_text(1, 0) ) {
334                                 add_subwindow(new BC_Title(x, y, _("Compression:")));
335                                 x = x2;
336                                 add_subwindow(new BC_Title(x,
337                                         y,
338                                         asset->get_compression_text(1, 0),
339                                         MEDIUMFONT,
340                                         mwindow->theme->assetedit_color));
341                                 y += vmargin;
342                                 x = x1;
343                         }
344                 }
345
346                 add_subwindow(new BC_Title(x, y, _("Channels:")));
347                 sprintf(string, "%d", asset_edit->changed_params->channels);
348
349                 x = x2;
350                 if( allow_edits ) {
351                         BC_TumbleTextBox *textbox = new AssetEditChannels(this,
352                                 string,
353                                 x,
354                                 y);
355                         textbox->create_objects();
356                         y += vmargin;
357                 }
358                 else {
359                         add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
360                         y += 20;
361                 }
362
363                 x = x1;
364                 add_subwindow(new BC_Title(x, y, _("Sample rate:")));
365                 sprintf(string, "%d", asset_edit->changed_params->sample_rate);
366
367                 x = x2;
368                 if( asset ) {
369                         BC_TextBox *textbox;
370                         add_subwindow(textbox = new AssetEditRate(this, string, x, y));
371                         x += textbox->get_w();
372                         add_subwindow(new SampleRatePulldown(mwindow, textbox, x, y));
373                 }
374                 else {
375                         add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
376                 }
377
378                 y += 30;
379                 x = x1;
380
381                 if( asset ) {
382                         add_subwindow(new BC_Title(x, y, _("Bits:")));
383                         x = x2;
384                         if( allow_edits ) {
385                                 bitspopup = new BitsPopup(this, x, y,
386                                         &asset_edit->changed_params->bits,
387                                         1, 1, 1, 0, 1);
388                                 bitspopup->create_objects();
389                         }
390                         else
391                                 add_subwindow(new BC_Title(x, y, File::bitstostr(asset->bits), MEDIUMFONT, mwindow->theme->assetedit_color));
392
393
394                         x = x1;
395                         y += vmargin;
396                         add_subwindow(new BC_Title(x, y, _("Header length:")));
397                         sprintf(string, "%d", asset->header);
398
399                         x = x2;
400                         if( allow_edits )
401                                 add_subwindow(new AssetEditHeader(this, string, x, y));
402                         else
403                                 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
404
405                         y += vmargin;
406                         x = x1;
407
408                         add_subwindow(new BC_Title(x, y, _("Byte order:")));
409
410                         if( allow_edits )
411                         {
412                                 x = x2;
413
414                                 add_subwindow(lohi = new AssetEditByteOrderLOHI(this,
415                                         asset->byte_order,
416                                         x,
417                                         y));
418                                 x += 70;
419                                 add_subwindow(hilo = new AssetEditByteOrderHILO(this,
420                                         !asset->byte_order,
421                                         x,
422                                         y));
423                                 y += vmargin;
424                         }
425                         else {
426                                 x = x2;
427                                 if( asset->byte_order )
428                                         add_subwindow(new BC_Title(x, y, _("Lo-Hi"), MEDIUMFONT, mwindow->theme->assetedit_color));
429                                 else
430                                         add_subwindow(new BC_Title(x, y, _("Hi-Lo"), MEDIUMFONT, mwindow->theme->assetedit_color));
431                                 y += vmargin;
432                         }
433
434
435                         x = x1;
436                         if( allow_edits ) {
437         //                      add_subwindow(new BC_Title(x, y, _("Values are signed:")));
438                                 add_subwindow(new AssetEditSigned(this, asset->signed_, x, y));
439                         }
440                         else {
441                                 if( !asset->signed_ && asset->bits == 8 )
442                                         add_subwindow(new BC_Title(x, y, _("Values are unsigned")));
443                                 else
444                                         add_subwindow(new BC_Title(x, y, _("Values are signed")));
445                         }
446
447                         y += 30;
448                 }
449         }
450
451         x = x1;
452         if( (asset && asset->video_data) || nested_edl ) {
453                 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
454                 y += 5;
455
456                 add_subwindow(new BC_Title(x, y, _("Video:"), LARGEFONT, RED));
457                 y += 30;
458                 x = x1;
459
460
461                 if( asset && asset->get_compression_text(0,1) ) {
462                         add_subwindow(new BC_Title(x, y, _("Compression:")));
463                         x = x2;
464                         add_subwindow(new BC_Title(x,
465                                 y,
466                                 asset->get_compression_text(0,1),
467                                 MEDIUMFONT,
468                                 mwindow->theme->assetedit_color));
469                         y += vmargin;
470                         x = x1;
471                 }
472
473                 add_subwindow(new BC_Title(x, y, _("Frame rate:")));
474                 x = x2;
475                 sprintf(string, "%.4f", asset_edit->changed_params->frame_rate);
476
477 //printf("AssetEditWindow::create_objects %d %f\n", __LINE__, asset_edit->changed_params->frame_rate);
478                 if( asset ) {
479                         BC_TextBox *framerate;
480                         add_subwindow(framerate = new AssetEditFRate(this, string, x, y));
481                         x += 105;
482                         add_subwindow(new FrameRatePulldown(mwindow, framerate, x, y));
483                 }
484                 else {
485                         add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
486                 }
487
488                 y += 30;
489                 x = x1;
490                 add_subwindow(new BC_Title(x, y, _("Width:")));
491                 x = x2;
492                 sprintf(string, "%d", asset_edit->changed_params->width);
493                 win_width = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color);
494                 add_subwindow(win_width);
495
496                 y += vmargin;
497                 x = x1;
498                 add_subwindow(new BC_Title(x, y, _("Height:")));
499                 x = x2;
500                 sprintf(string, "%d", asset_edit->changed_params->height);
501                 win_height = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color);
502                 add_subwindow(win_height);
503                 y += win_height->get_h() + 5;
504
505                 if( asset && (asset->format == FILE_MPEG || asset->format == FILE_FFMPEG )  ) {
506                         y += 5;
507                         x = x1;
508                         add_subwindow(new BC_Title(x, y, _("Actual width:")));
509                         x = x2;
510                         sprintf(string, "%d", asset->actual_width);
511                         add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
512
513                         BC_GenericButton *resize = new ResizeAssetButton(this, x+64, y);
514                         add_subwindow(resize);
515
516                         y += vmargin;
517                         x = x1;
518                         add_subwindow(new BC_Title(x, y, _("Actual height:")));
519                         x = x2;
520                         sprintf(string, "%d", asset->actual_height);
521                         title = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color);
522                         add_subwindow(title);
523                         y += title->get_h() + 5;
524                 }
525
526                 // --------------------
527                 add_subwindow(title = new BC_Title(x1, y, _("Fix interlacing:")));
528                 add_subwindow(ilacefixoption_chkboxw = new Interlaceautofix(mwindow,this, x2, y));
529                 y += ilacefixoption_chkboxw->get_h() + 5;
530                 // --------------------
531                 add_subwindow(title = new BC_Title(x1, y, _("Asset's interlacing:")));
532                 add_subwindow(textboxw = new AssetEditILacemode(this, "", ILACE_ASSET_MODEDEFAULT, x2, y, 200));
533                 ilacefixoption_chkboxw->ilacemode_textbox = textboxw;
534                 add_subwindow(listboxw = new AssetEditInterlacemodePulldown(mwindow,
535                                                         textboxw,
536                                                         &asset_edit->changed_params->interlace_mode,
537                                                         (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_asset_modes,
538                                                         ilacefixoption_chkboxw,
539                                                         x2 + textboxw->get_w(),
540                                                         y));
541                 ilacefixoption_chkboxw->ilacemode_listbox = listboxw;
542                 y += textboxw->get_h() + 5;
543
544                 // --------------------
545                 add_subwindow(title = new BC_Title(x1, y, _("Interlace correction:")));
546                 add_subwindow(textboxw = new AssetEditILacefixmethod(this, "", ILACE_FIXDEFAULT, x2, y, 200));
547                 ilacefixoption_chkboxw->ilacefixmethod_textbox = textboxw;
548                 add_subwindow(listboxw = new InterlacefixmethodPulldown(mwindow,
549                                                         textboxw,
550                                                         &asset_edit->changed_params->interlace_fixmethod,
551                                                         (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_asset_fixmethods,
552                                                         x2 + textboxw->get_w(),
553                                                         y));
554                 ilacefixoption_chkboxw->ilacefixmethod_listbox = listboxw;
555                 ilacefixoption_chkboxw->showhideotherwidgets();
556                 y += textboxw->get_h() + 5;
557         }
558
559         add_subwindow(new BC_OKButton(this));
560         add_subwindow(new BC_CancelButton(this));
561         show_window();
562         unlock_window();
563 }
564
565 void AssetEditWindow::show_info_detail()
566 {
567         int cur_x, cur_y;
568         get_abs_cursor_xy(cur_x, cur_y, 0);
569         detail_dialog->start((Asset*)asset_edit->indexable, cur_x, cur_y);
570 }
571
572
573 AssetEditChannels::AssetEditChannels(AssetEditWindow *fwindow,
574         char *text,
575         int x,
576         int y)
577  : BC_TumbleTextBox(fwindow,
578                 (int)atol(text),
579                 (int)1,
580                 (int)MAXCHANNELS,
581                 x,
582                 y,
583                 50)
584 {
585         this->fwindow = fwindow;
586 }
587
588 int AssetEditChannels::handle_event()
589 {
590         Asset *asset = fwindow->asset_edit->changed_params;
591         asset->channels = atol(get_text());
592         return 1;
593 }
594
595 AssetEditRate::AssetEditRate(AssetEditWindow *fwindow, char *text, int x, int y)
596  : BC_TextBox(x, y, 100, 1, text)
597 {
598         this->fwindow = fwindow;
599 }
600
601 int AssetEditRate::handle_event()
602 {
603         Asset *asset = fwindow->asset_edit->changed_params;
604         asset->sample_rate = atol(get_text());
605         return 1;
606 }
607
608 AssetEditFRate::AssetEditFRate(AssetEditWindow *fwindow, char *text, int x, int y)
609  : BC_TextBox(x, y, 100, 1, text)
610 {
611         this->fwindow = fwindow;
612 }
613
614 int AssetEditFRate::handle_event()
615 {
616         Asset *asset = fwindow->asset_edit->changed_params;
617         asset->frame_rate = atof(get_text());
618         return 1;
619 }
620
621 Interlaceautofix::Interlaceautofix(MWindow *mwindow,AssetEditWindow *fwindow, int x, int y)
622  : BC_CheckBox(x, y,
623         fwindow->asset_edit->changed_params->interlace_autofixoption,
624         _("Automatically Fix Interlacing"))
625 {
626         this->fwindow = fwindow;
627         this->mwindow = mwindow;
628 }
629
630 Interlaceautofix::~Interlaceautofix()
631 {
632 }
633
634 int Interlaceautofix::handle_event()
635 {
636         Asset *asset = fwindow->asset_edit->changed_params;
637         asset->interlace_autofixoption = get_value();
638         showhideotherwidgets();
639         return 1;
640 }
641
642 void Interlaceautofix::showhideotherwidgets()
643 {
644   int thevalue = get_value();
645
646         Asset *asset = fwindow->asset_edit->changed_params;
647         if( thevalue == ILACE_AUTOFIXOPTION_AUTO ) {
648                 this->ilacemode_textbox->enable();
649                 this->ilacemode_listbox->enable();
650                 this->ilacefixmethod_textbox->disable();
651                 this->ilacefixmethod_listbox->disable();
652                 int xx = ilaceautofixmethod(mwindow->edl->session->interlace_mode,asset->interlace_mode);
653                 ilacefixmethod_to_text(string, xx);
654                 this->ilacefixmethod_textbox->update(string);
655         }
656         if( thevalue == ILACE_AUTOFIXOPTION_MANUAL ) {
657                 this->ilacemode_textbox->disable();
658                 this->ilacemode_listbox->disable();
659                 this->ilacefixmethod_textbox->enable();
660                 this->ilacefixmethod_listbox->enable();
661                 ilacefixmethod_to_text(string, asset->interlace_fixmethod);
662                 this->ilacefixmethod_textbox->update(string);
663           }
664 }
665
666 InterlacefixmethodItem::InterlacefixmethodItem(const char *text, int value)
667  : BC_ListBoxItem(text)
668 {
669         this->value = value;
670 }
671
672 InterlacefixmethodPulldown::InterlacefixmethodPulldown(MWindow *mwindow,
673                 BC_TextBox *output_text, int *output_value,
674                 ArrayList<BC_ListBoxItem*> *data, int x, int y)
675  : BC_ListBox(x, y, 200, 150, LISTBOX_TEXT, data, 0, 0, 1, 0, 1)
676 {
677         this->mwindow = mwindow;
678         this->output_text = output_text;
679         this->output_value = output_value;
680         output_text->update(interlacefixmethod_to_text());
681 }
682
683 int InterlacefixmethodPulldown::handle_event()
684 {
685         output_text->update(get_selection(0, 0)->get_text());
686         *output_value = ((InterlacefixmethodItem*)get_selection(0, 0))->value;
687         return 1;
688 }
689
690 const char* InterlacefixmethodPulldown::interlacefixmethod_to_text()
691 {
692         ilacefixmethod_to_text(this->string,*output_value);
693         return (this->string);
694 }
695
696 AssetEditILaceautofixoption::AssetEditILaceautofixoption(AssetEditWindow *fwindow, char *text, int thedefault, int x, int y, int w)
697  : BC_TextBox(x, y, w, 1, text)
698 {
699         this->fwindow = fwindow;
700         this->thedefault = thedefault;
701 }
702
703 int AssetEditILaceautofixoption::handle_event()
704 {
705         Asset *asset = fwindow->asset_edit->changed_params;
706         asset->interlace_autofixoption = ilaceautofixoption_from_text(get_text(), this->thedefault);
707         return 1;
708 }
709
710
711 AssetEditILacemode::AssetEditILacemode(AssetEditWindow *fwindow, const char *text, int thedefault, int x, int y, int w)
712  : BC_TextBox(x, y, w, 1, text)
713 {
714         this->fwindow = fwindow;
715         this->thedefault = thedefault;
716 }
717
718 int AssetEditILacemode::handle_event()
719 {
720         Asset *asset = fwindow->asset_edit->changed_params;
721         asset->interlace_mode = ilacemode_from_text(get_text(),this->thedefault);
722         return 1;
723 }
724
725 AssetEditInterlacemodePulldown::AssetEditInterlacemodePulldown(MWindow *mwindow,
726                 BC_TextBox *output_text,
727                 int *output_value,
728                 ArrayList<BC_ListBoxItem*> *data,
729                 Interlaceautofix *fixoption_chkboxw,
730                 int x,
731                 int y)
732  : BC_ListBox(x,
733         y,
734         200,
735         150,
736         LISTBOX_TEXT,
737         data,
738         0,
739         0,
740         1,
741         0,
742         1)
743 {
744         this->fixoption_chkbox = fixoption_chkboxw;
745         this->mwindow = mwindow;
746         this->output_text = output_text;
747         this->output_value = output_value;
748         output_text->update(interlacemode_to_text());
749 }
750
751 int AssetEditInterlacemodePulldown::handle_event()
752 {
753         output_text->update(get_selection(0, 0)->get_text());
754         *output_value = ((InterlacemodeItem*)get_selection(0, 0))->value;
755         fixoption_chkbox->showhideotherwidgets();
756         return 1;
757 }
758
759 char* AssetEditInterlacemodePulldown::interlacemode_to_text()
760 {
761         ilacemode_to_text(this->string,*output_value);
762         return (this->string);
763 }
764
765 AssetEditILacefixmethod::AssetEditILacefixmethod(AssetEditWindow *fwindow, const char *text, int thedefault, int x, int y, int w)
766  : BC_TextBox(x, y, w, 1, text)
767 {
768         this->fwindow = fwindow;
769         this->thedefault = thedefault;
770 }
771
772 int AssetEditILacefixmethod::handle_event()
773 {
774         Asset *asset = fwindow->asset_edit->changed_params;
775         asset->interlace_fixmethod = ilacefixmethod_from_text(get_text(),this->thedefault);
776         return 1;
777 }
778
779 AssetEditHeader::AssetEditHeader(AssetEditWindow *fwindow, char *text, int x, int y)
780  : BC_TextBox(x, y, 100, 1, text)
781 {
782         this->fwindow = fwindow;
783 }
784
785 int AssetEditHeader::handle_event()
786 {
787         Asset *asset = fwindow->asset_edit->changed_params;
788         asset->header = atol(get_text());
789         return 1;
790 }
791
792 AssetEditByteOrderLOHI::AssetEditByteOrderLOHI(AssetEditWindow *fwindow,
793         int value,
794         int x,
795         int y)
796  : BC_Radial(x, y, value, _("Lo-Hi"))
797 {
798         this->fwindow = fwindow;
799 }
800
801 int AssetEditByteOrderLOHI::handle_event()
802 {
803         Asset *asset = fwindow->asset_edit->changed_params;
804         asset->byte_order = 1;
805         fwindow->hilo->update(0);
806         update(1);
807         return 1;
808 }
809
810 AssetEditByteOrderHILO::AssetEditByteOrderHILO(AssetEditWindow *fwindow,
811         int value,
812         int x,
813         int y)
814  : BC_Radial(x, y, value, _("Hi-Lo"))
815 {
816         this->fwindow = fwindow;
817 }
818
819 int AssetEditByteOrderHILO::handle_event()
820 {
821         Asset *asset = fwindow->asset_edit->changed_params;
822         asset->byte_order = 0;
823         fwindow->lohi->update(0);
824         update(1);
825         return 1;
826 }
827
828 AssetEditSigned::AssetEditSigned(AssetEditWindow *fwindow,
829         int value,
830         int x,
831         int y)
832  : BC_CheckBox(x, y, value, _("Values are signed"))
833 {
834         this->fwindow = fwindow;
835 }
836
837 int AssetEditSigned::handle_event()
838 {
839         Asset *asset = fwindow->asset_edit->changed_params;
840         asset->signed_ = get_value();
841         return 1;
842 }
843
844
845
846
847
848
849
850 AssetEditPathText::AssetEditPathText(AssetEditWindow *fwindow, int y)
851  : BC_TextBox(5, y, 300, 1, fwindow->asset_edit->changed_params->path)
852 {
853         this->fwindow = fwindow;
854 }
855 AssetEditPathText::~AssetEditPathText()
856 {
857 }
858 int AssetEditPathText::handle_event()
859 {
860         strcpy(fwindow->asset_edit->changed_params->path, get_text());
861         return 1;
862 }
863
864 AssetEditPath::AssetEditPath(MWindow *mwindow, AssetEditWindow *fwindow,
865         BC_TextBox *textbox, int y, const char *text,
866         const char *window_title, const char *window_caption)
867  : BrowseButton(mwindow->theme, fwindow, textbox, 310, y, text,
868         window_title, window_caption, 0)
869 {
870         this->fwindow = fwindow;
871 }
872
873 AssetEditPath::~AssetEditPath() {}
874
875
876
877
878
879
880 AssetEditFormat::AssetEditFormat(AssetEditWindow *fwindow, char* default_, int y)
881  : FormatPopup(fwindow->mwindow->plugindb, 90, y)
882 {
883         this->fwindow = fwindow;
884 }
885 AssetEditFormat::~AssetEditFormat()
886 {
887 }
888 int AssetEditFormat::handle_event()
889 {
890         Asset *asset = fwindow->asset_edit->changed_params;
891         asset->format = File::strtoformat(fwindow->mwindow->plugindb,
892                 get_selection(0, 0)->get_text());
893         return 1;
894 }
895
896
897
898
899 DetailAssetButton::DetailAssetButton(AssetEditWindow *fwindow, int x, int y)
900  : BC_GenericButton(x, y, _("Detail"))
901 {
902         this->fwindow = fwindow;
903         set_underline(0);
904 }
905
906 DetailAssetButton::~DetailAssetButton()
907 {
908 }
909
910 int DetailAssetButton::handle_event()
911 {
912         fwindow->show_info_detail();
913         return 1;
914 }
915
916 DetailAssetWindow::DetailAssetWindow(MWindow *mwindow,
917         DetailAssetDialog *detail_dialog, Asset *asset)
918  : BC_Window(_("Asset Detail"),
919         detail_dialog->x - 600/2, detail_dialog->y - 500/2, 600, 500)
920 {
921         this->mwindow = mwindow;
922         this->detail_dialog = detail_dialog;
923         this->asset = asset;
924         asset->add_user();
925         info[0] = 0;
926         text = 0;
927 }
928
929 DetailAssetWindow::~DetailAssetWindow()
930 {
931         asset->remove_user();
932         delete text;
933 }
934
935 DetailAssetDialog::DetailAssetDialog(MWindow *mwindow)
936  : BC_DialogThread()
937 {
938         this->mwindow = mwindow;
939         dwindow = 0;
940 }
941
942 DetailAssetDialog::~DetailAssetDialog()
943 {
944         close_window();
945 }
946
947 void DetailAssetWindow::create_objects()
948 {
949         int y = 10, x = 10;
950         char file_name[BCTEXTLEN];
951         int len = sizeof(info);
952         strncpy(info,_("no info available"),len);
953         if( !mwindow->preferences->get_asset_file_path(asset, file_name) ) {
954                 switch( asset->format ) {
955                 case FILE_MPEG:
956                         FileMPEG::get_info(asset->path, file_name, &info[0],len);
957                         break;
958                 case FILE_FFMPEG:
959                         FileFFMPEG::get_info(asset->path, &info[0],len);
960                         break;
961                 }
962         }
963         text = new BC_ScrollTextBox(this, x, y, get_w()-32, 23, info, -len);
964         text->create_objects();  text->set_text_row(0);
965         add_subwindow(new BC_OKButton(this));
966         show_window();
967 }
968
969 void DetailAssetDialog::start(Asset *asset, int x, int y)
970 {
971         delete dwindow;
972         this->asset = asset;
973         this->x = x;  this->y = y;
974         BC_DialogThread::start();
975 }
976
977 BC_Window *DetailAssetDialog::new_gui()
978 {
979         dwindow = new DetailAssetWindow(mwindow, this, asset);
980         dwindow->create_objects();
981         return dwindow;
982 }
983