9d3e6869b3cec69fbc4bd5e36514250dbacee221
[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)
80 {
81         if(this->indexable)
82         {
83                 close_window();
84         }
85
86         this->indexable = indexable;
87         this->indexable->add_user();
88
89 // Copy asset parameters into temporary storage for editing.
90         if(indexable->is_asset)
91         {
92                 changed_params->copy_from((Asset*)indexable, 0);
93         }
94         else
95         {
96                 EDL *nested_edl = (EDL*)indexable;
97
98         strcpy(changed_params->path, nested_edl->path);
99                 changed_params->sample_rate = nested_edl->session->sample_rate;
100         changed_params->channels = nested_edl->session->audio_channels;
101
102 //printf("AssetEdit::edit_asset %d %f\n", __LINE__, nested_edl->session->frame_rate);
103                 changed_params->frame_rate = nested_edl->session->frame_rate;
104         changed_params->width = nested_edl->session->output_w;
105         changed_params->height = nested_edl->session->output_h;
106         }
107
108         BC_DialogThread::start();
109 }
110
111 void AssetEdit::handle_close_event(int result)
112 {
113         if(!result)
114         {
115                 int changed = 0;
116                 Asset *asset = 0;
117                 EDL *nested_edl = 0;
118
119                 if(indexable->is_asset)
120                 {
121                         asset = (Asset*)indexable;
122                         if(!changed_params->equivalent(*asset, 1, 1))
123                                 changed = 1;
124                 }
125                 else
126                 {
127                         nested_edl = (EDL*)indexable;
128                         if(strcmp(changed_params->path, nested_edl->path)
129 //                ||
130 //                changed_params->sample_rate != nested_edl->session->sample_rate ||
131 //                              !EQUIV(changed_params->frame_rate, nested_edl->session->frame_rate)
132                 )
133                                 changed = 1;
134                 }
135 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
136
137                 if(changed)
138                 {
139                         mwindow->gui->lock_window();
140 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
141
142 // Omit index status from copy since an index rebuild may have been
143 // happening when new_asset was created but not be happening anymore.
144                         if(asset)
145                         {
146                         mwindow->remove_asset_from_caches(asset);
147 //printf("AssetEdit::handle_close_event %d %f\n", __LINE__, asset->get_frame_rate());
148                                 asset->copy_from(changed_params, 0);
149 //printf("AssetEdit::handle_close_event %d %d %d\n", __LINE__, changed_params->bits, asset->bits);
150                         }
151                         else
152                         {
153                                 strcpy(nested_edl->path, changed_params->path);
154 // Other parameters can't be changed because they're defined in the other EDL
155 //                nested_edl->session->frame_rate = changed_params->frame_rate;
156 //                nested_edl->session->sample_rate = changed_params->sample_rate;
157                         }
158 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
159
160                         mwindow->gui->update(0,
161                                 2,
162                                 0,
163                                 0,
164                                 0,
165                                 0,
166                                 0);
167 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
168
169 // Start index rebuilding
170                         if( (asset && asset->audio_data) || nested_edl)
171                         {
172                                 char source_filename[BCTEXTLEN];
173                                 char index_filename[BCTEXTLEN];
174                                 IndexFile::get_index_filename(source_filename,
175                                         mwindow->preferences->index_directory,
176                                         index_filename,
177                                         indexable->path);
178                                 remove_file(index_filename);
179                                 indexable->index_state->index_status = INDEX_NOTTESTED;
180                                 mwindow->mainindexes->add_next_asset(0, indexable);
181                                 mwindow->mainindexes->start_build();
182                         }
183                         mwindow->gui->unlock_window();
184 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
185                         mwindow->awindow->gui->async_update_assets();
186
187                         mwindow->restart_brender();
188                         mwindow->sync_parameters(CHANGE_ALL);
189 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
190                 }
191         }
192
193         this->indexable->remove_user();
194         this->indexable = 0;
195 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
196 }
197
198 BC_Window* AssetEdit::new_gui()
199 {
200         window = new AssetEditWindow(mwindow, this);
201         window->create_objects();
202         return window;
203 }
204
205
206
207
208
209
210
211
212
213 AssetEditWindow::AssetEditWindow(MWindow *mwindow, AssetEdit *asset_edit)
214  : BC_Window(_(PROGRAM_NAME ": Asset Info"),
215         mwindow->gui->get_abs_cursor_x(1) - 400 / 2,
216         mwindow->gui->get_abs_cursor_y(1) - (128 + 64 +
217                 (!asset_edit->indexable->have_audio() ? 0 : 180) +
218                 (!asset_edit->indexable->have_video() ? 0 : 350)) / 2,
219         400, (128 + 64 +
220                 (!asset_edit->indexable->have_audio() ? 0 : 180) +
221                 (!asset_edit->indexable->have_video() ? 0 : 350)), 0, 0, 1)
222 {
223         this->mwindow = mwindow;
224         this->asset_edit = asset_edit;
225         bitspopup = 0;
226         path_text = 0;
227         path_button = 0;
228         hilo = 0;
229         lohi = 0;
230         allow_edits = 0;
231         detail_thread = 0;
232 }
233
234
235
236
237
238 AssetEditWindow::~AssetEditWindow()
239 {
240         lock_window("AssetEditWindow::~AssetEditWindow");
241         if(bitspopup) delete bitspopup;
242         if(detail_thread) delete detail_thread;
243         unlock_window();
244 }
245
246
247
248
249 void AssetEditWindow::create_objects()
250 {
251         int y = 10, x = 10, x1 = 10, x2 = 160;
252         char string[BCTEXTLEN];
253         int vmargin;
254         FileSystem fs;
255         BC_Title *title;
256         BC_TextBox  *textboxw;
257         BC_ListBox  *listboxw;
258         Interlaceautofix *ilacefixoption_chkboxw;
259         Asset *asset = 0;
260         EDL *nested_edl = 0;
261
262         if(asset_edit->indexable->is_asset)
263                 asset = (Asset*)asset_edit->indexable;
264         else
265                 nested_edl = (EDL*)asset_edit->indexable;
266
267         if(asset && asset->format == FILE_PCM)
268                 allow_edits = 1;
269         else
270                 allow_edits = 0;
271
272         lock_window("AssetEditWindow::create_objects");
273         if(allow_edits)
274                 vmargin = 30;
275         else
276                 vmargin = 20;
277
278         add_subwindow(path_text = new AssetEditPathText(this, y));
279         add_subwindow(path_button = new AssetEditPath(mwindow,
280                 this,
281                 path_text,
282                 y,
283                 asset_edit->indexable->path,
284                 _(PROGRAM_NAME ": Asset path"), _("Select a file for this asset:")));
285         y += 30;
286
287         if(asset)
288         {
289                 add_subwindow(new BC_Title(x, y, _("File format:")));
290                 x = x2;
291                 add_subwindow(new BC_Title(x, y, File::formattostr(mwindow->plugindb,
292                                 asset->format),
293                         MEDIUMFONT,
294                         mwindow->theme->assetedit_color));
295                 x = x1;
296                 y += 20;
297
298                 int64_t bytes = fs.get_size(asset->path);
299                 add_subwindow(new BC_Title(x, y, _("Bytes:")));
300                 sprintf(string, "%jd", bytes);
301                 Units::punctuate(string);
302
303
304                 add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
305                 if(asset->format == FILE_MPEG || asset->format == FILE_FFMPEG)
306                 {
307                         detail_thread = new DetailAssetThread(mwindow);
308                         BC_GenericButton *detail = new DetailAssetButton(this, x2+120, y);
309                         add_subwindow(detail);
310                 }
311
312                 y += 20;
313                 x = x1;
314
315                 double length = 0.;
316                 y += 20;
317                 x = x1;
318
319                 if(asset->audio_length > 0)
320                         length = (double)asset->audio_length / asset->sample_rate;
321                 if(asset->video_length > 0)
322                         length = MAX(length, (double)asset->video_length / asset->frame_rate);
323                 int64_t bitrate;
324                 if(!EQUIV(length, 0))
325                         bitrate = (int64_t)(bytes * 8 / length);
326                 else
327                         bitrate = bytes;
328                 add_subwindow(new BC_Title(x, y, _("Bitrate (bits/sec):")));
329                 sprintf(string, "%jd", bitrate);
330
331                 Units::punctuate(string);
332                 add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
333
334                 y += 30;
335                 x = x1;
336         }
337
338         if((asset && asset->audio_data) || nested_edl)
339         {
340                 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
341                 y += 5;
342
343                 add_subwindow(new BC_Title(x, y, _("Audio:"), LARGEFONT, RED));
344
345                 y += 30;
346
347                 if(asset)
348                 {
349                         if(asset->get_compression_text(1, 0))
350                         {
351                                 add_subwindow(new BC_Title(x, y, _("Compression:")));
352                                 x = x2;
353                                 add_subwindow(new BC_Title(x,
354                                         y,
355                                         asset->get_compression_text(1, 0),
356                                         MEDIUMFONT,
357                                         mwindow->theme->assetedit_color));
358                                 y += vmargin;
359                                 x = x1;
360                         }
361                 }
362
363                 add_subwindow(new BC_Title(x, y, _("Channels:")));
364                 sprintf(string, "%d", asset_edit->changed_params->channels);
365
366                 x = x2;
367                 if(allow_edits)
368                 {
369                         BC_TumbleTextBox *textbox = new AssetEditChannels(this,
370                                 string,
371                                 x,
372                                 y);
373                         textbox->create_objects();
374                         y += vmargin;
375                 }
376                 else
377                 {
378                         add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
379                         y += 20;
380                 }
381
382                 x = x1;
383                 add_subwindow(new BC_Title(x, y, _("Sample rate:")));
384                 sprintf(string, "%d", asset_edit->changed_params->sample_rate);
385
386                 x = x2;
387                 if(asset)
388                 {
389                         BC_TextBox *textbox;
390                         add_subwindow(textbox = new AssetEditRate(this, string, x, y));
391                         x += textbox->get_w();
392                         add_subwindow(new SampleRatePulldown(mwindow, textbox, x, y));
393                 }
394                 else
395                 {
396                         add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
397                 }
398
399                 y += 30;
400                 x = x1;
401
402                 if(asset)
403                 {
404                         add_subwindow(new BC_Title(x, y, _("Bits:")));
405                         x = x2;
406                         if(allow_edits)
407                         {
408                                 bitspopup = new BitsPopup(this,
409                                         x,
410                                         y,
411                                         &asset_edit->changed_params->bits,
412                                         1,
413                                         1,
414                                         1,
415                                         0,
416                                         1);
417                                 bitspopup->create_objects();
418                         }
419                         else
420                                 add_subwindow(new BC_Title(x, y, File::bitstostr(asset->bits), MEDIUMFONT, mwindow->theme->assetedit_color));
421
422
423                         x = x1;
424                         y += vmargin;
425                         add_subwindow(new BC_Title(x, y, _("Header length:")));
426                         sprintf(string, "%d", asset->header);
427
428                         x = x2;
429                         if(allow_edits)
430                                 add_subwindow(new AssetEditHeader(this, string, x, y));
431                         else
432                                 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
433
434                         y += vmargin;
435                         x = x1;
436
437                         add_subwindow(new BC_Title(x, y, _("Byte order:")));
438
439                         if(allow_edits)
440                         {
441                                 x = x2;
442
443                                 add_subwindow(lohi = new AssetEditByteOrderLOHI(this,
444                                         asset->byte_order,
445                                         x,
446                                         y));
447                                 x += 70;
448                                 add_subwindow(hilo = new AssetEditByteOrderHILO(this,
449                                         !asset->byte_order,
450                                         x,
451                                         y));
452                                 y += vmargin;
453                         }
454                         else
455                         {
456                                 x = x2;
457                                 if(asset->byte_order)
458                                         add_subwindow(new BC_Title(x, y, _("Lo-Hi"), MEDIUMFONT, mwindow->theme->assetedit_color));
459                                 else
460                                         add_subwindow(new BC_Title(x, y, _("Hi-Lo"), MEDIUMFONT, mwindow->theme->assetedit_color));
461                                 y += vmargin;
462                         }
463
464
465                         x = x1;
466                         if(allow_edits)
467                         {
468         //                      add_subwindow(new BC_Title(x, y, _("Values are signed:")));
469                                 add_subwindow(new AssetEditSigned(this, asset->signed_, x, y));
470                         }
471                         else
472                         {
473                                 if(!asset->signed_ && asset->bits == 8)
474                                         add_subwindow(new BC_Title(x, y, _("Values are unsigned")));
475                                 else
476                                         add_subwindow(new BC_Title(x, y, _("Values are signed")));
477                         }
478
479                         y += 30;
480                 }
481         }
482
483         x = x1;
484         if((asset && asset->video_data) || nested_edl)
485         {
486                 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
487                 y += 5;
488
489                 add_subwindow(new BC_Title(x, y, _("Video:"), LARGEFONT, RED));
490                 y += 30;
491                 x = x1;
492
493
494                 if(asset && asset->get_compression_text(0,1))
495                 {
496                         add_subwindow(new BC_Title(x, y, _("Compression:")));
497                         x = x2;
498                         add_subwindow(new BC_Title(x,
499                                 y,
500                                 asset->get_compression_text(0,1),
501                                 MEDIUMFONT,
502                                 mwindow->theme->assetedit_color));
503                         y += vmargin;
504                         x = x1;
505                 }
506
507                 add_subwindow(new BC_Title(x, y, _("Frame rate:")));
508                 x = x2;
509                 sprintf(string, "%.2f", asset_edit->changed_params->frame_rate);
510
511 //printf("AssetEditWindow::create_objects %d %f\n", __LINE__, asset_edit->changed_params->frame_rate);
512                 if(asset)
513                 {
514                         BC_TextBox *framerate;
515                         add_subwindow(framerate = new AssetEditFRate(this, string, x, y));
516                         x += 105;
517                         add_subwindow(new FrameRatePulldown(mwindow, framerate, x, y));
518                 }
519                 else
520                 {
521                         add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
522                 }
523
524                 y += 30;
525                 x = x1;
526                 add_subwindow(new BC_Title(x, y, _("Width:")));
527                 x = x2;
528                 sprintf(string, "%d", asset_edit->changed_params->width);
529                 win_width = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color);
530                 add_subwindow(win_width);
531
532                 y += vmargin;
533                 x = x1;
534                 add_subwindow(new BC_Title(x, y, _("Height:")));
535                 x = x2;
536                 sprintf(string, "%d", asset_edit->changed_params->height);
537                 win_height = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color);
538                 add_subwindow(win_height);
539                 y += win_height->get_h() + 5;
540
541                 if(asset && (asset->format == FILE_MPEG || asset->format == FILE_FFMPEG ) )
542                 {
543                         y += 5;
544                         x = x1;
545                         add_subwindow(new BC_Title(x, y, _("Actual width:")));
546                         x = x2;
547                         sprintf(string, "%d", asset->actual_width);
548                         add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
549
550                         BC_GenericButton *resize = new ResizeAssetButton(this, x+64, y);
551                         add_subwindow(resize);
552
553                         y += vmargin;
554                         x = x1;
555                         add_subwindow(new BC_Title(x, y, _("Actual height:")));
556                         x = x2;
557                         sprintf(string, "%d", asset->actual_height);
558                         title = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color);
559                         add_subwindow(title);
560                         y += title->get_h() + 5;
561                 }
562
563                 // --------------------
564                 add_subwindow(title = new BC_Title(x1, y, _("Fix interlacing:")));
565                 add_subwindow(ilacefixoption_chkboxw = new Interlaceautofix(mwindow,this, x2, y));
566                 y += ilacefixoption_chkboxw->get_h() + 5;
567                 // --------------------
568                 add_subwindow(title = new BC_Title(x1, y, _("Asset's interlacing:")));
569                 add_subwindow(textboxw = new AssetEditILacemode(this, "", BC_ILACE_ASSET_MODEDEFAULT, x2, y, 200));
570                 ilacefixoption_chkboxw->ilacemode_textbox = textboxw;
571                 add_subwindow(listboxw = new AssetEditInterlacemodePulldown(mwindow,
572                                                         textboxw,
573                                                         &asset->interlace_mode,
574                                                         (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_asset_modes,
575                                                         ilacefixoption_chkboxw,
576                                                         x2 + textboxw->get_w(),
577                                                         y));
578                 ilacefixoption_chkboxw->ilacemode_listbox = listboxw;
579                 y += textboxw->get_h() + 5;
580
581                 // --------------------
582                 add_subwindow(title = new BC_Title(x1, y, _("Interlace correction:")));
583                 add_subwindow(textboxw = new AssetEditILacefixmethod(this, "", BC_ILACE_FIXDEFAULT, x2, y, 200));
584                 ilacefixoption_chkboxw->ilacefixmethod_textbox = textboxw;
585                 add_subwindow(listboxw = new InterlacefixmethodPulldown(mwindow,
586                                                         textboxw,
587                                                         &asset->interlace_fixmethod,
588                                                         (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_asset_fixmethods,
589                                                         x2 + textboxw->get_w(),
590                                                         y));
591                 ilacefixoption_chkboxw->ilacefixmethod_listbox = listboxw;
592                 ilacefixoption_chkboxw->showhideotherwidgets();
593                 y += textboxw->get_h() + 5;
594
595                 x = x1;
596                 add_subwindow(new BC_Title(x, y, _("Reel Name:")));
597                 x = x2;
598                 add_subwindow(new AssetEditReelName(this, x, y));
599                 y += 30;
600
601                 x = x1;
602                 add_subwindow(new BC_Title(x, y, _("Reel Number:")));
603                 x = x2;
604                 add_subwindow(new AssetEditReelNumber(this, x, y));
605                 y += 30;
606
607                 x = x1;
608                 add_subwindow(new BC_Title(x, y, _("Time Code Start:")));
609                 x = x2;
610
611 // Calculate values to enter into textboxes
612                 char tc[12];
613
614                 Units::totext(tc,
615                         asset->tcstart / asset->frame_rate,
616                         TIME_HMSF,
617                         asset->sample_rate,
618                         asset->frame_rate);
619
620                 char *tc_hours = tc;
621                 char *tc_minutes = strchr(tc, ':') + 1;
622                 *(tc_minutes - 1) = 0;
623                 char *tc_seconds = strchr(tc_minutes, ':') + 1;
624                 *(tc_seconds - 1) = 0;
625                 char *tc_rest = strchr(tc_seconds, ':') + 1;
626                 *(tc_rest - 1) = 0;
627
628                 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc_hours), x, y,
629                         (int) (asset->frame_rate * 60 * 60)));
630                 x += 30;
631                 add_subwindow(new BC_Title(x, y, ":"));
632                 x += 10;
633                 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc_minutes), x, y,
634                         (int) (asset->frame_rate * 60)));
635                 x += 30;
636                 add_subwindow(new BC_Title(x, y, ":"));
637                 x += 10;
638                 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc_seconds), x, y,
639                         (int) (asset->frame_rate)));
640                 x += 30;
641                 add_subwindow(new BC_Title(x, y, ":"));
642                 x += 10;
643                 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc_rest), x, y, 1));
644
645
646                 y += 30;
647         }
648
649         add_subwindow(new BC_OKButton(this));
650         add_subwindow(new BC_CancelButton(this));
651         show_window();
652         unlock_window();
653 }
654
655 void AssetEditWindow::show_info_detail()
656 {
657         detail_thread->start((Asset*)asset_edit->indexable);
658 }
659
660
661 AssetEditChannels::AssetEditChannels(AssetEditWindow *fwindow,
662         char *text,
663         int x,
664         int y)
665  : BC_TumbleTextBox(fwindow,
666                 (int)atol(text),
667                 (int)1,
668                 (int)MAXCHANNELS,
669                 x,
670                 y,
671                 50)
672 {
673         this->fwindow = fwindow;
674 }
675
676 int AssetEditChannels::handle_event()
677 {
678         Asset *asset = fwindow->asset_edit->changed_params;
679         asset->channels = atol(get_text());
680         return 1;
681 }
682
683 AssetEditRate::AssetEditRate(AssetEditWindow *fwindow, char *text, int x, int y)
684  : BC_TextBox(x, y, 100, 1, text)
685 {
686         this->fwindow = fwindow;
687 }
688
689 int AssetEditRate::handle_event()
690 {
691         Asset *asset = fwindow->asset_edit->changed_params;
692         asset->sample_rate = atol(get_text());
693         return 1;
694 }
695
696 AssetEditFRate::AssetEditFRate(AssetEditWindow *fwindow, char *text, int x, int y)
697  : BC_TextBox(x, y, 100, 1, text)
698 {
699         this->fwindow = fwindow;
700 }
701
702 int AssetEditFRate::handle_event()
703 {
704         Asset *asset = fwindow->asset_edit->changed_params;
705         asset->frame_rate = atof(get_text());
706         return 1;
707 }
708
709 Interlaceautofix::Interlaceautofix(MWindow *mwindow,AssetEditWindow *fwindow, int x, int y)
710  : BC_CheckBox(x, y,
711         ((Asset *)fwindow->asset_edit->indexable)->interlace_autofixoption,
712         _("Automatically Fix Interlacing"))
713 {
714         this->fwindow = fwindow;
715         this->mwindow = mwindow;
716 }
717
718 Interlaceautofix::~Interlaceautofix()
719 {
720 }
721
722 int Interlaceautofix::handle_event()
723 {
724         Asset *asset = (Asset *)fwindow->asset_edit->indexable;
725         asset->interlace_autofixoption = get_value();
726         showhideotherwidgets();
727         return 1;
728 }
729
730 void Interlaceautofix::showhideotherwidgets()
731 {
732   int thevalue = get_value();
733
734         Asset *asset = (Asset *)fwindow->asset_edit->indexable;
735         if (thevalue == BC_ILACE_AUTOFIXOPTION_AUTO)
736           {
737             this->ilacemode_textbox->enable();
738             this->ilacemode_listbox->enable();
739             this->ilacefixmethod_textbox->disable();
740             this->ilacefixmethod_listbox->disable();
741             int xx = ilaceautofixmethod(mwindow->edl->session->interlace_mode,asset->interlace_mode);
742             ilacefixmethod_to_text(string,xx);
743             this->ilacefixmethod_textbox->update(string);
744           }
745         if (thevalue == BC_ILACE_AUTOFIXOPTION_MANUAL)
746           {
747             this->ilacemode_textbox->disable();
748             this->ilacemode_listbox->disable();
749             this->ilacefixmethod_textbox->enable();
750             this->ilacefixmethod_listbox->enable();
751             ilacefixmethod_to_text(string,asset->interlace_fixmethod);
752             this->ilacefixmethod_textbox->update(string);
753           }
754 }
755
756 InterlacefixmethodItem::InterlacefixmethodItem(const char *text, int value)
757  : BC_ListBoxItem(text)
758 {
759         this->value = value;
760 }
761
762 InterlacefixmethodPulldown::InterlacefixmethodPulldown(MWindow *mwindow,
763                 BC_TextBox *output_text, int *output_value,
764                 ArrayList<BC_ListBoxItem*> *data, int x, int y)
765  : BC_ListBox(x, y, 200, 150, LISTBOX_TEXT, data, 0, 0, 1, 0, 1)
766 {
767         this->mwindow = mwindow;
768         this->output_text = output_text;
769         this->output_value = output_value;
770         output_text->update(interlacefixmethod_to_text());
771 }
772
773 int InterlacefixmethodPulldown::handle_event()
774 {
775         output_text->update(get_selection(0, 0)->get_text());
776         *output_value = ((InterlacefixmethodItem*)get_selection(0, 0))->value;
777         return 1;
778 }
779
780 const char* InterlacefixmethodPulldown::interlacefixmethod_to_text()
781 {
782         ilacefixmethod_to_text(this->string,*output_value);
783         return (this->string);
784 }
785
786 AssetEditILaceautofixoption::AssetEditILaceautofixoption(AssetEditWindow *fwindow, char *text, int thedefault, int x, int y, int w)
787  : BC_TextBox(x, y, w, 1, text)
788 {
789         this->fwindow = fwindow;
790         this->thedefault = thedefault;
791 }
792
793 int AssetEditILaceautofixoption::handle_event()
794 {
795         Asset *asset = (Asset *)fwindow->asset_edit->indexable;
796         asset->interlace_autofixoption = ilaceautofixoption_from_text(get_text(), this->thedefault);
797         return 1;
798 }
799
800
801 AssetEditILacemode::AssetEditILacemode(AssetEditWindow *fwindow, const char *text, int thedefault, int x, int y, int w)
802  : BC_TextBox(x, y, w, 1, text)
803 {
804         this->fwindow = fwindow;
805         this->thedefault = thedefault;
806 }
807
808 int AssetEditILacemode::handle_event()
809 {
810         Asset *asset = (Asset *)fwindow->asset_edit->indexable;
811         asset->interlace_mode = ilacemode_from_text(get_text(),this->thedefault);
812         return 1;
813 }
814
815 AssetEditInterlacemodePulldown::AssetEditInterlacemodePulldown(MWindow *mwindow,
816                 BC_TextBox *output_text,
817                 int *output_value,
818                 ArrayList<BC_ListBoxItem*> *data,
819                 Interlaceautofix *fixoption_chkboxw,
820                 int x,
821                 int y)
822  : BC_ListBox(x,
823         y,
824         200,
825         150,
826         LISTBOX_TEXT,
827         data,
828         0,
829         0,
830         1,
831         0,
832         1)
833 {
834         this->fixoption_chkbox = fixoption_chkboxw;
835         this->mwindow = mwindow;
836         this->output_text = output_text;
837         this->output_value = output_value;
838         output_text->update(interlacemode_to_text());
839 }
840
841 int AssetEditInterlacemodePulldown::handle_event()
842 {
843         output_text->update(get_selection(0, 0)->get_text());
844         *output_value = ((InterlacemodeItem*)get_selection(0, 0))->value;
845         fixoption_chkbox->showhideotherwidgets();
846         return 1;
847 }
848
849 char* AssetEditInterlacemodePulldown::interlacemode_to_text()
850 {
851         ilacemode_to_text(this->string,*output_value);
852         return (this->string);
853 }
854
855 AssetEditILacefixmethod::AssetEditILacefixmethod(AssetEditWindow *fwindow, const char *text, int thedefault, int x, int y, int w)
856  : BC_TextBox(x, y, w, 1, text)
857 {
858         this->fwindow = fwindow;
859         this->thedefault = thedefault;
860 }
861
862 int AssetEditILacefixmethod::handle_event()
863 {
864         Asset *asset = fwindow->asset_edit->changed_params;
865         asset->interlace_fixmethod = ilacefixmethod_from_text(get_text(),this->thedefault);
866         return 1;
867 }
868
869 AssetEditHeader::AssetEditHeader(AssetEditWindow *fwindow, char *text, int x, int y)
870  : BC_TextBox(x, y, 100, 1, text)
871 {
872         this->fwindow = fwindow;
873 }
874
875 int AssetEditHeader::handle_event()
876 {
877         Asset *asset = fwindow->asset_edit->changed_params;
878         asset->header = atol(get_text());
879         return 1;
880 }
881
882 AssetEditByteOrderLOHI::AssetEditByteOrderLOHI(AssetEditWindow *fwindow,
883         int value,
884         int x,
885         int y)
886  : BC_Radial(x, y, value, _("Lo-Hi"))
887 {
888         this->fwindow = fwindow;
889 }
890
891 int AssetEditByteOrderLOHI::handle_event()
892 {
893         Asset *asset = fwindow->asset_edit->changed_params;
894         asset->byte_order = 1;
895         fwindow->hilo->update(0);
896         update(1);
897         return 1;
898 }
899
900 AssetEditByteOrderHILO::AssetEditByteOrderHILO(AssetEditWindow *fwindow,
901         int value,
902         int x,
903         int y)
904  : BC_Radial(x, y, value, _("Hi-Lo"))
905 {
906         this->fwindow = fwindow;
907 }
908
909 int AssetEditByteOrderHILO::handle_event()
910 {
911         Asset *asset = fwindow->asset_edit->changed_params;
912         asset->byte_order = 0;
913         fwindow->lohi->update(0);
914         update(1);
915         return 1;
916 }
917
918 AssetEditSigned::AssetEditSigned(AssetEditWindow *fwindow,
919         int value,
920         int x,
921         int y)
922  : BC_CheckBox(x, y, value, _("Values are signed"))
923 {
924         this->fwindow = fwindow;
925 }
926
927 int AssetEditSigned::handle_event()
928 {
929         Asset *asset = fwindow->asset_edit->changed_params;
930         asset->signed_ = get_value();
931         return 1;
932 }
933
934
935
936
937
938
939
940 AssetEditPathText::AssetEditPathText(AssetEditWindow *fwindow, int y)
941  : BC_TextBox(5, y, 300, 1, fwindow->asset_edit->changed_params->path)
942 {
943         this->fwindow = fwindow;
944 }
945 AssetEditPathText::~AssetEditPathText()
946 {
947 }
948 int AssetEditPathText::handle_event()
949 {
950         strcpy(fwindow->asset_edit->changed_params->path, get_text());
951         return 1;
952 }
953
954 AssetEditPath::AssetEditPath(MWindow *mwindow, AssetEditWindow *fwindow,
955         BC_TextBox *textbox, int y, const char *text,
956         const char *window_title, const char *window_caption)
957  : BrowseButton(mwindow, fwindow, textbox, 310, y, text,
958         window_title, window_caption, 0)
959 {
960         this->fwindow = fwindow;
961 }
962
963 AssetEditPath::~AssetEditPath() {}
964
965
966
967
968
969
970 AssetEditFormat::AssetEditFormat(AssetEditWindow *fwindow, char* default_, int y)
971  : FormatPopup(fwindow->mwindow->plugindb, 90, y)
972 {
973         this->fwindow = fwindow;
974 }
975 AssetEditFormat::~AssetEditFormat()
976 {
977 }
978 int AssetEditFormat::handle_event()
979 {
980         Asset *asset = fwindow->asset_edit->changed_params;
981         asset->format = File::strtoformat(fwindow->mwindow->plugindb,
982                 get_selection(0, 0)->get_text());
983         return 1;
984 }
985
986
987
988
989 DetailAssetButton::DetailAssetButton(AssetEditWindow *fwindow, int x, int y)
990  : BC_GenericButton(x, y, _("Detail"))
991 {
992         this->fwindow = fwindow;
993         set_underline(0);
994 }
995
996 DetailAssetButton::~DetailAssetButton()
997 {
998 }
999
1000 int DetailAssetButton::handle_event()
1001 {
1002         fwindow->show_info_detail();
1003         return 1;
1004 }
1005
1006 DetailAssetWindow::DetailAssetWindow(MWindow *mwindow, Asset *asset)
1007  : BC_Window(_("Asset Detail"),
1008         mwindow->gui->get_abs_cursor_x(1) - 600/2,
1009         mwindow->gui->get_abs_cursor_y(1) - 500/2,
1010         600, 500)
1011 {
1012         this->mwindow = mwindow;
1013         this->asset = asset;
1014         asset->add_user();
1015         info[0] = 0;
1016         text = 0;
1017 }
1018
1019 DetailAssetWindow::~DetailAssetWindow()
1020 {
1021         asset->remove_user();
1022         delete text;
1023 }
1024
1025 DetailAssetThread::DetailAssetThread(MWindow *mwindow)
1026  : Thread(1, 0, 0)
1027 {
1028         this->mwindow = mwindow;
1029         dwindow = 0;
1030 }
1031
1032 DetailAssetThread::~DetailAssetThread()
1033 {
1034         stop();
1035 }
1036
1037 void DetailAssetThread::stop()
1038 {
1039         if( Thread::running() ) {
1040                 dwindow->lock_window("DetailAssetThread::stop");
1041                 dwindow->set_done(1);
1042                 dwindow->unlock_window();
1043                 Thread::join();
1044         }
1045 }
1046
1047 void DetailAssetWindow::create_objects()
1048 {
1049         int y = 10, x = 10;
1050         char file_name[BCTEXTLEN];
1051         int len = sizeof(info);
1052         strncpy(info,_("no info available"),len);
1053         if( !mwindow->preferences->get_asset_file_path(asset, file_name) ) {
1054                 switch( asset->format ) {
1055                 case FILE_MPEG:
1056                         FileMPEG::get_info(asset->path, file_name, &info[0],len);
1057                         break;
1058                 case FILE_FFMPEG:
1059                         FileFFMPEG::get_info(asset->path, &info[0],len);
1060                         break;
1061                 }
1062         }
1063         lock_window("DetailAssetThread::create_objects");
1064         text = new BC_ScrollTextBox(this, x, y, get_w()-32, 23, info, -len);
1065         text->create_objects();  text->set_text_row(0);
1066         add_subwindow(new BC_OKButton(this));
1067         show_window();
1068         unlock_window();
1069 }
1070
1071 void DetailAssetThread::start(Asset *asset)
1072 {
1073         stop();
1074         delete dwindow;
1075         dwindow = new DetailAssetWindow(mwindow, asset);
1076         Thread::start();
1077 }
1078
1079 void DetailAssetThread::run()
1080 {
1081 // Get length from TOC
1082         dwindow->create_objects();
1083         dwindow->run_window();
1084         delete dwindow;
1085         dwindow = 0;
1086 }
1087
1088
1089
1090
1091
1092 AssetEditReelName::AssetEditReelName(AssetEditWindow *fwindow, int x, int y)
1093  : BC_TextBox(x, y, 300, 1,
1094         ((Asset *)fwindow->asset_edit->indexable)->reel_name,
1095         1, MEDIUMFONT, 1)
1096 {
1097         this->fwindow = fwindow;
1098 }
1099 AssetEditReelName::~AssetEditReelName()
1100 {
1101 }
1102 int AssetEditReelName::handle_event()
1103 {
1104         Asset *asset = fwindow->asset_edit->changed_params;
1105         strcpy(asset->reel_name, get_text());
1106         return 1;
1107 }
1108
1109
1110
1111
1112
1113 AssetEditReelNumber::AssetEditReelNumber(AssetEditWindow *fwindow, int x, int y)
1114  : BC_TextBox(x, y, 200, 1, ((Asset *)fwindow->asset_edit->indexable)->reel_number)
1115 {
1116         this->fwindow = fwindow;
1117 }
1118 AssetEditReelNumber::~AssetEditReelNumber()
1119 {
1120 }
1121 int AssetEditReelNumber::handle_event()
1122 {
1123         Asset *asset = fwindow->asset_edit->changed_params;
1124         asset->reel_number = atoi(get_text());
1125         return 1;
1126 }
1127
1128
1129
1130
1131
1132 AssetEditTCStartTextBox::AssetEditTCStartTextBox(AssetEditWindow *fwindow, int value, int x, int y, int multiplier)
1133  : BC_TextBox(x, y, 30, 1, value)
1134 {
1135         this->fwindow = fwindow;
1136         this->multiplier = multiplier;
1137         previous = value;
1138 }
1139 AssetEditTCStartTextBox::~AssetEditTCStartTextBox()
1140 {
1141 }
1142 int AssetEditTCStartTextBox::handle_event()
1143 {
1144         Asset *asset = fwindow->asset_edit->changed_params;
1145         asset->tcstart -= previous * multiplier;
1146         asset->tcstart += atoi(get_text()) * multiplier;
1147         previous = atoi(get_text());
1148         return 1;
1149 }
1150
1151