b5a733bc3a4153de67a8a349a79599f10b22831f
[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(mwindow->plugindb,
276                                 asset->format),
277                         MEDIUMFONT,
278                         mwindow->theme->assetedit_color));
279                 x = x1;
280                 y += 20;
281
282                 int64_t bytes = fs.get_size(asset->path);
283                 add_subwindow(new BC_Title(x, y, _("Bytes:")));
284                 sprintf(string, "%jd", bytes);
285                 Units::punctuate(string);
286
287
288                 add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
289                 if( asset->format == FILE_MPEG || asset->format == FILE_FFMPEG ) {
290                         detail_dialog = new DetailAssetDialog(mwindow);
291                         BC_GenericButton *detail = new DetailAssetButton(this, x2+120, y);
292                         add_subwindow(detail);
293                 }
294
295                 y += 20;
296                 x = x1;
297
298                 double length = 0.;
299                 y += 20;
300                 x = x1;
301
302                 if( asset->audio_length > 0 )
303                         length = (double)asset->audio_length / asset->sample_rate;
304                 if( asset->video_length > 0 )
305                         length = MAX(length, (double)asset->video_length / asset->frame_rate);
306                 int64_t bitrate;
307                 if( !EQUIV(length, 0) )
308                         bitrate = (int64_t)(bytes * 8 / length);
309                 else
310                         bitrate = bytes;
311                 add_subwindow(new BC_Title(x, y, _("Bitrate (bits/sec):")));
312                 sprintf(string, "%jd", bitrate);
313
314                 Units::punctuate(string);
315                 add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
316
317                 y += 30;
318                 x = x1;
319         }
320
321         if( (asset && asset->audio_data) || nested_edl ) {
322                 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
323                 y += 5;
324
325                 add_subwindow(new BC_Title(x, y, _("Audio:"), LARGEFONT, RED));
326
327                 y += 30;
328
329                 if( asset ) {
330                         if( asset->get_compression_text(1, 0) ) {
331                                 add_subwindow(new BC_Title(x, y, _("Compression:")));
332                                 x = x2;
333                                 add_subwindow(new BC_Title(x,
334                                         y,
335                                         asset->get_compression_text(1, 0),
336                                         MEDIUMFONT,
337                                         mwindow->theme->assetedit_color));
338                                 y += vmargin;
339                                 x = x1;
340                         }
341                 }
342
343                 add_subwindow(new BC_Title(x, y, _("Channels:")));
344                 sprintf(string, "%d", asset_edit->changed_params->channels);
345
346                 x = x2;
347                 if( allow_edits ) {
348                         BC_TumbleTextBox *textbox = new AssetEditChannels(this,
349                                 string,
350                                 x,
351                                 y);
352                         textbox->create_objects();
353                         y += vmargin;
354                 }
355                 else {
356                         add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
357                         y += 20;
358                 }
359
360                 x = x1;
361                 add_subwindow(new BC_Title(x, y, _("Sample rate:")));
362                 sprintf(string, "%d", asset_edit->changed_params->sample_rate);
363
364                 x = x2;
365                 if( asset ) {
366                         BC_TextBox *textbox;
367                         add_subwindow(textbox = new AssetEditRate(this, string, x, y));
368                         x += textbox->get_w();
369                         add_subwindow(new SampleRatePulldown(mwindow, textbox, x, y));
370                 }
371                 else {
372                         add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
373                 }
374
375                 y += 30;
376                 x = x1;
377
378                 if( asset ) {
379                         add_subwindow(new BC_Title(x, y, _("Bits:")));
380                         x = x2;
381                         if( allow_edits ) {
382                                 bitspopup = new BitsPopup(this, x, y,
383                                         &asset_edit->changed_params->bits,
384                                         1, 1, 1, 0, 1);
385                                 bitspopup->create_objects();
386                         }
387                         else
388                                 add_subwindow(new BC_Title(x, y, File::bitstostr(asset->bits), MEDIUMFONT, mwindow->theme->assetedit_color));
389
390
391                         x = x1;
392                         y += vmargin;
393                         add_subwindow(new BC_Title(x, y, _("Header length:")));
394                         sprintf(string, "%d", asset->header);
395
396                         x = x2;
397                         if( allow_edits )
398                                 add_subwindow(new AssetEditHeader(this, string, x, y));
399                         else
400                                 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
401
402                         y += vmargin;
403                         x = x1;
404
405                         add_subwindow(new BC_Title(x, y, _("Byte order:")));
406
407                         if( allow_edits )
408                         {
409                                 x = x2;
410
411                                 add_subwindow(lohi = new AssetEditByteOrderLOHI(this,
412                                         asset->byte_order,
413                                         x,
414                                         y));
415                                 x += 70;
416                                 add_subwindow(hilo = new AssetEditByteOrderHILO(this,
417                                         !asset->byte_order,
418                                         x,
419                                         y));
420                                 y += vmargin;
421                         }
422                         else {
423                                 x = x2;
424                                 if( asset->byte_order )
425                                         add_subwindow(new BC_Title(x, y, _("Lo-Hi"), MEDIUMFONT, mwindow->theme->assetedit_color));
426                                 else
427                                         add_subwindow(new BC_Title(x, y, _("Hi-Lo"), MEDIUMFONT, mwindow->theme->assetedit_color));
428                                 y += vmargin;
429                         }
430
431
432                         x = x1;
433                         if( allow_edits ) {
434         //                      add_subwindow(new BC_Title(x, y, _("Values are signed:")));
435                                 add_subwindow(new AssetEditSigned(this, asset->signed_, x, y));
436                         }
437                         else {
438                                 if( !asset->signed_ && asset->bits == 8 )
439                                         add_subwindow(new BC_Title(x, y, _("Values are unsigned")));
440                                 else
441                                         add_subwindow(new BC_Title(x, y, _("Values are signed")));
442                         }
443
444                         y += 30;
445                 }
446         }
447
448         x = x1;
449         if( (asset && asset->video_data) || nested_edl ) {
450                 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
451                 y += 5;
452
453                 add_subwindow(new BC_Title(x, y, _("Video:"), LARGEFONT, RED));
454                 y += 30;
455                 x = x1;
456
457
458                 if( asset && asset->get_compression_text(0,1) ) {
459                         add_subwindow(new BC_Title(x, y, _("Compression:")));
460                         x = x2;
461                         add_subwindow(new BC_Title(x,
462                                 y,
463                                 asset->get_compression_text(0,1),
464                                 MEDIUMFONT,
465                                 mwindow->theme->assetedit_color));
466                         y += vmargin;
467                         x = x1;
468                 }
469
470                 add_subwindow(new BC_Title(x, y, _("Frame rate:")));
471                 x = x2;
472                 sprintf(string, "%.4f", asset_edit->changed_params->frame_rate);
473
474 //printf("AssetEditWindow::create_objects %d %f\n", __LINE__, asset_edit->changed_params->frame_rate);
475                 if( asset ) {
476                         BC_TextBox *framerate;
477                         add_subwindow(framerate = new AssetEditFRate(this, string, x, y));
478                         x += 105;
479                         add_subwindow(new FrameRatePulldown(mwindow, framerate, x, y));
480                 }
481                 else {
482                         add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
483                 }
484
485                 y += 30;
486                 x = x1;
487                 add_subwindow(new BC_Title(x, y, _("Width:")));
488                 x = x2;
489                 sprintf(string, "%d", asset_edit->changed_params->width);
490                 win_width = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color);
491                 add_subwindow(win_width);
492
493                 y += vmargin;
494                 x = x1;
495                 add_subwindow(new BC_Title(x, y, _("Height:")));
496                 x = x2;
497                 sprintf(string, "%d", asset_edit->changed_params->height);
498                 win_height = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color);
499                 add_subwindow(win_height);
500                 y += win_height->get_h() + 5;
501
502                 if( asset && (asset->format == FILE_MPEG || asset->format == FILE_FFMPEG )  ) {
503                         y += 5;
504                         x = x1;
505                         add_subwindow(new BC_Title(x, y, _("Actual width:")));
506                         x = x2;
507                         sprintf(string, "%d", asset->actual_width);
508                         add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
509
510                         BC_GenericButton *resize = new ResizeAssetButton(this, x+64, y);
511                         add_subwindow(resize);
512
513                         y += vmargin;
514                         x = x1;
515                         add_subwindow(new BC_Title(x, y, _("Actual height:")));
516                         x = x2;
517                         sprintf(string, "%d", asset->actual_height);
518                         title = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color);
519                         add_subwindow(title);
520                         y += title->get_h() + 5;
521                 }
522
523                 // --------------------
524                 add_subwindow(title = new BC_Title(x1, y, _("Fix interlacing:")));
525                 add_subwindow(ilacefixoption_chkboxw = new Interlaceautofix(mwindow,this, x2, y));
526                 y += ilacefixoption_chkboxw->get_h() + 5;
527                 // --------------------
528                 add_subwindow(title = new BC_Title(x1, y, _("Asset's interlacing:")));
529                 add_subwindow(textboxw = new AssetEditILacemode(this, "", ILACE_ASSET_MODEDEFAULT, x2, y, 200));
530                 ilacefixoption_chkboxw->ilacemode_textbox = textboxw;
531                 add_subwindow(listboxw = new AssetEditInterlacemodePulldown(mwindow,
532                                                         textboxw,
533                                                         &asset_edit->changed_params->interlace_mode,
534                                                         (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_asset_modes,
535                                                         ilacefixoption_chkboxw,
536                                                         x2 + textboxw->get_w(),
537                                                         y));
538                 ilacefixoption_chkboxw->ilacemode_listbox = listboxw;
539                 y += textboxw->get_h() + 5;
540
541                 // --------------------
542                 add_subwindow(title = new BC_Title(x1, y, _("Interlace correction:")));
543                 add_subwindow(textboxw = new AssetEditILacefixmethod(this, "", ILACE_FIXDEFAULT, x2, y, 200));
544                 ilacefixoption_chkboxw->ilacefixmethod_textbox = textboxw;
545                 add_subwindow(listboxw = new InterlacefixmethodPulldown(mwindow,
546                                                         textboxw,
547                                                         &asset_edit->changed_params->interlace_fixmethod,
548                                                         (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_asset_fixmethods,
549                                                         x2 + textboxw->get_w(),
550                                                         y));
551                 ilacefixoption_chkboxw->ilacefixmethod_listbox = listboxw;
552                 ilacefixoption_chkboxw->showhideotherwidgets();
553                 y += textboxw->get_h() + 5;
554         }
555
556         add_subwindow(new BC_OKButton(this));
557         add_subwindow(new BC_CancelButton(this));
558         show_window();
559         unlock_window();
560 }
561
562 void AssetEditWindow::show_info_detail()
563 {
564         int cur_x, cur_y;
565         get_abs_cursor_xy(cur_x, cur_y, 0);
566         detail_dialog->start((Asset*)asset_edit->indexable, cur_x, cur_y);
567 }
568
569
570 AssetEditChannels::AssetEditChannels(AssetEditWindow *fwindow,
571         char *text,
572         int x,
573         int y)
574  : BC_TumbleTextBox(fwindow,
575                 (int)atol(text),
576                 (int)1,
577                 (int)MAXCHANNELS,
578                 x,
579                 y,
580                 50)
581 {
582         this->fwindow = fwindow;
583 }
584
585 int AssetEditChannels::handle_event()
586 {
587         Asset *asset = fwindow->asset_edit->changed_params;
588         asset->channels = atol(get_text());
589         return 1;
590 }
591
592 AssetEditRate::AssetEditRate(AssetEditWindow *fwindow, char *text, int x, int y)
593  : BC_TextBox(x, y, 100, 1, text)
594 {
595         this->fwindow = fwindow;
596 }
597
598 int AssetEditRate::handle_event()
599 {
600         Asset *asset = fwindow->asset_edit->changed_params;
601         asset->sample_rate = atol(get_text());
602         return 1;
603 }
604
605 AssetEditFRate::AssetEditFRate(AssetEditWindow *fwindow, char *text, int x, int y)
606  : BC_TextBox(x, y, 100, 1, text)
607 {
608         this->fwindow = fwindow;
609 }
610
611 int AssetEditFRate::handle_event()
612 {
613         Asset *asset = fwindow->asset_edit->changed_params;
614         asset->frame_rate = atof(get_text());
615         return 1;
616 }
617
618 Interlaceautofix::Interlaceautofix(MWindow *mwindow,AssetEditWindow *fwindow, int x, int y)
619  : BC_CheckBox(x, y,
620         fwindow->asset_edit->changed_params->interlace_autofixoption,
621         _("Automatically Fix Interlacing"))
622 {
623         this->fwindow = fwindow;
624         this->mwindow = mwindow;
625 }
626
627 Interlaceautofix::~Interlaceautofix()
628 {
629 }
630
631 int Interlaceautofix::handle_event()
632 {
633         Asset *asset = fwindow->asset_edit->changed_params;
634         asset->interlace_autofixoption = get_value();
635         showhideotherwidgets();
636         return 1;
637 }
638
639 void Interlaceautofix::showhideotherwidgets()
640 {
641   int thevalue = get_value();
642
643         Asset *asset = fwindow->asset_edit->changed_params;
644         if( thevalue == ILACE_AUTOFIXOPTION_AUTO ) {
645                 this->ilacemode_textbox->enable();
646                 this->ilacemode_listbox->enable();
647                 this->ilacefixmethod_textbox->disable();
648                 this->ilacefixmethod_listbox->disable();
649                 int xx = ilaceautofixmethod(mwindow->edl->session->interlace_mode,asset->interlace_mode);
650                 ilacefixmethod_to_text(string, xx);
651                 this->ilacefixmethod_textbox->update(string);
652         }
653         if( thevalue == ILACE_AUTOFIXOPTION_MANUAL ) {
654                 this->ilacemode_textbox->disable();
655                 this->ilacemode_listbox->disable();
656                 this->ilacefixmethod_textbox->enable();
657                 this->ilacefixmethod_listbox->enable();
658                 ilacefixmethod_to_text(string, asset->interlace_fixmethod);
659                 this->ilacefixmethod_textbox->update(string);
660           }
661 }
662
663 InterlacefixmethodItem::InterlacefixmethodItem(const char *text, int value)
664  : BC_ListBoxItem(text)
665 {
666         this->value = value;
667 }
668
669 InterlacefixmethodPulldown::InterlacefixmethodPulldown(MWindow *mwindow,
670                 BC_TextBox *output_text, int *output_value,
671                 ArrayList<BC_ListBoxItem*> *data, int x, int y)
672  : BC_ListBox(x, y, 200, 150, LISTBOX_TEXT, data, 0, 0, 1, 0, 1)
673 {
674         this->mwindow = mwindow;
675         this->output_text = output_text;
676         this->output_value = output_value;
677         output_text->update(interlacefixmethod_to_text());
678 }
679
680 int InterlacefixmethodPulldown::handle_event()
681 {
682         output_text->update(get_selection(0, 0)->get_text());
683         *output_value = ((InterlacefixmethodItem*)get_selection(0, 0))->value;
684         return 1;
685 }
686
687 const char* InterlacefixmethodPulldown::interlacefixmethod_to_text()
688 {
689         ilacefixmethod_to_text(this->string,*output_value);
690         return (this->string);
691 }
692
693 AssetEditILaceautofixoption::AssetEditILaceautofixoption(AssetEditWindow *fwindow, char *text, int thedefault, int x, int y, int w)
694  : BC_TextBox(x, y, w, 1, text)
695 {
696         this->fwindow = fwindow;
697         this->thedefault = thedefault;
698 }
699
700 int AssetEditILaceautofixoption::handle_event()
701 {
702         Asset *asset = fwindow->asset_edit->changed_params;
703         asset->interlace_autofixoption = ilaceautofixoption_from_text(get_text(), this->thedefault);
704         return 1;
705 }
706
707
708 AssetEditILacemode::AssetEditILacemode(AssetEditWindow *fwindow, const char *text, int thedefault, int x, int y, int w)
709  : BC_TextBox(x, y, w, 1, text)
710 {
711         this->fwindow = fwindow;
712         this->thedefault = thedefault;
713 }
714
715 int AssetEditILacemode::handle_event()
716 {
717         Asset *asset = fwindow->asset_edit->changed_params;
718         asset->interlace_mode = ilacemode_from_text(get_text(),this->thedefault);
719         return 1;
720 }
721
722 AssetEditInterlacemodePulldown::AssetEditInterlacemodePulldown(MWindow *mwindow,
723                 BC_TextBox *output_text,
724                 int *output_value,
725                 ArrayList<BC_ListBoxItem*> *data,
726                 Interlaceautofix *fixoption_chkboxw,
727                 int x,
728                 int y)
729  : BC_ListBox(x,
730         y,
731         200,
732         150,
733         LISTBOX_TEXT,
734         data,
735         0,
736         0,
737         1,
738         0,
739         1)
740 {
741         this->fixoption_chkbox = fixoption_chkboxw;
742         this->mwindow = mwindow;
743         this->output_text = output_text;
744         this->output_value = output_value;
745         output_text->update(interlacemode_to_text());
746 }
747
748 int AssetEditInterlacemodePulldown::handle_event()
749 {
750         output_text->update(get_selection(0, 0)->get_text());
751         *output_value = ((InterlacemodeItem*)get_selection(0, 0))->value;
752         fixoption_chkbox->showhideotherwidgets();
753         return 1;
754 }
755
756 char* AssetEditInterlacemodePulldown::interlacemode_to_text()
757 {
758         ilacemode_to_text(this->string,*output_value);
759         return (this->string);
760 }
761
762 AssetEditILacefixmethod::AssetEditILacefixmethod(AssetEditWindow *fwindow, const char *text, int thedefault, int x, int y, int w)
763  : BC_TextBox(x, y, w, 1, text)
764 {
765         this->fwindow = fwindow;
766         this->thedefault = thedefault;
767 }
768
769 int AssetEditILacefixmethod::handle_event()
770 {
771         Asset *asset = fwindow->asset_edit->changed_params;
772         asset->interlace_fixmethod = ilacefixmethod_from_text(get_text(),this->thedefault);
773         return 1;
774 }
775
776 AssetEditHeader::AssetEditHeader(AssetEditWindow *fwindow, char *text, int x, int y)
777  : BC_TextBox(x, y, 100, 1, text)
778 {
779         this->fwindow = fwindow;
780 }
781
782 int AssetEditHeader::handle_event()
783 {
784         Asset *asset = fwindow->asset_edit->changed_params;
785         asset->header = atol(get_text());
786         return 1;
787 }
788
789 AssetEditByteOrderLOHI::AssetEditByteOrderLOHI(AssetEditWindow *fwindow,
790         int value,
791         int x,
792         int y)
793  : BC_Radial(x, y, value, _("Lo-Hi"))
794 {
795         this->fwindow = fwindow;
796 }
797
798 int AssetEditByteOrderLOHI::handle_event()
799 {
800         Asset *asset = fwindow->asset_edit->changed_params;
801         asset->byte_order = 1;
802         fwindow->hilo->update(0);
803         update(1);
804         return 1;
805 }
806
807 AssetEditByteOrderHILO::AssetEditByteOrderHILO(AssetEditWindow *fwindow,
808         int value,
809         int x,
810         int y)
811  : BC_Radial(x, y, value, _("Hi-Lo"))
812 {
813         this->fwindow = fwindow;
814 }
815
816 int AssetEditByteOrderHILO::handle_event()
817 {
818         Asset *asset = fwindow->asset_edit->changed_params;
819         asset->byte_order = 0;
820         fwindow->lohi->update(0);
821         update(1);
822         return 1;
823 }
824
825 AssetEditSigned::AssetEditSigned(AssetEditWindow *fwindow,
826         int value,
827         int x,
828         int y)
829  : BC_CheckBox(x, y, value, _("Values are signed"))
830 {
831         this->fwindow = fwindow;
832 }
833
834 int AssetEditSigned::handle_event()
835 {
836         Asset *asset = fwindow->asset_edit->changed_params;
837         asset->signed_ = get_value();
838         return 1;
839 }
840
841
842
843
844
845
846
847 AssetEditPathText::AssetEditPathText(AssetEditWindow *fwindow, int y)
848  : BC_TextBox(5, y, 300, 1, fwindow->asset_edit->changed_params->path)
849 {
850         this->fwindow = fwindow;
851 }
852 AssetEditPathText::~AssetEditPathText()
853 {
854 }
855 int AssetEditPathText::handle_event()
856 {
857         strcpy(fwindow->asset_edit->changed_params->path, get_text());
858         return 1;
859 }
860
861 AssetEditPath::AssetEditPath(MWindow *mwindow, AssetEditWindow *fwindow,
862         BC_TextBox *textbox, int y, const char *text,
863         const char *window_title, const char *window_caption)
864  : BrowseButton(mwindow->theme, fwindow, textbox, 310, y, text,
865         window_title, window_caption, 0)
866 {
867         this->fwindow = fwindow;
868 }
869
870 AssetEditPath::~AssetEditPath() {}
871
872
873
874
875
876
877 AssetEditFormat::AssetEditFormat(AssetEditWindow *fwindow, char* default_, int y)
878  : FormatPopup(fwindow->mwindow->plugindb, 90, y)
879 {
880         this->fwindow = fwindow;
881 }
882 AssetEditFormat::~AssetEditFormat()
883 {
884 }
885 int AssetEditFormat::handle_event()
886 {
887         Asset *asset = fwindow->asset_edit->changed_params;
888         asset->format = File::strtoformat(fwindow->mwindow->plugindb,
889                 get_selection(0, 0)->get_text());
890         return 1;
891 }
892
893
894
895
896 DetailAssetButton::DetailAssetButton(AssetEditWindow *fwindow, int x, int y)
897  : BC_GenericButton(x, y, _("Detail"))
898 {
899         this->fwindow = fwindow;
900         set_underline(0);
901 }
902
903 DetailAssetButton::~DetailAssetButton()
904 {
905 }
906
907 int DetailAssetButton::handle_event()
908 {
909         fwindow->show_info_detail();
910         return 1;
911 }
912
913 DetailAssetWindow::DetailAssetWindow(MWindow *mwindow,
914         DetailAssetDialog *detail_dialog, Asset *asset)
915  : BC_Window(_("Asset Detail"),
916         detail_dialog->x - 600/2, detail_dialog->y - 500/2, 600, 500)
917 {
918         this->mwindow = mwindow;
919         this->detail_dialog = detail_dialog;
920         this->asset = asset;
921         asset->add_user();
922         info[0] = 0;
923         text = 0;
924 }
925
926 DetailAssetWindow::~DetailAssetWindow()
927 {
928         asset->remove_user();
929         delete text;
930 }
931
932 DetailAssetDialog::DetailAssetDialog(MWindow *mwindow)
933  : BC_DialogThread()
934 {
935         this->mwindow = mwindow;
936         dwindow = 0;
937 }
938
939 DetailAssetDialog::~DetailAssetDialog()
940 {
941         close_window();
942 }
943
944 void DetailAssetWindow::create_objects()
945 {
946         int y = 10, x = 10;
947         char file_name[BCTEXTLEN];
948         int len = sizeof(info);
949         strncpy(info,_("no info available"),len);
950         if( !mwindow->preferences->get_asset_file_path(asset, file_name) ) {
951                 switch( asset->format ) {
952                 case FILE_MPEG:
953                         FileMPEG::get_info(asset->path, file_name, &info[0],len);
954                         break;
955                 case FILE_FFMPEG:
956                         FileFFMPEG::get_info(asset->path, &info[0],len);
957                         break;
958                 }
959         }
960         text = new BC_ScrollTextBox(this, x, y, get_w()-32, 23, info, -len);
961         text->create_objects();  text->set_text_row(0);
962         add_subwindow(new BC_OKButton(this));
963         show_window();
964 }
965
966 void DetailAssetDialog::start(Asset *asset, int x, int y)
967 {
968         close_window();
969         this->asset = asset;
970         this->x = x;  this->y = y;
971         BC_DialogThread::start();
972 }
973
974 BC_Window *DetailAssetDialog::new_gui()
975 {
976         dwindow = new DetailAssetWindow(mwindow, this, asset);
977         dwindow->create_objects();
978         return dwindow;
979 }
980