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