4 #include "awindowgui.h"
5 #include "bcprogressbox.h"
11 #include "filesystem.h"
12 #include "indexfile.h"
14 #include "mainindexes.h"
16 #include "mwindowgui.h"
18 #include "preferences.h"
19 #include "transportque.h"
25 AssetEdit::AssetEdit(MWindow *mwindow)
28 this->mwindow = mwindow;
35 AssetEdit::~AssetEdit()
40 void AssetEdit::edit_asset(Asset *asset)
44 // Allow more than one window
51 int AssetEdit::set_asset(Asset *asset)
61 new_asset = new Asset(asset->path);
65 window = new AssetEditWindow(mwindow, this);
66 window->create_objects();
67 result = window->run_window();
71 if(!asset->equivalent(*new_asset, 1, 1))
73 mwindow->gui->lock_window();
74 // Omit index status from copy since an index rebuild may have been
75 // happening when new_asset was created but not be happening anymore.
76 asset->copy_from(new_asset, 0);
78 mwindow->gui->update(0,
86 // Start index rebuilding
89 char source_filename[BCTEXTLEN];
90 char index_filename[BCTEXTLEN];
91 IndexFile::get_index_filename(source_filename,
92 mwindow->preferences->index_directory,
95 remove(index_filename);
96 asset->index_status = INDEX_NOTTESTED;
97 mwindow->mainindexes->add_next_asset(asset);
98 mwindow->mainindexes->start_build();
100 mwindow->gui->unlock_window();
103 mwindow->awindow->gui->lock_window();
104 mwindow->awindow->gui->update_assets();
105 mwindow->awindow->gui->unlock_window();
107 mwindow->restart_brender();
108 mwindow->sync_parameters(CHANGE_ALL);
125 AssetEditWindow::AssetEditWindow(MWindow *mwindow, AssetEdit *asset_edit)
126 : BC_Window(PROGRAM_NAME ": Asset Info",
127 mwindow->gui->get_abs_cursor_x(1) - 400 / 2,
128 mwindow->gui->get_abs_cursor_y(1) - 500 / 2,
137 this->mwindow = mwindow;
138 this->asset_edit = asset_edit;
139 this->asset = asset_edit->new_asset;
141 if(asset->format == FILE_PCM)
151 AssetEditWindow::~AssetEditWindow()
153 if(bitspopup) delete bitspopup;
156 int AssetEditWindow::create_objects()
158 int y = 10, x = 10, x1 = 10, x2 = 150;
161 int hmargin1 = 180, hmargin2 = 290;
169 add_subwindow(path_text = new AssetEditPathText(this, y));
170 add_subwindow(path_button = new AssetEditPath(mwindow,
175 PROGRAM_NAME ": Asset path", _("Select a file for this asset:")));
178 add_subwindow(new BC_Title(x, y, _("File format:")));
180 add_subwindow(new BC_Title(x, y, File::formattostr(mwindow->plugindb, asset->format), MEDIUMFONT, YELLOW));
184 add_subwindow(new BC_Title(x, y, _("Bytes:")));
185 sprintf(string, "%lld", fs.get_size(asset->path));
187 int len = strlen(string);
188 int commas = (len - 1) / 3;
189 for(int i = len + commas, j = len, k; j >= 0 && i >= 0; i--, j--)
191 k = (len - j - 1) / 3;
192 if(k * 3 == len - j - 1 && j != len - 1 && string[j] != 0)
197 string[i] = string[j];
201 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, YELLOW));
205 if(asset->audio_data)
207 add_subwindow(new BC_Title(x, y, _("Audio:"), LARGEFONT, RED));
213 add_subwindow(new BC_Title(x, y, _("Compression:")));
214 sprintf(string, "%c%c%c%c",
220 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, YELLOW));
225 add_subwindow(new BC_Title(x, y, _("Channels:")));
226 sprintf(string, "%d", asset->channels);
231 BC_TumbleTextBox *textbox = new AssetEditChannels(this, string, x, y);
232 textbox->create_objects();
237 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, YELLOW));
242 add_subwindow(new BC_Title(x, y, _("Sample rate:")));
243 sprintf(string, "%d", asset->sample_rate);
250 add_subwindow(textbox = new AssetEditRate(this, string, x, y));
251 x += textbox->get_w();
252 add_subwindow(new SampleRatePulldown(mwindow, textbox, x, y));
256 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, YELLOW));
262 add_subwindow(new BC_Title(x, y, _("Bits:")));
266 bitspopup = new BitsPopup(this,
275 bitspopup->create_objects();
278 add_subwindow(new BC_Title(x, y, File::bitstostr(asset->bits), MEDIUMFONT, YELLOW));
283 add_subwindow(new BC_Title(x, y, _("Header length:")));
284 sprintf(string, "%d", asset->header);
288 add_subwindow(new AssetEditHeader(this, string, x, y));
290 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, YELLOW));
295 add_subwindow(new BC_Title(x, y, _("Byte order:")));
301 add_subwindow(lohi = new AssetEditByteOrderLOHI(this,
306 add_subwindow(hilo = new AssetEditByteOrderHILO(this,
315 if(asset->byte_order)
316 add_subwindow(new BC_Title(x, y, _("Lo-Hi"), MEDIUMFONT, YELLOW));
318 add_subwindow(new BC_Title(x, y, _("Hi-Lo"), MEDIUMFONT, YELLOW));
326 // add_subwindow(new BC_Title(x, y, _("Values are signed:")));
327 add_subwindow(new AssetEditSigned(this, asset->signed_, x, y));
331 if(!asset->signed_ && asset->bits == 8)
332 add_subwindow(new BC_Title(x, y, _("Values are unsigned")));
334 add_subwindow(new BC_Title(x, y, _("Values are signed")));
341 if(asset->video_data)
343 add_subwindow(new BC_Title(x, y, _("Video:"), LARGEFONT, RED));
349 add_subwindow(new BC_Title(x, y, _("Compression:")));
350 sprintf(string, "%c%c%c%c",
356 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, YELLOW));
361 add_subwindow(new BC_Title(x, y, _("Frame rate:")));
363 sprintf(string, "%.2f", asset->frame_rate);
364 BC_TextBox *framerate;
365 add_subwindow(framerate = new AssetEditFRate(this, string, x, y));
367 add_subwindow(new FrameRatePulldown(mwindow, framerate, x, y));
371 add_subwindow(new BC_Title(x, y, _("Width:")));
373 sprintf(string, "%d", asset->width);
374 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, YELLOW));
378 add_subwindow(new BC_Title(x, y, _("Height:")));
380 sprintf(string, "%d", asset->height);
381 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, YELLOW));
385 add_subwindow(new BC_OKButton(this));
386 add_subwindow(new BC_CancelButton(this));
392 AssetEditChannels::AssetEditChannels(AssetEditWindow *fwindow,
396 : BC_TumbleTextBox(fwindow,
404 this->fwindow = fwindow;
407 int AssetEditChannels::handle_event()
409 fwindow->asset->channels = atol(get_text());
413 AssetEditRate::AssetEditRate(AssetEditWindow *fwindow, char *text, int x, int y)
414 : BC_TextBox(x, y, 100, 1, text)
416 this->fwindow = fwindow;
419 int AssetEditRate::handle_event()
421 fwindow->asset->sample_rate = atol(get_text());
425 AssetEditFRate::AssetEditFRate(AssetEditWindow *fwindow, char *text, int x, int y)
426 : BC_TextBox(x, y, 100, 1, text)
428 this->fwindow = fwindow;
431 int AssetEditFRate::handle_event()
433 fwindow->asset->frame_rate = atof(get_text());
437 AssetEditHeader::AssetEditHeader(AssetEditWindow *fwindow, char *text, int x, int y)
438 : BC_TextBox(x, y, 100, 1, text)
440 this->fwindow = fwindow;
443 int AssetEditHeader::handle_event()
445 fwindow->asset->header = atol(get_text());
449 AssetEditByteOrderLOHI::AssetEditByteOrderLOHI(AssetEditWindow *fwindow,
453 : BC_Radial(x, y, value, _("Lo-Hi"))
455 this->fwindow = fwindow;
458 int AssetEditByteOrderLOHI::handle_event()
460 fwindow->asset->byte_order = 1;
461 fwindow->hilo->update(0);
466 AssetEditByteOrderHILO::AssetEditByteOrderHILO(AssetEditWindow *fwindow,
470 : BC_Radial(x, y, value, _("Hi-Lo"))
472 this->fwindow = fwindow;
475 int AssetEditByteOrderHILO::handle_event()
477 fwindow->asset->byte_order = 0;
478 fwindow->lohi->update(0);
483 AssetEditSigned::AssetEditSigned(AssetEditWindow *fwindow,
487 : BC_CheckBox(x, y, value, _("Values are signed"))
489 this->fwindow = fwindow;
492 int AssetEditSigned::handle_event()
494 fwindow->asset->signed_ = get_value();
504 AssetEditPathText::AssetEditPathText(AssetEditWindow *fwindow, int y)
505 : BC_TextBox(5, y, 300, 1, fwindow->asset->path)
507 this->fwindow = fwindow;
509 AssetEditPathText::~AssetEditPathText()
512 int AssetEditPathText::handle_event()
514 strcpy(fwindow->asset->path, get_text());
518 AssetEditPath::AssetEditPath(MWindow *mwindow, AssetEditWindow *fwindow, BC_TextBox *textbox, int y, char *text, char *window_title, char *window_caption)
519 : BrowseButton(mwindow, fwindow, textbox, 310, y, text, window_title, window_caption, 0)
521 this->fwindow = fwindow;
523 AssetEditPath::~AssetEditPath() {}
530 AssetEditFormat::AssetEditFormat(AssetEditWindow *fwindow, char* default_, int y)
531 : FormatPopup(fwindow->mwindow->plugindb, 90, y)
533 this->fwindow = fwindow;
535 AssetEditFormat::~AssetEditFormat()
538 int AssetEditFormat::handle_event()
540 fwindow->asset->format = File::strtoformat(fwindow->mwindow->plugindb, get_selection(0, 0)->get_text());