merge hv v6, rework trace methods
[goodguy/history.git] / cinelerra-5.1 / cinelerra / trackcanvas.C
index 2a64845af735e32a78d69bbac13b4298c386ac5c..87e6f0747606343d7fca48030254797ee135ca45 100644 (file)
@@ -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"
@@ -253,7 +254,7 @@ int TrackCanvas::drag_motion(Track **over_track,
        }
 
         if( !*over_track )
-               *over_track = pane->is_over_patchbay();
+               *over_track = pane->over_patchbay();
 
        return 0;
 }
@@ -281,7 +282,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;
                }
@@ -1851,41 +1852,34 @@ 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)
        {
-               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->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,
@@ -1990,8 +1984,8 @@ int TrackCanvas::do_keyframes(int cursor_x,
                                                                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; }
 
@@ -2002,8 +1996,8 @@ int TrackCanvas::do_keyframes(int cursor_x,
                                                                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; }
                                        }
@@ -2633,7 +2627,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;
@@ -3422,7 +3419,7 @@ void TrackCanvas::draw_overlays()
 
 // Loop points
        draw_loop_points();
-       draw_brender_start();
+       draw_brender_range();
 
 // Highlighted areas
        draw_highlighting();
@@ -4721,8 +4718,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,
@@ -4761,8 +4757,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,
@@ -4784,6 +4779,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;
@@ -4803,17 +4799,17 @@ 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;
 }