X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fsketcher%2Fsketcherwindow.C;h=22abb7345aa8913f493d54e945ae4765d3aba793;hb=fb3e53778e49a406768506de9bf8edfd3d4c36e6;hp=ff97dd14dc14343348ec09cb8cee330319fbd786;hpb=5d8a7826b0f80f00622e46baf75453995a76e343;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/plugins/sketcher/sketcherwindow.C b/cinelerra-5.1/plugins/sketcher/sketcherwindow.C index ff97dd14..22abb734 100644 --- a/cinelerra-5.1/plugins/sketcher/sketcherwindow.C +++ b/cinelerra-5.1/plugins/sketcher/sketcherwindow.C @@ -143,7 +143,7 @@ int SketcherCurveColor::handle_new_color(int color, int alpha) SketcherCoord::SketcherCoord(SketcherWindow *gui, int x, int y, coord output, coord mn, coord mx) - : BC_TumbleTextBox(gui, output, mn, mx, x, y, 64, 1) + : BC_TumbleTextBox(gui, output, mn, mx, x, y, xS(80), 1) { this->gui = gui; set_increment(1); @@ -154,7 +154,7 @@ SketcherCoord::~SketcherCoord() SketcherNum::SketcherNum(SketcherWindow *gui, int x, int y, int output, int mn, int mx) - : BC_TumbleTextBox(gui, output, mn, mx, x, y, 54) + : BC_TumbleTextBox(gui, output, mn, mx, x, y, xS(54)) { this->gui = gui; set_increment(1); @@ -273,11 +273,12 @@ int SketcherAliasItem::handle_event() SketcherAliasing::SketcherAliasing(SketcherWindow *gui, Sketcher *plugin, int x, int y) - : BC_PopupMenu(x, y, xS(64), + : BC_PopupMenu(x, y, xS(80), alias_to_text(plugin->config.aliasing), 1, 0, xS(3)) { this->gui = gui; this->plugin = plugin; + set_tooltip(_("Anti-Aliasing")); } SketcherAliasing::~SketcherAliasing() { @@ -293,14 +294,14 @@ void SketcherAliasing::create_objects() const char *SketcherAliasing::alias_to_text(int alias) { if( alias < 0 ) return _("Off"); - if( alias > 0 ) return _("Dbl"); + if( alias > 0 ) return _("Double"); return _("On"); } SketcherWindow::SketcherWindow(Sketcher *plugin) - : PluginClientWindow(plugin, xS(400), yS(620), xS(400), yS(620), 0) + : PluginClientWindow(plugin, xS(460), yS(680), xS(460), yS(680), 0) { this->plugin = plugin; this->title_pen = 0; this->curve_pen = 0; @@ -326,6 +327,9 @@ SketcherWindow::SketcherWindow(Sketcher *plugin) new_points = 0; pending_motion = 0; pending_config = 0; + helped = 0; + help_h = get_h(); + last_time = 0; } SketcherWindow::~SketcherWindow() @@ -345,7 +349,7 @@ void SketcherWindow::create_objects() ci = plugin->new_curve(); SketcherCurve *cv = plugin->config.curves[ci]; - reset_curves = new SketcherResetCurves(this, plugin, x1=x, y+yS(3)); + reset_curves = new SketcherResetCurves(this, plugin, x1=x, y); add_subwindow(reset_curves); dy = bmax(dy,reset_curves->get_h()); x1 += reset_curves->get_w() + 2*margin; const char *curve_text = _("Curve"); @@ -468,6 +472,9 @@ void SketcherWindow::create_objects() y += dy + margin + yS(5); dy = 0; point_list->update(pi); + add_subwindow(help = new SketcherHelp(this, plugin, x, y)); + y += help->get_h() + yS(5); + help_y = y; bar = new BC_Bar(x, y, get_w()-xS(2)*x); add_subwindow(bar); dy = bmax(dy,bar->get_h()); y += dy + yS(2)*margin; @@ -486,7 +493,7 @@ void SketcherWindow::create_objects() "drag point\n" "drag all curves\n" "new fill point"))); dy = bmax(dy, notes1->get_h()); - add_subwindow(notes2 = new BC_Title(x+xS(220), y, + add_subwindow(notes2 = new BC_Title(x+xS(280), y, _(" RMB\n" "new arc point\n" "select curve\n" @@ -496,7 +503,11 @@ void SketcherWindow::create_objects() y += dy + margin + yS(10); add_subwindow(notes3 = new BC_Title(x, y, - "Key DEL= delete point, +Shift= delete curve\n")); + _("Wheel: rotate, centered on cursor\n" + "Wheel: shift: scale, centered on cursor\n" + "Key DEL= delete point, +Shift= delete curve\n"))); + + resize_window(get_w(), help_y); show_window(1); } @@ -614,8 +625,38 @@ int SketcherWindow::grab_button_press(XEvent *event) SketcherPoints &points = cv->points; int pi = config.pt_selected; + float s = 1.001; // min scale + float th = 0.1 * M_PI/180.f; // min theta .1 deg per wheel_btn + int64_t ms = event->xbutton.time; + double dt = (ms - last_time) / 1000.; // seconds + last_time = ms; + double mx_accel = 100., r = mx_accel / exp(1.); + double mx_dt = 1./2., mn_dt = 1./15.; // mn..mx period in sec/xev + bclip(dt, mn_dt, mx_dt); + double accel = r * exp(-(dt-mn_dt)/(mx_dt-mn_dt)); int button_no = event->xbutton.button; switch( button_no ) { + case WHEEL_DOWN: + s = 2 - s; + th = -th; // fall thru + case WHEEL_UP: { // shift_down scale, !shift_down rotate + s = 1 + (s-1)*accel; + th *= accel; + float st = sin(th), ct = cos(th); + int sz = points.size(); + int shift_down = (state & ShiftMask) ? 1 : 0; + for( int i=0; ix - track_x, py = pt->y - track_y; + float nx = shift_down ? px*s : px*ct + py*st; + float ny = shift_down ? py*s : py*ct - px*st; + point_list->set_point(i, PT_X, pt->x = nx + track_x); + point_list->set_point(i, PT_Y, pt->y = ny + track_y); + } + point_list->update(-1); + button_no = 0; + break; } + case LEFT_BUTTON: { if( (state & ShiftMask) ) { // create new point/string ++new_points; @@ -878,7 +919,7 @@ void SketcherCurveList::add_curve(const char *id, const char *pen, } SketcherNewCurve::SketcherNewCurve(SketcherWindow *gui, Sketcher *plugin, int x, int y) - : BC_GenericButton(x, y, xS(64), _("New")) + : BC_GenericButton(x, y, xS(96), _("New")) { this->gui = gui; this->plugin = plugin; @@ -904,7 +945,7 @@ int SketcherNewCurve::handle_event() } SketcherDelCurve::SketcherDelCurve(SketcherWindow *gui, Sketcher *plugin, int x, int y) - : BC_GenericButton(x, y, xS(64), C_("Del")) + : BC_GenericButton(x, y, xS(96), C_("Del")) { this->gui = gui; this->plugin = plugin; @@ -930,7 +971,7 @@ int SketcherDelCurve::handle_event() } SketcherCurveUp::SketcherCurveUp(SketcherWindow *gui, int x, int y) - : BC_GenericButton(x, y, _("Up")) + : BC_GenericButton(x, y, xS(96), _("Up")) { this->gui = gui; } @@ -954,7 +995,7 @@ int SketcherCurveUp::handle_event() } SketcherCurveDn::SketcherCurveDn(SketcherWindow *gui, int x, int y) - : BC_GenericButton(x, y, _("Dn")) + : BC_GenericButton(x, y, xS(96), _("Dn")) { this->gui = gui; } @@ -1161,7 +1202,7 @@ void SketcherWindow::update_gui() SketcherPointUp::SketcherPointUp(SketcherWindow *gui, int x, int y) - : BC_GenericButton(x, y, _("Up")) + : BC_GenericButton(x, y, xS(96), _("Up")) { this->gui = gui; } @@ -1199,7 +1240,7 @@ int SketcherPointUp::handle_event() } SketcherPointDn::SketcherPointDn(SketcherWindow *gui, int x, int y) - : BC_GenericButton(x, y, _("Dn")) + : BC_GenericButton(x, y, xS(96), _("Dn")) { this->gui = gui; } @@ -1238,7 +1279,7 @@ int SketcherPointDn::handle_event() } SketcherDrag::SketcherDrag(SketcherWindow *gui, int x, int y) - : BC_CheckBox(x, y, gui->plugin->config.drag, _("Drag")) + : BC_CheckBox(x, y, gui->plugin->config.drag, (C_("Drag"))) { this->gui = gui; } @@ -1258,9 +1299,20 @@ int SketcherDrag::handle_event() gui->send_configure_change(); return 1; } +int SketcherWindow::handle_ungrab() +{ + CWindowGUI *cwindow_gui = plugin->server->mwindow->cwindow->gui; + int ret = ungrab(cwindow_gui); + if( ret ) { + drag->update(0); + plugin->config.drag = 0; + send_configure_change(); + } + return ret; +} SketcherNewPoint::SketcherNewPoint(SketcherWindow *gui, Sketcher *plugin, int x, int y) - : BC_GenericButton(x, y, xS(64), _("New")) + : BC_GenericButton(x, y, xS(96), _("New")) { this->gui = gui; this->plugin = plugin; @@ -1279,7 +1331,7 @@ int SketcherNewPoint::handle_event() } SketcherDelPoint::SketcherDelPoint(SketcherWindow *gui, Sketcher *plugin, int x, int y) - : BC_GenericButton(x, y, xS(64), C_("Del")) + : BC_GenericButton(x, y, xS(96), C_("Del")) { this->gui = gui; this->plugin = plugin; @@ -1334,7 +1386,7 @@ int SketcherResetCurves::handle_event() } SketcherResetPoints::SketcherResetPoints(SketcherWindow *gui, Sketcher *plugin, int x, int y) - : BC_GenericButton(x, y, _("Reset")) + : BC_GenericButton(x, y-yS(2), _("Reset")) { this->gui = gui; this->plugin = plugin; @@ -1355,3 +1407,23 @@ int SketcherResetPoints::handle_event() return 1; } +SketcherHelp::SketcherHelp(SketcherWindow *gui, Sketcher *plugin, int x, int y) + : BC_CheckBox(x, y, 0, _("Help")) +{ + this->gui = gui; + this->plugin = plugin; + set_tooltip(_("Show help text")); +} +SketcherHelp::~SketcherHelp() +{ +} + +int SketcherHelp::handle_event() +{ + gui->helped = get_value(); + gui->resize_window(gui->get_w(), + gui->helped ? gui->help_h : gui->help_y); + gui->update_gui(); + return 1; +} +