add timecode units/alignment/probe, add prefs auto_rotate,
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / assetedit.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2010 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "asset.h"
23 #include "assetedit.h"
24 #include "awindow.h"
25 #include "awindowgui.h"
26 #include "bcprogressbox.h"
27 #include "bcsignals.h"
28 #include "bitspopup.h"
29 #include "cache.h"
30 #include "clip.h"
31 #include "cplayback.h"
32 #include "cwindow.h"
33 #include "edl.h"
34 #include "edlsession.h"
35 #include "file.h"
36 #include "filempeg.h"
37 #include "fileffmpeg.h"
38 #include "filesystem.h"
39 #include "indexable.h"
40 #include "indexfile.h"
41 #include "indexstate.h"
42 #include "language.h"
43 #include "mainindexes.h"
44 #include "mwindow.h"
45 #include "mwindowgui.h"
46 #include "theme.h"
47 #include "new.h"
48 #include "preferences.h"
49 #include "resizetrackthread.h"
50 #include "removefile.h"
51 #include "theme.h"
52 #include "transportque.h"
53 #include "interlacemodes.h"
54 #include "edl.h"
55 #include "edlsession.h"
56
57 #include <string.h>
58
59
60
61 AssetEdit::AssetEdit(MWindow *mwindow)
62  : BC_DialogThread()
63 {
64         this->mwindow = mwindow;
65         indexable = 0;
66         window = 0;
67         changed_params = new Asset;
68         //set_synchronous(0);
69 }
70
71
72 AssetEdit::~AssetEdit()
73 {
74         close_window();
75         changed_params->remove_user();
76 }
77
78
79 void AssetEdit::edit_asset(Indexable *indexable, int x, int y)
80 {
81         close_window();
82         this->indexable = indexable;
83         this->indexable->add_user();
84         this->x = x;  this->y = y;
85
86 // Copy asset parameters into temporary storage for editing.
87         if( indexable->is_asset ) {
88                 changed_params->copy_from((Asset*)indexable, 0);
89         }
90         else {
91                 EDL *nested_edl = (EDL*)indexable;
92                 strcpy(changed_params->path, nested_edl->path);
93                 changed_params->sample_rate = nested_edl->session->sample_rate;
94                 changed_params->channels = nested_edl->session->audio_channels;
95
96 //printf("AssetEdit::edit_asset %d %f\n", __LINE__, nested_edl->session->frame_rate);
97                 changed_params->frame_rate = nested_edl->session->frame_rate;
98                 changed_params->width = nested_edl->session->output_w;
99                 changed_params->height = nested_edl->session->output_h;
100         }
101
102         BC_DialogThread::start();
103 }
104
105 void AssetEdit::handle_done_event(int result)
106 {
107         if( !result && changed_params->timecode >= 0 ) {
108                 double rate = indexable->get_frame_rate();
109                 changed_params->timecode =
110                         atoi(window->tc_hrs->get_text()) * 3600 +
111                         atoi(window->tc_mins->get_text()) * 60 +
112                         atoi(window->tc_secs->get_text()) +
113                         atoi(window->tc_rest->get_text()) / rate;
114         }
115 }
116
117 void AssetEdit::handle_close_event(int result)
118 {
119         if( !result ) {
120                 int changed = 0;
121                 Asset *asset = 0;
122                 EDL *nested_edl = 0;
123
124                 if( indexable->is_asset ) {
125                         asset = (Asset*)indexable;
126                         if( !changed_params->equivalent(*asset, 1, 1, mwindow->edl) )
127                                 changed = 1;
128                 }
129                 else {
130                         nested_edl = (EDL*)indexable;
131                         if( strcmp(changed_params->path, nested_edl->path)
132 //                              || changed_params->sample_rate != nested_edl->session->sample_rate
133 //                              || !EQUIV(changed_params->frame_rate, nested_edl->session->frame_rate
134                         )
135                                 changed = 1;
136                 }
137                 if( changed ) {
138                         mwindow->gui->lock_window();
139 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
140
141 // Omit index status from copy since an index rebuild may have been
142 // happening when new_asset was created but not be happening anymore.
143                         if( asset ) {
144                                 mwindow->remove_from_caches(asset);
145 //printf("AssetEdit::handle_close_event %d %f\n", __LINE__, asset->get_frame_rate());
146                                 asset->copy_from(changed_params, 0);
147 //printf("AssetEdit::handle_close_event %d %d %d\n", __LINE__, changed_params->bits, asset->bits);
148                         }
149                         else {
150                                 strcpy(nested_edl->path, changed_params->path);
151 // Other parameters can't be changed because they're defined in the other EDL
152 //              nested_edl->session->frame_rate = changed_params->frame_rate;
153 //              nested_edl->session->sample_rate = changed_params->sample_rate;
154                         }
155 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
156
157                         mwindow->gui->update(0, FORCE_REDRAW, 0, 0, 0, 0, 0);
158 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
159
160 // Start index rebuilding
161                         if( (asset && asset->audio_data) || nested_edl) {
162                                 char source_filename[BCTEXTLEN];
163                                 char index_filename[BCTEXTLEN];
164                                 IndexFile::get_index_filename(source_filename,
165                                         mwindow->preferences->index_directory,
166                                         index_filename,
167                                         indexable->path);
168                                 remove_file(index_filename);
169                                 indexable->index_state->index_status = INDEX_NOTTESTED;
170                                 mwindow->mainindexes->add_indexable(indexable);
171                                 mwindow->mainindexes->start_build();
172                         }
173                         mwindow->gui->unlock_window();
174 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
175                         mwindow->awindow->gui->update_picon(indexable);
176                         mwindow->awindow->gui->async_update_assets();
177
178                         mwindow->restart_brender();
179                         mwindow->sync_parameters(CHANGE_ALL);
180 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
181                 }
182         }
183
184         this->indexable->remove_user();
185         this->indexable = 0;
186 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
187 }
188
189 BC_Window* AssetEdit::new_gui()
190 {
191         window = new AssetEditWindow(mwindow, this);
192         window->create_objects();
193         return window;
194 }
195
196 int AssetEdit::window_height()
197 {
198         int h = yS(128 + 64);
199         if( indexable->have_audio() ) h += yS(200);
200         if( indexable->have_video() ) {
201                 h += yS(160);
202                 if( indexable->is_asset ) {
203                         Asset *asset = (Asset *)indexable;
204                         if( File::can_scale_input(asset) )
205                                 h += yS(42);
206                         if( asset->timecode >= 0 )
207                                 h += yS(32);
208                 }
209         }
210         return yS(h);
211 }
212
213 #define AEW_W xS(450)
214
215 AssetEditWindow::AssetEditWindow(MWindow *mwindow, AssetEdit *asset_edit)
216  : BC_Window(_(PROGRAM_NAME ": Asset Info"),
217         asset_edit->x - AEW_W/2, asset_edit->y - asset_edit->window_height()/2,
218         AEW_W, asset_edit->window_height(), 0, 0, 1)
219 {
220         this->mwindow = mwindow;
221         this->asset_edit = asset_edit;
222         bitspopup = 0;
223         path_text = 0;
224         path_button = 0;
225         hilo = 0;
226         lohi = 0;
227         allow_edits = 0;
228         detail_dialog = 0;
229         win_width = 0;
230         win_height = 0;
231 }
232
233
234
235
236
237 AssetEditWindow::~AssetEditWindow()
238 {
239         lock_window("AssetEditWindow::~AssetEditWindow");
240         delete bitspopup;
241         delete detail_dialog;
242         unlock_window();
243 }
244
245
246
247
248 void AssetEditWindow::create_objects()
249 {
250         int xpad10 = xS(10);
251         int ypad5 = yS(5), ypad10 = yS(10), ypad20 = yS(20), ypad30 = yS(30);
252         int y = ypad10, x = xpad10, x1 = xpad10, x2 = xS(190);
253         char string[BCTEXTLEN];
254         FileSystem fs;
255         BC_Title *title;
256         Asset *asset = 0;
257         EDL *nested_edl = 0;
258
259         if( asset_edit->indexable->is_asset )
260                 asset = (Asset*)asset_edit->indexable;
261         else
262                 nested_edl = (EDL*)asset_edit->indexable;
263
264         allow_edits = asset && asset->format == FILE_PCM ? 1 : 0;
265         int vmargin = yS(allow_edits ? 30 : 20);
266         lock_window("AssetEditWindow::create_objects");
267
268         add_subwindow(path_text = new AssetEditPathText(this, y));
269         add_subwindow(path_button = new AssetEditPath(mwindow, this,
270                 path_text, y, asset_edit->indexable->path,
271                 _(PROGRAM_NAME ": Asset path"),
272                 _("Select a file for this asset:")));
273         y += yS(30);
274
275         if( asset ) {
276                 add_subwindow(new BC_Title(x, y, _("File format:")));
277                 x = x2;
278                 add_subwindow(new BC_Title(x, y, File::formattostr(asset->format),
279                         MEDIUMFONT,
280                         mwindow->theme->assetedit_color));
281                 x = x1;
282                 y += ypad20;
283
284                 int64_t bytes = fs.get_size(asset->path);
285                 add_subwindow(new BC_Title(x, y, _("Bytes:")));
286                 sprintf(string, "%jd", bytes);
287                 Units::punctuate(string);
288
289
290                 add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
291                 if( asset->format == FILE_MPEG || asset->format == FILE_FFMPEG ) {
292                         detail_dialog = new DetailAssetDialog(mwindow);
293                         BC_GenericButton *detail = new DetailAssetButton(this, x2+xS(120), y);
294                         add_subwindow(detail);
295                 }
296
297                 y += ypad20;
298                 x = x1;
299
300                 double length = 0.;
301                 y += ypad20;
302                 x = x1;
303
304                 if( asset->audio_length > 0 )
305                         length = (double)asset->audio_length / asset->sample_rate;
306                 if( asset->video_length > 0 )
307                         length = MAX(length, (double)asset->video_length / asset->frame_rate);
308                 int64_t bitrate;
309                 if( !EQUIV(length, 0) )
310                         bitrate = (int64_t)(bytes * 8 / length);
311                 else
312                         bitrate = bytes;
313                 add_subwindow(new BC_Title(x, y, _("Bitrate (bits/sec):")));
314                 sprintf(string, "%jd", bitrate);
315
316                 Units::punctuate(string);
317                 add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
318
319                 y += ypad30;
320                 x = x1;
321         }
322
323         if( (asset && asset->audio_data) || nested_edl ) {
324                 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
325                 y += ypad5;
326
327                 add_subwindow(new BC_Title(x, y, _("Audio:"), LARGEFONT, RED));
328
329                 y += ypad30;
330
331                 if( asset ) {
332                         if( asset->get_compression_text(1, 0) ) {
333                                 add_subwindow(new BC_Title(x, y, _("Compression:")));
334                                 x = x2;
335                                 add_subwindow(new BC_Title(x,
336                                         y,
337                                         asset->get_compression_text(1, 0),
338                                         MEDIUMFONT,
339                                         mwindow->theme->assetedit_color));
340                                 y += vmargin;
341                                 x = x1;
342                         }
343                 }
344
345                 add_subwindow(new BC_Title(x, y, _("Channels:")));
346                 sprintf(string, "%d", asset_edit->changed_params->channels);
347
348                 x = x2;
349                 if( allow_edits ) {
350                         BC_TumbleTextBox *textbox = new AssetEditChannels(this,
351                                 string,
352                                 x,
353                                 y);
354                         textbox->create_objects();
355                         y += vmargin;
356                 }
357                 else {
358                         add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
359                         y += ypad20;
360                 }
361
362                 x = x1;
363                 add_subwindow(new BC_Title(x, y, _("Sample rate:")));
364                 sprintf(string, "%d", asset_edit->changed_params->sample_rate);
365
366                 x = x2;
367                 if( asset ) {
368                         BC_TextBox *textbox;
369                         add_subwindow(textbox = new AssetEditRate(this, string, x, y));
370                         x += textbox->get_w();
371                         add_subwindow(new SampleRatePulldown(mwindow, textbox, x, y));
372                 }
373                 else {
374                         add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
375                 }
376
377                 y += ypad30;
378                 x = x1;
379
380                 if( asset ) {
381                         add_subwindow(new BC_Title(x, y, _("Bits:")));
382                         x = x2;
383                         if( allow_edits ) {
384                                 bitspopup = new BitsPopup(this, x, y,
385                                         &asset_edit->changed_params->bits,
386                                         1, 1, 1, 0, 1);
387                                 bitspopup->create_objects();
388                         }
389                         else
390                                 add_subwindow(new BC_Title(x, y, File::bitstostr(asset->bits), MEDIUMFONT, mwindow->theme->assetedit_color));
391
392
393                         x = x1;
394                         y += vmargin;
395                         add_subwindow(new BC_Title(x, y, _("Header length:")));
396                         sprintf(string, "%d", asset->header);
397
398                         x = x2;
399                         if( allow_edits )
400                                 add_subwindow(new AssetEditHeader(this, string, x, y));
401                         else
402                                 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
403
404                         y += vmargin;
405                         x = x1;
406
407                         add_subwindow(new BC_Title(x, y, _("Byte order:")));
408
409                         if( allow_edits )
410                         {
411                                 x = x2;
412
413                                 add_subwindow(lohi = new AssetEditByteOrderLOHI(this,
414                                         asset->byte_order, x, y));
415                                 x += xS(70);
416                                 add_subwindow(hilo = new AssetEditByteOrderHILO(this,
417                                         !asset->byte_order, x, y));
418                                 y += vmargin;
419                         }
420                         else {
421                                 x = x2;
422                                 if( asset->byte_order )
423                                         add_subwindow(new BC_Title(x, y, _("Lo-Hi"), MEDIUMFONT, mwindow->theme->assetedit_color));
424                                 else
425                                         add_subwindow(new BC_Title(x, y, _("Hi-Lo"), MEDIUMFONT, mwindow->theme->assetedit_color));
426                                 y += vmargin;
427                         }
428
429
430                         x = x1;
431                         if( allow_edits ) {
432         //                      add_subwindow(new BC_Title(x, y, _("Values are signed:")));
433                                 add_subwindow(new AssetEditSigned(this, asset->signed_, x, y));
434                         }
435                         else {
436                                 if( !asset->signed_ && asset->bits == 8 )
437                                         add_subwindow(new BC_Title(x, y, _("Values are unsigned")));
438                                 else
439                                         add_subwindow(new BC_Title(x, y, _("Values are signed")));
440                         }
441
442                         y += ypad30;
443                 }
444         }
445
446         x = x1;
447         if( (asset && asset->video_data) || nested_edl ) {
448                 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
449                 y += ypad5;
450
451                 add_subwindow(new BC_Title(x, y, _("Video:"), LARGEFONT, RED));
452                 y += ypad30;
453                 x = x1;
454
455
456                 if( asset && asset->get_compression_text(0,1) ) {
457                         add_subwindow(new BC_Title(x, y, _("Compression:")));
458                         x = x2;
459                         add_subwindow(new BC_Title(x,
460                                 y,
461                                 asset->get_compression_text(0,1),
462                                 MEDIUMFONT,
463                                 mwindow->theme->assetedit_color));
464                         y += vmargin;
465                         x = x1;
466                 }
467
468                 add_subwindow(new BC_Title(x, y, _("Frame rate:")));
469                 x = x2;
470                 sprintf(string, "%.4f", asset_edit->changed_params->frame_rate);
471
472 //printf("AssetEditWindow::create_objects %d %f\n", __LINE__, asset_edit->changed_params->frame_rate);
473                 if( asset ) {
474                         BC_TextBox *framerate;
475                         add_subwindow(framerate = new AssetEditFRate(this, string, x, y));
476                         x += framerate->get_w();
477                         add_subwindow(new FrameRatePulldown(mwindow, framerate, x, y));
478                 }
479                 else {
480                         add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
481                 }
482
483                 y += ypad30;
484                 x = x1;
485                 add_subwindow(new BC_Title(x, y, _("Width:")));
486                 x = x2;
487                 sprintf(string, "%d", asset_edit->changed_params->width);
488                 win_width = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color);
489                 add_subwindow(win_width);
490
491                 y += vmargin;
492                 x = x1;
493                 add_subwindow(new BC_Title(x, y, _("Height:")));
494                 x = x2;
495                 sprintf(string, "%d", asset_edit->changed_params->height);
496                 win_height = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color);
497                 add_subwindow(win_height);
498                 y += win_height->get_h() + ypad5;
499
500                 if( asset && File::can_scale_input(asset) ) {
501                         y += ypad5;
502                         x = x1;
503                         add_subwindow(new BC_Title(x, y, _("Actual width:")));
504                         x = x2;
505                         sprintf(string, "%d", asset->actual_width);
506                         add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
507
508                         BC_GenericButton *resize = new ResizeAssetButton(this, x+xS(64), y);
509                         add_subwindow(resize);
510
511                         y += vmargin;
512                         x = x1;
513                         add_subwindow(new BC_Title(x, y, _("Actual height:")));
514                         x = x2;
515                         sprintf(string, "%d", asset->actual_height);
516                         title = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color);
517                         add_subwindow(title);
518                         y += title->get_h() + ypad5;
519                 }
520                 if( asset ) {
521                         add_subwindow(title = new BC_Title(x1, y, _("Asset's interlacing:")));
522                         ilacemode_to_text(string, asset->interlace_mode);
523                         AssetEditILacemode *edit_ilace_mode;
524                         add_subwindow(edit_ilace_mode = new AssetEditILacemode(this, string, x2, y, xS(160)));
525                         add_subwindow(new AssetEditInterlacemodePulldown(mwindow, edit_ilace_mode,
526                                 &asset_edit->changed_params->interlace_mode,
527                                 (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_asset_modes,
528                                 x2 + edit_ilace_mode->get_w(), y));
529                         y += title->get_h() + yS(15);
530                 }
531         }
532         if( asset && asset->timecode >= 0 ) {
533                 char text[BCSTRLEN], *tc = text;
534                 Units::totext(tc, asset->timecode, TIME_HMSF,
535                         asset->sample_rate, asset->frame_rate);
536                 const char *hrs  = tc;  tc = strchr(tc, ':');  *tc++ = 0;
537                 const char *mins = tc;  tc = strchr(tc, ':');  *tc++ = 0;
538                 const char *secs = tc;  tc = strchr(tc, ':');  *tc++ = 0;
539                 const char *rest = tc;
540                 int padw = BC_Title::calculate_w(this, ":", MEDIUMFONT);
541                 int fldw = BC_Title::calculate_w(this, "00", MEDIUMFONT) + 5;
542                 int hdrw = fldw + padw;  x = x2;
543                 add_subwindow(title = new BC_Title(x, y, _("hour"), SMALLFONT));  x += hdrw;
544                 add_subwindow(title = new BC_Title(x, y, _("min"),  SMALLFONT));  x += hdrw;
545                 add_subwindow(title = new BC_Title(x, y, _("sec"),  SMALLFONT));  x += hdrw;
546                 add_subwindow(title = new BC_Title(x, y, _("frms"), SMALLFONT));
547                 y += title->get_h() + xS(3);
548                 add_subwindow(title = new BC_Title(x1, y, _("Time Code Start:")));
549                 add_subwindow(tc_hrs = new BC_TextBox(x=x2, y, fldw, 1, hrs));
550                 add_subwindow(new BC_Title(x += tc_hrs->get_w(), y, ":"));
551                 add_subwindow(tc_mins = new BC_TextBox(x += padw, y, fldw, 1, mins));
552                 add_subwindow(new BC_Title(x += tc_mins->get_w(), y, ":"));
553                 add_subwindow(tc_secs = new BC_TextBox(x += padw, y , fldw, 1, secs));
554                 add_subwindow(new BC_Title(x += tc_secs->get_w(), y, ":"));
555                 add_subwindow(tc_rest = new BC_TextBox(x += 10, y, fldw, 1, rest));
556                 y += title->get_h() + ypad5;
557         }
558
559         add_subwindow(new BC_OKButton(this));
560         add_subwindow(new BC_CancelButton(this));
561         show_window();
562         unlock_window();
563 }
564
565 void AssetEditWindow::show_info_detail()
566 {
567         int cur_x, cur_y;
568         get_abs_cursor(cur_x, cur_y, 0);
569         detail_dialog->start((Asset*)asset_edit->indexable, cur_x, cur_y);
570 }
571
572
573 AssetEditChannels::AssetEditChannels(AssetEditWindow *fwindow,
574         char *text,
575         int x,
576         int y)
577  : BC_TumbleTextBox(fwindow, (int)atol(text), (int)1,
578                 (int)MAXCHANNELS, x, y, xS(50))
579 {
580         this->fwindow = fwindow;
581 }
582
583 int AssetEditChannels::handle_event()
584 {
585         Asset *asset = fwindow->asset_edit->changed_params;
586         asset->channels = atol(get_text());
587         return 1;
588 }
589
590 AssetEditRate::AssetEditRate(AssetEditWindow *fwindow, char *text, int x, int y)
591  : BC_TextBox(x, y, xS(100), 1, text)
592 {
593         this->fwindow = fwindow;
594 }
595
596 int AssetEditRate::handle_event()
597 {
598         Asset *asset = fwindow->asset_edit->changed_params;
599         asset->sample_rate = atol(get_text());
600         return 1;
601 }
602
603 AssetEditFRate::AssetEditFRate(AssetEditWindow *fwindow, char *text, int x, int y)
604  : BC_TextBox(x, y, xS(100), 1, text)
605 {
606         this->fwindow = fwindow;
607 }
608
609 int AssetEditFRate::handle_event()
610 {
611         Asset *asset = fwindow->asset_edit->changed_params;
612         asset->frame_rate = atof(get_text());
613         return 1;
614 }
615
616
617 AssetEditILacemode::AssetEditILacemode(AssetEditWindow *fwindow, const char *text, int x, int y, int w)
618  : BC_TextBox(x, y, w, 1, text)
619 {
620         this->fwindow = fwindow;
621 }
622
623 int AssetEditILacemode::handle_event()
624 {
625         Asset *asset = fwindow->asset_edit->changed_params;
626         asset->interlace_mode = ilacemode_from_text(get_text(), ILACE_ASSET_MODEDEFAULT);
627         return 1;
628 }
629
630 AssetEditInterlacemodePulldown::AssetEditInterlacemodePulldown(MWindow *mwindow,
631                 BC_TextBox *output_text, int *output_value,
632                 ArrayList<BC_ListBoxItem*> *data, int x, int y)
633  : BC_ListBox(x, y, xS(160), yS(80), LISTBOX_TEXT, data, 0, 0, 1, 0, 1)
634 {
635         this->mwindow = mwindow;
636         this->output_text = output_text;
637         this->output_value = output_value;
638         output_text->update(interlacemode_to_text());
639 }
640
641 int AssetEditInterlacemodePulldown::handle_event()
642 {
643         output_text->update(get_selection(0, 0)->get_text());
644         *output_value = ((InterlacemodeItem*)get_selection(0, 0))->value;
645         return 1;
646 }
647
648 char* AssetEditInterlacemodePulldown::interlacemode_to_text()
649 {
650         ilacemode_to_text(this->string,*output_value);
651         return (this->string);
652 }
653
654 AssetEditHeader::AssetEditHeader(AssetEditWindow *fwindow, char *text, int x, int y)
655  : BC_TextBox(x, y, xS(100), 1, text)
656 {
657         this->fwindow = fwindow;
658 }
659
660 int AssetEditHeader::handle_event()
661 {
662         Asset *asset = fwindow->asset_edit->changed_params;
663         asset->header = atol(get_text());
664         return 1;
665 }
666
667 AssetEditByteOrderLOHI::AssetEditByteOrderLOHI(AssetEditWindow *fwindow,
668         int value,
669         int x,
670         int y)
671  : BC_Radial(x, y, value, _("Lo-Hi"))
672 {
673         this->fwindow = fwindow;
674 }
675
676 int AssetEditByteOrderLOHI::handle_event()
677 {
678         Asset *asset = fwindow->asset_edit->changed_params;
679         asset->byte_order = 1;
680         fwindow->hilo->update(0);
681         update(1);
682         return 1;
683 }
684
685 AssetEditByteOrderHILO::AssetEditByteOrderHILO(AssetEditWindow *fwindow,
686         int value,
687         int x,
688         int y)
689  : BC_Radial(x, y, value, _("Hi-Lo"))
690 {
691         this->fwindow = fwindow;
692 }
693
694 int AssetEditByteOrderHILO::handle_event()
695 {
696         Asset *asset = fwindow->asset_edit->changed_params;
697         asset->byte_order = 0;
698         fwindow->lohi->update(0);
699         update(1);
700         return 1;
701 }
702
703 AssetEditSigned::AssetEditSigned(AssetEditWindow *fwindow,
704         int value,
705         int x,
706         int y)
707  : BC_CheckBox(x, y, value, _("Values are signed"))
708 {
709         this->fwindow = fwindow;
710 }
711
712 int AssetEditSigned::handle_event()
713 {
714         Asset *asset = fwindow->asset_edit->changed_params;
715         asset->signed_ = get_value();
716         return 1;
717 }
718
719
720
721
722
723
724
725 AssetEditPathText::AssetEditPathText(AssetEditWindow *fwindow, int y)
726  : BC_TextBox(5, y, xS(300), 1, fwindow->asset_edit->changed_params->path)
727 {
728         this->fwindow = fwindow;
729 }
730 AssetEditPathText::~AssetEditPathText()
731 {
732 }
733 int AssetEditPathText::handle_event()
734 {
735         strcpy(fwindow->asset_edit->changed_params->path, get_text());
736         return 1;
737 }
738
739 AssetEditPath::AssetEditPath(MWindow *mwindow, AssetEditWindow *fwindow,
740         BC_TextBox *textbox, int y, const char *text,
741         const char *window_title, const char *window_caption)
742  : BrowseButton(mwindow->theme, fwindow, textbox, yS(310), y, text,
743         window_title, window_caption, 0)
744 {
745         this->fwindow = fwindow;
746 }
747
748 AssetEditPath::~AssetEditPath() {}
749
750
751
752
753 DetailAssetButton::DetailAssetButton(AssetEditWindow *fwindow, int x, int y)
754  : BC_GenericButton(x, y, _("Detail"))
755 {
756         this->fwindow = fwindow;
757 }
758
759 DetailAssetButton::~DetailAssetButton()
760 {
761 }
762
763 int DetailAssetButton::handle_event()
764 {
765         fwindow->show_info_detail();
766         return 1;
767 }
768
769 #define DTL_W xS(600)
770 #define DTL_H yS(500)
771
772 DetailAssetWindow::DetailAssetWindow(MWindow *mwindow,
773         DetailAssetDialog *detail_dialog, Asset *asset)
774  : BC_Window(_("Asset Detail"),
775         detail_dialog->x - DTL_W/2, detail_dialog->y - DTL_H/2, DTL_W, DTL_H)
776 {
777         this->mwindow = mwindow;
778         this->detail_dialog = detail_dialog;
779         this->asset = asset;
780         asset->add_user();
781         info[0] = 0;
782         text = 0;
783 }
784
785 DetailAssetWindow::~DetailAssetWindow()
786 {
787         asset->remove_user();
788         delete text;
789 }
790
791 DetailAssetDialog::DetailAssetDialog(MWindow *mwindow)
792  : BC_DialogThread()
793 {
794         this->mwindow = mwindow;
795         dwindow = 0;
796 }
797
798 DetailAssetDialog::~DetailAssetDialog()
799 {
800         close_window();
801 }
802
803 void DetailAssetWindow::create_objects()
804 {
805         int y = yS(10), x = xS(10);
806         char file_name[BCTEXTLEN];
807         int len = sizeof(info);
808         strncpy(info,_("no info available"),len);
809         if( !mwindow->preferences->get_asset_file_path(asset, file_name) ) {
810                 switch( asset->format ) {
811 #ifdef HAVE_LIBZMPEG
812                 case FILE_MPEG:
813                         FileMPEG::get_info(asset->path, file_name, &info[0],len);
814                         break;
815 #endif
816                 case FILE_FFMPEG:
817                         FileFFMPEG::get_info(asset->path, &info[0],len);
818                         break;
819                 }
820         }
821         lock_window("DetailAssetWindow::create_objects");
822         int text_h = get_h()-y - BC_OKButton::calculate_h() - yS(15);
823         int lines = BC_TextBox::pixels_to_rows(this, MEDIUMFONT, text_h);
824         text = new BC_ScrollTextBox(this, x, y, get_w()-xS(32), lines, info, -len);
825         text->create_objects();  text->set_text_row(0);
826         add_subwindow(new BC_OKButton(this));
827         show_window();
828         unlock_window();
829 }
830
831 void DetailAssetDialog::start(Asset *asset, int x, int y)
832 {
833         close_window();
834         this->asset = asset;
835         this->x = x;  this->y = y;
836         BC_DialogThread::start();
837 }
838
839 BC_Window *DetailAssetDialog::new_gui()
840 {
841         dwindow = new DetailAssetWindow(mwindow, this, asset);
842         dwindow->create_objects();
843         return dwindow;
844 }
845