X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fvwindowgui.C;h=db6312bcacba94ce3a2eb404de726eaa490feb38;hb=3594cc12d62e8bf2c92e4e897aaf130645cbbc56;hp=6bd71b1f5a6c307478d70b1a83f048b295be1a7c;hpb=30bdb85eb33a8ee7ba675038a86c6be59c43d7bd;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/vwindowgui.C b/cinelerra-5.1/cinelerra/vwindowgui.C index 6bd71b1f..db6312bc 100644 --- a/cinelerra-5.1/cinelerra/vwindowgui.C +++ b/cinelerra-5.1/cinelerra/vwindowgui.C @@ -76,6 +76,7 @@ VWindowGUI::VWindowGUI(MWindow *mwindow, VWindow *vwindow) meters = 0; // source = 0; strcpy(loaded_title, ""); + highlighted = 0; } VWindowGUI::~VWindowGUI() @@ -103,6 +104,7 @@ void VWindowGUI::change_source(EDL *edl, const char *title) sprintf(string, _(PROGRAM_NAME ": Viewer")); lock_window("VWindowGUI::change_source"); + canvas->clear(); timebar->update(0); set_title(string); unlock_window(); @@ -346,12 +348,44 @@ int VWindowGUI::keypress_event() break; } if(!result) result = transport->keypress_event(); - return result; } +void VWindowGUI::stop_transport(const char *lock_msg) +{ + if( !transport->is_stopped() ) { + if( lock_msg ) unlock_window(); + transport->handle_transport(STOP, 1, 0, 0); + if( lock_msg ) lock_window(lock_msg); + } +} + int VWindowGUI::button_press_event() { + if( vwindow->get_edl() != 0 && canvas->get_canvas() && + canvas->get_canvas()->get_cursor_over_window() ) { + switch( get_buttonpress() ) { + case LEFT_BUTTON: + if( !vwindow->playback_engine->is_playing_back ) { + double length = vwindow->get_edl()->tracks->total_playable_length(); + double position = vwindow->playback_engine->get_tracking_position(); + if( position >= length ) transport->goto_start(); + } + return transport->forward_play->handle_event(); + case MIDDLE_BUTTON: + if( !vwindow->playback_engine->is_playing_back ) { + double position = vwindow->playback_engine->get_tracking_position(); + if( position <= 0 ) transport->goto_end(); + } + return transport->reverse_play->handle_event(); + case RIGHT_BUTTON: // activates popup + break; + case WHEEL_UP: + return transport->frame_forward_play->handle_event(); + case WHEEL_DOWN: + return transport->frame_reverse_play->handle_event(); + } + } if(canvas->get_canvas()) return canvas->button_press_event_base(canvas->get_canvas()); return 0; @@ -394,35 +428,22 @@ void VWindowGUI::drag_motion() // Window hidden if(get_hidden()) return; if(mwindow->session->current_operation != DRAG_ASSET) return; - - int old_status = mwindow->session->vcanvas_highlighted; - - int cursor_x = get_relative_cursor_x(); - int cursor_y = get_relative_cursor_y(); - - mwindow->session->vcanvas_highlighted = (get_cursor_over_window() && - cursor_x >= canvas->x && - cursor_x < canvas->x + canvas->w && - cursor_y >= canvas->y && - cursor_y < canvas->y + canvas->h); - - -//printf("VWindowGUI::drag_motion 1 %d %d %d %d %d\n", __LINE__, -// mwindow->session->vcanvas_highlighted, get_cursor_over_window(), cursor_x, cursor_y); - - if(old_status != mwindow->session->vcanvas_highlighted) - canvas->draw_refresh(); + int need_highlight = cursor_above() && get_cursor_over_window() ? 1 : 0; + if( highlighted == need_highlight ) return; + highlighted = need_highlight; + canvas->draw_refresh(); } int VWindowGUI::drag_stop() { if(get_hidden()) return 0; - if(mwindow->session->vcanvas_highlighted && + if(highlighted && mwindow->session->current_operation == DRAG_ASSET) { - mwindow->session->vcanvas_highlighted = 0; + highlighted = 0; canvas->draw_refresh(); + unlock_window(); Indexable *indexable = mwindow->session->drag_assets->size() ? mwindow->session->drag_assets->get(0) : @@ -430,12 +451,12 @@ int VWindowGUI::drag_stop() EDL *edl = mwindow->session->drag_clips->size() ? mwindow->session->drag_clips->get(0) : 0; - if(indexable) vwindow->change_source(indexable); else if(edl) vwindow->change_source(edl); + lock_window("VWindowGUI::drag_stop"); return 1; } @@ -627,17 +648,15 @@ void VWindowEditing::next_label() double VWindowEditing::get_position() { EDL *edl = vwindow->get_edl(); - double position = !edl ? 0 : edl->local_session->get_selectionstart(1) + - edl->session->get_frame_offset() / edl->session->frame_rate; + double position = !edl ? 0 : edl->local_session->get_selectionstart(1); return position; } void VWindowEditing::set_position(double position) { EDL *edl = vwindow->get_edl(); - if( edl ) return; + if( !edl ) return; if( get_position() != position ) { - position -= edl->session->get_frame_offset() / edl->session->frame_rate; if( position < 0 ) position = 0; edl->local_session->set_selectionstart(position); edl->local_session->set_selectionend(position); @@ -655,73 +674,19 @@ void VWindowEditing::set_outpoint() vwindow->set_outpoint(); } -void VWindowEditing::clear_inpoint() +void VWindowEditing::unset_inoutpoint() { - vwindow->clear_inpoint(); + vwindow->unset_inoutpoint(); } -void VWindowEditing::clear_outpoint() -{ - vwindow->clear_outpoint(); -} void VWindowEditing::to_clip() { - if(vwindow->get_edl()) - { - FileXML file; - EDL *edl = vwindow->get_edl(); - double start = edl->local_session->get_selectionstart(); - double end = edl->local_session->get_selectionend(); - - if(EQUIV(start, end)) - { - end = edl->tracks->total_length(); - start = 0; - } - - - - edl->copy(start, - end, - 1, - 0, - 0, - &file, - "", - 1); - - - - - EDL *new_edl = new EDL(mwindow->edl); - new_edl->create_objects(); - new_edl->load_xml(&file, LOAD_ALL); - sprintf(new_edl->local_session->clip_title, - _("Clip %d"), mwindow->session->clip_number++); - char string[BCTEXTLEN]; - Units::totext(string, - end - start, - edl->session->time_format, - edl->session->sample_rate, - edl->session->frame_rate, - edl->session->frames_per_foot); - - sprintf(new_edl->local_session->clip_notes, - _("%s\n Created from:\n%s"), string, vwindow->gui->loaded_title); - - new_edl->local_session->set_selectionstart(0); - new_edl->local_session->set_selectionend(0); - - -//printf("VWindowEditing::to_clip 1 %s\n", edl->local_session->clip_title); - new_edl->local_session->set_selectionstart(0.0); - new_edl->local_session->set_selectionend(0.0); - vwindow->clip_edit->create_clip(new_edl); - } + EDL *edl = vwindow->get_edl(); + if( !edl ) return; + mwindow->to_clip(edl, _("viewer window: ")); } - VWindowSource::VWindowSource(MWindow *mwindow, VWindowGUI *vwindow, int x, int y) : BC_PopupTextBox(vwindow, &vwindow->sources, @@ -878,7 +843,7 @@ void VWindowCanvas::draw_refresh(int flush) void VWindowCanvas::draw_overlays() { - if(mwindow->session->vcanvas_highlighted) + if( gui->highlighted ) { get_canvas()->set_color(WHITE); get_canvas()->set_inverse(); @@ -944,7 +909,7 @@ void VWindowGUI::update_points() //printf("VWindowGUI::update_points 2\n"); long pixel = (long)((double)edl->local_session->in_point / - edl->tracks->total_playable_length() * + edl->tracks->total_length() * (mwindow->theme->vtimebar_w - 2 * mwindow->theme->in_point[0]->get_w())) + @@ -996,7 +961,7 @@ void VWindowGUI::update_points() //printf("VWindowGUI::update_points 10\n"); pixel = (long)((double)edl->local_session->out_point / - (edl->tracks->total_playable_length() + 0.5) * + (edl->tracks->total_length() + 0.5) * (mwindow->theme->vtimebar_w - 2 * mwindow->theme->in_point[0]->get_w())) +