X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;ds=inline;f=cinelerra-5.1%2Fplugins%2Fsketcher%2Fsketcherwindow.C;h=eb5a49f23b8ffbb98641eee51fbdc541daaec939;hb=9fed7535470aa37781733db836068da3b4c17a0d;hp=7cbf15dd14b27b920bcde42b7da4a8c327d9ac34;hpb=258d9cb69d560f40961acdd20866e12e940c2f93;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/plugins/sketcher/sketcherwindow.C b/cinelerra-5.1/plugins/sketcher/sketcherwindow.C index 7cbf15dd..eb5a49f2 100644 --- a/cinelerra-5.1/plugins/sketcher/sketcherwindow.C +++ b/cinelerra-5.1/plugins/sketcher/sketcherwindow.C @@ -79,7 +79,7 @@ int SketcherCurvePenItem::handle_event() } SketcherCurvePen::SketcherCurvePen(SketcherWindow *gui, int x, int y, int pen) - : BC_PopupMenu(x,y,72,_(cv_pen[pen])) + : BC_PopupMenu(x,y,100,_(cv_pen[pen])) { this->gui = gui; this->pen = pen; @@ -122,7 +122,9 @@ void SketcherCurveColor::handle_done_event(int result) if( ci >= 0 && ci < config.curves.size() ) { SketcherCurve *cv = config.curves[ci]; cv->color = color; + gui->lock_window("SketcherCurveColor::handle_done_event"); gui->curve_list->update(ci); + gui->unlock_window(); gui->send_configure_change(); } } @@ -278,8 +280,8 @@ SketcherWindow::SketcherWindow(Sketcher *plugin) position = -1; track_w = track_h -1; - cursor_x = cursor_y = -1; output_x = output_y = -1; + track_x = track_y = -1; last_x = last_y = -1; projector_x = projector_y = projector_z = -1; state = 0; dragging = 0; @@ -433,7 +435,7 @@ void SketcherWindow::create_objects() "Shift=\n" "None=\n" "Ctrl=\n" - "Alt=\n" + "Ctrl+Alt=\n" "Ctrl+Shift="))); dy = bmax(dy, notes0->get_h()); add_subwindow(notes1 = new BC_Title(x+100, y, _(" LMB\n" @@ -458,6 +460,8 @@ void SketcherWindow::create_objects() void SketcherWindow::done_event(int result) { + curve_color->close_picker(); + ungrab(plugin->server->mwindow->cwindow->gui); } void SketcherWindow::send_configure_change() @@ -504,16 +508,17 @@ int SketcherWindow::do_grab_event(XEvent *event) MWindow *mwindow = plugin->server->mwindow; CWindowGUI *cwindow_gui = mwindow->cwindow->gui; CWindowCanvas *canvas = cwindow_gui->canvas; - int cx, cy; cwindow_gui->get_relative_cursor(cx, cy); - cx -= mwindow->theme->ccanvas_x; - cy -= mwindow->theme->ccanvas_y; + cwindow_gui->get_relative_cursor(cursor_x, cursor_y); + output_x = cursor_x - canvas->view_x; + output_y = cursor_y - canvas->view_y; if( !dragging ) { - if( cx < 0 || cx >= mwindow->theme->ccanvas_w || - cy < 0 || cy >= mwindow->theme->ccanvas_h ) + if( output_x < 0 || output_x >= canvas->view_w || + output_y < 0 || output_y >= canvas->view_h ) return 0; } + switch( event->type ) { case ButtonPress: if( dragging ) return 0; @@ -528,19 +533,8 @@ int SketcherWindow::do_grab_event(XEvent *event) return 0; } - cursor_x = cx, cursor_y = cy; - canvas->canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y); - position = plugin->get_source_position(); - Track *track = plugin->server->plugin->track; - track_w = track->track_w; - track_h = track->track_h; - track->automation->get_projector( - &projector_x, &projector_y, &projector_z, - position, PLAY_FORWARD); - projector_x += mwindow->edl->session->output_w / 2; - projector_y += mwindow->edl->session->output_h / 2; - output_x = (cursor_x - projector_x) / projector_z + track_w / 2; - output_y = (cursor_y - projector_y) / projector_z + track_h / 2; + canvas->canvas_to_output(mwindow->edl, 0, output_x, output_y); + plugin->output_to_track(output_x, output_y, track_x, track_y); state = event->xmotion.state; if( event->type == MotionNotify ) { @@ -569,6 +563,10 @@ int SketcherWindow::grab_button_press(XEvent *event) int ci = config.cv_selected; if( ci < 0 || ci >= plugin->config.curves.size() ) return 0; + MWindow *mwindow = plugin->server->mwindow; + CWindowGUI *cwindow_gui = mwindow->cwindow->gui; + CWindowCanvas *canvas = cwindow_gui->canvas; + SketcherCurves &curves = config.curves; SketcherCurve *cv = curves[ci]; SketcherPoints &points = cv->points; @@ -581,20 +579,22 @@ int SketcherWindow::grab_button_press(XEvent *event) ++new_points; pi = plugin->new_point(cv, !(state & ControlMask) ? ARC_LINE : ARC_FILL, - output_x, output_y, pi+1); + track_x, track_y, pi+1); point_list->update(pi); break; } SketcherPoint *pt = 0; // select point - double dist = cv->nearest_point(pi, output_x,output_y); + double dist = cv->nearest_point(pi, track_x,track_y); if( dist >= 0 ) { pt = points[pi]; - Track *track = plugin->server->plugin->track; - int track_w = track->track_w, track_h = track->track_h; - float px = (pt->x - track_w / 2) * projector_z + projector_x; - float py = (pt->y - track_h / 2) * projector_z + projector_y; - float pix = DISTANCE(px, py, cursor_x,cursor_y); - if( (state & ControlMask) && pix >= HANDLE_W ) { pi = -1; pt = 0; } + float cx, cy; + plugin->track_to_output(pt->x, pt->y, cx, cy); + canvas->output_to_canvas(mwindow->edl, 0, cx, cy); + cx += canvas->view_x; cy += canvas->view_y; + dist = DISTANCE(cx,cy, cursor_x,cursor_y); + if( (state & ControlMask) && dist >= HANDLE_W ) { + pi = -1; pt = 0; + } } point_list->set_selected(pi); break; } @@ -603,26 +603,28 @@ int SketcherWindow::grab_button_press(XEvent *event) ++new_points; pi = plugin->new_point(cv, !(state & ControlMask) ? ARC_CURVE : ARC_OFF, - output_x, output_y, pi+1); + track_x, track_y, pi+1); point_list->update(pi); break; } - if( (state & AltMask) ) { // create new curve + if( (state & ControlMask) && (state & AltMask) ) { // create new curve ci = plugin->new_curve(cv->pen, cv->width, curve_color->color); curve_list->update(ci); point_list->update(-1); break; } SketcherPoint *pt = 0; - double dist = config.nearest_point(ci, pi, output_x,output_y); + double dist = config.nearest_point(ci, pi, track_x,track_y); if( dist >= 0 ) { pt = curves[ci]->points[pi]; - Track *track = plugin->server->plugin->track; - int track_w = track->track_w, track_h = track->track_h; - float px = (pt->x - track_w / 2) * projector_z + projector_x; - float py = (pt->y - track_h / 2) * projector_z + projector_y; - float pix = DISTANCE(px, py, cursor_x,cursor_y); - if( (state & ControlMask) && pix >= HANDLE_W ) { ci = pi = -1; pt = 0; } + float cx, cy; + plugin->track_to_output(pt->x, pt->y, cx, cy); + canvas->output_to_canvas(mwindow->edl, 0, cx, cy); + cx += canvas->view_x; cy += canvas->view_y; + dist = DISTANCE(cx,cy, cursor_x,cursor_y); + if( (state & ControlMask) && dist >= HANDLE_W ) { + ci = pi = -1; pt = 0; + } } if( pt ) { curve_list->update(ci); @@ -651,31 +653,31 @@ int SketcherWindow::grab_cursor_motion() if( (state & (Button1Mask|Button3Mask)) ) { SketcherPoint *pt = pi >= 0 && pi < points.size() ? points[pi] : 0; if( pt ) { - float dist = DISTANCE(pt->x, pt->y, output_x, output_y); + float dist = DISTANCE(pt->x, pt->y, track_x, track_y); if( dist < get_w()*0.1 ) return 0; // tolerance w/10 } ++new_points; int arc = (state & Button1Mask) ? ARC_LINE : ARC_CURVE; - pi = plugin->new_point(cv, arc, output_x, output_y, pi+1); + pi = plugin->new_point(cv, arc, track_x, track_y, pi+1); point_list->update(pi); } return 1; } if( (state & Button1Mask) ) { - if( (state & ControlMask) ) { // drag selected point + if( (state & ControlMask) && !(state & AltMask) ) { // drag selected point SketcherPoint *pt = pi >= 0 && pi < points.size() ? points[pi] : 0; if( pt ) { - point_list->set_point(pi, PT_X, pt->x = output_x); - point_list->set_point(pi, PT_Y, pt->y = output_y); + point_list->set_point(pi, PT_X, pt->x = track_x); + point_list->set_point(pi, PT_Y, pt->y = track_y); point_list->update_list(pi); point_x->update(pt->x); point_y->update(pt->y); } return 1; } - if( (state & AltMask) ) { // drag all curves - int dx = round(output_x - last_x); - int dy = round(output_y - last_y); + if( (state & ControlMask) && (state & AltMask) ) { // drag all curves + int dx = round(track_x - last_x); + int dy = round(track_y - last_y); for( int i=0; iconfig.curves[i]; int pts = crv->points.size(); @@ -692,15 +694,15 @@ int SketcherWindow::grab_cursor_motion() point_list->update(pi); return 1; } - double dist = cv->nearest_point(pi, output_x,output_y); + double dist = cv->nearest_point(pi, track_x,track_y); if( dist >= 0 ) point_list->set_selected(pi); return 1; } if( (state & Button3Mask) ) { if( (state & (ControlMask | AltMask)) ) { // drag selected curve(s) - int dx = round(output_x - last_x); - int dy = round(output_y - last_y); + int dx = round(track_x - last_x); + int dy = round(track_y - last_y); for( int i=0; ix += dx; pt->y += dy; @@ -713,7 +715,7 @@ int SketcherWindow::grab_cursor_motion() point_list->update(pi); return 1; } - double dist = config.nearest_point(ci, pi, output_x,output_y); + double dist = config.nearest_point(ci, pi, track_x,track_y); if( dist >= 0 ) { curve_list->update(ci); point_list->update(pi); @@ -774,6 +776,7 @@ int SketcherCurveList::handle_event() int SketcherCurveList::selection_changed() { + gui->curve_color->close_picker(); handle_event(); return 1; } @@ -970,7 +973,7 @@ int SketcherPointTypeItem::handle_event() } SketcherPointType::SketcherPointType(SketcherWindow *gui, int x, int y, int arc) - : BC_PopupMenu(x,y,64,_(pt_type[arc])) + : BC_PopupMenu(x,y,100,_(pt_type[arc])) { this->gui = gui; this->type = arc;