Exemplo n.º 1
0
int MainMenu::add_load(char *new_path)
{
	char filename[BCTEXTLEN];
	FileSystem dir;

	int total_loads = recent_load->items.total;

	if(total_loads == 0)
	{
		filemenu->add_item(new BC_MenuItem("-"));
	}

	int new_total = recent_load->add_item(NULL, new_path);

	if (new_total > total_loads) {
		// just create a new item if there is room for it
		int i = new_total - 1;
		load[i] = new LoadPrevious(mwindow);
		dir.extract_name(filename, new_path, 0);
		load[i]->set_text(filename);
		load[i]->set_path(new_path);
		filemenu->add_item(load[i]);
	}

	// reassign the paths to adjust for the shift down
	for(int i = 0; i < new_total; i++) {
		char *path = recent_load->items.values[i]->get_text();
		dir.extract_name(filename, path, 0);
		load[i]->set_text(filename);
		load[i]->set_path(path);
	}

	return 0;
}
Exemplo n.º 2
0
void Render::start_progress()
{
	char filename[BCTEXTLEN];
	char string[BCTEXTLEN];
	FileSystem fs;

	progress_max = Units::to_int64(default_asset->sample_rate * 
			(total_end - total_start)) +
		Units::to_int64(preferences->render_preroll * 
			packages->total_allocated * 
			default_asset->sample_rate);
	progress_timer->update();
	last_eta = 0;
	if(mwindow)
	{
// Generate the progress box
		fs.extract_name(filename, default_asset->path);
		sprintf(string, _("Rendering %s..."), filename);

// Don't bother with the filename since renderfarm defeats the meaning
		progress = mwindow->mainprogress->start_progress(_("Rendering..."), 
			progress_max);
		render_progress = new RenderProgress(mwindow, this);
		render_progress->start();
	}
}
Exemplo n.º 3
0
int MainMenu::init_loads(BC_Hash *defaults)
{
//printf("MainMenu::init_loads 1\n");
//printf("MainMenu::init_loads 1\n");
	char string[BCTEXTLEN], path[BCTEXTLEN], filename[BCTEXTLEN];
//printf("MainMenu::init_loads 1\n");
	FileSystem dir;
	
	recent_load->load_items();

	int total_loads = recent_load->items.total;
//printf("MainMenu::init_loads 2\n");
	if(total_loads > 0) filemenu->add_item(new BC_MenuItem("-"));

	for(int i = 0; i < total_loads; i++)
	{
		char *path = recent_load->items.values[i]->get_text();

		filemenu->add_item(load[i] = new LoadPrevious(mwindow));
//printf("MainMenu::init_loads 5\n");
		dir.extract_name(filename, path, 0);
//printf("MainMenu::init_loads 6\n");
		load[i]->set_text(filename);
//printf("MainMenu::init_loads 7\n");
		load[i]->set_path(path);
//printf("MainMenu::init_loads 8\n");
	}
//printf("MainMenu::init_loads 9\n");
	return 0;
}
Exemplo n.º 4
0
void ResourcePixmap::draw_title(Edit *edit,
	int64_t edit_x, 
	int64_t edit_w, 
	int64_t pixmap_x, 
	int64_t pixmap_w)
{
// coords relative to pixmap
	int64_t total_x = edit_x - pixmap_x, total_w = edit_w;
	int64_t x = total_x, w = total_w;
	int left_margin = 10;

	if(x < 0) 
	{
		w -= -x;
		x = 0;
	}
	if(w > pixmap_w) w -= w - pixmap_w;

	canvas->draw_3segmenth(x, 
		0, 
		w, 
		total_x,
		total_w,
		mwindow->theme->get_image("title_bg_data"),
		this);

	if(total_x > -BC_INFINITY)
	{
		char title[BCTEXTLEN], channel[BCTEXTLEN];
		FileSystem fs;

		if(edit->user_title[0])
			strcpy(title, edit->user_title);
		else
		{
			fs.extract_name(title, edit->asset->path);

			sprintf(channel, " #%d", edit->channel + 1);
			strcat(title, channel);
		}

		canvas->set_color(mwindow->theme->title_color);
		canvas->set_font(mwindow->theme->title_font);
//printf("ResourcePixmap::draw_title 1 %d\n", total_x + 10);
		
// Justify the text on the left boundary of the edit if it is visible.
// Otherwise justify it on the left side of the screen.
		int text_x = total_x + left_margin;
		text_x = MAX(left_margin, text_x);
		canvas->draw_text(text_x, 
			canvas->get_text_ascent(MEDIUMFONT_3D) + 2, 
			title,
			strlen(title),
			this);
	}
}
Exemplo n.º 5
0
void VWindow::change_source(Asset *asset)
{
//printf("VWindow::change_source 1\n");
// 	if(asset && this->asset &&
// 		asset->id == this->asset->id &&
// 		asset == this->asset) return;

//printf("VWindow::change_source(Asset *asset) 1\n");

	char title[BCTEXTLEN];
	FileSystem fs;
	fs.extract_name(title, asset->path);
//printf("VWindow::change_source 1\n");

	delete_edl();
//printf("VWindow::change_source 1\n");

// Generate EDL off of main EDL for cutting
	this->asset = new Asset;
	*this->asset = *asset;
	mwindow->edl->vwindow_edl = new EDL(mwindow->edl);
	mwindow->edl->vwindow_edl_shared = 0;
	mwindow->edl->vwindow_edl->create_objects();
	mwindow->asset_to_edl(mwindow->edl->vwindow_edl, asset);
//printf("VWindow::change_source 1 %d %d\n", edl->local_session->loop_playback, mwindow->edl->local_session->loop_playback);
//edl->dump();

// Update GUI
	gui->change_source(mwindow->edl->vwindow_edl, title);
	update_position(CHANGE_ALL, 1, 1);


// Update master session
	strcpy(mwindow->edl->session->vwindow_folder, MEDIA_FOLDER);
	mwindow->edl->session->vwindow_source = 0;
	int i = 0;
	for(Asset *current = mwindow->edl->assets->first; 
		current;
		current = NEXT)
	{
		if(this->asset->equivalent(*current, 0, 0))
		{
			mwindow->edl->session->vwindow_source = i;
			break;
		}
		i++;
	}

//printf("VWindow::change_source 2\n");
}
Exemplo n.º 6
0
int ReverbMenu::add_load(char *path)
{
    if(total_loads == 0)
    {
        filemenu->add_item(new BC_MenuItem("-"));
    }

// test for existing copy
    FileSystem fs;
    char text[1024], new_path[1024];      // get text and path
    fs.extract_name(text, path);
    strcpy(new_path, path);

    for(int i = 0; i < total_loads; i++)
    {
        if(!strcmp(prev_load[i]->get_text(), text))     // already exists
        {   // swap for top load
            for(int j = i; j > 0; j--)   // move preceeding loads down
            {
                prev_load[j]->set_text(prev_load[j - 1]->get_text());
                prev_load[j]->set_path(prev_load[j - 1]->path);
            }
            prev_load[0]->set_text(text);
            prev_load[0]->set_path(new_path);
            return 1;
        }
    }

// add another load
    if(total_loads < TOTAL_LOADS)
    {
        filemenu->add_item(prev_load[total_loads] = new ReverbLoadPrev(reverb, this));
        total_loads++;
    }

// cycle loads down
    for(int i = total_loads - 1; i > 0; i--)
    {
        // set menu item text
        prev_load[i]->set_text(prev_load[i - 1]->get_text());
        // set filename
        prev_load[i]->set_path(prev_load[i - 1]->path);
    }

// set up the new load
    prev_load[0]->set_text(text);
    prev_load[0]->set_path(new_path);
    return 0;
}
Exemplo n.º 7
0
int ReverbMenu::load_defaults(BC_Hash *defaults)
{
    FileSystem fs;
    total_loads = defaults->get("TOTAL_LOADS", 0);
    if(total_loads > 0)
    {
        filemenu->add_item(new BC_MenuItem("-"));
        char string[1024], path[1024], filename[1024];

        for(int i = 0; i < total_loads; i++)
        {
            sprintf(string, "LOADPREVIOUS%d", i);
            defaults->get(string, path);
            fs.extract_name(filename, path);
//printf("ReverbMenu::load_defaults %s\n", path);
            filemenu->add_item(prev_load[i] = new ReverbLoadPrev(reverb, this, filename, path));
        }
    }
    return 0;
}
Exemplo n.º 8
0
void Render::start_progress()
{
	char filename[BCTEXTLEN];
	char string[BCTEXTLEN];
	FileSystem fs;

	progress_max = packages->get_progress_max();

	progress_timer->update();
	last_eta = 0;
	if(mwindow)
	{
// Generate the progress box
		fs.extract_name(filename, default_asset->path);
		sprintf(string, _("Rendering %s..."), filename);

// Don't bother with the filename since renderfarm defeats the meaning
		progress = mwindow->mainprogress->start_progress(_("Rendering..."), 
			progress_max);
		render_progress = new RenderProgress(mwindow, this);
		render_progress->start();
	}
}
Exemplo n.º 9
0
int Asset::write(FileXML *file, 
	int include_index, 
	const char *output_path)
{
	char new_path[BCTEXTLEN];
	char asset_directory[BCTEXTLEN];
	char output_directory[BCTEXTLEN];
	FileSystem fs;

// Make path relative
	fs.extract_dir(asset_directory, path);
	if(output_path && output_path[0]) 
		fs.extract_dir(output_directory, output_path);
	else
		output_directory[0] = 0;

// Asset and EDL are in same directory.  Extract just the name.
	if(!strcmp(asset_directory, output_directory))
	{
		fs.extract_name(new_path, path);
	}
	else
	{
		strcpy(new_path, path);
	}

	file->tag.set_title("ASSET");
	file->tag.set_property("SRC", new_path);
	file->append_tag();
	file->append_newline();

	file->tag.set_title("FOLDER");
	file->tag.set_property("NUMBER", awindow_folder);
	file->append_tag();
	file->tag.set_title("/FOLDER");
	file->append_tag();
	file->append_newline();

// Write the format information
	file->tag.set_title("FORMAT");

	file->tag.set_property("TYPE", 
		File::formattostr(format));
	file->tag.set_property("USE_HEADER", use_header);

	file->append_tag();
	file->tag.set_title("/FORMAT");
	file->append_tag();
	file->append_newline();

// Requiring data to exist caused batch render to lose settings.
// But the only way to know if an asset doesn't have audio or video data 
// is to not write the block.
// So change the block name if the asset doesn't have the data.
	/* if(audio_data) */ write_audio(file);
	/* if(video_data) */ write_video(file);
	if(index_status == 0 && include_index) write_index(file);  // index goes after source

	file->tag.set_title("/ASSET");
	file->append_tag();
	file->append_newline();
	return 0;
}
Exemplo n.º 10
0
int Edit::copy(int64_t start, 
	int64_t end, 
	FileXML *file, 
	const char *output_path)
{
// variables
//printf("Edit::copy 1\n");

	int64_t endproject = startproject + length;
	int result;

	if((startproject >= start && startproject <= end) ||  // startproject in range
		 (endproject <= end && endproject >= start) ||	   // endproject in range
		 (startproject <= start && endproject >= end))    // range in project
	{   
// edit is in range
		int64_t startproject_in_selection = startproject; // start of edit in selection in project
		int64_t startsource_in_selection = startsource; // start of source in selection in source
		int64_t endsource_in_selection = startsource + length; // end of source in selection
		int64_t length_in_selection = length;             // length of edit in selection
//printf("Edit::copy 2\n");

		if(startproject < start)
		{         // start is after start of edit in project
			int64_t length_difference = start - startproject;

			startsource_in_selection += length_difference;
			startproject_in_selection += length_difference;
			length_in_selection -= length_difference;
		}
//printf("Edit::copy 3\n");

		if(endproject > end)
		{         // end is before end of edit in project
			length_in_selection = end - startproject_in_selection;
		}
		
//printf("Edit::copy 4\n");
		if(file)    // only if not counting
		{
			file->tag.set_title("EDIT");
			file->tag.set_property("STARTSOURCE", startsource_in_selection);
			file->tag.set_property("CHANNEL", (int64_t)channel);
			file->tag.set_property("LENGTH", length_in_selection);
			if(user_title[0]) file->tag.set_property("USER_TITLE", user_title);
//printf("Edit::copy 5\n");

			copy_properties_derived(file, length_in_selection);

			file->append_tag();
//			file->append_newline();
//printf("Edit::copy 6\n");

			if(nested_edl)
			{
				file->tag.set_title("NESTED_EDL");
				file->tag.set_property("SRC", nested_edl->path);
				file->append_tag();
			}

			if(asset)
			{
//printf("Edit::copy 6 %s\n", asset->path);
				char stored_path[BCTEXTLEN];
				char asset_directory[BCTEXTLEN];
				char output_directory[BCTEXTLEN];
				FileSystem fs;

//printf("Edit::copy 6 %s\n", asset->path);
				fs.extract_dir(asset_directory, asset->path);
//printf("Edit::copy 6 %s\n", asset->path);

				if(output_path)
					fs.extract_dir(output_directory, output_path);
				else
					output_directory[0] = 0;
//printf("Edit::copy %s, %s %s, %s\n", asset->path, asset_directory, output_path, output_directory);

				if(output_path && !strcmp(asset_directory, output_directory))
					fs.extract_name(stored_path, asset->path);
				else
					strcpy(stored_path, asset->path);

				file->tag.set_title("FILE");
				file->tag.set_property("SRC", stored_path);
				file->append_tag();
			}

			if(transition)
			{
				transition->save_xml(file);
			}

//printf("Edit::copy 7\n");
			file->tag.set_title("/EDIT");
			file->append_tag();
			file->append_newline();	
//printf("Edit::copy 8\n");
		}
//printf("Edit::copy 9\n");
		result = 1;
	}
	else
	{
		result = 0;
	}
//printf("Edit::copy 10\n");
	return result;
}
Exemplo n.º 11
0
// Get source list from master EDL
void VWindowGUI::update_sources(const char *title)
{
	lock_window("VWindowGUI::update_sources");

//printf("VWindowGUI::update_sources 1\n");
	sources.remove_all_objects();
//printf("VWindowGUI::update_sources 2\n");



	for(int i = 0;
		i < mwindow->edl->clips.total;
		i++)
	{
		char *clip_title = mwindow->edl->clips.values[i]->local_session->clip_title;
		int exists = 0;

		for(int j = 0; j < sources.total; j++)
		{
			if(!strcasecmp(sources.values[j]->get_text(), clip_title))
			{
				exists = 1;
			}
		}

		if(!exists)
		{
			sources.append(new BC_ListBoxItem(clip_title));
		}
	}
//printf("VWindowGUI::update_sources 3\n");

	FileSystem fs;
	for(Asset *current = mwindow->edl->assets->first; 
		current;
		current = NEXT)
	{
		char clip_title[BCTEXTLEN];
		fs.extract_name(clip_title, current->path);
		int exists = 0;
		
		for(int j = 0; j < sources.total; j++)
		{
			if(!strcasecmp(sources.values[j]->get_text(), clip_title))
			{
				exists = 1;
			}
		}
		
		if(!exists)
		{
			sources.append(new BC_ListBoxItem(clip_title));
		}
	}

//printf("VWindowGUI::update_sources 4\n");

//	source->update_list(&sources);
//	source->update(title);
	unlock_window();
}