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