4 #include "awindowgui.h"
5 #include "bcprogressbox.h"
11 #include "filesystem.h"
12 #include "indexfile.h"
13 #include "mainindexes.h"
15 #include "mwindowgui.h"
17 #include "preferences.h"
18 #include "transportque.h"
23 #define _(String) gettext(String)
24 #define gettext_noop(String) String
25 #define N_(String) gettext_noop (String)
28 AssetEdit::AssetEdit(MWindow *mwindow)
31 this->mwindow = mwindow;
38 AssetEdit::~AssetEdit()
43 void AssetEdit::edit_asset(Asset *asset)
47 // Allow more than one window
54 int AssetEdit::set_asset(Asset *asset)
64 new_asset = new Asset(asset->path);
68 window = new AssetEditWindow(mwindow, this);
69 window->create_objects();
70 result = window->run_window();
74 if(!asset->equivalent(*new_asset, 1, 1))
76 mwindow->gui->lock_window();
77 // Omit index status from copy since an index rebuild may have been
78 // happening when new_asset was created but not be happening anymore.
79 asset->copy_from(new_asset, 0);
81 mwindow->gui->update(0,
89 // Start index rebuilding
92 char source_filename[BCTEXTLEN];
93 char index_filename[BCTEXTLEN];
94 IndexFile::get_index_filename(source_filename,
95 mwindow->preferences->index_directory,
98 remove(index_filename);
99 asset->index_status = INDEX_NOTTESTED;
100 mwindow->mainindexes->add_next_asset(asset);
101 mwindow->mainindexes->start_build();
103 mwindow->gui->unlock_window();
106 mwindow->awindow->gui->lock_window();
107 mwindow->awindow->gui->update_assets();
108 mwindow->awindow->gui->unlock_window();
110 mwindow->restart_brender();
111 mwindow->sync_parameters(CHANGE_ALL);
128 AssetEditWindow::AssetEditWindow(MWindow *mwindow, AssetEdit *asset_edit)
129 : BC_Window(PROGRAM_NAME ": Asset Info",
130 mwindow->gui->get_abs_cursor_x() - 400 / 2,
131 mwindow->gui->get_abs_cursor_y() - 500 / 2,
140 this->mwindow = mwindow;
141 this->asset_edit = asset_edit;
142 this->asset = asset_edit->new_asset;
144 if(asset->format == FILE_PCM)
154 AssetEditWindow::~AssetEditWindow()
156 if(bitspopup) delete bitspopup;
159 int AssetEditWindow::create_objects()
161 int y = 10, x = 10, x1 = 10, x2 = 150;
164 int hmargin1 = 180, hmargin2 = 290;
172 add_subwindow(path_text = new AssetEditPathText(this, y));
173 add_subwindow(path_button = new AssetEditPath(mwindow,
178 PROGRAM_NAME ": Asset path", _("Select a file for this asset:")));
181 add_subwindow(new BC_Title(x, y, _("File format:")));
184 add_subwindow(new BC_Title(x, y, file.formattostr(mwindow->plugindb, asset->format), MEDIUMFONT, YELLOW));
188 add_subwindow(new BC_Title(x, y, _("Bytes:")));
189 sprintf(string, "%lld", fs.get_size(asset->path));
191 int len = strlen(string);
192 int commas = (len - 1) / 3;
193 for(int i = len + commas, j = len, k; j >= 0 && i >= 0; i--, j--)
195 k = (len - j - 1) / 3;
196 if(k * 3 == len - j - 1 && j != len - 1 && string[j] != 0)
201 string[i] = string[j];
205 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, YELLOW));
209 if(asset->audio_data)
211 add_subwindow(new BC_Title(x, y, _("Audio:"), LARGEFONT, RED));
217 add_subwindow(new BC_Title(x, y, _("Compression:")));
218 sprintf(string, "%c%c%c%c",
224 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, YELLOW));
229 add_subwindow(new BC_Title(x, y, _("Channels:")));
230 sprintf(string, "%d", asset->channels);
235 BC_TumbleTextBox *textbox = new AssetEditChannels(this, string, x, y);
236 textbox->create_objects();
241 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, YELLOW));
246 add_subwindow(new BC_Title(x, y, _("Sample rate:")));
247 sprintf(string, "%d", asset->sample_rate);
254 add_subwindow(textbox = new AssetEditRate(this, string, x, y));
255 x += textbox->get_w();
256 add_subwindow(new SampleRatePulldown(mwindow, textbox, x, y));
260 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, YELLOW));
266 add_subwindow(new BC_Title(x, y, _("Bits:")));
270 bitspopup = new BitsPopup(this,
279 bitspopup->create_objects();
282 add_subwindow(new BC_Title(x, y, File::bitstostr(asset->bits), MEDIUMFONT, YELLOW));
287 add_subwindow(new BC_Title(x, y, _("Header length:")));
288 sprintf(string, "%d", asset->header);
292 add_subwindow(new AssetEditHeader(this, string, x, y));
294 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, YELLOW));
299 add_subwindow(new BC_Title(x, y, _("Byte order:")));
304 add_subwindow(hilo = new AssetEditByteOrderHILO(this,
309 add_subwindow(lohi = new AssetEditByteOrderLOHI(this,
318 if(asset->byte_order)
319 add_subwindow(new BC_Title(x, y, _("Lo-Hi"), MEDIUMFONT, YELLOW));
321 add_subwindow(new BC_Title(x, y, _("Hi-Lo"), MEDIUMFONT, YELLOW));
329 // add_subwindow(new BC_Title(x, y, _("Values are signed:")));
330 add_subwindow(new AssetEditSigned(this, asset->signed_, x, y));
334 if(!asset->signed_ && asset->bits == 8)
335 add_subwindow(new BC_Title(x, y, _("Values are unsigned")));
337 add_subwindow(new BC_Title(x, y, _("Values are signed")));
344 if(asset->video_data)
346 add_subwindow(new BC_Title(x, y, _("Video:"), LARGEFONT, RED));
352 add_subwindow(new BC_Title(x, y, _("Compression:")));
353 sprintf(string, "%c%c%c%c",
359 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, YELLOW));
364 add_subwindow(new BC_Title(x, y, _("Frame rate:")));
366 sprintf(string, "%.2f", asset->frame_rate);
367 BC_TextBox *framerate;
368 add_subwindow(framerate = new AssetEditFRate(this, string, x, y));
370 add_subwindow(new FrameRatePulldown(mwindow, framerate, x, y));
374 add_subwindow(new BC_Title(x, y, _("Width:")));
376 sprintf(string, "%d", asset->width);
377 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, YELLOW));
381 add_subwindow(new BC_Title(x, y, _("Height:")));
383 sprintf(string, "%d", asset->height);
384 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, YELLOW));
388 add_subwindow(new BC_OKButton(this));
389 add_subwindow(new BC_CancelButton(this));
395 AssetEditChannels::AssetEditChannels(AssetEditWindow *fwindow,
399 : BC_TumbleTextBox(fwindow,
407 this->fwindow = fwindow;
410 int AssetEditChannels::handle_event()
412 fwindow->asset->channels = atol(get_text());
416 AssetEditRate::AssetEditRate(AssetEditWindow *fwindow, char *text, int x, int y)
417 : BC_TextBox(x, y, 100, 1, text)
419 this->fwindow = fwindow;
422 int AssetEditRate::handle_event()
424 fwindow->asset->sample_rate = atol(get_text());
428 AssetEditFRate::AssetEditFRate(AssetEditWindow *fwindow, char *text, int x, int y)
429 : BC_TextBox(x, y, 100, 1, text)
431 this->fwindow = fwindow;
434 int AssetEditFRate::handle_event()
436 fwindow->asset->frame_rate = atof(get_text());
440 AssetEditHeader::AssetEditHeader(AssetEditWindow *fwindow, char *text, int x, int y)
441 : BC_TextBox(x, y, 100, 1, text)
443 this->fwindow = fwindow;
446 int AssetEditHeader::handle_event()
448 fwindow->asset->header = atol(get_text());
452 AssetEditByteOrderLOHI::AssetEditByteOrderLOHI(AssetEditWindow *fwindow,
456 : BC_Radial(x, y, value, _("Lo-Hi"))
458 this->fwindow = fwindow;
461 int AssetEditByteOrderLOHI::handle_event()
463 fwindow->asset->byte_order = 1;
464 fwindow->hilo->update(0);
469 AssetEditByteOrderHILO::AssetEditByteOrderHILO(AssetEditWindow *fwindow,
473 : BC_Radial(x, y, value, _("Hi-Lo"))
475 this->fwindow = fwindow;
478 int AssetEditByteOrderHILO::handle_event()
480 fwindow->asset->byte_order = 0;
481 fwindow->lohi->update(0);
486 AssetEditSigned::AssetEditSigned(AssetEditWindow *fwindow,
490 : BC_CheckBox(x, y, value, _("Values are signed"))
492 this->fwindow = fwindow;
495 int AssetEditSigned::handle_event()
497 fwindow->asset->signed_ = get_value();
507 AssetEditPathText::AssetEditPathText(AssetEditWindow *fwindow, int y)
508 : BC_TextBox(5, y, 300, 1, fwindow->asset->path)
510 this->fwindow = fwindow;
512 AssetEditPathText::~AssetEditPathText()
515 int AssetEditPathText::handle_event()
517 strcpy(fwindow->asset->path, get_text());
521 AssetEditPath::AssetEditPath(MWindow *mwindow, AssetEditWindow *fwindow, BC_TextBox *textbox, int y, char *text, char *window_title, char *window_caption)
522 : BrowseButton(mwindow, fwindow, textbox, 310, y, text, window_title, window_caption, 0)
524 this->fwindow = fwindow;
526 AssetEditPath::~AssetEditPath() {}
533 AssetEditFormat::AssetEditFormat(AssetEditWindow *fwindow, char* default_, int y)
534 : FormatPopup(fwindow->mwindow->plugindb, 90, y)
536 this->fwindow = fwindow;
538 AssetEditFormat::~AssetEditFormat()
541 int AssetEditFormat::handle_event()
543 fwindow->asset->format = File::strtoformat(fwindow->mwindow->plugindb, get_selection(0, 0)->get_text());