filemenu->add_item(new BC_MenuItem("-"));
filemenu->add_item(quit_program = new Quit(mwindow));
quit_program->create_objects(save);
- filemenu->add_item(new DumpEDL(mwindow));
- filemenu->add_item(new DumpPlugins(mwindow));
+ filemenu->add_item(dump_menu = new MainDumpsMenu(mwindow));
+ dump_menu->create_objects();
filemenu->add_item(new LoadBackup(mwindow));
filemenu->add_item(new SaveBackup(mwindow));
// ================================== menu items
+MainDumpsSubMenu::MainDumpsSubMenu(BC_MenuItem *menu_item)
+ : BC_SubMenu()
+{
+ this->menu_item = menu_item;
+}
+MainDumpsSubMenu::~MainDumpsSubMenu()
+{
+}
+
+
+MainDumpsMenu::MainDumpsMenu(MWindow *mwindow)
+ : BC_MenuItem(_("Dumps..."))
+{
+ this->mwindow = mwindow;
+ this->dumps_menu = 0;
+}
+MainDumpsMenu::~MainDumpsMenu()
+{
+}
+
+void MainDumpsMenu::create_objects()
+{
+ add_submenu(dumps_menu = new MainDumpsSubMenu(this));
+// dumps_menu->add_item(new DumpCICache(mwindow));
+ dumps_menu->add_item(new DumpEDL(mwindow));
+ dumps_menu->add_item(new DumpPlugins(mwindow));
+ dumps_menu->add_item(new DumpAssets(mwindow));
+ dumps_menu->add_item(new DumpUndo(mwindow));
+};
+
DumpCICache::DumpCICache(MWindow *mwindow)
: BC_MenuItem(_("Dump CICache"))
int DumpEDL::handle_event()
{
-//printf("DumpEDL::handle_event 1\n");
mwindow->dump_edl();
-//printf("DumpEDL::handle_event 2\n");
return 1;
}
int DumpPlugins::handle_event()
{
-//printf("DumpEDL::handle_event 1\n");
mwindow->dump_plugins();
-//printf("DumpEDL::handle_event 2\n");
return 1;
}
-
DumpAssets::DumpAssets(MWindow *mwindow)
: BC_MenuItem(_("Dump Assets"))
{ this->mwindow = mwindow; }
int DumpAssets::handle_event()
{
- mwindow->assets->dump();
+ mwindow->edl->assets->dump();
+ return 1;
+}
+
+DumpUndo::DumpUndo(MWindow *mwindow)
+ : BC_MenuItem(_("Dump Undo"))
+{
+ this->mwindow = mwindow;
+}
+
+int DumpUndo::handle_event()
+{
+ mwindow->dump_undo();
return 1;
}
{
int result = gui->drag_stop();
if( !result && mwindow->session->current_operation ) {
- mwindow->edl->tracks->clear_selected_edits();
mwindow->session->current_operation = NO_OPERATION;
drag_scroll = 0;
}
double drop_position = new_pos;
int ret = test_track_group(drag_group, drop_track, new_pos);
if( !ret && new_pos != drop_position ) {
+ drop_position = new_pos;
ret = test_track_group(drag_group, drop_track, new_pos);
}
- if( ret )
- mwindow->move_group(drag_group, drop_track, new_pos);
+ if( ret >= 0 )
+ mwindow->move_group(drag_group, drop_track, drop_position,
+ ret > 0 ? !shift_down() : shift_down());
drag_group->remove_user();
mwindow->session->drag_group = 0;
}
void TrackCanvas::update_cursor(int flush)
{
- switch(mwindow->edl->session->editing_mode)
- {
- case EDITING_ARROW: set_cursor(ARROW_CURSOR, 0, flush); break;
- case EDITING_IBEAM: set_cursor(IBEAM_CURSOR, 0, flush); break;
- }
+ if( arrow_mode() )
+ set_cursor(ARROW_CURSOR, 0, flush);
+ else if( ibeam_mode() )
+ set_cursor(IBEAM_CURSOR, 0, flush);
}
void TrackCanvas::test_timer()
{
- if(resource_timer->get_difference() > 1000 &&
- !hourglass_enabled)
- {
+ if( resource_timer->get_difference() > 1000 && !hourglass_enabled ) {
start_hourglass();
hourglass_enabled = 1;
}
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;
+ if( ret < 0 )
+ color = ORANGE;
+ else if( !ret ) {
+ if( 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 > 0 ? YELLOW : shift_down() ? RED : BLUE;
}
- else if( !ret )
- color = RED;
track_dimensions(mwindow->session->track_highlighted, x, y, w, h);
int dx = cx - mwindow->session->drag_origin_x;
int dy = y - mwindow->session->drag_origin_y;
draw_selected_edits(mwindow->edl, 0, 0, GREEN+BLUE, RED);
}
+// x does not reliably draw a really big rectangle
+void TrackCanvas::draw_selected(int x, int y, int w, int h)
+{
+ int x1 = bmax(x, 0), x2 = bmin(x+w, get_w());
+ if( x1 > x2 ) return;
+ int y1 = bmax(y, 0), y2 = bmin(y+h, get_h());
+ if( y1 > y2 ) return;
+ if( x >= 0 && x < get_w() ) draw_line(x,y1, x,y2);
+ if( x+w >= 0 && x+w < get_w() ) draw_line(x+w,y1, x+w,y2);
+ if( y >= 0 && y < get_h() ) draw_line(x1,y, x2,y);
+ if( y+h >= 0 && y+h < get_h() ) draw_line(x1,y+h, x2,y+h);
+}
+
void TrackCanvas::draw_selected_edits(EDL *edl, int dx, int dy, int color0, int color1)
{
for( Track *track=edl->tracks->first; track; track=track->next ) {
int inner = color1 < 0 ? color0 : !edit->group_id ? color0 :
mwindow->get_group_color(edit->group_id);
set_color(inner);
- draw_rectangle(x, y, w, h);
+ draw_selected(x, y, w, h);
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);
+ draw_selected(x-1, y-1, w+2, h+2);
+ draw_selected(x-2, y-2, w+1, h+1);
}
}
}
int update_scroll = 0;
int update_overlay = 0;
int update_cursor = 0;
- int new_cursor = 0;
int rerender = 0;
double position = 0.;
//printf("TrackCanvas::cursor_update %d\n", __LINE__);
// Default cursor
- switch(mwindow->edl->session->editing_mode)
- {
- case EDITING_ARROW: new_cursor = ARROW_CURSOR; break;
- case EDITING_IBEAM: new_cursor = IBEAM_CURSOR; break;
- }
+ int new_cursor =
+ arrow_mode() ? ARROW_CURSOR :
+ ibeam_mode() ? IBEAM_CURSOR : 0;
switch(mwindow->session->current_operation)
{
return result;
}
+int TrackCanvas::arrow_mode()
+{
+ return mwindow->edl->session->editing_mode == EDITING_ARROW ? 1 : 0;
+}
+int TrackCanvas::ibeam_mode()
+{
+ return mwindow->edl->session->editing_mode == EDITING_IBEAM ? 1 : 0;
+}
+
int TrackCanvas::do_edits(int cursor_x, int cursor_y, int button_press, int drag_start,
int &redraw, int &rerender, int &new_cursor, int &update_cursor)
{
// Cursor inside a track
// 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( cursor_x >= edit_x && cursor_x < edit_x + edit_w &&
+ cursor_y >= edit_y && cursor_y < edit_y + edit_h ) {
if( button_press && get_buttonpress() == LEFT_BUTTON ) {
- if( get_double_click() && (ctrl_down() ||
- mwindow->edl->session->editing_mode == EDITING_IBEAM) ) {
-// Select duration of edit
+ if( get_double_click() ) {
+ mwindow->edl->tracks->clear_selected_edits();
+ mwindow->edl->tracks->select_affected_edits(
+ edit->track->from_units(edit->startproject),
+ edit->track, 1);
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;
+ result = 1; // Select edit duration or select_region
}
- else if( mwindow->edl->session->editing_mode == EDITING_ARROW ||
- ctrl_down() ) {
+ else if( arrow_mode() || (ibeam_mode() && ctrl_down()) ) {
mwindow->session->drag_edit = edit;
mwindow->session->current_operation = GROUP_TOGGLE;
result = 1;
drag_start = 0; // if unselected "fast" drag
if( !edit->silence() && !edit->is_selected ) {
mwindow->edl->tracks->clear_selected_edits();
- if( ctrl_down() ) {
+ if( ibeam_mode() ) {
double start = edit->track->from_units(edit->startproject);
+ mwindow->edl->local_session->set_selectionstart(start);
mwindow->edl->local_session->set_selectionend(start);
edit->set_selected(1);
}
drag_start = 1;
}
// Construct list of all affected edits
- if( ctrl_down() || drag_start ) {
+ if( drag_start || ibeam_mode() ) {
mwindow->edl->tracks->get_selected_edits(mwindow->session->drag_edits);
if( mwindow->session->drag_edits->size() > 0 ) {
mwindow->session->current_operation = DRAG_EDIT;
update_cursor = 1;
}
}
- else if( edit->is_selected ) {
+ else if( edit->is_selected && arrow_mode() ) {
if( mwindow->session->drag_group )
mwindow->session->drag_group->remove_user();
double start_position = 0;
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;
+ if( src->data_type != track->data_type ) return -1;
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;
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);
+ int64_t trk_start = track->to_units(new_start, 1);
+ int64_t trk_end = track->to_units(new_end, 1);
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);
+ int64_t lt_dist = labs(trk_end - edit_start);
+ int64_t rt_dist = labs(edit_end - trk_start);
+ int64_t position;
if( lt_dist < rt_dist ) {
- pos = edit->track->from_units(edit_start) -
- src_edit->track->from_units(src_end);
+ position = edit_start;
+ lt_dist = abs(trk_start - edit_start);
+ rt_dist = abs(trk_end - edit_start);
+ if( lt_dist > rt_dist )
+ position -= src_end;
}
else {
- pos = edit->track->from_units(edit_end);
+ position = edit_end;
+ lt_dist = abs(trk_start - edit_end);
+ rt_dist = abs(trk_end - edit_end);
+ if( lt_dist > rt_dist )
+ position -= src_end;
}
+ pos = edit->track->from_units(position);
return 1;
}
return 0;
mwindow->move_right(get_w() / 5);
}
else {
- switch(mwindow->edl->session->editing_mode) {
+ if( arrow_mode() ) do {
// Test handles and resource boundaries and highlight a track
- case EDITING_ARROW: {
if( do_transitions(cursor_x, cursor_y,
1, new_cursor, update_cursor) ) break;
if( do_tracks(cursor_x, cursor_y, 1) ) break;
result = 0;
- break; }
-
+ } while(0);
+ else if( ibeam_mode() ) do {
// Test handles only and select a region
- case EDITING_IBEAM: {
double position = mwindow->edl->get_cursor_position(cursor_x, pane->number);
//printf("TrackCanvas::button_press_event %d\n", position);
rerender = start_selection(position);
mwindow->session->current_operation = SELECT_REGION;
update_cursor = 1;
- break; }
- }
+ } while(0);
}
if( rerender ) {