confirm prefs update, fix bg_pixmap sz, plugin layout tweaks
[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 }
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, FORCE_REDRAW, 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 += 160;
194                 if( indexable->is_asset ) {
195                         Asset *asset = (Asset *)indexable;
196                         if( File::can_scale_input(asset) )
197                                 h += 42;
198                 }
199         }
200         return yS(h);
201 }
202
203 #define AEW_W xS(450)
204
205 AssetEditWindow::AssetEditWindow(MWindow *mwindow, AssetEdit *asset_edit)
206  : BC_Window(_(PROGRAM_NAME ": Asset Info"),
207         asset_edit->x - AEW_W/2, asset_edit->y - asset_edit->window_height()/2,
208         AEW_W, asset_edit->window_height(), 0, 0, 1)
209 {
210         this->mwindow = mwindow;
211         this->asset_edit = asset_edit;
212         bitspopup = 0;
213         path_text = 0;
214         path_button = 0;
215         hilo = 0;
216         lohi = 0;
217         allow_edits = 0;
218         detail_dialog = 0;
219         win_width = 0;
220         win_height = 0;
221 }
222
223
224
225
226
227 AssetEditWindow::~AssetEditWindow()
228 {
229         lock_window("AssetEditWindow::~AssetEditWindow");
230         delete bitspopup;
231         delete detail_dialog;
232         unlock_window();
233 }
234
235
236
237
238 void AssetEditWindow::create_objects()
239 {
240         int xpad10 = xS(10);
241         int ypad5 = yS(5), ypad10 = yS(10), ypad20 = yS(20), ypad30 = yS(30);
242         int y = ypad10, x = xpad10, x1 = xpad10, x2 = xS(190);
243         char string[BCTEXTLEN];
244         FileSystem fs;
245         BC_Title *title;
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         allow_edits = asset && asset->format == FILE_PCM ? 1 : 0;
255         int vmargin = yS(allow_edits ? 30 : 20);
256         lock_window("AssetEditWindow::create_objects");
257
258         add_subwindow(path_text = new AssetEditPathText(this, y));
259         add_subwindow(path_button = new AssetEditPath(mwindow, this,
260                 path_text, y, asset_edit->indexable->path,
261                 _(PROGRAM_NAME ": Asset path"),
262                 _("Select a file for this asset:")));
263         y += yS(30);
264
265         if( asset ) {
266                 add_subwindow(new BC_Title(x, y, _("File format:")));
267                 x = x2;
268                 add_subwindow(new BC_Title(x, y, File::formattostr(asset->format),
269                         MEDIUMFONT,
270                         mwindow->theme->assetedit_color));
271                 x = x1;
272                 y += ypad20;
273
274                 int64_t bytes = fs.get_size(asset->path);
275                 add_subwindow(new BC_Title(x, y, _("Bytes:")));
276                 sprintf(string, "%jd", bytes);
277                 Units::punctuate(string);
278
279
280                 add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
281                 if( asset->format == FILE_MPEG || asset->format == FILE_FFMPEG ) {
282                         detail_dialog = new DetailAssetDialog(mwindow);
283                         BC_GenericButton *detail = new DetailAssetButton(this, x2+xS(120), y);
284                         add_subwindow(detail);
285                 }
286
287                 y += ypad20;
288                 x = x1;
289
290                 double length = 0.;
291                 y += ypad20;
292                 x = x1;
293
294                 if( asset->audio_length > 0 )
295                         length = (double)asset->audio_length / asset->sample_rate;
296                 if( asset->video_length > 0 )
297                         length = MAX(length, (double)asset->video_length / asset->frame_rate);
298                 int64_t bitrate;
299                 if( !EQUIV(length, 0) )
300                         bitrate = (int64_t)(bytes * 8 / length);
301                 else
302                         bitrate = bytes;
303                 add_subwindow(new BC_Title(x, y, _("Bitrate (bits/sec):")));
304                 sprintf(string, "%jd", bitrate);
305
306                 Units::punctuate(string);
307                 add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
308
309                 y += ypad30;
310                 x = x1;
311         }
312
313         if( (asset && asset->audio_data) || nested_edl ) {
314                 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
315                 y += ypad5;
316
317                 add_subwindow(new BC_Title(x, y, _("Audio:"), LARGEFONT, RED));
318
319                 y += ypad30;
320
321                 if( asset ) {
322                         if( asset->get_compression_text(1, 0) ) {
323                                 add_subwindow(new BC_Title(x, y, _("Compression:")));
324                                 x = x2;
325                                 add_subwindow(new BC_Title(x,
326                                         y,
327                                         asset->get_compression_text(1, 0),
328                                         MEDIUMFONT,
329                                         mwindow->theme->assetedit_color));
330                                 y += vmargin;
331                                 x = x1;
332                         }
333                 }
334
335                 add_subwindow(new BC_Title(x, y, _("Channels:")));
336                 sprintf(string, "%d", asset_edit->changed_params->channels);
337
338                 x = x2;
339                 if( allow_edits ) {
340                         BC_TumbleTextBox *textbox = new AssetEditChannels(this,
341                                 string,
342                                 x,
343                                 y);
344                         textbox->create_objects();
345                         y += vmargin;
346                 }
347                 else {
348                         add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
349                         y += ypad20;
350                 }
351
352                 x = x1;
353                 add_subwindow(new BC_Title(x, y, _("Sample rate:")));
354                 sprintf(string, "%d", asset_edit->changed_params->sample_rate);
355
356                 x = x2;
357                 if( asset ) {
358                         BC_TextBox *textbox;
359                         add_subwindow(textbox = new AssetEditRate(this, string, x, y));
360                         x += textbox->get_w();
361                         add_subwindow(new SampleRatePulldown(mwindow, textbox, x, y));
362                 }
363                 else {
364                         add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
365                 }
366
367                 y += ypad30;
368                 x = x1;
369
370                 if( asset ) {
371                         add_subwindow(new BC_Title(x, y, _("Bits:")));
372                         x = x2;
373                         if( allow_edits ) {
374                                 bitspopup = new BitsPopup(this, x, y,
375                                         &asset_edit->changed_params->bits,
376                                         1, 1, 1, 0, 1);
377                                 bitspopup->create_objects();
378                         }
379                         else
380                                 add_subwindow(new BC_Title(x, y, File::bitstostr(asset->bits), MEDIUMFONT, mwindow->theme->assetedit_color));
381
382
383                         x = x1;
384                         y += vmargin;
385                         add_subwindow(new BC_Title(x, y, _("Header length:")));
386                         sprintf(string, "%d", asset->header);
387
388                         x = x2;
389                         if( allow_edits )
390                                 add_subwindow(new AssetEditHeader(this, string, x, y));
391                         else
392                                 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
393
394                         y += vmargin;
395                         x = x1;
396
397                         add_subwindow(new BC_Title(x, y, _("Byte order:")));
398
399                         if( allow_edits )
400                         {
401                                 x = x2;
402
403                                 add_subwindow(lohi = new AssetEditByteOrderLOHI(this,
404                                         asset->byte_order, x, y));
405                                 x += xS(70);
406                                 add_subwindow(hilo = new AssetEditByteOrderHILO(this,
407                                         !asset->byte_order, x, y));
408                                 y += vmargin;
409                         }
410                         else {
411                                 x = x2;
412                                 if( asset->byte_order )
413                                         add_subwindow(new BC_Title(x, y, _("Lo-Hi"), MEDIUMFONT, mwindow->theme->assetedit_color));
414                                 else
415                                         add_subwindow(new BC_Title(x, y, _("Hi-Lo"), MEDIUMFONT, mwindow->theme->assetedit_color));
416                                 y += vmargin;
417                         }
418
419
420                         x = x1;
421                         if( allow_edits ) {
422         //                      add_subwindow(new BC_Title(x, y, _("Values are signed:")));
423                                 add_subwindow(new AssetEditSigned(this, asset->signed_, x, y));
424                         }
425                         else {
426                                 if( !asset->signed_ && asset->bits == 8 )
427                                         add_subwindow(new BC_Title(x, y, _("Values are unsigned")));
428                                 else
429                                         add_subwindow(new BC_Title(x, y, _("Values are signed")));
430                         }
431
432                         y += ypad30;
433                 }
434         }
435
436         x = x1;
437         if( (asset && asset->video_data) || nested_edl ) {
438                 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
439                 y += ypad5;
440
441                 add_subwindow(new BC_Title(x, y, _("Video:"), LARGEFONT, RED));
442                 y += ypad30;
443                 x = x1;
444
445
446                 if( asset && asset->get_compression_text(0,1) ) {
447                         add_subwindow(new BC_Title(x, y, _("Compression:")));
448                         x = x2;
449                         add_subwindow(new BC_Title(x,
450                                 y,
451                                 asset->get_compression_text(0,1),
452                                 MEDIUMFONT,
453                                 mwindow->theme->assetedit_color));
454                         y += vmargin;
455                         x = x1;
456                 }
457
458                 add_subwindow(new BC_Title(x, y, _("Frame rate:")));
459                 x = x2;
460                 sprintf(string, "%.4f", asset_edit->changed_params->frame_rate);
461
462 //printf("AssetEditWindow::create_objects %d %f\n", __LINE__, asset_edit->changed_params->frame_rate);
463                 if( asset ) {
464                         BC_TextBox *framerate;
465                         add_subwindow(framerate = new AssetEditFRate(this, string, x, y));
466                         x += framerate->get_w();
467                         add_subwindow(new FrameRatePulldown(mwindow, framerate, x, y));
468                 }
469                 else {
470                         add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
471                 }
472
473                 y += ypad30;
474                 x = x1;
475                 add_subwindow(new BC_Title(x, y, _("Width:")));
476                 x = x2;
477                 sprintf(string, "%d", asset_edit->changed_params->width);
478                 win_width = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color);
479                 add_subwindow(win_width);
480
481                 y += vmargin;
482                 x = x1;
483                 add_subwindow(new BC_Title(x, y, _("Height:")));
484                 x = x2;
485                 sprintf(string, "%d", asset_edit->changed_params->height);
486                 win_height = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color);
487                 add_subwindow(win_height);
488                 y += win_height->get_h() + ypad5;
489
490                 if( asset && File::can_scale_input(asset) ) {
491                         y += ypad5;
492                         x = x1;
493                         add_subwindow(new BC_Title(x, y, _("Actual width:")));
494                         x = x2;
495                         sprintf(string, "%d", asset->actual_width);
496                         add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
497
498                         BC_GenericButton *resize = new ResizeAssetButton(this, x+xS(64), y);
499                         add_subwindow(resize);
500
501                         y += vmargin;
502                         x = x1;
503                         add_subwindow(new BC_Title(x, y, _("Actual height:")));
504                         x = x2;
505                         sprintf(string, "%d", asset->actual_height);
506                         title = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color);
507                         add_subwindow(title);
508                         y += title->get_h() + ypad5;
509                 }
510                 if( asset ) {
511                         add_subwindow(title = new BC_Title(x1, y, _("Asset's interlacing:")));
512                         ilacemode_to_text(string, asset->interlace_mode);
513                         AssetEditILacemode *edit_ilace_mode;
514                         add_subwindow(edit_ilace_mode = new AssetEditILacemode(this, string, x2, y, xS(160)));
515                         add_subwindow(new AssetEditInterlacemodePulldown(mwindow, edit_ilace_mode,
516                                 &asset_edit->changed_params->interlace_mode,
517                                 (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_asset_modes,
518                                 x2 + edit_ilace_mode->get_w(), y));
519                 }
520         }
521
522         add_subwindow(new BC_OKButton(this));
523         add_subwindow(new BC_CancelButton(this));
524         show_window();
525         unlock_window();
526 }
527
528 void AssetEditWindow::show_info_detail()
529 {
530         int cur_x, cur_y;
531         get_abs_cursor(cur_x, cur_y, 0);
532         detail_dialog->start((Asset*)asset_edit->indexable, cur_x, cur_y);
533 }
534
535
536 AssetEditChannels::AssetEditChannels(AssetEditWindow *fwindow,
537         char *text,
538         int x,
539         int y)
540  : BC_TumbleTextBox(fwindow, (int)atol(text), (int)1,
541                 (int)MAXCHANNELS, x, y, xS(50))
542 {
543         this->fwindow = fwindow;
544 }
545
546 int AssetEditChannels::handle_event()
547 {
548         Asset *asset = fwindow->asset_edit->changed_params;
549         asset->channels = atol(get_text());
550         return 1;
551 }
552
553 AssetEditRate::AssetEditRate(AssetEditWindow *fwindow, char *text, int x, int y)
554  : BC_TextBox(x, y, xS(100), 1, text)
555 {
556         this->fwindow = fwindow;
557 }
558
559 int AssetEditRate::handle_event()
560 {
561         Asset *asset = fwindow->asset_edit->changed_params;
562         asset->sample_rate = atol(get_text());
563         return 1;
564 }
565
566 AssetEditFRate::AssetEditFRate(AssetEditWindow *fwindow, char *text, int x, int y)
567  : BC_TextBox(x, y, xS(100), 1, text)
568 {
569         this->fwindow = fwindow;
570 }
571
572 int AssetEditFRate::handle_event()
573 {
574         Asset *asset = fwindow->asset_edit->changed_params;
575         asset->frame_rate = atof(get_text());
576         return 1;
577 }
578
579
580 AssetEditILacemode::AssetEditILacemode(AssetEditWindow *fwindow, const char *text, int x, int y, int w)
581  : BC_TextBox(x, y, w, 1, text)
582 {
583         this->fwindow = fwindow;
584 }
585
586 int AssetEditILacemode::handle_event()
587 {
588         Asset *asset = fwindow->asset_edit->changed_params;
589         asset->interlace_mode = ilacemode_from_text(get_text(), ILACE_ASSET_MODEDEFAULT);
590         return 1;
591 }
592
593 AssetEditInterlacemodePulldown::AssetEditInterlacemodePulldown(MWindow *mwindow,
594                 BC_TextBox *output_text, int *output_value,
595                 ArrayList<BC_ListBoxItem*> *data, int x, int y)
596  : BC_ListBox(x, y, xS(160), yS(80), LISTBOX_TEXT, data, 0, 0, 1, 0, 1)
597 {
598         this->mwindow = mwindow;
599         this->output_text = output_text;
600         this->output_value = output_value;
601         output_text->update(interlacemode_to_text());
602 }
603
604 int AssetEditInterlacemodePulldown::handle_event()
605 {
606         output_text->update(get_selection(0, 0)->get_text());
607         *output_value = ((InterlacemodeItem*)get_selection(0, 0))->value;
608         return 1;
609 }
610
611 char* AssetEditInterlacemodePulldown::interlacemode_to_text()
612 {
613         ilacemode_to_text(this->string,*output_value);
614         return (this->string);
615 }
616
617 AssetEditHeader::AssetEditHeader(AssetEditWindow *fwindow, char *text, int x, int y)
618  : BC_TextBox(x, y, xS(100), 1, text)
619 {
620         this->fwindow = fwindow;
621 }
622
623 int AssetEditHeader::handle_event()
624 {
625         Asset *asset = fwindow->asset_edit->changed_params;
626         asset->header = atol(get_text());
627         return 1;
628 }
629
630 AssetEditByteOrderLOHI::AssetEditByteOrderLOHI(AssetEditWindow *fwindow,
631         int value,
632         int x,
633         int y)
634  : BC_Radial(x, y, value, _("Lo-Hi"))
635 {
636         this->fwindow = fwindow;
637 }
638
639 int AssetEditByteOrderLOHI::handle_event()
640 {
641         Asset *asset = fwindow->asset_edit->changed_params;
642         asset->byte_order = 1;
643         fwindow->hilo->update(0);
644         update(1);
645         return 1;
646 }
647
648 AssetEditByteOrderHILO::AssetEditByteOrderHILO(AssetEditWindow *fwindow,
649         int value,
650         int x,
651         int y)
652  : BC_Radial(x, y, value, _("Hi-Lo"))
653 {
654         this->fwindow = fwindow;
655 }
656
657 int AssetEditByteOrderHILO::handle_event()
658 {
659         Asset *asset = fwindow->asset_edit->changed_params;
660         asset->byte_order = 0;
661         fwindow->lohi->update(0);
662         update(1);
663         return 1;
664 }
665
666 AssetEditSigned::AssetEditSigned(AssetEditWindow *fwindow,
667         int value,
668         int x,
669         int y)
670  : BC_CheckBox(x, y, value, _("Values are signed"))
671 {
672         this->fwindow = fwindow;
673 }
674
675 int AssetEditSigned::handle_event()
676 {
677         Asset *asset = fwindow->asset_edit->changed_params;
678         asset->signed_ = get_value();
679         return 1;
680 }
681
682
683
684
685
686
687
688 AssetEditPathText::AssetEditPathText(AssetEditWindow *fwindow, int y)
689  : BC_TextBox(5, y, xS(300), 1, fwindow->asset_edit->changed_params->path)
690 {
691         this->fwindow = fwindow;
692 }
693 AssetEditPathText::~AssetEditPathText()
694 {
695 }
696 int AssetEditPathText::handle_event()
697 {
698         strcpy(fwindow->asset_edit->changed_params->path, get_text());
699         return 1;
700 }
701
702 AssetEditPath::AssetEditPath(MWindow *mwindow, AssetEditWindow *fwindow,
703         BC_TextBox *textbox, int y, const char *text,
704         const char *window_title, const char *window_caption)
705  : BrowseButton(mwindow->theme, fwindow, textbox, yS(310), y, text,
706         window_title, window_caption, 0)
707 {
708         this->fwindow = fwindow;
709 }
710
711 AssetEditPath::~AssetEditPath() {}
712
713
714
715
716 DetailAssetButton::DetailAssetButton(AssetEditWindow *fwindow, int x, int y)
717  : BC_GenericButton(x, y, _("Detail"))
718 {
719         this->fwindow = fwindow;
720 }
721
722 DetailAssetButton::~DetailAssetButton()
723 {
724 }
725
726 int DetailAssetButton::handle_event()
727 {
728         fwindow->show_info_detail();
729         return 1;
730 }
731
732 #define DTL_W xS(600)
733 #define DTL_H yS(500)
734
735 DetailAssetWindow::DetailAssetWindow(MWindow *mwindow,
736         DetailAssetDialog *detail_dialog, Asset *asset)
737  : BC_Window(_("Asset Detail"),
738         detail_dialog->x - DTL_W/2, detail_dialog->y - DTL_H/2, DTL_W, DTL_H)
739 {
740         this->mwindow = mwindow;
741         this->detail_dialog = detail_dialog;
742         this->asset = asset;
743         asset->add_user();
744         info[0] = 0;
745         text = 0;
746 }
747
748 DetailAssetWindow::~DetailAssetWindow()
749 {
750         asset->remove_user();
751         delete text;
752 }
753
754 DetailAssetDialog::DetailAssetDialog(MWindow *mwindow)
755  : BC_DialogThread()
756 {
757         this->mwindow = mwindow;
758         dwindow = 0;
759 }
760
761 DetailAssetDialog::~DetailAssetDialog()
762 {
763         close_window();
764 }
765
766 void DetailAssetWindow::create_objects()
767 {
768         int y = yS(10), x = xS(10);
769         char file_name[BCTEXTLEN];
770         int len = sizeof(info);
771         strncpy(info,_("no info available"),len);
772         if( !mwindow->preferences->get_asset_file_path(asset, file_name) ) {
773                 switch( asset->format ) {
774 #ifdef HAVE_LIBZMPEG
775                 case FILE_MPEG:
776                         FileMPEG::get_info(asset->path, file_name, &info[0],len);
777                         break;
778 #endif
779                 case FILE_FFMPEG:
780                         FileFFMPEG::get_info(asset->path, &info[0],len);
781                         break;
782                 }
783         }
784         lock_window("DetailAssetWindow::create_objects");
785         int text_h = get_h()-y - BC_OKButton::calculate_h() - yS(15);
786         int lines = BC_TextBox::pixels_to_rows(this, MEDIUMFONT, text_h);
787         text = new BC_ScrollTextBox(this, x, y, get_w()-xS(32), lines, info, -len);
788         text->create_objects();  text->set_text_row(0);
789         add_subwindow(new BC_OKButton(this));
790         show_window();
791         unlock_window();
792 }
793
794 void DetailAssetDialog::start(Asset *asset, int x, int y)
795 {
796         close_window();
797         this->asset = asset;
798         this->x = x;  this->y = y;
799         BC_DialogThread::start();
800 }
801
802 BC_Window *DetailAssetDialog::new_gui()
803 {
804         dwindow = new DetailAssetWindow(mwindow, this, asset);
805         dwindow->create_objects();
806         return dwindow;
807 }
808