4 #include "awindowgui.h"
5 #include "bcprogressbox.h"
11 #include "filesystem.h"
12 #include "indexfile.h"
14 #include "mainindexes.h"
16 #include "mwindowgui.h"
19 #include "preferences.h"
20 #include "transportque.h"
26 AssetEdit::AssetEdit(MWindow *mwindow)
29 this->mwindow = mwindow;
36 AssetEdit::~AssetEdit()
41 void AssetEdit::edit_asset(Asset *asset)
45 // Allow more than one window
52 int AssetEdit::set_asset(Asset *asset)
62 new_asset = new Asset(asset->path);
66 window = new AssetEditWindow(mwindow, this);
67 window->create_objects();
68 result = window->run_window();
72 if(!asset->equivalent(*new_asset, 1, 1))
74 mwindow->gui->lock_window();
75 // Omit index status from copy since an index rebuild may have been
76 // happening when new_asset was created but not be happening anymore.
77 asset->copy_from(new_asset, 0);
79 mwindow->gui->update(0,
87 // Start index rebuilding
90 char source_filename[BCTEXTLEN];
91 char index_filename[BCTEXTLEN];
92 IndexFile::get_index_filename(source_filename,
93 mwindow->preferences->index_directory,
96 remove(index_filename);
97 asset->index_status = INDEX_NOTTESTED;
98 mwindow->mainindexes->add_next_asset(asset);
99 mwindow->mainindexes->start_build();
101 mwindow->gui->unlock_window();
104 mwindow->awindow->gui->lock_window();
105 mwindow->awindow->gui->update_assets();
106 mwindow->awindow->gui->unlock_window();
108 mwindow->restart_brender();
109 mwindow->sync_parameters(CHANGE_ALL);
126 AssetEditWindow::AssetEditWindow(MWindow *mwindow, AssetEdit *asset_edit)
127 : BC_Window(PROGRAM_NAME ": Asset Info",
128 mwindow->gui->get_abs_cursor_x(1) - 400 / 2,
129 mwindow->gui->get_abs_cursor_y(1) - 500 / 2,
138 this->mwindow = mwindow;
139 this->asset_edit = asset_edit;
140 this->asset = asset_edit->new_asset;
142 if(asset->format == FILE_PCM)
152 AssetEditWindow::~AssetEditWindow()
154 if(bitspopup) delete bitspopup;
157 int AssetEditWindow::create_objects()
159 int y = 10, x = 10, x1 = 10, x2 = 150;
162 int hmargin1 = 180, hmargin2 = 290;
170 add_subwindow(path_text = new AssetEditPathText(this, y));
171 add_subwindow(path_button = new AssetEditPath(mwindow,
176 PROGRAM_NAME ": Asset path", _("Select a file for this asset:")));
179 add_subwindow(new BC_Title(x, y, _("File format:")));
181 add_subwindow(new BC_Title(x, y, File::formattostr(mwindow->plugindb, asset->format), MEDIUMFONT, mwindow->theme->edit_font_color));
185 add_subwindow(new BC_Title(x, y, _("Bytes:")));
186 sprintf(string, "%lld", fs.get_size(asset->path));
188 int len = strlen(string);
189 int commas = (len - 1) / 3;
190 for(int i = len + commas, j = len, k; j >= 0 && i >= 0; i--, j--)
192 k = (len - j - 1) / 3;
193 if(k * 3 == len - j - 1 && j != len - 1 && string[j] != 0)
198 string[i] = string[j];
202 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
206 if(asset->audio_data)
208 add_subwindow(new BC_Title(x, y, _("Audio:"), LARGEFONT, RED));
214 add_subwindow(new BC_Title(x, y, _("Compression:")));
215 sprintf(string, "%c%c%c%c",
221 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
226 add_subwindow(new BC_Title(x, y, _("Channels:")));
227 sprintf(string, "%d", asset->channels);
232 BC_TumbleTextBox *textbox = new AssetEditChannels(this, string, x, y);
233 textbox->create_objects();
238 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
243 add_subwindow(new BC_Title(x, y, _("Sample rate:")));
244 sprintf(string, "%d", asset->sample_rate);
251 add_subwindow(textbox = new AssetEditRate(this, string, x, y));
252 x += textbox->get_w();
253 add_subwindow(new SampleRatePulldown(mwindow, textbox, x, y));
257 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
263 add_subwindow(new BC_Title(x, y, _("Bits:")));
267 bitspopup = new BitsPopup(this,
276 bitspopup->create_objects();
279 add_subwindow(new BC_Title(x, y, File::bitstostr(asset->bits), MEDIUMFONT, mwindow->theme->edit_font_color));
284 add_subwindow(new BC_Title(x, y, _("Header length:")));
285 sprintf(string, "%d", asset->header);
289 add_subwindow(new AssetEditHeader(this, string, x, y));
291 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
296 add_subwindow(new BC_Title(x, y, _("Byte order:")));
302 add_subwindow(lohi = new AssetEditByteOrderLOHI(this,
307 add_subwindow(hilo = new AssetEditByteOrderHILO(this,
316 if(asset->byte_order)
317 add_subwindow(new BC_Title(x, y, _("Lo-Hi"), MEDIUMFONT, mwindow->theme->edit_font_color));
319 add_subwindow(new BC_Title(x, y, _("Hi-Lo"), MEDIUMFONT, mwindow->theme->edit_font_color));
327 // add_subwindow(new BC_Title(x, y, _("Values are signed:")));
328 add_subwindow(new AssetEditSigned(this, asset->signed_, x, y));
332 if(!asset->signed_ && asset->bits == 8)
333 add_subwindow(new BC_Title(x, y, _("Values are unsigned")));
335 add_subwindow(new BC_Title(x, y, _("Values are signed")));
342 if(asset->video_data)
344 add_subwindow(new BC_Title(x, y, _("Video:"), LARGEFONT, RED));
350 add_subwindow(new BC_Title(x, y, _("Compression:")));
351 sprintf(string, "%c%c%c%c",
357 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
362 add_subwindow(new BC_Title(x, y, _("Frame rate:")));
364 sprintf(string, "%.2f", asset->frame_rate);
365 BC_TextBox *framerate;
366 add_subwindow(framerate = new AssetEditFRate(this, string, x, y));
368 add_subwindow(new FrameRatePulldown(mwindow, framerate, x, y));
372 add_subwindow(new BC_Title(x, y, _("Width:")));
374 sprintf(string, "%d", asset->width);
375 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
379 add_subwindow(new BC_Title(x, y, _("Height:")));
381 sprintf(string, "%d", asset->height);
382 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
386 add_subwindow(new BC_Title(x, y, _("Reel Name:")));
388 add_subwindow(new AssetEditReelName(this, x, y));
392 add_subwindow(new BC_Title(x, y, _("Reel Number:")));
394 add_subwindow(new AssetEditReelNumber(this, x, y));
398 add_subwindow(new BC_Title(x, y, _("Time Code Start:")));
401 // Calculate values to enter into textboxes
405 asset->tcstart / asset->frame_rate,
414 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc), x, y,
415 (int) (asset->frame_rate * 60 * 60)));
417 add_subwindow(new BC_Title(x, y, ":"));
419 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc + 2), x, y,
420 (int) (asset->frame_rate * 60)));
422 add_subwindow(new BC_Title(x, y, ":"));
424 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc + 5), x, y,
425 (int) (asset->frame_rate)));
427 add_subwindow(new BC_Title(x, y, ":"));
429 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc + 8), x, y, 1));
435 add_subwindow(new BC_OKButton(this));
436 add_subwindow(new BC_CancelButton(this));
442 AssetEditChannels::AssetEditChannels(AssetEditWindow *fwindow,
446 : BC_TumbleTextBox(fwindow,
454 this->fwindow = fwindow;
457 int AssetEditChannels::handle_event()
459 fwindow->asset->channels = atol(get_text());
463 AssetEditRate::AssetEditRate(AssetEditWindow *fwindow, char *text, int x, int y)
464 : BC_TextBox(x, y, 100, 1, text)
466 this->fwindow = fwindow;
469 int AssetEditRate::handle_event()
471 fwindow->asset->sample_rate = atol(get_text());
475 AssetEditFRate::AssetEditFRate(AssetEditWindow *fwindow, char *text, int x, int y)
476 : BC_TextBox(x, y, 100, 1, text)
478 this->fwindow = fwindow;
481 int AssetEditFRate::handle_event()
483 fwindow->asset->frame_rate = atof(get_text());
487 AssetEditHeader::AssetEditHeader(AssetEditWindow *fwindow, char *text, int x, int y)
488 : BC_TextBox(x, y, 100, 1, text)
490 this->fwindow = fwindow;
493 int AssetEditHeader::handle_event()
495 fwindow->asset->header = atol(get_text());
499 AssetEditByteOrderLOHI::AssetEditByteOrderLOHI(AssetEditWindow *fwindow,
503 : BC_Radial(x, y, value, _("Lo-Hi"))
505 this->fwindow = fwindow;
508 int AssetEditByteOrderLOHI::handle_event()
510 fwindow->asset->byte_order = 1;
511 fwindow->hilo->update(0);
516 AssetEditByteOrderHILO::AssetEditByteOrderHILO(AssetEditWindow *fwindow,
520 : BC_Radial(x, y, value, _("Hi-Lo"))
522 this->fwindow = fwindow;
525 int AssetEditByteOrderHILO::handle_event()
527 fwindow->asset->byte_order = 0;
528 fwindow->lohi->update(0);
533 AssetEditSigned::AssetEditSigned(AssetEditWindow *fwindow,
537 : BC_CheckBox(x, y, value, _("Values are signed"))
539 this->fwindow = fwindow;
542 int AssetEditSigned::handle_event()
544 fwindow->asset->signed_ = get_value();
554 AssetEditPathText::AssetEditPathText(AssetEditWindow *fwindow, int y)
555 : BC_TextBox(5, y, 300, 1, fwindow->asset->path)
557 this->fwindow = fwindow;
559 AssetEditPathText::~AssetEditPathText()
562 int AssetEditPathText::handle_event()
564 strcpy(fwindow->asset->path, get_text());
568 AssetEditPath::AssetEditPath(MWindow *mwindow, AssetEditWindow *fwindow, BC_TextBox *textbox, int y, char *text, char *window_title, char *window_caption)
569 : BrowseButton(mwindow, fwindow, textbox, 310, y, text, window_title, window_caption, 0)
571 this->fwindow = fwindow;
573 AssetEditPath::~AssetEditPath() {}
580 AssetEditFormat::AssetEditFormat(AssetEditWindow *fwindow, char* default_, int y)
581 : FormatPopup(fwindow->mwindow->plugindb, 90, y)
583 this->fwindow = fwindow;
585 AssetEditFormat::~AssetEditFormat()
588 int AssetEditFormat::handle_event()
590 fwindow->asset->format = File::strtoformat(fwindow->mwindow->plugindb, get_selection(0, 0)->get_text());
597 AssetEditReelName::AssetEditReelName(AssetEditWindow *fwindow, int x, int y)
598 : BC_TextBox(x, y, 300, 1, fwindow->asset->reel_name)
600 this->fwindow = fwindow;
602 AssetEditReelName::~AssetEditReelName()
605 int AssetEditReelName::handle_event()
607 strcpy(fwindow->asset->reel_name, get_text());
614 AssetEditReelNumber::AssetEditReelNumber(AssetEditWindow *fwindow, int x, int y)
615 : BC_TextBox(x, y, 200, 1, fwindow->asset->reel_number)
617 this->fwindow = fwindow;
619 AssetEditReelNumber::~AssetEditReelNumber()
622 int AssetEditReelNumber::handle_event()
624 char *text = get_text() + strlen(get_text()) - 1;
626 // Don't let user enter an invalid character -- only numbers here
633 fwindow->asset->reel_number = atoi(get_text());
640 AssetEditTCStartTextBox::AssetEditTCStartTextBox(AssetEditWindow *fwindow, int value, int x, int y, int multiplier)
641 : BC_TextBox(x, y, 30, 1, value)
643 this->fwindow = fwindow;
644 this->multiplier = multiplier;
647 AssetEditTCStartTextBox::~AssetEditTCStartTextBox()
650 int AssetEditTCStartTextBox::handle_event()
652 fwindow->asset->tcstart -= previous * multiplier;
653 fwindow->asset->tcstart += atoi(get_text()) * multiplier;
654 previous = atoi(get_text());