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