asset,
asset ? asset->path : "");
fflush(fp);
- fprintf(fp," channel %d, color %08x, group_id %d\n", channel, color, group_id);
+ fprintf(fp," channel %d, color %08x, group_id %d, is_selected %d\n",
+ channel, color, group_id, is_selected);
if(transition)
{
fprintf(fp," TRANSITION %p\n", transition);
int EditTitleColorDefault::handle_event()
{
- const int color = 0, alpha = 0xff;
+ const unsigned color = 0, alpha = 0xff;
color_picker->color = color | (~alpha << 24);
color_picker->update_gui(color, alpha);
return 1;
(double)local_session->view_start[pane_no] *
local_session->zoom_sample / session->sample_rate;
}
+int64_t EDL::get_position_cursorx(double position, int pane_no)
+{
+ return (int64_t)(position * session->sample_rate / local_session->zoom_sample)
+ - local_session->view_start[pane_no];
+}
int EDL::in_use(Indexable *indexable)
{
double frame_align(double position, int round);
// frame align if cursor alignment is enabled
double align_to_frame(double position, int round);
-// get position under cursor in pane
+// get position under cursor in pane, and inverse
double get_cursor_position(int cursor_x, int pane_no);
+ int64_t get_position_cursorx(double position, int pane_no);
// increase track w/h to at least session w/h
void retrack();
sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
add_subwindow(min_db = new MeterMinDB(pwindow, string, x1, y));
x1 += min_db->get_w() + 10;
- add_subwindow(title = new BC_Title(x1, y + 5, _("Max DB:")));
+ add_subwindow(title = new BC_Title(x1, y + 5, _("Max:")));
x1 += title->get_w() + 10;
sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
add_subwindow(max_db = new MeterMaxDB(pwindow, string, x1, y));
cwindow_controls = 1;
trim_edits = 0;
current_tip = -1;
- drag_handle = 0;
cwindow_fullscreen = 0;
rwindow_fullscreen = 0;
vwindow_fullscreen = 0;
DRAG_PLUGINHANDLE2, // Dragging outside drag threshold
DRAG_SPEED,
DRAG_GROUP,
+ DRAG_BUTTON_DOWN,
DROP_TARGETING,
};
void move_edits(ArrayList<Edit*> *edits, Track *track, double position,
// 0 - old style (cut and insert elswhere), 1- new style - (clear and overwrite elsewere)
int behaviour);
- void move_group(EDL *group, Track *first_track, double position);
+ void move_group(EDL *group, Track *first_track, double position, int overwrite);
// Move effect to position
void move_effect(Plugin *plugin, Track *track, int64_t position);
void move_effect(Plugin *plugin, PluginSet *plugin_set, int64_t position);
gui->update(1, NORMAL_DRAW, 1, 0, 0, 0, 0);
}
-void MWindow::move_group(EDL *group, Track *first_track, double position)
+void MWindow::move_group(EDL *group, Track *first_track, double position, int overwrite)
{
undo->update_undo_before();
- edl->tracks->move_group(group, first_track, position);
+ edl->tracks->move_group(group, first_track, position, overwrite);
save_backup();
undo->update_undo_after(_("move group"), LOAD_ALL);
restart_brender();
#define WIDTH 400
#define HEIGHT 330
#define MAX_SCALE 16
-#define PROXY_DEFAULT_VCODEC "h265.mp4"
ProxyMenuItem::ProxyMenuItem(MWindow *mwindow)
: BC_MenuItem(_("Proxy settings..."), _("Alt-r"), 'r')
this->mwindow = mwindow;
gui = 0;
asset = new Asset;
- strcpy(asset->vcodec, PROXY_DEFAULT_VCODEC);
+
+// quicker than some, not as good as others
+ asset->format = FILE_FFMPEG;
+ strcpy(asset->fformat, "mpeg");
+ strcpy(asset->vcodec, "mpeg.mpeg");
+ asset->ff_video_bitrate = 2000000;
+
bzero(size_text, sizeof(char*) * MAX_SIZES);
bzero(size_factors, sizeof(int) * MAX_SIZES);
size_text[0] = cstrdup(_("Original size"));
int jobs = proxy_render->needed_proxies.size();
int processors = preferences->project_smp / jobs + 1, result = 0;
+// each cpu should process at least about 1 MB, or it thrashes
+ int size = edl->session->output_w * edl->session->output_h * 4;
+ int cpus = size / 0x100000 + 1;
+ if( processors > cpus ) processors = cpus;
+
if( orig->is_asset ) {
src_file = new File;
src_file->set_processors(processors);
char title[BCTEXTLEN];
edit->get_title(title);
- color = color ? ~color & 0xffffff : mwindow->theme->title_color;
- canvas->set_color(color);
+ canvas->set_color(mwindow->theme->title_color);
canvas->set_font(mwindow->theme->title_font);
// Justify the text on the left boundary of the edit if it is visible.
edit_track = edit_track->previous;
drop_track = drop_track->previous;
}
- if( drop_track && test_track_group(drag_group, drop_track) ) {
- double position = mwindow->edl->get_cursor_position(cursor_x, pane->number);
- position = mwindow->edl->align_to_frame(position, 0);
- position -= mwindow->session->drag_group_position;
- mwindow->move_group(drag_group, drop_track, position);
+ if( drop_track ) {
+ double cur_pos = mwindow->session->drag_group_position;
+ double new_pos = mwindow->edl->get_cursor_position(cursor_x, pane->number);
+ new_pos -= mwindow->session->drag_position - cur_pos;
+ new_pos = mwindow->edl->align_to_frame(new_pos, 0);
+ double drop_position = new_pos;
+ int ret = test_track_group(drag_group, drop_track, new_pos);
+ if( !ret && new_pos != drop_position ) {
+ ret = test_track_group(drag_group, drop_track, new_pos);
+ }
+ if( ret )
+ mwindow->move_group(drag_group, drop_track, new_pos, 1);
+ drag_group->remove_user();
+ mwindow->session->drag_group = 0;
+ mwindow->edl->tracks->clear_selected_edits();
}
- drag_group->remove_user();
- mwindow->session->drag_group = 0;
}
result = 1;
break;
int rerender = 0;
int new_cursor, update_cursor;
- if(mwindow->session->current_operation != NO_OPERATION) return 0;
+ if( mwindow->session->current_operation == DRAG_BUTTON_DOWN )
+ mwindow->session->current_operation = NO_OPERATION;
+ else if( mwindow->session->current_operation != NO_OPERATION )
+ return 0;
if(is_event_win()) {
if(do_plugins(get_drag_x(), get_drag_y(),
edit_track = edit_track->previous;
track = track->previous;
}
- int color = track && test_track_group(drag_group, track) ? GREEN : RED;
+ int cx = get_cursor_x();
+ double cur_pos = mwindow->session->drag_group_position;
+ double new_pos = mwindow->edl->get_cursor_position(cx, pane->number);
+ new_pos -= mwindow->session->drag_position - cur_pos;
+ new_pos = mwindow->edl->align_to_frame(new_pos, 0);
+ double drop_position = new_pos;
+ int color = GREEN;
+ int ret = test_track_group(drag_group, track, new_pos);
+ if( !ret && new_pos != drop_position ) {
+ double pos = new_pos;
+ pos += mwindow->session->drag_position - cur_pos;
+ cx = mwindow->edl->get_position_cursorx(pos, pane->number);
+ ret = test_track_group(drag_group, track, new_pos);
+ color = ret ? YELLOW : RED;
+ }
+ else if( !ret )
+ color = RED;
track_dimensions(mwindow->session->track_highlighted, x, y, w, h);
- int dx = get_cursor_x() - mwindow->session->drag_origin_x;
+ int dx = cx - mwindow->session->drag_origin_x;
int dy = y - mwindow->session->drag_origin_y;
draw_selected_edits(mwindow->edl, dx, dy, color, -1);
}
int outer = color1 < 0 ? color0 : !edit->group_id ? color1 : inner;
set_color(outer);
draw_rectangle(x-1, y-1, w+2, h+2);
+ draw_rectangle(x-2, y-2, w+1, h+1);
}
}
}
result = 1;
break; }
+ case DRAG_BUTTON_DOWN: {
+ Edit *edit = mwindow->session->drag_edit;
+ if( edit ) {
+ if( shift_down() && edit->is_selected ) {
+ if( edit->group_id > 0 ) {
+ mwindow->edl->tracks->clear_selected_edits();
+ mwindow->edl->tracks->del_group(edit->group_id);
+ }
+ else {
+ int id = mwindow->session->group_number++;
+ mwindow->edl->tracks->new_group(id);
+ }
+ redraw = 0;
+ }
+ else {
+ if( edit->group_id )
+ mwindow->edl->tracks->set_group_selected(edit->group_id, -1);
+ else
+ edit->is_selected = !edit->is_selected ? 1 : 0;
+ }
+ }
+ mwindow->session->current_operation = NO_OPERATION;
+ update_overlay = 1;
+ result = 1;
+ drag_scroll = 0;
+ break; }
+
default:
- if(mwindow->session->current_operation) {
+ if( mwindow->session->current_operation ) {
// if(mwindow->session->current_operation == SELECT_REGION) {
// mwindow->undo->update_undo_after(_("select"), LOAD_SESSION, 0, 0);
// }
mwindow->session->current_operation = NO_OPERATION;
drag_scroll = 0;
-// Traps button release events
-// result = 1;
+ //result = 0;
+ break;
}
break;
}
// Cursor inside an edit
if(cursor_x >= edit_x && cursor_x < edit_x + edit_w &&
cursor_y >= edit_y && cursor_y < edit_y + edit_h) {
+ if( button_press ) {
+ if( mwindow->edl->session->editing_mode == EDITING_IBEAM &&
+ get_double_click() ) {
// Select duration of edit
- if(button_press) {
- if( get_double_click() ) {
- if( shift_down() ) {
- if( edit->group_id > 0 ) {
- mwindow->edl->tracks->clear_selected_edits();
- mwindow->edl->tracks->del_group(edit->group_id);
- }
- else {
- int id = mwindow->session->group_number++;
- mwindow->edl->tracks->new_group(id);
- }
- mwindow->session->current_operation = NO_OPERATION;
- result = 1;
- }
- else if( !drag_start ) {
- double start = edit->track->from_units(edit->startproject);
- start = mwindow->edl->align_to_frame(start, 0);
- mwindow->edl->local_session->set_selectionstart(start);
- double end = edit->track->from_units(edit->startproject+edit->length);
- end = mwindow->edl->align_to_frame(end, 0);
- mwindow->edl->local_session->set_selectionend(end);
- result = 1;
- }
- }
- else if( ctrl_down() && get_buttonpress() == 1 &&
- mwindow->edl->session->editing_mode == EDITING_ARROW ) {
- int v = !edit->is_selected ? 1 : 0;
- if( !edit->group_id )
- edit->is_selected = v;
- else
- mwindow->edl->tracks->set_group_selected(edit->group_id, v);
+ double start = edit->track->from_units(edit->startproject);
+ start = mwindow->edl->align_to_frame(start, 0);
+ mwindow->edl->local_session->set_selectionstart(start);
+ double end = edit->track->from_units(edit->startproject+edit->length);
+ end = mwindow->edl->align_to_frame(end, 0);
+ mwindow->edl->local_session->set_selectionend(end);
+ mwindow->edl->tracks->clear_selected_edits();
+ mwindow->edl->tracks->select_affected_edits(
+ edit->track->from_units(edit->startproject),
+ edit->track, 1);
result = 1;
}
+ else if( mwindow->edl->session->editing_mode == EDITING_ARROW ) {
+ mwindow->session->drag_edit = edit;
+ mwindow->session->current_operation = DRAG_BUTTON_DOWN;
+ }
if( result ) {
- redraw = 1;
rerender = 1;
update_cursor = -1;
}
mwindow->session->drag_position =
mwindow->edl->get_cursor_position(cursor_x, pane->number);
// Construct list of all affected edits
- if( !shift_down() ) {
+ if( ctrl_down() ) {
mwindow->session->current_operation = DRAG_EDIT;
- mwindow->edl->tracks->clear_selected_edits();
- if( !ctrl_down() ) {
- mwindow->edl->tracks->select_affected_edits(
- edit->track->from_units(edit->startproject),
- edit->track);
- }
- else
- edit->is_selected = 1;
mwindow->edl->tracks->get_selected_edits(mwindow->session->drag_edits);
int cx, cy; get_abs_cursor(cx, cy);
gui->drag_popup = new BC_DragWindow(gui,
&mwindow->session->drag_group_first_track);
if( mwindow->session->drag_group ) {
mwindow->session->current_operation = DRAG_GROUP;
- mwindow->session->drag_group_position =
- mwindow->session->drag_position - start_position;
+ mwindow->session->drag_group_position = start_position;
mwindow->session->drag_group_edit = edit;
mwindow->session->drag_origin_y = edit_y;
}
}
-int TrackCanvas::test_track_group(EDL *group, Track *first_track)
+int TrackCanvas::test_track_group(EDL *group, Track *first_track, double &pos)
{
Track *src = group->tracks->first;
for( Track *track=first_track; track && src; track=track->next ) {
if( !track->record ) continue;
if( src->data_type != track->data_type ) return 0;
+ for( Edit *src_edit=src->edits->first; src_edit; src_edit=src_edit->next ) {
+ if( src_edit->silence() ) continue;
+ if( edit_intersects(track, src_edit, pos) ) return 0;
+ }
src = src->next;
}
return !src ? 1 : 0;
}
+int TrackCanvas::edit_intersects(Track *track, Edit *src_edit, double &pos)
+{
+ int64_t src_start = src_edit->startproject;
+ int64_t src_end = src_start + src_edit->length;
+ double new_start = src_edit->track->from_units(src_start) + pos;
+ double new_end = src_edit->track->from_units(src_end) + pos;
+ int64_t trk_start = track->to_units(new_start, 0);
+ int64_t trk_end = track->to_units(new_end, 0);
+ for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
+ if( edit->is_selected || edit->silence() ) continue;
+ int64_t edit_start = edit->startproject;
+ if( edit_start >= trk_end ) continue;
+ int64_t edit_end = edit_start + edit->length;
+ if( trk_start >= edit_end ) continue;
+ int lt_dist = abs(trk_end - edit_start);
+ int rt_dist = abs(edit_end - trk_start);
+ if( lt_dist < rt_dist ) {
+ pos = edit->track->from_units(edit_start) -
+ src_edit->track->from_units(src_end);
+ }
+ else {
+ pos = edit->track->from_units(edit_end);
+ }
+ return 1;
+ }
+ return 0;
+}
+
int TrackCanvas::test_resources(int cursor_x, int cursor_y)
{
return 0;
int do_tracks(int cursor_x,
int cursor_y,
int button_press);
- int test_track_group(EDL *group, Track *first_track);
+ int test_track_group(EDL *group, Track *first_track, double &pos);
+ int edit_intersects(Track *track, Edit *src_edit, double &pos);
int test_resources(int cursor_x, int cursor_y);
int do_plugins(int cursor_x,
int cursor_y,
}
}
-void Tracks::select_affected_edits(double position, Track *start_track)
+void Tracks::select_affected_edits(double position, Track *start_track, int sense)
{
for( Track *track=start_track; track; track=track->next ) {
if( !track->record ) continue;
for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
double startproject = track->from_units(edit->startproject);
if( edl->equivalent(startproject, position) ) {
- edit->is_selected = 1;
+ edit->is_selected = sense >= 0 ? sense :
+ edit->is_selected ? 0 : 1;
break;
}
}
for( Track *track=first; track; track=track->next ) {
for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
if( edit->group_id != id ) continue;
- edit->is_selected = v;
+ edit->is_selected = v >= 0 ? v : !edit->is_selected ? 1 : 0;
++count;
}
}
uint32_t load_flags);
void move_edits(ArrayList<Edit*> *edits, Track *track, double position,
int edit_labels, int edit_plugins, int edit_autos, int behaviour);
- void move_group(EDL *group, Track *first_track, double position);
+ void move_group(EDL *group, Track *first_track, double position, int overwrite);
void move_effect(Plugin *plugin, Track *track, int64_t position);
void move_effect(Plugin *plugin, PluginSet *plugin_set, int64_t position);
// Construct a list of all the recordable edits which start on position
void clear_selected_edits();
- void select_affected_edits(double position, Track *start_track);
+ void select_affected_edits(double position, Track *start_track, int sense);
void get_selected_edits(ArrayList<Edit*> *drag_edits);
int next_group_id();
int new_group(int id);
int64_t length_units = current_track->to_units(end_time, 0) -
total_units;
if(length_units < 1) length_units = 1;
-printf("Tracks::set_edit_length %d %f %f\n", __LINE__, end_time, current_track->from_units(total_units));
+//printf("Tracks::set_edit_length %d %f %f\n", __LINE__,
+// end_time, current_track->from_units(total_units));
total_units += length_units;
// Go in using the edit handle interface
}
}
-void Tracks::move_group(EDL *group, Track *first_track, double position)
+void Tracks::move_group(EDL *group, Track *first_track, double position, int overwrite)
{
for( Track *track=first; track; track=track->next ) {
if( !track->record ) continue;
if( edit->silence() ) continue;
int64_t start = pos + edit->startproject;
int64_t end = start + edit->length;
- track->edits->clear(start, end);
+ if( overwrite )
+ track->edits->clear(start, end);
Edit *dst = track->edits->insert_new_edit(start);
dst->copy_from(edit);
dst->startproject = start;
x += length_value->get_w() + 5;
add_subwindow(to_value = new ToTextBox(mwindow, this, x, y));
x += to_value->get_w() + 5;
- add_subwindow(title_alpha = new TitleBarAlpha(mwindow, this, x, y));
+ add_subwindow(title_alpha_bar = new TitleAlphaBar(mwindow, this, x, y));
+ x += title_alpha_bar->get_w() + 5;
+ add_subwindow(title_alpha_text = new TitleAlphaText(mwindow, this, x, y));
update_formatting(from_value);
update_formatting(length_value);
return 0;
}
-TitleBarAlpha::TitleBarAlpha(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
+TitleAlphaBar::TitleAlphaBar(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
: BC_FSlider(x, y, 0, 150, 200, 0, 1.0, mwindow->session->title_bar_alpha, 0)
{
this->mwindow = mwindow;
this->zoombar = zoombar;
set_precision(0.01);
- set_tooltip(_("TitleBar Alpha"));
+ set_tooltip(_("Title Alpha"));
}
-int TitleBarAlpha::handle_event()
+int TitleAlphaBar::handle_event()
{
- mwindow->session->title_bar_alpha = get_value();
+ float v = get_value();
+ mwindow->session->title_bar_alpha = v;
+ zoombar->title_alpha_text->update(v);
+ mwindow->gui->draw_trackmovement();
+ mwindow->gui->flush();
+ return 1;
+}
+
+TitleAlphaText::TitleAlphaText(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
+ : BC_TextBox(x, y, 48, 1, mwindow->session->title_bar_alpha, 0, MEDIUMFONT, 2)
+{
+ this->mwindow = mwindow;
+ this->zoombar = zoombar;
+ set_tooltip(_("Title Alpha"));
+}
+
+int TitleAlphaText::handle_event()
+{
+ float v = atof(get_text())*100;
+ mwindow->session->title_bar_alpha = v;
+ zoombar->title_alpha_bar->update(v);
mwindow->gui->draw_trackmovement();
mwindow->gui->flush();
return 1;
LengthTextBox *length_value;
FromTextBox *from_value;
ToTextBox *to_value;
- TitleBarAlpha *title_alpha;
+ TitleAlphaBar *title_alpha_bar;
+ TitleAlphaText *title_alpha_text;
char string[256], string2[256];
};
ZoomBar *zoombar;
};
-class TitleBarAlpha : public BC_FSlider
+class TitleAlphaBar : public BC_FSlider
{
public:
- TitleBarAlpha(MWindow *mwindow, ZoomBar *zoombar, int x, int y);
+ TitleAlphaBar(MWindow *mwindow, ZoomBar *zoombar, int x, int y);
+ int handle_event();
+ MWindow *mwindow;
+ ZoomBar *zoombar;
+};
+
+class TitleAlphaText : public BC_TextBox
+{
+public:
+ TitleAlphaText(MWindow *mwindow, ZoomBar *zoombar, int x, int y);
int handle_event();
MWindow *mwindow;
ZoomBar *zoombar;
class FromTextBox;
class LengthTextBox;
class ToTextBox;
-class TitleBarAlpha;
+class TitleAlphaBar;
+class TitleAlphaText;
#define ZOOMBAR_PIXELS 24