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);
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);
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;
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;
new_points = 0;
pending_motion = 0;
pending_config = 0;
+ helped = 0;
+ help_h = get_h();
+ last_time = 0;
}
SketcherWindow::~SketcherWindow()
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");
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;
y += dy + margin + yS(10);
add_subwindow(notes3 = new BC_Title(x, y,
+ "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);
}
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; i<sz; ++i ) {
+ SketcherPoint *pt = points[i];
+ float px = pt->x - 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;
}
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;
}
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;
}
SketcherCurveUp::SketcherCurveUp(SketcherWindow *gui, int x, int y)
- : BC_GenericButton(x, y, _("Up"))
+ : BC_GenericButton(x, y, xS(96), _("Up"))
{
this->gui = gui;
}
}
SketcherCurveDn::SketcherCurveDn(SketcherWindow *gui, int x, int y)
- : BC_GenericButton(x, y, _("Dn"))
+ : BC_GenericButton(x, y, xS(96), _("Dn"))
{
this->gui = gui;
}
SketcherPointUp::SketcherPointUp(SketcherWindow *gui, int x, int y)
- : BC_GenericButton(x, y, _("Up"))
+ : BC_GenericButton(x, y, xS(96), _("Up"))
{
this->gui = gui;
}
}
SketcherPointDn::SketcherPointDn(SketcherWindow *gui, int x, int y)
- : BC_GenericButton(x, y, _("Dn"))
+ : BC_GenericButton(x, y, xS(96), _("Dn"))
{
this->gui = gui;
}
}
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;
}
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;
}
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;
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;
+}
+