X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fcwindowgui.C;h=ea957147637ff434eb2234f4ef164302391aaadd;hb=21eb2e0b479adf7bf846b835e5c7d9613b6f1a6d;hp=bc37551a84bf87b49f070cd8d4583cf660c9ec7c;hpb=2162ee52e4d53d53ad5ce40af82784d8c8da0bad;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/cwindowgui.C b/cinelerra-5.1/cinelerra/cwindowgui.C index bc37551a..ea957147 100644 --- a/cinelerra-5.1/cinelerra/cwindowgui.C +++ b/cinelerra-5.1/cinelerra/cwindowgui.C @@ -92,23 +92,28 @@ CWindowGUI::CWindowGUI(MWindow *mwindow, CWindow *cwindow) this->mwindow = mwindow; this->cwindow = cwindow; affected_track = 0; - affected_x = 0; - affected_y = 0; - affected_z = 0; + affected_x = affected_y = affected_z = 0; mask_keyframe = 0; orig_mask_keyframe = new MaskAuto(0, 0); affected_point = 0; - x_offset = 0; - y_offset = 0; - x_origin = 0; - y_origin = 0; + x_offset = y_offset = 0; + x_origin = y_origin = 0; current_operation = CWINDOW_NONE; tool_panel = 0; - translating_zoom = 0; active = 0; inactive = 0; - crop_translate = 0; + crop_handle = -1; crop_translate = 0; + crop_origin_x = crop_origin_y = 0; + crop_origin_x1 = crop_origin_y1 = 0; + crop_origin_x2 = crop_origin_y2 = 0; eyedrop_visible = 0; + eyedrop_x = eyedrop_y = 0; + ruler_origin_x = ruler_origin_y = 0; + ruler_handle = -1; ruler_translate = 0; + center_x = center_y = center_z = 0; + control_in_x = control_in_y = 0; + control_out_x = control_out_y = 0; + translating_zoom = 0; highlighted = 0; } @@ -214,14 +219,7 @@ void CWindowGUI::create_objects() tool_panel = new CWindowTool(mwindow, this); tool_panel->Thread::start(); - set_operation(mwindow->edl->session->cwindow_operation); - - - - canvas->draw_refresh(0); - - draw_status(0); unlock_window(); } @@ -245,7 +243,7 @@ int CWindowGUI::resize_event(int w, int h) flash(0); composite_panel->reposition_buttons(mwindow->theme->ccomposite_x, - mwindow->theme->ccomposite_y); + mwindow->theme->ccomposite_y, mwindow->theme->ccomposite_h); canvas->reposition_window(mwindow->edl, mwindow->theme->ccanvas_x, @@ -291,6 +289,32 @@ int CWindowGUI::resize_event(int w, int h) int CWindowGUI::button_press_event() { + if( current_operation == CWINDOW_NONE && + mwindow->edl != 0 && canvas->get_canvas() && + mwindow->edl->session->cwindow_click2play && + canvas->get_canvas()->get_cursor_over_window() ) { + switch( get_buttonpress() ) { + case LEFT_BUTTON: + if( !cwindow->playback_engine->is_playing_back ) { + double length = mwindow->edl->tracks->total_playable_length(); + double position = cwindow->playback_engine->get_tracking_position(); + if( position >= length ) transport->goto_start(); + } + return transport->forward_play->handle_event(); + case MIDDLE_BUTTON: + if( !cwindow->playback_engine->is_playing_back ) { + double position = cwindow->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; @@ -370,27 +394,23 @@ float CWindowGUI::get_auto_zoom() void CWindowGUI::zoom_canvas(double value, int update_menu) { - EDL *edl = mwindow->edl; - float x = canvas->get_xscroll(), y = canvas->get_yscroll(); - float old_zoom = mwindow->edl->session->cwindow_zoom; - float new_zoom = !value ? get_auto_zoom() : value; - edl->session->cwindow_scrollbars = !value ? 0 : 1; + float x = 0, y = 0; + float zoom = !value ? get_auto_zoom() : value; + mwindow->edl->session->cwindow_scrollbars = !value ? 0 : 1; if( value ) { - float z = (1 - old_zoom / new_zoom) / 2; - x += canvas->w_visible * z; - y += canvas->h_visible * z; + float cx = canvas->get_xscroll() + 0.5f*canvas->w_visible; + float cy = canvas->get_yscroll() + 0.5f*canvas->h_visible; + float output_x = cx, output_y = cy; + canvas->output_to_canvas(mwindow->edl, 0, cx, cy); + x = output_x - cx / zoom; + y = output_y - cy / zoom; } - else - x = y = 0; - - canvas->update_zoom((int)x, (int)y, new_zoom); - if( !value ) - mwindow->edl->session->cwindow_scrollbars = 0; + canvas->update_zoom((int)(x+0.5), (int)(y+0.5), zoom); if( update_menu ) zoom_panel->update(value); if( mwindow->edl->session->cwindow_operation == CWINDOW_ZOOM ) - composite_panel->cpanel_zoom->update(new_zoom); + composite_panel->cpanel_zoom->update(zoom); canvas->reposition_window(mwindow->edl, mwindow->theme->ccanvas_x, mwindow->theme->ccanvas_y, @@ -398,15 +418,26 @@ void CWindowGUI::zoom_canvas(double value, int update_menu) canvas->draw_refresh(); } - - void CWindowGUI::set_operation(int value) { - mwindow->edl->session->cwindow_operation = value; + switch( value ) { + case CWINDOW_TOOL_WINDOW: + mwindow->edl->session->tool_window = !mwindow->edl->session->tool_window; + composite_panel->operation[CWINDOW_TOOL_WINDOW]->update(mwindow->edl->session->tool_window); + tool_panel->update_show_window(); + return; + case CWINDOW_TITLESAFE: + mwindow->edl->session->safe_regions = !mwindow->edl->session->safe_regions; + composite_panel->operation[CWINDOW_TITLESAFE]->update(mwindow->edl->session->safe_regions); + value = mwindow->edl->session->cwindow_operation; + break; + default: + mwindow->edl->session->cwindow_operation = value; + composite_panel->set_operation(value); + break; + } - composite_panel->set_operation(value); edit_panel->update(); - tool_panel->start_tool(value); canvas->draw_refresh(); } @@ -426,6 +457,7 @@ int CWindowGUI::close_event() int CWindowGUI::keypress_event() { int result = 0; + int cwindow_operation = CWINDOW_NONE; switch(get_keypress()) { @@ -472,61 +504,80 @@ int CWindowGUI::keypress_event() lock_window("CWindowGUI::keypress_event 4"); break; case LEFT: - if(!ctrl_down()) - { - if (alt_down()) - { - int shift_down = this->shift_down(); - unlock_window(); - mwindow->gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0); - - mwindow->gui->lock_window("CWindowGUI::keypress_event 2"); + if( !ctrl_down() ) { + int alt_down = this->alt_down(); + int shift_down = this->shift_down(); + unlock_window(); + stop_transport(0); + mwindow->gui->lock_window("CWindowGUI::keypress_event 5"); + if( alt_down ) mwindow->prev_edit_handle(shift_down); - mwindow->gui->unlock_window(); - - lock_window("CWindowGUI::keypress_event 1"); - } else - { - unlock_window(); - - mwindow->gui->lock_window("CWindowGUI::keypress_event 3"); mwindow->move_left(); - mwindow->gui->unlock_window(); - - lock_window("CWindowGUI::keypress_event 2"); - } + mwindow->gui->unlock_window(); + lock_window("CWindowGUI::keypress_event 6"); result = 1; } break; - case RIGHT: - if(!ctrl_down()) - { - if (alt_down()) - { - int shift_down = this->shift_down(); - unlock_window(); - mwindow->gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0); - mwindow->gui->lock_window("CWindowGUI::keypress_event 2"); - mwindow->next_edit_handle(shift_down); - mwindow->gui->unlock_window(); + case ',': + if( !ctrl_down() && !alt_down() ) { + unlock_window(); + stop_transport(0); + mwindow->gui->lock_window("CWindowGUI::keypress_event 7"); + mwindow->move_left(); + mwindow->gui->unlock_window(); + lock_window("CWindowGUI::keypress_event 8"); + result = 1; + } + break; - lock_window("CWindowGUI::keypress_event 2"); - } + case RIGHT: + if( !ctrl_down() ) { + int alt_down = this->alt_down(); + int shift_down = this->shift_down(); + unlock_window(); + stop_transport(0); + mwindow->gui->lock_window("CWindowGUI::keypress_event 8"); + if( alt_down ) + mwindow->next_edit_handle(shift_down); else - { - unlock_window(); - - mwindow->gui->lock_window("CWindowGUI::keypress_event 4"); mwindow->move_right(); - mwindow->gui->unlock_window(); + mwindow->gui->unlock_window(); + lock_window("CWindowGUI::keypress_event 9"); + result = 1; + } + break; - lock_window("CWindowGUI::keypress_event 3"); - } + case '.': + if( !ctrl_down() && !alt_down() ) { + unlock_window(); + stop_transport(0); + mwindow->gui->lock_window("CWindowGUI::keypress_event 10"); + mwindow->move_right(); + mwindow->gui->unlock_window(); + lock_window("CWindowGUI::keypress_event 11"); result = 1; } break; + + case KEY_F1: cwindow_operation = CWINDOW_PROTECT; break; + case KEY_F2: cwindow_operation = CWINDOW_ZOOM; break; + case KEY_F3: cwindow_operation = CWINDOW_MASK; break; + case KEY_F4: cwindow_operation = CWINDOW_RULER; break; + case KEY_F5: cwindow_operation = CWINDOW_CAMERA; break; + case KEY_F6: cwindow_operation = CWINDOW_PROJECTOR; break; + case KEY_F7: cwindow_operation = CWINDOW_CROP; break; + case KEY_F8: cwindow_operation = CWINDOW_EYEDROP; break; + case KEY_F9: cwindow_operation = CWINDOW_TOOL_WINDOW; break; + case KEY_F10: cwindow_operation = CWINDOW_TITLESAFE; break; + case KEY_F11: canvas->reset_camera(); break; + case KEY_F12: canvas->reset_projector(); break; + } + + if( cwindow_operation >= 0 ) { + set_operation(cwindow_operation); + result = 1; } if(!result) result = transport->keypress_event(); @@ -675,30 +726,36 @@ void CWindowGUI::update_meters() } } +void CWindowGUI::stop_transport(const char *lock_msg) +{ + if( lock_msg ) unlock_window(); + mwindow->stop_transport(); + if( lock_msg ) lock_window(lock_msg); +} + CWindowEditing::CWindowEditing(MWindow *mwindow, CWindow *cwindow) - : EditPanel(mwindow, - cwindow->gui, - mwindow->theme->cedit_x, - mwindow->theme->cedit_y, + : EditPanel(mwindow, cwindow->gui, CWINDOW_ID, + mwindow->theme->cedit_x, mwindow->theme->cedit_y, mwindow->edl->session->editing_mode, - 0, - 1, - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 0, + 0, // use_editing_mode + 1, // use_keyframe + 0, // use_splice + 0, // use_overwrite + 1, // use_lift + 1, // use_extract + 1, // use_copy + 1, // use_paste + 1, // use_undo + 0, // use_fit 0, // locklabels - 1, - 1, - 1, - 0, - 1, - 0) + 1, // use_labels + 1, // use_toclip + 1, // use_meters + 1, // use_cut + 0, // use_commerical + 0, // use_goto + 1) // use_clk2play { this->mwindow = mwindow; this->cwindow = cwindow; @@ -715,15 +772,23 @@ CWrapper(splice_selection) CWrapper(overwrite_selection) CWrapper(set_inpoint) CWrapper(set_outpoint) -CWrapper(clear_inpoint) -CWrapper(clear_outpoint) -CWrapper(to_clip) +CWrapper(unset_inoutpoint) CWrapper(toggle_label) -CWrapper(prev_label) -CWrapper(next_label) -CWrapper(prev_edit) -CWrapper(next_edit) +#define CWrapper_cut(fn) void CWindowEditing::fn(int cut) { \ + mwindow->gui->lock_window("CWrapper::" #fn); \ + EditPanel::fn(cut); \ + mwindow->gui->unlock_window(); \ +} +CWrapper_cut(prev_label) +CWrapper_cut(next_label) +CWrapper_cut(prev_edit) +CWrapper_cut(next_edit) + +void CWindowEditing::to_clip() +{ + mwindow->to_clip(mwindow->edl, _("composer window: "), 0); +} CWindowMeters::CWindowMeters(MWindow *mwindow, @@ -825,21 +890,10 @@ int CWindowSlider::handle_event() void CWindowSlider::set_position() { - double new_length = mwindow->edl->tracks->total_playable_length(); -// if(mwindow->edl->local_session->preview_end <= 0 || -// mwindow->edl->local_session->preview_end > new_length) -// mwindow->edl->local_session->preview_end = new_length; -// if(mwindow->edl->local_session->preview_start > -// mwindow->edl->local_session->preview_end) -// mwindow->edl->local_session->preview_start = 0; - - + double new_length = mwindow->edl->tracks->total_length(); update(mwindow->theme->cslider_w, mwindow->edl->local_session->get_selectionstart(1), - 0, - new_length); -// mwindow->edl->local_session->preview_start, -// mwindow->edl->local_session->preview_end); + 0, new_length); } @@ -1037,12 +1091,13 @@ void CWindowCanvas::draw_refresh(int flush) (int)out_x1, (int)out_y1, (int)(out_x2 - out_x1), - (int)(out_y2 - out_y1), - (int)in_x1, - (int)in_y1, - (int)(in_x2 - in_x1), - (int)(in_y2 - in_y1), - 0); + (int)(out_y2 - out_y1)); +// if refresh_frame session geometry... +// (int)in_x1, +// (int)in_y1, +// (int)(in_x2 - in_x1), +// (int)(in_y2 - in_y1), +// 0); } } else @@ -1054,6 +1109,9 @@ void CWindowCanvas::draw_refresh(int flush) } draw_overlays(); +// allow last opengl write to complete before redraw +// tried sync_display, glFlush, glxMake*Current(0..) +usleep(20000); get_canvas()->flash(flush); } //printf("CWindowCanvas::draw_refresh 10\n"); @@ -2163,15 +2221,24 @@ int CWindowCanvas::do_eyedrop(int &rerender, int button_press, int draw) float blue = (float)*row++ / max; \ if(do_yuv) \ { \ - mwindow->edl->local_session->red += red + V_TO_R * (blue - 0.5); \ - mwindow->edl->local_session->green += red + U_TO_G * (green - 0.5) + V_TO_G * (blue - 0.5); \ - mwindow->edl->local_session->blue += red + U_TO_B * (green - 0.5); \ + float r = red + V_TO_R * (blue - 0.5); \ + float g = red + U_TO_G * (green - 0.5) + V_TO_G * (blue - 0.5); \ + float b = red + U_TO_B * (green - 0.5); \ + mwindow->edl->local_session->red += r; \ + mwindow->edl->local_session->green += g; \ + mwindow->edl->local_session->blue += b; \ + if(r > mwindow->edl->local_session->red_max) mwindow->edl->local_session->red_max = r; \ + if(g > mwindow->edl->local_session->green_max) mwindow->edl->local_session->green_max = g; \ + if(b > mwindow->edl->local_session->blue_max) mwindow->edl->local_session->blue_max = b; \ } \ else \ { \ mwindow->edl->local_session->red += red; \ mwindow->edl->local_session->green += green; \ mwindow->edl->local_session->blue += blue; \ + if(red > mwindow->edl->local_session->red_max) mwindow->edl->local_session->red_max = red; \ + if(green > mwindow->edl->local_session->green_max) mwindow->edl->local_session->green_max = green; \ + if(blue > mwindow->edl->local_session->blue_max) mwindow->edl->local_session->blue_max = blue; \ } \ } @@ -2180,6 +2247,9 @@ int CWindowCanvas::do_eyedrop(int &rerender, int button_press, int draw) mwindow->edl->local_session->red = 0; mwindow->edl->local_session->green = 0; mwindow->edl->local_session->blue = 0; + mwindow->edl->local_session->red_max = 0; + mwindow->edl->local_session->green_max = 0; + mwindow->edl->local_session->blue_max = 0; for(int i = row1; i < row2; i++) { for(int j = column1; j < column2; j++) @@ -2242,6 +2312,24 @@ int CWindowCanvas::do_eyedrop(int &rerender, int button_press, int draw) return result; } +int CWindowCanvas::need_overlays() +{ + if( mwindow->edl->session->safe_regions ) return 1; + if( mwindow->edl->session->cwindow_scrollbars ) return 1; + if( gui->highlighted ) return 1; + switch( mwindow->edl->session->cwindow_operation ) { + case CWINDOW_EYEDROP: + if( ! gui->eyedrop_visible ) break; + case CWINDOW_CAMERA: + case CWINDOW_PROJECTOR: + case CWINDOW_CROP: + case CWINDOW_MASK: + case CWINDOW_RULER: + return 1; + } + return 0; +} + void CWindowCanvas::draw_overlays() { if(mwindow->edl->session->safe_regions) @@ -2490,7 +2578,7 @@ int CWindowCanvas::test_crop(int button_press, int &redraw) redraw = 1; } } - else + else // Translate all 4 points if(gui->current_operation == CWINDOW_CROP && gui->crop_translate) { @@ -2944,13 +3032,7 @@ int CWindowCanvas::test_zoom(int &redraw) float x, y; float zoom = 0; - if( !mwindow->edl->session->cwindow_scrollbars ) { - mwindow->edl->session->cwindow_scrollbars = 1; - x = (mwindow->edl->session->output_w - w) / 2; - y = (mwindow->edl->session->output_h - h) / 2; - zoom = 1; - } - else { + if( mwindow->edl->session->cwindow_scrollbars ) { if( *gui->zoom_panel->get_text() != 'x' ) { // Find current zoom in table int idx = total_zooms; float old_zoom = get_zoom(); @@ -2963,19 +3045,25 @@ int CWindowCanvas::test_zoom(int &redraw) } } x = get_cursor_x(); y = get_cursor_y(); + if( !zoom ) { + mwindow->edl->session->cwindow_scrollbars = 0; + gui->zoom_panel->update(0); + zoom = gui->get_auto_zoom(); + } + else { + gui->zoom_panel->ZoomPanel::update(zoom); + float output_x = x, output_y = y; + canvas_to_output(mwindow->edl, 0, output_x, output_y); + x = output_x - x / zoom; + y = output_y - y / zoom; + } } - if( !zoom ) { - mwindow->edl->session->cwindow_scrollbars = 0; - gui->zoom_panel->update(0); - zoom = gui->get_auto_zoom(); + else { + mwindow->edl->session->cwindow_scrollbars = 1; + x = (mwindow->edl->session->output_w - w) / 2; + y = (mwindow->edl->session->output_h - h) / 2; + zoom = 1; } - else - gui->zoom_panel->ZoomPanel::update(zoom); - - float output_x = x, output_y = y; - canvas_to_output(mwindow->edl, 0, output_x, output_y); - x = output_x - x / zoom; - y = output_y - y / zoom; update_zoom((int)x, (int)y, zoom); gui->composite_panel->cpanel_zoom->update(zoom); @@ -3162,10 +3250,7 @@ int CWindowCanvas::cursor_motion_event() gui->unlock_window(); mwindow->restart_brender(); mwindow->sync_parameters(CHANGE_PARAMS); - gui->cwindow->playback_engine->que->send_command(CURRENT_FRAME, - CHANGE_NONE, - mwindow->edl, - 1); + mwindow->cwindow->refresh_frame(CHANGE_NONE); if(!redraw) gui->update_tool(); gui->lock_window("CWindowCanvas::cursor_motion_event 2"); } @@ -3192,7 +3277,8 @@ int CWindowCanvas::button_press_event() gui->y_offset = get_y_offset(mwindow->edl, 0, zoom_y, conformed_w, conformed_h); // Scroll view - if(get_buttonpress() == 2) + if( mwindow->edl->session->cwindow_operation != CWINDOW_PROTECT && + get_buttonpress() == 2 ) { gui->current_operation = CWINDOW_SCROLL; result = 1; @@ -3254,10 +3340,7 @@ int CWindowCanvas::button_press_event() mwindow->restart_brender(); mwindow->sync_parameters(CHANGE_PARAMS); - gui->cwindow->playback_engine->que->send_command(CURRENT_FRAME, - CHANGE_NONE, - mwindow->edl, - 1); + mwindow->cwindow->refresh_frame(CHANGE_NONE); if(!redraw) gui->update_tool(); gui->lock_window("CWindowCanvas::button_press_event 2"); }