X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Ftrackcanvas.C;h=00ca2b6392588eb75c9f2be0085f630100ffae4f;hb=3f6a262cfe390b3f8b275297d64565a5b6272969;hp=016e6aa3b5bff84e127f45e25d46d7443f1bc1fc;hpb=dab459d8fcf93c377836bc30a1c4bc5505b79323;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/trackcanvas.C b/cinelerra-5.1/cinelerra/trackcanvas.C index 016e6aa3..00ca2b63 100644 --- a/cinelerra-5.1/cinelerra/trackcanvas.C +++ b/cinelerra-5.1/cinelerra/trackcanvas.C @@ -26,7 +26,7 @@ #include "bcsignals.h" #include "bctimer.h" #include "clip.h" -#include "colors.h" +#include "bccolors.h" #include "cplayback.h" #include "cursors.h" #include "cwindowgui.h" @@ -38,6 +38,7 @@ #include "edlsession.h" #include "floatauto.h" #include "floatautos.h" +#include "gwindowgui.h" #include "indexstate.h" #include "intauto.h" #include "intautos.h" @@ -45,6 +46,7 @@ #include "keyframepopup.h" #include "keyframes.h" #include "keys.h" +#include "labels.h" #include "localsession.h" #include "mainclock.h" #include "maincursor.h" @@ -108,6 +110,7 @@ TrackCanvas::TrackCanvas(MWindow *mwindow, render_timer = new Timer; hourglass_enabled = 0; timebar_position = -1; + snapped = 0; } TrackCanvas::~TrackCanvas() @@ -185,7 +188,7 @@ int TrackCanvas::drag_motion(Track **over_track, int cursor_y = get_relative_cursor_y(); if( get_cursor_over_window() && - cursor_x >= 0 && cursor_y >= 0 && + cursor_x >= 0 && cursor_y >= 0 && cursor_x < get_w() && cursor_y < get_h() ) { //printf("TrackCanvas::drag_motion %d %d\n", __LINE__, pane->number); @@ -203,15 +206,24 @@ int TrackCanvas::drag_motion(Track **over_track, { int64_t edit_x, edit_y, edit_w, edit_h; edit_dimensions(edit, edit_x, edit_y, edit_w, edit_h); - - if(cursor_x >= edit_x && - cursor_y >= edit_y && - cursor_x < edit_x + edit_w && - cursor_y < edit_y + edit_h) - { + if( cursor_y < edit_y || cursor_y >= edit_y + edit_h ) continue; + if( cursor_x >= edit_x && cursor_x < edit_x + edit_w ) { *over_edit = edit; break; } + if( edit != track->edits->last ) continue; + if( mwindow->session->current_operation != DRAG_ATRANSITION && + mwindow->session->current_operation != DRAG_VTRANSITION ) continue; + if( !edit->silence() ) { + // add silence to allow drag transition past last edit + // will be deleted by Edits::optimize if not used + double length = mwindow->edl->session->default_transition_length; + int64_t start = edit->startproject+edit->length; + int64_t units = track->to_units(length, 1); + track->edits->create_silence(start, start+units); + continue; + } + if( cursor_x >= edit_x ) { *over_edit = edit; break; } } for(int i = 0; i < track->plugin_set.total; i++) @@ -244,7 +256,7 @@ int TrackCanvas::drag_motion(Track **over_track, } if( !*over_track ) - *over_track = pane->is_over_patchbay(); + *over_track = pane->over_patchbay(); return 0; } @@ -272,7 +284,7 @@ int TrackCanvas::drag_stop(int *redraw) (cursor_y = get_relative_cursor_y()) >= 0 && cursor_y < get_h() ) over_window = 1; else { - Track *track = pane->is_over_patchbay(); + Track *track = pane->over_patchbay(); if( track && mwindow->session->track_highlighted == track ) over_window = 1; } @@ -383,7 +395,7 @@ int TrackCanvas::drag_stop(int *redraw) double asset_duration = 0; int64_t asset_length_units = 0; int64_t position = 0; - + if(mwindow->session->current_operation == DRAG_ASSET && mwindow->session->drag_assets->total) { Indexable *indexable = mwindow->session->drag_assets->values[0]; @@ -395,8 +407,8 @@ int TrackCanvas::drag_stop(int *redraw) if (video_length < 0) { if(mwindow->edl->session->si_useduration) video_length = mwindow->edl->session->si_duration; - else - video_length = 1.0 / mwindow->edl->session->frame_rate ; + else + video_length = 1.0 / mwindow->edl->session->frame_rate ; } asset_duration = video_length / indexable->get_frame_rate(); } @@ -418,14 +430,14 @@ int TrackCanvas::drag_stop(int *redraw) else { printf("DRAG_ASSET error: Asset dropped, but both drag_clips and drag_assets total is zero\n"); } - + asset_length_units = mwindow->session->track_highlighted->to_units(asset_duration, 1); position = drop_edit_position (&insertion, NULL, asset_length_units); if( position == -1 ) { result = 1; break; // Do not do anything } - + double position_f = mwindow->session->track_highlighted->from_units(position); Track *track = mwindow->session->track_highlighted; @@ -433,7 +445,7 @@ int TrackCanvas::drag_stop(int *redraw) // // FIXME, we should create an mwindow/EDL method that overwrites, without clearing the keyframes and autos // // Unfortunately, this is _a lot_ of work to do right // printf("Problematic insertion\n"); -// mwindow->edl->tracks->clear(position_f, +// mwindow->edl->tracks->clear(position_f, // position_f + asset_duration, 0); // } mwindow->paste_assets(position_f, track, !insertion); @@ -454,7 +466,7 @@ int TrackCanvas::drag_stop(int *redraw) result = 1; break; // Do not do anything } - + double position_f = mwindow->session->track_highlighted->from_units(position); Track *track = mwindow->session->track_highlighted; mwindow->move_edits(mwindow->session->drag_edits, @@ -1088,9 +1100,9 @@ void TrackCanvas::draw_paste_destination() } // Get the x coordinate - x = Units::to_int64(position * + x = Units::to_int64(position * mwindow->edl->session->sample_rate / - mwindow->edl->local_session->zoom_sample) - + mwindow->edl->local_session->zoom_sample) - mwindow->edl->local_session->view_start[pane->number]; double paste_position = -1.; @@ -1267,7 +1279,7 @@ void TrackCanvas::draw_highlight_rectangle(int x, int y, int w, int h) h = MIN(h, get_h() + 20); if(w > 0 && h > 0) { - set_color(WHITE); + set_color(mwindow->preferences->highlight_inverse); set_inverse(); //draw_rectangle(x, y, w, h); draw_rectangle(x + 1, y + 1, w - 2, h - 2); @@ -1329,7 +1341,7 @@ void TrackCanvas::draw_highlight_insertion(int x, int y, int w, int h) } w = MIN(w, get_w() + 20); h = MIN(h, get_h() + 20); - set_color(WHITE); + set_color(mwindow->preferences->highlight_inverse); set_inverse(); draw_rectangle(x, y, w, h); draw_rectangle(x + 1, y + 1, w - 2, h - 2); @@ -1584,7 +1596,7 @@ void TrackCanvas::draw_plugins() char string[BCTEXTLEN]; int current_on = 0; int current_show = 0; - + int current_preset = 0; // if(!mwindow->edl->session->show_assets) goto done; @@ -1592,6 +1604,8 @@ void TrackCanvas::draw_plugins() plugin_on_toggles.values[i]->in_use = 0; for(int i = 0; i < plugin_show_toggles.total; i++) plugin_show_toggles.values[i]->in_use = 0; + for(int i = 0; i < preset_edit_buttons.total; i++) + plugin_show_toggles.values[i]->in_use = 0; for(Track *track = mwindow->edl->tracks->first; @@ -1699,9 +1713,21 @@ void TrackCanvas::draw_plugins() } current_show++; } - - - + toggle_x -= PluginPresetEdit::calculate_w(mwindow) + 10; + if(toggle_x > min_x) + { + if(current_preset >= preset_edit_buttons.total) + { + PluginPresetEdit *preset_edit = new PluginPresetEdit(mwindow, toggle_x, toggle_y, plugin); + add_subwindow(preset_edit); + preset_edit_buttons.append(preset_edit); + } + else + { + preset_edit_buttons.values[current_preset]->update(toggle_x, toggle_y, plugin); + } + current_preset++; + } } } } @@ -1711,6 +1737,10 @@ void TrackCanvas::draw_plugins() // Remove unused toggles + while(current_preset < preset_edit_buttons.total) + { + preset_edit_buttons.remove_object_number(current_preset); + } while(current_show < plugin_show_toggles.total) { plugin_show_toggles.remove_object_number(current_show); @@ -1720,7 +1750,6 @@ void TrackCanvas::draw_plugins() { plugin_on_toggles.remove_object_number(current_on); } - } void TrackCanvas::refresh_plugintoggles() @@ -1735,6 +1764,41 @@ void TrackCanvas::refresh_plugintoggles() PluginShow *show = plugin_show_toggles.values[i]; show->reposition_window(show->get_x(), show->get_y()); } + for(int i = 0; i < preset_edit_buttons.total; i++) + { + PluginPresetEdit *preset_edit = preset_edit_buttons.values[i]; + preset_edit->reposition_window(preset_edit->get_x(), preset_edit->get_y()); + } +} + +void TrackCanvas::draw_hard_edges() +{ + int64_t x, y, w, h; + +// if(!mwindow->edl->session->show_assets) return; + + for(Track *track = mwindow->edl->tracks->first; track; track = track->next) { + for(Edit *edit = track->edits->first; edit; edit = edit->next) { + if( !edit->hard_left && !edit->hard_right ) continue; + edit_dimensions(edit, x, y, w, h); + set_color(GREEN); + set_opaque(); int y1 = y+h-1; + if( edit->hard_left ) { + ArrayList xpt, ypt; + xpt.append(x); ypt.append(y1); + xpt.append(x+HANDLE_W); ypt.append(y1); + xpt.append(x); ypt.append(y1-HANDLE_H); + fill_polygon(&xpt, &ypt); + } + if( edit->hard_right ) { + ArrayList xpt, ypt; int x1 = x+w-1; + xpt.append(x1); ypt.append(y1); + xpt.append(x1-HANDLE_W); ypt.append(y1); + xpt.append(x1); ypt.append(y1-HANDLE_H); + fill_polygon(&xpt, &ypt); + } + } + } } void TrackCanvas::draw_inout_points() @@ -1753,7 +1817,7 @@ void TrackCanvas::draw_drag_handle() mwindow->edl->local_session->zoom_sample - mwindow->edl->local_session->view_start[pane->number]); //printf("TrackCanvas::draw_drag_handle 2 %d %jd\n", pane->number, pixel1); - set_color(GREEN); + set_color(!snapped ? GREEN : (snapped=0, YELLOW)); set_inverse(); //printf("TrackCanvas::draw_drag_handle 3\n"); draw_line(pixel1, 0, pixel1, get_h()); @@ -1842,41 +1906,36 @@ void TrackCanvas::draw_loop_points() //printf("TrackCanvas::draw_loop_points 7\n"); } -void TrackCanvas::draw_brender_start() +void TrackCanvas::draw_brender_range() { - if(mwindow->preferences->use_brender) + if( !mwindow->preferences->use_brender || !mwindow->brender_active ) return; + if( mwindow->edl->session->brender_start >= mwindow->edl->session->brender_end ) return; + if( mwindow->edl->session->brender_end > 0 ) { - int64_t x = Units::round(mwindow->edl->session->brender_start * + int64_t x1 = Units::round(mwindow->edl->session->brender_start * + mwindow->edl->session->sample_rate / + mwindow->edl->local_session->zoom_sample - + mwindow->edl->local_session->view_start[pane->number]); + if(MWindowGUI::visible(x1, x1 + 1, 0, get_w())) + { + set_color(RED); + draw_line(x1, 0, x1, get_h()); + } + int64_t x2 = Units::round(mwindow->edl->session->brender_end * mwindow->edl->session->sample_rate / mwindow->edl->local_session->zoom_sample - mwindow->edl->local_session->view_start[pane->number]); - if(MWindowGUI::visible(x, x + 1, 0, get_w())) + if(MWindowGUI::visible(x2, x2 + 1, 0, get_w())) { set_color(RED); - draw_line(x, 0, x, get_h()); + draw_line(x2, 0, x2, get_h()); } } } -static int auto_colors[AUTOMATION_TOTAL] = -{ - BLUE, - RED, - GREEN, - BLUE, - RED, - GREEN, - BLUE, - WHITE, - 0, - 0, - 0, - WHITE -}; - // The operations which correspond to each automation type -static int auto_operations[AUTOMATION_TOTAL] = +int TrackCanvas::auto_operations[AUTOMATION_TOTAL] = { DRAG_MUTE, DRAG_CAMERA_X, @@ -1976,25 +2035,25 @@ int TrackCanvas::do_keyframes(int cursor_x, int grouptype = automation.autogrouptype(i, track); if(draw) // Do dropshadow result = do_float_autos(track, autos, - cursor_x, cursor_y, draw, + cursor_x, cursor_y, draw, buttonpress, 1, 1, MDGREY, auto_keyframe, grouptype); result = do_float_autos(track, autos, - cursor_x, cursor_y, draw, - buttonpress, 0, 0, auto_colors[i], + cursor_x, cursor_y, draw, buttonpress, + 0, 0, GWindowGUI::auto_colors[i], auto_keyframe, grouptype); break; } case Autos::AUTOMATION_TYPE_INT: { if(draw) // Do dropshadow result = do_int_autos(track, autos, - cursor_x, cursor_y, draw, + cursor_x, cursor_y, draw, buttonpress, 1, 1, MDGREY, auto_keyframe); result = do_int_autos(track, autos, - cursor_x, cursor_y, draw, - buttonpress, 0, 0, auto_colors[i], + cursor_x, cursor_y, draw, buttonpress, + 0, 0, GWindowGUI::auto_colors[i], auto_keyframe); break; } } @@ -2031,6 +2090,12 @@ int TrackCanvas::do_keyframes(int cursor_x, gui->keyframe_menu->activate_menu(); rerender = 1; // the position changes } + else if( autos ) + { + gui->keyframe_hide->update(autos); + gui->keyframe_hide->activate_menu(); + rerender = 1; // the position changes + } if(buttonpress == 1 && ctrl_down() && AUTOMATION_TYPE_FLOAT == autos->get_type()) rerender = 1; // special case: curve mode changed @@ -2085,6 +2150,45 @@ int TrackCanvas::do_keyframes(int cursor_x, return result; } +void TrackCanvas::draw_keyframe_reticle() +{ + int keyframe_hairline = mwindow->preferences->keyframe_reticle; + if( keyframe_hairline == HAIRLINE_NEVER ) return; + + int current_op = mwindow->session->current_operation, dragging = 0; + for( int i=0; !dragging && isession->drag_auto && get_buttonpress() == 1 ) { + draw_hairline(mwindow->session->drag_auto, RED); + return; + } + } + + if( keyframe_hairline == HAIRLINE_ALWAYS || ( get_buttonpress() == 2 && + keyframe_hairline == HAIRLINE_DRAGGING && dragging ) ) { + for( Track *track = mwindow->edl->tracks->first; track; + track=track->next ) { + Automation *automation = track->automation; + for( int i=0; iedl->session->auto_conf->autos[i] ) continue; + // automation visible + Autos *autos = automation->autos[i]; + if( !autos ) continue; + for( Auto *auto_keyframe=autos->first; auto_keyframe; + auto_keyframe = auto_keyframe->next ) { + draw_hairline(auto_keyframe, GREEN); + } + } + + if( dragging && mwindow->session->drag_auto ) { + draw_hairline(mwindow->session->drag_auto, RED); + } + } + } +} + void TrackCanvas::draw_auto(Auto *current, int x, int y, @@ -2152,14 +2256,14 @@ void TrackCanvas::draw_cropped_line(int x1, } -void TrackCanvas::draw_floatauto(FloatAuto *current, - int x, - int y, - int in_x, - int in_y, - int out_x, - int out_y, - int center_pixel, +void TrackCanvas::draw_floatauto(FloatAuto *current, + int x, + int y, + int in_x, + int in_y, + int out_x, + int out_y, + int center_pixel, int zoom_track, int color) { @@ -2180,7 +2284,7 @@ void TrackCanvas::draw_floatauto(FloatAuto *current, draw_box(x1, y1, x2 - x1, y2 - y1); } -// show bezier control points (only) if this +// show bezier control points (only) if this // floatauto doesn't adjust it's tangents automatically if(current->curve_mode != FloatAuto::FREE && current->curve_mode != FloatAuto::TFREE) @@ -2208,22 +2312,22 @@ inline void TrackCanvas::draw_floatauto_ctrlpoint( y += center_pixel; cp_y += center_pixel; - + // drawing the tangent as a dashed line... int const dash = HANDLE_W; int const gap = HANDLE_W / 2; float sx = 3 * (cp_x - x) / 4.; float ex = 0; - + // q is the x displacement for a unit line of slope float q = (sx > 0 ? 1 : -1) / sqrt(1 + slope * slope); - + float dist = 1/q * sx; if( dist > dash ) ex = sx - q * dash; - + set_color(color); - do { + do { float sy = slope * sx, ey = slope * ex; draw_line(quantize(sx + x), quantize(sy + y), quantize(ex + x), quantize(ey + y)); sx = ex - q * gap; @@ -2306,10 +2410,10 @@ inline float test_curve_line( int x0, int y0, int ctrl_x, int ctrl_y, } -inline +inline float levered_position(float position, float ref_pos) { - if( 1e-6 > fabs(ref_pos) || isnan(ref_pos)) + if( 1e-6 > fabs(ref_pos) || isnan(ref_pos)) return 0.0; return ref_pos / position; } @@ -2331,7 +2435,7 @@ float TrackCanvas::value_to_percentage(float auto_value, int autogrouptype) int TrackCanvas::test_floatauto(FloatAuto *current, int x, int y, int in_x, - int in_y, int out_x, int out_y, int center_pixel, int zoom_track, + int in_y, int out_x, int out_y, int center_pixel, int zoom_track, int cursor_x, int cursor_y, int buttonpress, int autogrouptype) { int result = 0; @@ -2382,7 +2486,7 @@ int TrackCanvas::test_floatauto(FloatAuto *current, int x, int y, int in_x, if( WITHIN(x1,x2,y1,y2)) { // cursor hits node result = 1; - + if(buttonpress && (buttonpress != 3)) { INIT_DRAG(current->position, value_to_percentage(current->get_value(), autogrouptype)) @@ -2399,13 +2503,13 @@ int TrackCanvas::test_floatauto(FloatAuto *current, int x, int y, int in_x, // could be ctrl-click or ctrl-drag // click would cycle through tangent modes ((FloatAuto*)current)->toggle_curve_mode(); - + // drag will start dragging the tangent, if applicable INIT_DRAG(current->position, value_to_percentage(current->get_value(), autogrouptype)) mwindow->session->drag_handle = 0; } } - + float lever = 0.0; // we use the tangent as a draggable lever. 1.0 is at the ctrl point // Test in control @@ -2454,8 +2558,8 @@ int TrackCanvas::test_floatauto(FloatAuto *current, int x, int y, int in_x, #undef WITHIN #undef INIT_DRAG -// if(buttonpress) -// printf("TrackCanvas::test_floatauto 2 drag_handle=%d ctrl_down=%d cursor_x=%d cursor_y=%d x1=%d x2=%d y1=%d y2=%d\n", +// if(buttonpress) +// printf("TrackCanvas::test_floatauto 2 drag_handle=%d ctrl_down=%d cursor_x=%d cursor_y=%d x1=%d x2=%d y1=%d y2=%d\n", // mwindow->session->drag_handle, // ctrl_down(), // cursor_x, @@ -2506,7 +2610,7 @@ void TrackCanvas::draw_floatline(int center_pixel, // Not using slope intercept x1 = MAX(0, x1); - int prev_y = y1; + int prev_y = y1 + center_pixel; // Call by reference fails for some reason here @@ -2529,6 +2633,7 @@ void TrackCanvas::draw_floatline(int center_pixel, // (int)(center_pixel - yscale / 2), // (int)(center_pixel + yscale / 2 - 1)); +//printf("draw_line(%d,%d, %d,%d)\n", x - 1, prev_y , x, y); draw_line(x - 1, prev_y , x, y ); } prev_y = y; @@ -2578,7 +2683,10 @@ int TrackCanvas::test_floatline(int center_pixel, { Auto *current; mwindow->undo->update_undo_before(); - current = mwindow->session->drag_auto = autos->insert_auto(position1); + double position = autos->track->from_units(position1); + position = mwindow->edl->align_to_frame(position, 0); + int64_t new_position = autos->track->to_units(position,0); + current = mwindow->session->drag_auto = autos->insert_auto(new_position); ((FloatAuto*)current)->set_value(value); mwindow->session->drag_start_percentage = value_to_percentage(value, autogrouptype); mwindow->session->drag_start_position = current->position; @@ -2853,10 +2961,10 @@ int TrackCanvas::do_float_autos(Track *track, Autos *autos, int cursor_x, int cu autos->first ? autos->first : autos->default_auto; double ax = 0, ay = 0, ax2 = 0, ay2 = 0; - if( first_auto ) + if( first_auto ) { calculate_auto_position(&ax, &ay, 0, 0, 0, 0, first_auto, unit_start, zoom_units, yscale, autogrouptype); - + } if( current ) current = NEXT; else { @@ -2939,7 +3047,7 @@ int TrackCanvas::do_float_autos(Track *track, Autos *autos, int cursor_x, int cu (int)ax, (int)ax2, cursor_x, cursor_y, buttonpress, autogrouptype); } - if( draw ) + if( draw ) draw_floatline(center_pixel, (FloatAuto*)previous, (FloatAuto*)current, (FloatAutos*)autos, unit_start, zoom_units, yscale, @@ -3321,6 +3429,28 @@ int TrackCanvas::do_plugin_autos(Track *track, int cursor_x, int cursor_y, return result; } +int TrackCanvas::draw_hairline(Auto *auto_keyframe, int color) +{ + Track *track = auto_keyframe->autos->track; + int autogrouptype = auto_keyframe->autos->get_type(); + + int center_pixel; + double view_start, unit_start; + double view_end, unit_end, yscale; + double zoom_sample, zoom_units; + + calculate_viewport(track, view_start, unit_start, view_end, unit_end, + yscale, center_pixel, zoom_sample, zoom_units); + + double ax = 0, ay = 0; + calculate_auto_position(&ax, &ay, 0, 0, 0, 0, + auto_keyframe, unit_start, zoom_units, yscale, autogrouptype); + + set_color(color); + draw_line(ax, 0, ax, get_h()); + return 0; +} + void TrackCanvas::draw_overlays() { int new_cursor, update_cursor, rerender; @@ -3342,10 +3472,11 @@ void TrackCanvas::draw_overlays() // Plugins draw_plugins(); + draw_hard_edges(); // Loop points draw_loop_points(); - draw_brender_start(); + draw_brender_range(); // Highlighted areas draw_highlighting(); @@ -3362,6 +3493,8 @@ void TrackCanvas::draw_overlays() // Playback cursor draw_playback_cursor(); + draw_keyframe_reticle(); + show_window(0); } @@ -3394,15 +3527,46 @@ int TrackCanvas::deactivate() void TrackCanvas::update_drag_handle() { double new_position; + int cursor_x = get_cursor_x(); new_position = - (double)(get_cursor_x() + + (double)(cursor_x + mwindow->edl->local_session->view_start[pane->number]) * mwindow->edl->local_session->zoom_sample / mwindow->edl->session->sample_rate; + new_position = mwindow->edl->align_to_frame(new_position, 0); + if( ctrl_down() && alt_down() ) { +#define snapper(v) do { \ + double pos = (v); \ + if( pos < 0 ) break; \ + double dist = fabs(new_position - pos); \ + if( dist >= snap_min ) break; \ + snap_position = pos; snap_min = dist; \ +} while(0) + double snap_position = new_position; + double snap_min = DBL_MAX; + if( mwindow->edl->local_session->inpoint_valid() ) + snapper(mwindow->edl->local_session->get_inpoint()); + if( mwindow->edl->local_session->outpoint_valid() ) + snapper(mwindow->edl->local_session->get_outpoint()); + snapper(mwindow->edl->prev_edit(new_position)); + snapper(mwindow->edl->next_edit(new_position)); + Label *prev_label = mwindow->edl->labels->prev_label(new_position); + if( prev_label ) snapper(prev_label->position); + Label *next_label = mwindow->edl->labels->next_label(new_position); + if( next_label ) snapper(next_label->position); + int snap_x = snap_position * mwindow->edl->session->sample_rate / + mwindow->edl->local_session->zoom_sample - + mwindow->edl->local_session->view_start[pane->number]; + if( abs(snap_x - cursor_x) < HANDLE_W ) { + snapped = 1; + new_position = snap_position; + } +#undef snapper + } if(new_position != mwindow->session->drag_position) { @@ -3506,7 +3670,7 @@ int TrackCanvas::update_drag_floatauto(int cursor_x, int cursor_y) // not really editing the node, rather start editing the curve // tangent is editable and drag movement is significant if( (FloatAuto::FREE == current->curve_mode || - FloatAuto::TFREE==current->curve_mode) && + FloatAuto::TFREE==current->curve_mode) && (fabs(x) > HANDLE_W / 2 || fabs(y) > HANDLE_W / 2)) mwindow->session->drag_handle = x < 0 ? 1 : 2; } @@ -3552,7 +3716,7 @@ int TrackCanvas::update_drag_floatauto(int cursor_x, int cursor_y) if(value != old_value || position != current->position) { result = 1; - float change = value - old_value; + float change = value - old_value; current->adjust_to_new_coordinates(position, value); synchronize_autos(change, current->autos->track, current, 0); show_message(current, 1,", %.2f", current->get_value()); @@ -3629,7 +3793,7 @@ int TrackCanvas::update_drag_auto(int cursor_x, int cursor_y) double position_f = current->autos->track->from_units(current->position); double center_f = (mwindow->edl->local_session->get_selectionstart(1) + - mwindow->edl->local_session->get_selectionend(1)) / + mwindow->edl->local_session->get_selectionend(1)) / 2; if(!shift_down()) { @@ -3661,7 +3825,7 @@ int TrackCanvas::update_drag_pluginauto(int cursor_x, int cursor_y) //PluginAutos *pluginautos = (PluginAutos *)current->autos; PluginSet *pluginset; Plugin *plugin = 0; -// figure out the correct pluginset & correct plugin +// figure out the correct pluginset & correct plugin int found = 0; for(int i = 0; i < track->plugin_set.total; i++) { @@ -3673,16 +3837,16 @@ int TrackCanvas::update_drag_pluginauto(int cursor_x, int cursor_y) currentkeyframe; currentkeyframe = (KeyFrame *) currentkeyframe->next) { - if (currentkeyframe == current) + if (currentkeyframe == current) { found = 1; break; } - + } - if (found) break; + if (found) break; } - if (found) break; + if (found) break; } mwindow->session->plugin_highlighted = plugin; @@ -3693,7 +3857,7 @@ int TrackCanvas::update_drag_pluginauto(int cursor_x, int cursor_y) double position_f = current->autos->track->from_units(current->position); double center_f = (mwindow->edl->local_session->get_selectionstart(1) + - mwindow->edl->local_session->get_selectionend(1)) / + mwindow->edl->local_session->get_selectionend(1)) / 2; if(!shift_down()) { @@ -3718,7 +3882,7 @@ void TrackCanvas::update_drag_caption() switch(mwindow->session->current_operation) { case DRAG_FADE: - + break; } } @@ -4168,53 +4332,58 @@ int TrackCanvas::do_edit_handles(int cursor_x, int cursor_y, int button_press, int &rerender, int &update_overlay, int &new_cursor, int &update_cursor) { Edit *edit_result = 0; - int handle_result = 0; + int handle_result = -1; int result = 0; - if(!mwindow->edl->session->show_assets) return 0; + if( !mwindow->edl->session->show_assets ) return 0; - for(Track *track = mwindow->edl->tracks->first; - track && !result; - track = track->next) { - for(Edit *edit = track->edits->first; - edit && !result; - edit = edit->next) { + for( Track *track=mwindow->edl->tracks->first; track && !result; track=track->next) { + for( Edit *edit=track->edits->first; edit && !result; edit=edit->next ) { int64_t edit_x, edit_y, edit_w, edit_h; edit_dimensions(edit, edit_x, edit_y, edit_w, edit_h); - 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 + HANDLE_W) { + 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 + HANDLE_W ) { edit_result = edit; handle_result = 0; - result = 1; + if( cursor_y >= edit_y+edit_h - HANDLE_W ) { + new_cursor = DOWNLEFT_RESIZE; + if( button_press == LEFT_BUTTON ) + result = -1; + } + else + result = 1; } - else if(cursor_x >= edit_x + edit_w - HANDLE_W) { + else if( cursor_x >= edit_x + edit_w - HANDLE_W ) { edit_result = edit; handle_result = 1; - result = 1; - } - else { - result = 0; + if( cursor_y >= edit_y+edit_h - HANDLE_W ) { + new_cursor = DOWNRIGHT_RESIZE; + if( button_press == LEFT_BUTTON ) + result = -1; + } + else + result = 1; } } } } update_cursor = 1; - if(result) { + if( result > 0 ) { double position = 0; - if(handle_result == 0) { + if( handle_result == 0 ) { position = edit_result->track->from_units(edit_result->startproject); new_cursor = LEFT_CURSOR; } - else if(handle_result == 1) { + else if( handle_result == 1 ) { position = edit_result->track->from_units(edit_result->startproject + edit_result->length); new_cursor = RIGHT_CURSOR; } // Reposition cursor - if(button_press) { + if( button_press ) { mwindow->session->drag_edit = edit_result; mwindow->session->drag_handle = handle_result; mwindow->session->drag_button = get_buttonpress() - 1; @@ -4228,6 +4397,43 @@ int TrackCanvas::do_edit_handles(int cursor_x, int cursor_y, int button_press, update_overlay = 1; } } + else if( result < 0) { + mwindow->undo->update_undo_before(); + if( !shift_down() ) { + if( handle_result == 0 ) + edit_result->hard_left = !edit_result->hard_left; + else if( handle_result == 1 ) + edit_result->hard_right = !edit_result->hard_right; + } + else { + int status = handle_result == 0 ? edit_result->hard_left : + handle_result == 1 ? edit_result->hard_right : 0; + int new_status = !status; + int64_t edit_edge = edit_result->startproject; + if( handle_result == 1 ) edit_edge += edit_result->length; + double edge_position = edit_result->track->from_units(edit_edge); + for( Track *track=mwindow->edl->tracks->first; track!=0; track=track->next ) { + int64_t track_position = track->to_units(edge_position, 1); + Edit *left_edit = track->edits->editof(track_position, PLAY_FORWARD, 0); + if( left_edit ) { + int64_t left_edge = left_edit->startproject; + double left_position = track->from_units(left_edge); + if( EQUIV(edge_position, left_position) ) + left_edit->hard_left = new_status; + } + Edit *right_edit = track->edits->editof(track_position, PLAY_REVERSE, 0); + if( right_edit ) { + int64_t right_edge = right_edit->startproject + right_edit->length; + double right_position = track->from_units(right_edge); + if( EQUIV(edge_position, right_position) ) + right_edit->hard_right = new_status; + } + } + } + rerender = update_overlay = 1; + mwindow->undo->update_undo_after(_("hard_edge"), LOAD_EDITS); + result = 1; + } return result; } @@ -4320,7 +4526,7 @@ int TrackCanvas::do_tracks(int cursor_x, int cursor_y, int button_press) int64_t track_x, track_y, track_w, track_h; track_dimensions(track, track_x, track_y, track_w, track_h); - if(button_press && get_buttonpress() == 3 && + if(button_press && get_buttonpress() == RIGHT_BUTTON && cursor_y >= track_y && cursor_y < track_y + track_h) { gui->edit_menu->update(track, 0); gui->edit_menu->activate_menu(); @@ -4396,10 +4602,10 @@ int TrackCanvas::do_edits(int cursor_x, int cursor_y, int button_press, int drag mwindow->edl->local_session->zoom_sample / mwindow->edl->session->sample_rate; + int cx, cy; + get_abs_cursor(cx, cy); gui->drag_popup = new BC_DragWindow(gui, - mwindow->theme->get_image("clip_icon") /*, - get_abs_cursor_x(0) - mwindow->theme->get_image("clip_icon")->get_w() / 2, - get_abs_cursor_y(0) - mwindow->theme->get_image("clip_icon")->get_h() / 2 */); + mwindow->theme->get_image("clip_icon"), cx, cy); result = 1; } @@ -4508,19 +4714,18 @@ int TrackCanvas::do_plugins(int cursor_x, int cursor_y, int drag_start, frame = mwindow->theme->get_image("veffect_icon"); } } - - gui->drag_popup = new BC_DragWindow(gui, frame /*, - get_abs_cursor_x(0) - frame->get_w() / 2, - get_abs_cursor_y(0) - frame->get_h() / 2 */); + int cx, cy; + get_abs_cursor(cx, cy); + gui->drag_popup = new BC_DragWindow(gui, frame, cx, cy); break; } case PLUGIN_SHAREDPLUGIN: - case PLUGIN_SHAREDMODULE: - gui->drag_popup = new BC_DragWindow(gui, - mwindow->theme->get_image("clip_icon") /*, - get_abs_cursor_x(0) - mwindow->theme->get_image("clip_icon")->get_w() / 2, - get_abs_cursor_y(0) - mwindow->theme->get_image("clip_icon")->get_h() / 2 */); - break; + case PLUGIN_SHAREDMODULE: { + VFrame *frame = mwindow->theme->get_image("clip_icon"); + int cx, cy; + get_abs_cursor(cx, cy); + gui->drag_popup = new BC_DragWindow(gui, frame, cx, cy); + break; } } result = 1; @@ -4598,7 +4803,8 @@ int TrackCanvas::button_press_event() activate(); } - if( get_buttonpress() == LEFT_BUTTON ) { + if( get_buttonpress() == LEFT_BUTTON && + gui->mbuttons->transport->engine->command->command != STOP ) { gui->unlock_window(); gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0); gui->lock_window("TrackCanvas::button_press_event"); @@ -4642,8 +4848,7 @@ int TrackCanvas::button_press_event() switch(mwindow->edl->session->editing_mode) { // Test handles and resource boundaries and highlight a track case EDITING_ARROW: { - if( mwindow->edl->session->auto_conf->transitions && - do_transitions(cursor_x, cursor_y, + if( do_transitions(cursor_x, cursor_y, 1, new_cursor, update_cursor) ) break; if( do_keyframes(cursor_x, cursor_y, @@ -4682,8 +4887,7 @@ int TrackCanvas::button_press_event() mwindow->edl->session->sample_rate; //printf("TrackCanvas::button_press_event %d\n", position); - if(mwindow->edl->session->auto_conf->transitions && - do_transitions(cursor_x, cursor_y, + if( do_transitions(cursor_x, cursor_y, 1, new_cursor, update_cursor)) break; if(do_keyframes(cursor_x, cursor_y, 0, get_buttonpress(), new_cursor, @@ -4705,6 +4909,7 @@ int TrackCanvas::button_press_event() if( do_tracks(cursor_x, cursor_y, 1) ) break; // Highlight selection + if( get_buttonpress() != LEFT_BUTTON ) break; rerender = start_selection(position); mwindow->session->current_operation = SELECT_REGION; update_cursor = 1; @@ -4724,31 +4929,32 @@ int TrackCanvas::button_press_event() if( update_overlay ) { gui->draw_overlays(1); } - - if( update_cursor > 0 ) { + if( update_cursor < 0 ) { +// double_click edit + gui->swindow->update_selection(); + } + if( update_cursor ) { gui->update_timebar(0); gui->hide_cursor(0); gui->show_cursor(1); gui->zoombar->update(); gui->flash_canvas(1); } - else if(update_cursor < 0) { - gui->swindow->update_selection(); - } } + return result; } int TrackCanvas::start_selection(double position) { int rerender = 0; - position = mwindow->edl->align_to_frame(position, 0); + position = mwindow->edl->align_to_frame(position, 1); // Extend a border if(shift_down()) { - double midpoint = (mwindow->edl->local_session->get_selectionstart(1) + + double midpoint = (mwindow->edl->local_session->get_selectionstart(1) + mwindow->edl->local_session->get_selectionend(1)) / 2; if(position < midpoint) @@ -4775,7 +4981,7 @@ int TrackCanvas::start_selection(double position) // Que the CWindow rerender = 1; } - + return rerender; } @@ -4792,8 +4998,8 @@ void TrackCanvas::end_pluginhandle_selection() double TrackCanvas::time_visible() { - return (double)get_w() * - mwindow->edl->local_session->zoom_sample / + return (double)get_w() * + mwindow->edl->local_session->zoom_sample / mwindow->edl->session->sample_rate; } @@ -4807,7 +5013,7 @@ void TrackCanvas::show_message(Auto *current, int show_curve_type, const char *f FloatAuto::curve_name(((FloatAuto*)current)->curve_mode)); } char string2[BCTEXTLEN]; - Units::totext(string2, + Units::totext(string2, current->autos->track->from_units(current->position), mwindow->edl->session->time_format, mwindow->edl->session->sample_rate, @@ -4835,7 +5041,7 @@ void TrackCanvas::show_message(Auto *current, int show_curve_type, const char *f // else // return gui->pane[BOTTOM_LEFT_PANE]->patchbay; // } -// +// // return 0; // }