X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Ftimebar.C;h=44e321724135526a203b68c2d3286f1165131ca6;hb=09c2f5f26f06b33101230e42cdb0a482a6cccf76;hp=10a095f9546edbb81a97c4a0a10ec38bca83a73c;hpb=d60a59baa6cfe24c0fb153ed9e150a834ba29feb;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/timebar.C b/cinelerra-5.1/cinelerra/timebar.C index 10a095f9..44e32172 100644 --- a/cinelerra-5.1/cinelerra/timebar.C +++ b/cinelerra-5.1/cinelerra/timebar.C @@ -19,6 +19,8 @@ * */ +#include "awindow.h" +#include "awindowgui.h" #include "bcsignals.h" #include "clip.h" #include "cplayback.h" @@ -71,6 +73,8 @@ LabelGUI::LabelGUI(MWindow *mwindow, TimeBar *timebar, LabelGUI::~LabelGUI() { + if( timebar->drag_label == this ) + timebar->drag_label = 0; } int LabelGUI::get_y(MWindow *mwindow, TimeBar *timebar) @@ -93,7 +97,7 @@ void LabelGUI::reposition(int flush) int LabelGUI::button_press_event() { - int result = 0; + int result = test_drag_label(1); if( this->is_event_win() && get_buttonpress() == 3 ) { if( label ) { @@ -110,12 +114,58 @@ int LabelGUI::button_press_event() return result; } +int LabelGUI::button_release_event() +{ + int ret = BC_Toggle::button_release_event(); + test_drag_label(0); + return ret; +} + +int LabelGUI::test_drag_label(int press) +{ + if( is_event_win() && get_buttonpress() == 1 ) { + switch( timebar->current_operation ) { + case TIMEBAR_NONE: + if( press && get_value() ) { + timebar->current_operation = TIMEBAR_DRAG_LABEL; + timebar->drag_label = this; + set_cursor(HSEPARATE_CURSOR, 0, 0); + mwindow->undo->update_undo_before(_("drag label"), this); + return 1; + } + break; + case TIMEBAR_DRAG_LABEL: + if( !press ) { + timebar->current_operation = TIMEBAR_NONE; + timebar->drag_label = 0; + set_cursor(ARROW_CURSOR, 0, 0); + mwindow->undo->update_undo_after(_("drag label"), LOAD_TIMEBAR); + mwindow->awindow->gui->async_update_assets(); // labels folder + } + break; + } + } + return 0; +} + int LabelGUI::handle_event() { timebar->select_label(position); return 1; } +void LabelGUI::update_value() +{ + EDL *edl = timebar->get_edl(); + double start = edl->local_session->get_selectionstart(1); + double end = edl->local_session->get_selectionend(1); + int v = ( label->position >= start && end >= label->position ) || + edl->equivalent(label->position, start) || + edl->equivalent(label->position, end) || + timebar->drag_label == this ? 1 : 0; + update(v); +} + InPointGUI::InPointGUI(MWindow *mwindow, TimeBar *timebar, int64_t pixel, double position) @@ -171,6 +221,7 @@ TimeBar::TimeBar(MWindow *mwindow, BC_WindowBase *gui, //printf("TimeBar::TimeBar %d %d %d %d\n", x, y, w, h); this->gui = gui; this->mwindow = mwindow; + this->drag_label = 0; label_edit = new LabelEdit(mwindow, mwindow->awindow, 0); pane = 0; highlighted = 0; @@ -245,23 +296,16 @@ void TimeBar::update_labels() gui->pixel = pixel; gui->reposition(0); } - else { - gui->draw_face(1,0); - } +// else { +// gui->draw_face(1,0); +// } labels.values[output]->position = current->position; labels.values[output]->set_tooltip(current->textstr); labels.values[output]->label = current; } - if( edl->local_session->get_selectionstart(1) <= current->position && - edl->local_session->get_selectionend(1) >= current->position ) - labels.values[output]->update(1); - else - if( labels.values[output]->get_value() ) - labels.values[output]->update(0); - - output++; + labels.values[output++]->update_value(); } } } @@ -281,15 +325,7 @@ void TimeBar::update_highlights() EDL *edl = get_edl(); if( !edl ) return; for( int i = 0; i < labels.total; i++ ) { - LabelGUI *label = labels.values[i]; - if( edl->equivalent(label->position, - edl->local_session->get_selectionstart(1)) || - edl->equivalent(label->position, - edl->local_session->get_selectionend(1)) ) { - if( !label->get_value() ) label->update(1); - } - else - if( label->get_value() ) label->update(0); + labels.values[i]->update_value(); } if( edl->equivalent(edl->local_session->get_inpoint(), @@ -325,7 +361,7 @@ void TimeBar::draw_inout_highlight() int out_x = position_to_pixel(out_position); CLAMP(in_x, 0, get_w()); CLAMP(out_x, 0, get_w()); - set_color(GREEN); + set_color(mwindow->theme->inout_highlight_color); int lw = 5; set_line_width(lw); set_inverse(); @@ -706,7 +742,7 @@ int TimeBar::button_press_event() result = test_preview(1); } // Change time format - else if( ctrl_down() ) { + else if( !is_vwindow() && ctrl_down() ) { if( get_buttonpress() == 1 ) mwindow->next_time_format(); else @@ -747,45 +783,61 @@ int TimeBar::cursor_motion_event() int result = 0; int redraw = 0; -//printf("TimeBar::cursor_motion_event %d %p %d\n", __LINE__, this, current_operation); - switch( current_operation ) - { - case TIMEBAR_DRAG: - { - update_cursor(); - handle_mwindow_drag(); - result = 1; -//printf("TimeBar::cursor_motion_event %d %d\n", __LINE__, current_operation); - break; - } - - - case TIMEBAR_DRAG_LEFT: - case TIMEBAR_DRAG_RIGHT: - case TIMEBAR_DRAG_CENTER: - if( has_preview() ) - result = move_preview(redraw); - break; - - default: - if( cursor_above() ) { - highlighted = 1; - redraw = 1; + switch( current_operation ) { + case TIMEBAR_DRAG_LEFT: + case TIMEBAR_DRAG_RIGHT: + case TIMEBAR_DRAG_CENTER: + if( has_preview() ) + result = move_preview(redraw); + break; + + case TIMEBAR_DRAG_LABEL: + if( drag_label ) { + EDL *edl = get_edl(); + int pixel = get_relative_cursor_x(); + double position = pixel_to_position(pixel); + if( drag_label->label ) + drag_label->label->position = position; + else if( drag_label == in_point ) { + if( out_point && edl->local_session->outpoint_valid() ) { + double out_pos = edl->local_session->get_outpoint(); + if( position > out_pos ) { + edl->local_session->set_outpoint(position); + drag_label = out_point; + position = out_pos; + } + } + edl->local_session->set_inpoint(position); + } + else if( drag_label == out_point ) { + if( in_point && edl->local_session->inpoint_valid() ) { + double in_pos = edl->local_session->get_inpoint(); + if( position < in_pos ) { + edl->local_session->set_inpoint(position); + drag_label = in_point; + position = in_pos; + } + } + edl->local_session->set_outpoint(position); } + } + // fall thru + case TIMEBAR_DRAG: + update_cursor(); + handle_mwindow_drag(); + result = 1; + break; -//printf("TimeBar::cursor_motion_event 20\n"); - if( has_preview() ) - result = test_preview(0); -//printf("TimeBar::cursor_motion_event 30\n"); - break; + default: + if( has_preview() ) + result = test_preview(0); + break; } -//printf("TimeBar::cursor_motion_event %d %d\n", __LINE__, current_operation); if( redraw ) { update(1); } -//printf("TimeBar::cursor_motion_event %d %p %d\n", __LINE__, this, current_operation); return result; }