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