sketcher tweaks + strengthen, yuv alpha draw_pixel fix
authorGood Guy <[email protected]>
Wed, 21 Nov 2018 18:59:20 +0000 (11:59 -0700)
committerGood Guy <[email protected]>
Wed, 21 Nov 2018 18:59:20 +0000 (11:59 -0700)
cinelerra-5.1/doc/shortcuts.html
cinelerra-5.1/guicast/vframe.C
cinelerra-5.1/info/plugins.txt
cinelerra-5.1/plugins/sketcher/sketcher.C
cinelerra-5.1/plugins/sketcher/sketcher.h
cinelerra-5.1/plugins/sketcher/sketcherwindow.C
cinelerra-5.1/plugins/sketcher/sketcherwindow.h

index eec60962a303c8e210d26e6dd2e0303907876583..bc9ec7b856afdd247b174b98b82ac5d1cb524da6 100644 (file)
                <td align="left"><font face="Liberation Serif,Times New Roman" size=4>Ctrl-z</font></td>
                <td align="left"><font face="Liberation Serif,Times New Roman" size=4>Deselects any selected files</font></td>
        </tr>
+       <tr>
+               <td height="26" align="left"><font face="Liberation Serif,Times New Roman" size=4><br></font></td>
+               <td align="left"><font face="Liberation Serif,Times New Roman" size=4>DEL key</font></td>
+               <td align="left"><font face="Liberation Serif,Times New Roman" size=4></font></td>
+               <td align="left"><font face="Liberation Serif,Times New Roman" size=4>Resources/Media, delete from project</font></td>
+       </tr>
+       <tr>
+               <td height="26" align="left"><font face="Liberation Serif,Times New Roman" size=4><br></font></td>
+               <td align="left"><font face="Liberation Serif,Times New Roman" size=4>DEL key</font></td>
+               <td align="left"><font face="Liberation Serif,Times New Roman" size=4>'Shift'</font></td>
+               <td align="left"><font face="Liberation Serif,Times New Roman" size=4>Resources/Media, delete from disk + OK</font></td>
+       </tr>
+       <tr>
+               <td height="26" align="left"><font face="Liberation Serif,Times New Roman" size=4><br></font></td>
+               <td align="left"><font face="Liberation Serif,Times New Roman" size=4>DEL key</font></td>
+               <td align="left"><font face="Liberation Serif,Times New Roman" size=4>'Ctrl+Shift'</font></td>
+               <td align="left"><font face="Liberation Serif,Times New Roman" size=4>Resources/plugin delete from disk + OK</font></td>
+       </tr>
        <tr>
                <td height="26" align="left"><font face="Liberation Serif,Times New Roman" size=4><br></font></td>
                <td align="left"><font face="Liberation Serif,Times New Roman" size=4><br></font></td>
index 82d0830c92d1effd7ebf9693d48830048c8e6dc3..5cd9901b3666e38eb813ac4c0d1f92da3060a741 100644 (file)
@@ -1359,7 +1359,7 @@ void VFrame::set_pixel_color(int rgb, int a)
        int ig = 0xff & (pixel_rgb >> 8);
        int ib = 0xff & (pixel_rgb >> 0);
        YUV::yuv.rgb_to_yuv_8(ir, ig, ib);
-       pixel_yuv =  (a<<24) | (ir<<16) | (ig<<8) | (ib<<0);
+       pixel_yuv =  (~a<<24) | (ir<<16) | (ig<<8) | (ib<<0);
 }
 
 void VFrame::set_stiple(int mask)
index fc19135492f8118b2fbbf41aa2e2a22c76f20a64..82ed02619bd930d72931dbe88d423f671a24095b 100644 (file)
@@ -182,6 +182,8 @@ Selective Temporal Averaging: Smooths out non-moving areas of a video
 Sharpen:       Sharpen the video, either the luminance, horizontal,
                or interlace.
 ShiftInterlace:        Shift the interlace lines using odd or even.
+Sketcher:      Sketch lines, curves, or points in different colors/
+               alpha and with fill using various pen widths/types.
 Sphere Cam:    Converts a fisheye image into a panoramic projection.
 Swap Frames:   Swap frames with 0-1, 2-3, 4-5... or 1-2, 3-4, 5-6...
 Swap channels: Swap R,G,B,Alpha with another color channel.
index 906980467729a76a626162aaa6d5fb840cd72c29..9bbdd675e22322929edad0a858d3391c2010f0b8 100644 (file)
 #include "language.h"
 #include "vframe.h"
 
-void SketcherPoint::init(int id, int pty, coord x, coord y)
+void SketcherPoint::init(int id, int arc, coord x, coord y)
 {
-       this->id = id;  this->pty = pty;
+       this->id = id;  this->arc = arc;
        this->x = x;    this->y = y;
 }
 SketcherPoint::SketcherPoint(int id)
 {
-       init(id, PTY_LINE, 0, 0);
+       init(id, ARC_LINE, 0, 0);
 }
-SketcherPoint::SketcherPoint(int id, int pty, coord x, coord y)
+SketcherPoint::SketcherPoint(int id, int arc, coord x, coord y)
 {
-       init(id, pty, x, y);
+       init(id, arc, x, y);
 }
 SketcherPoint::~SketcherPoint()
 {
@@ -60,13 +60,13 @@ SketcherPoint::SketcherPoint(SketcherPoint &pt)
 int SketcherPoint::equivalent(SketcherPoint &that)
 {
        return this->id == that.id &&
-               this->pty == that.pty &&
+               this->arc == that.arc &&
                EQUIV(this->x, that.x) &&
                EQUIV(this->y, that.y) ? 1 : 0;
 }
 void SketcherPoint::copy_from(SketcherPoint &that)
 {
-       this->id = that.id;  this->pty = that.pty;
+       this->id = that.id;  this->arc = that.arc;
        this->x = that.x;    this->y = that.y;
 }
 void SketcherPoint::save_data(FileXML &output)
@@ -74,7 +74,7 @@ void SketcherPoint::save_data(FileXML &output)
        char point[BCSTRLEN];
        sprintf(point,"/POINT_%d",id);
        output.tag.set_title(point+1);
-       output.tag.set_property("TYPE", pty);
+       output.tag.set_property("TYPE", arc);
        output.tag.set_property("X", x);
        output.tag.set_property("Y", y);
        output.append_tag();
@@ -85,10 +85,10 @@ void SketcherPoint::save_data(FileXML &output)
 void SketcherPoint::read_data(FileXML &input)
 {
        id = atoi(input.tag.get_title() + 6);
-       pty = input.tag.get_property("TYPE", PTY_OFF);
+       arc = input.tag.get_property("TYPE", ARC_OFF);
        x = input.tag.get_property("X", (coord)0);
        y = input.tag.get_property("Y", (coord)0);
-       bclamp(pty, 0, PTY_SZ-1);
+       bclamp(arc, 0, ARC_SZ-1);
 }
 
 void SketcherCurve::init(int id, int pen, int width, int color)
@@ -100,7 +100,7 @@ void SketcherCurve::init(int id, int pen, int width, int color)
 }
 SketcherCurve::SketcherCurve(int id)
 {
-       init(id, 1, PTY_LINE, CV_COLOR);
+       init(id, 1, ARC_LINE, CV_COLOR);
 }
 SketcherCurve::SketcherCurve(int id, int pen, int width, int color)
 {
@@ -139,7 +139,6 @@ void SketcherCurve::copy_from(SketcherCurve &that)
 }
 void SketcherCurve::save_data(FileXML &output)
 {
-       this->pen = pen;  this->color = color;
        char curve[BCSTRLEN];
        sprintf(curve,"/CURVE_%d",id);
        output.tag.set_title(curve+1);
@@ -157,7 +156,7 @@ void SketcherCurve::save_data(FileXML &output)
 void SketcherCurve::read_data(FileXML &input)
 {
        id = atoi(input.tag.get_title() + 6);
-       pen = input.tag.get_property("PEN", PTY_OFF);
+       pen = input.tag.get_property("PEN", PEN_OFF);
        width = input.tag.get_property("RADIUS", 1.);
        color = input.tag.get_property("COLOR", CV_COLOR);
        bclamp(pen, 0, PEN_SZ-1);
@@ -182,21 +181,21 @@ int Sketcher::new_curve()
        return new_curve(PEN_XLANT, 1, CV_COLOR);
 }
 
-int Sketcher::new_point(SketcherCurve *cv, int pty, coord x, coord y, int idx)
+int Sketcher::new_point(SketcherCurve *cv, int arc, coord x, coord y, int idx)
 {
        int id = 1;
        for( int i=cv->points.size(); --i>=0; ) {
                int n = cv->points[i]->id;
                if( n >= id ) id = n + 1;
        }
-       SketcherPoint *pt = new SketcherPoint(id, pty, x, y);
+       SketcherPoint *pt = new SketcherPoint(id, arc, x, y);
        int n = cv->points.size();
        if( idx < 0 || idx > n ) idx = n;
        cv->points.insert(pt, idx);
        return idx;
 }
 
-int Sketcher::new_point(int idx)
+int Sketcher::new_point(int idx, int arc)
 {
        int ci = config.cv_selected;
        if( ci < 0 || ci >= config.curves.size() )
@@ -205,7 +204,7 @@ int Sketcher::new_point(int idx)
        EDLSession *session = get_edlsession();
        coord x = !session ? 0.f : session->output_w / 2.f;
        coord y = !session ? 0.f : session->output_h / 2.f;
-       return new_point(cv, PTY_LINE, x, y, idx);
+       return new_point(cv, arc, x, y, idx);
 }
 
 double SketcherCurve::nearest_point(int &pi, coord x, coord y)
@@ -317,7 +316,7 @@ void SketcherConfig::interpolate(SketcherConfig &prev, SketcherConfig &next,
                                        if( y != nt->y )
                                                y = y * prev_scale + nt->y * next_scale;
                                }
-                               cv->points.append(new SketcherPoint(pt.id, pt.pty, x, y));
+                               cv->points.append(new SketcherPoint(pt.id, pt.arc, x, y));
                        }
                }
                else
@@ -624,7 +623,8 @@ SketcherPoint *FillRegion::next()
 {
        while( nxt < points.size() ) {
                SketcherPoint *pt = points[nxt];
-               if( pt->pty != PTY_FILL ) break;
+               if( pt->arc == ARC_OFF ) continue;
+               if( pt->arc != ARC_FILL ) break;
                start_at(pt->x, pt->y);
                ++nxt;
        }
@@ -650,11 +650,11 @@ void SketcherCurve::draw(VFrame *img)
                smooth_axy(ax,ay, bx,by, cx,cy, dx,dy);
                while( pt2 ) {
                        dx = pt2->x;  dy = pt2->y;
-                       switch( pt0->pty ) {
-                       case PTY_LINE:
+                       switch( pt0->arc ) {
+                       case ARC_LINE:
                                vpen->draw_line(bx, by, cx, cy);
                                break;
-                       case PTY_CURVE: {
+                       case ARC_CURVE: {
                                // s = ac thru b x bd thru c
                                intersects_at(sx,sy, ax,ay,cx,cy,bx,by, bx,by,dx,dy,cx,cy,fmx);
                                vpen->draw_smooth(bx,by, sx,sy, cx,cy);
@@ -664,15 +664,15 @@ void SketcherCurve::draw(VFrame *img)
                        bx = cx;  by = cy;  pt1 = pt2;
                        cx = dx;  cy = dy;  pt2 = fill.next();
                }
-               switch( pt1->pty ) {
-               case PTY_LINE:
+               switch( pt1->arc ) {
+               case ARC_LINE:
                        vpen->draw_line(bx, by, cx, cy);
                        if( fill.exists() ) {
                                dx = pnt0->x;  dy = pnt0->y;
                                vpen->draw_line(cx,cy, dx,dy);
                        }
                        break;
-               case PTY_CURVE: {
+               case ARC_CURVE: {
                        if( fill.exists() ) {
                                dx = pnt0->x;  dy = pnt0->y;
                                intersects_at(sx,sy, ax,ay,cx,cy,bx,by, bx,by,dx,dy,cx,cy,fmx);
@@ -736,8 +736,9 @@ int Sketcher::process_realtime(VFrame *input, VFrame *output)
 
        for( int ci=0, n=config.curves.size(); ci<n; ++ci ) {
                SketcherCurve *cv = config.curves[ci];
+               if( cv->pen == PEN_OFF ) continue;
                int m = cv->points.size();
-               if( !m || cv->pen == PTY_OFF ) continue;
+               if( !m ) continue;
                img->clear_frame();
                img->set_pixel_color(cv->color, (~cv->color>>24)&0xff);
                cv->draw(img);
@@ -768,8 +769,8 @@ void SketcherPoints::dump()
 {
        for( int i=0; i<size(); ++i ) {
                SketcherPoint *pt = get(i);
-               printf("  Pt %d, id=%d, pty=%s, x=%0.1f, y=%0.1f\n",
-                       i, pt->id, pt_type[pt->pty], pt->x, pt->y);
+               printf("  Pt %d, id=%d, arc=%s, x=%0.1f, y=%0.1f\n",
+                       i, pt->id, pt_type[pt->arc], pt->x, pt->y);
        }
 }
 void SketcherCurves::dump()
index a40b17b068163faf9936572a0f1d665efe472867..3df08768f0037a9c561fbf98c219daf129291506 100644 (file)
@@ -35,7 +35,7 @@ class Sketcher;
 
 enum { PT_ID, PT_TY, PT_X, PT_Y, PT_SZ };
 enum { CV_ID, CV_RAD, CV_PEN, CV_CLR, CV_ALP, CV_SZ };
-enum { PTY_OFF, PTY_LINE, PTY_CURVE, PTY_FILL, PTY_SZ };
+enum { ARC_OFF, ARC_LINE, ARC_CURVE, ARC_FILL, ARC_SZ };
 enum { PEN_OFF, PEN_SQUARE, PEN_PLUS, PEN_SLANT, PEN_XLANT, PEN_SZ };
 typedef float coord;
 
@@ -97,11 +97,11 @@ public:
 class SketcherPoint
 {
 public:
-       int id, pty;
+       int id, arc;
        coord x, y;
 
-       void init(int id, int pty, coord x, coord y);
-       SketcherPoint(int id, int pty, coord x, coord y);
+       void init(int id, int arc, coord x, coord y);
+       SketcherPoint(int id, int arc, coord x, coord y);
        SketcherPoint(int id=-1);
        SketcherPoint(SketcherPoint &pt);
        ~SketcherPoint();
@@ -109,7 +109,7 @@ public:
        void copy_from(SketcherPoint &that);
        void save_data(FileXML &output);
        void read_data(FileXML &input);
-       static const char *types[PTY_SZ];
+       static const char *types[ARC_SZ];
 };
 class SketcherPoints : public ArrayList<SketcherPoint *>
 {
@@ -181,8 +181,8 @@ public:
        void read_data(KeyFrame *keyframe);
        int new_curve(int pen, int width, int color);
        int new_curve();
-       int new_point(SketcherCurve *cv, int pty, coord x, coord y, int idx=-1);
-       int new_point(int idx=-1);
+       int new_point(SketcherCurve *cv, int arc, coord x, coord y, int idx=-1);
+       int new_point(int idx, int arc);
        int process_realtime(VFrame *input, VFrame *output);
        static void draw_point(VFrame *vfrm, SketcherPoint *pt, int color, int d);
        void draw_point(VFrame *vfrm, SketcherPoint *pt, int color);
index bd2eaa9f58934a76a60b22372f90ce5deae6e25b..08412fc8d1211929e6e6d834b5cfd432640a38a2 100644 (file)
@@ -39,7 +39,7 @@
 
 #define AltMask Mod1Mask
 
-#define COLOR_W 32
+#define COLOR_W 40
 #define COLOR_H 24
 
 const char *SketcherPoint::types[] = {
@@ -82,6 +82,7 @@ SketcherCurvePen::SketcherCurvePen(SketcherWindow *gui, int x, int y, int pen)
  : BC_PopupMenu(x,y,72,_(cv_pen[pen]))
 {
        this->gui = gui;
+       this->pen = pen;
 }
 void SketcherCurvePen::create_objects()
 {
@@ -91,7 +92,7 @@ void SketcherCurvePen::create_objects()
 }
 void SketcherCurvePen::update(int pen)
 {
-       set_text(_(cv_pen[pen]));
+       set_text(_(cv_pen[this->pen=pen]));
 }
 
 
@@ -345,6 +346,15 @@ int SketcherPointId::handle_event()
        return 1;
 }
 
+SketcherCurveWidth::SketcherCurveWidth(SketcherWindow *gui, int x, int y, int width)
+ : SketcherNum(gui, x, y, width, 0, 255)
+{
+       this->width = width;
+}
+SketcherCurveWidth::~SketcherCurveWidth()
+{
+}
+
 int SketcherCurveWidth::handle_event()
 {
        if( !SketcherNum::handle_event() ) return 0;
@@ -360,9 +370,14 @@ int SketcherCurveWidth::handle_event()
        return 1;
 }
 
+void SketcherCurveWidth::update(int width)
+{
+       SketcherNum::update(this->width=width);
+}
+
 
 SketcherWindow::SketcherWindow(Sketcher *plugin)
- : PluginClientWindow(plugin, 380, 580, 380, 580, 0)
+ : PluginClientWindow(plugin, 380, 620, 380, 620, 0)
 {
        this->plugin = plugin;
        this->title_pen = 0;  this->curve_pen = 0;
@@ -434,10 +449,12 @@ void SketcherWindow::create_objects()
        curve_up = new SketcherCurveUp(this, x1, y);
        add_subwindow(curve_up);        dy = bmax(dy,curve_up->get_h());
        x1 += curve_up->get_w() + 4*margin;
-       title_pen = new BC_Title(x1+30, y, _("Pen:"));
+       y1 = BC_Title::calculate_h(this, _("Pen:"));
+       title_pen = new BC_Title(x1+30, y+dy-y1, _("Pen:"));
        add_subwindow(title_pen);       dy = bmax(dy,title_pen->get_h());
-       int x2 = (get_w()+x1)/2;
-       title_color = new BC_Title(x2+10, y, _("Color:"));
+       int x2 = (get_w()+x1)/2 + 20;
+       y1 = BC_Title::calculate_h(this, _("Color:"));
+       title_color = new BC_Title(x2, y+dy-y1, _("Color:"));
        add_subwindow(title_color);     dy = bmax(dy,title_color->get_h());
        y += dy + margin;               dy = 0;
 
@@ -450,7 +467,7 @@ void SketcherWindow::create_objects()
        curve_pen = new SketcherCurvePen(this, x1, y, cv->pen);
        add_subwindow(curve_pen);       dy = bmax(dy,curve_pen->get_h());
        curve_pen->create_objects();
-       curve_color = new SketcherCurveColor(this, x2+20, y, COLOR_W, COLOR_H);
+       curve_color = new SketcherCurveColor(this, x2, y, COLOR_W, COLOR_H);
        add_subwindow(curve_color);     dy = bmax(dy,curve_color->get_h());
        curve_color->set_color(cv->color);
        curve_color->draw_face();
@@ -460,6 +477,8 @@ void SketcherWindow::create_objects()
        BC_Bar *bar;
        bar = new BC_Bar(x, y, get_w()-2*x);
        add_subwindow(bar);             dy = bmax(dy,bar->get_h());
+       bar = new BC_Bar(x, y+=dy, get_w()-2*x);
+       add_subwindow(bar);             dy = bmax(dy,bar->get_h());
        y += dy + 2*margin;
 
        int pi = plugin->config.pt_selected;
@@ -476,8 +495,8 @@ void SketcherWindow::create_objects()
        drag = new SketcherDrag(this, x1, y);
        add_subwindow(drag);            dy = bmax(dy,drag->get_h());
        x1 += drag->get_w() + 2*margin;
-       int pty = pt ? pt->pty : PTY_LINE;
-       point_type = new SketcherPointType(this, x1, y, pty);
+       int arc = pt ? pt->arc : ARC_LINE;
+       point_type = new SketcherPointType(this, x1, y, arc);
        add_subwindow(point_type);      dy = bmax(dy,point_type->get_h());
        point_type->create_objects();
        y += dy + margin;  dy = 0;
@@ -502,8 +521,9 @@ void SketcherWindow::create_objects()
        x1 += title_x->get_w() + margin;
        point_x = new SketcherPointX(this, x1, y, !pt ? 0.f : pt->x);
        point_x->create_objects();      dy = bmax(dy, point_x->get_h());
-       x2 = x1 + point_x->get_w() + 2*margin;
-       title_id = new BC_Title(x2, y, _("ID:"));
+       x2 = x1 + point_x->get_w() + 2*margin + 10;
+       y1 = BC_Title::calculate_h(this, _("ID:"));
+       title_id = new BC_Title(x2+16, y+dy-y1, _("ID:"));
        add_subwindow(title_id);        dy = bmax(dy, title_id->get_h());
        y += dy + margin;  dy = 0;
 
@@ -518,32 +538,40 @@ void SketcherWindow::create_objects()
        x1 += title_y->get_w() + margin;
        point_y = new SketcherPointY(this, x1, y, !pt ? 0.f : pt->y);
        point_y->create_objects();      dy = bmax(dy, point_y->get_h());
-       point_id = new SketcherPointId(this, x2+10, y, !pt ? 0 : pt->id);
+       point_id = new SketcherPointId(this, x2, y, !pt ? 0 : pt->id);
        point_id->create_objects();     dy = bmax(dy, point_id->get_h());
-       y += dy + margin + 5;
+       y += dy + margin + 5;           dy = 0;
        point_list->update(pi);
 
+       bar = new BC_Bar(x, y, get_w()-2*x);
+       add_subwindow(bar);             dy = bmax(dy,bar->get_h());
+       y += dy + 2*margin;
+
        add_subwindow(notes0 = new BC_Title(x, y,
                 _("\n"
                   "Shift=\n"
                   "None=\n"
                   "Ctrl=\n"
                   "Alt=\n"
-                  "DEL=\n")));
-       add_subwindow(notes1 = new BC_Title(x+80, y,
+                  "Ctrl+Shift=")));    dy = bmax(dy, notes0->get_h());
+       add_subwindow(notes1 = new BC_Title(x+100, y,
                 _("     LMB\n"
                   "new line point\n"
                   "select point\n"
                   "drag point\n"
                   "drag all curves\n"
-                  "deletes point\n")));
-       add_subwindow(notes2 = new BC_Title(x+200, y,
+                  "new fill point"))); dy = bmax(dy, notes1->get_h());
+       add_subwindow(notes2 = new BC_Title(x+220, y,
                 _("      RMB\n"
                   "new arc point\n"
                   "select curve\n"
                   "drag curve\n"
                   "new curve\n"
-                  "deletes curve\n")));
+                  "new off point"))); dy = bmax(dy, notes2->get_h());
+       y += dy + margin + 10;
+
+       add_subwindow(notes3 = new BC_Title(x, y,
+                  "Key DEL= delete point, +Shift= delete curve\n"));
        show_window(1);
 }
 
@@ -558,12 +586,13 @@ int SketcherWindow::grab_event(XEvent *event)
 {
        int ret = do_grab_event(event);
        if( !grab_event_count() ) {
-               if( pending_motion && grab_cursor_motion(&motion_event) )
+               if( grab_cursor_motion() )
                        pending_config = 1;
-               if( pending_config )
+               if( pending_config ) {
+                       last_x = output_x;  last_y = output_y;
                        send_configure_change();
+               }
        }
-       last_x = output_x;  last_y = output_y;
        return ret;
 }
 
@@ -629,6 +658,14 @@ int SketcherWindow::do_grab_event(XEvent *event)
        output_y = (cursor_y - projector_y) / projector_z + track_h / 2;
        state = event->xmotion.state;
 
+       if( event->type == MotionNotify ) {
+               memcpy(&motion_event, event, sizeof(motion_event));
+               pending_motion = 1;
+               return 1;
+       }
+       if( grab_cursor_motion() )
+               pending_config = 1;
+
        switch( event->type ) {
        case ButtonPress:
                pending_config = grab_button_press(event);
@@ -636,10 +673,6 @@ int SketcherWindow::do_grab_event(XEvent *event)
        case ButtonRelease:
                new_points = 0;
                break;
-       case MotionNotify:
-               memcpy(&motion_event, event, sizeof(motion_event));
-               pending_motion = 1;
-               break;
        }
 
        return 1;
@@ -661,7 +694,9 @@ int SketcherWindow::grab_button_press(XEvent *event)
        case LEFT_BUTTON: {
                if( (state & ShiftMask) ) { // create new point/string
                        ++new_points;
-                       pi = plugin->new_point(cv, PTY_LINE, output_x, output_y, pi+1);
+                       pi = plugin->new_point(cv,
+                               !(state & ControlMask) ? ARC_LINE : ARC_FILL,
+                               output_x, output_y, pi+1);
                        point_list->update(pi);
                        break;
                }
@@ -681,13 +716,14 @@ int SketcherWindow::grab_button_press(XEvent *event)
        case RIGHT_BUTTON: {
                if( (state & ShiftMask) ) { // create new curve point
                        ++new_points;
-                       pi = plugin->new_point(cv, PTY_CURVE,
-                                       output_x, output_y, pi+1);
+                       pi = plugin->new_point(cv,
+                               !(state & ControlMask) ? ARC_CURVE : ARC_OFF,
+                               output_x, output_y, pi+1);
                        point_list->update(pi);
                        break;
                }
                if( (state & AltMask) ) { // create new curve
-                       ci = plugin->new_curve(cv->pen, cv->width, cv->color);
+                       ci = plugin->new_curve(cv->pen, cv->width, curve_color->color);
                        curve_list->update(ci);
                        point_list->update(-1);
                        break;
@@ -712,8 +748,10 @@ int SketcherWindow::grab_button_press(XEvent *event)
        return 1;
 }
 
-int SketcherWindow::grab_cursor_motion(XEvent *event)
+int SketcherWindow::grab_cursor_motion()
 {
+       if( !pending_motion )
+               return 0;
        pending_motion = 0;
        SketcherConfig &config = plugin->config;
        int ci = config.cv_selected;
@@ -732,8 +770,8 @@ int SketcherWindow::grab_cursor_motion(XEvent *event)
                                if( dist < get_w()*0.1 ) return 0; // tolerance w/10
                        }
                        ++new_points;
-                       int pty = (state & Button1Mask) ? PTY_LINE : PTY_CURVE;
-                       pi = plugin->new_point(cv, pty, output_x, output_y, pi+1);
+                       int arc = (state & Button1Mask) ? ARC_LINE : ARC_CURVE;
+                       pi = plugin->new_point(cv, arc, output_x, output_y, pi+1);
                        point_list->update(pi);
                }
                return 1;
@@ -811,11 +849,6 @@ int SketcherWindow::keypress_event()
        return 0;
 }
 
-void SketcherWindow::done_event(int result)
-{
-       ungrab(client->server->mwindow->cwindow->gui);
-}
-
 void SketcherWindow::start_color_thread(SketcherCurveColor *color_button)
 {
        unlock_window();
@@ -939,7 +972,9 @@ SketcherNewCurve::~SketcherNewCurve()
 }
 int SketcherNewCurve::handle_event()
 {
-       int pen = PTY_LINE, width = 1, color = CV_COLOR;
+       int pen = gui->curve_pen->pen;
+       int color = gui->curve_color->color;
+       int width = gui->curve_width->width;
        int ci = plugin->config.cv_selected;
        if( ci >= 0 && ci < plugin->config.curves.size() ) {
                SketcherCurve *cv = plugin->config.curves[ci];
@@ -1027,15 +1062,15 @@ int SketcherCurveDn::handle_event()
 }
 
 
-SketcherPointTypeItem::SketcherPointTypeItem(int pty)
- : BC_MenuItem(_(pt_type[pty]))
+SketcherPointTypeItem::SketcherPointTypeItem(int arc)
+ : BC_MenuItem(_(pt_type[arc]))
 {
-       this->pty = pty;
+       this->arc = arc;
 }
 int SketcherPointTypeItem::handle_event()
 {
        SketcherPointType *popup = (SketcherPointType*)get_popup_menu();
-       popup->update(pty);
+       popup->update(arc);
        SketcherWindow *gui = popup->gui;
        SketcherConfig &config = gui->plugin->config;
        SketcherCurves &curves = config.curves;
@@ -1054,8 +1089,8 @@ int SketcherPointTypeItem::handle_event()
                int k = selected[i];
                if( k < 0 || k >= points.size() ) continue;
                SketcherPoint *pt = cv->points[k];
-               pt->pty = pty;
-               gui->point_list->set_point(k, PT_TY, _(pt_type[pty]));
+               pt->arc = arc;
+               gui->point_list->set_point(k, PT_TY, _(pt_type[arc]));
        }
 
        gui->point_list->update_list(pi);
@@ -1063,19 +1098,20 @@ int SketcherPointTypeItem::handle_event()
        return 1;
 }
 
-SketcherPointType::SketcherPointType(SketcherWindow *gui, int x, int y, int pty)
- : BC_PopupMenu(x,y,64,_(pt_type[pty]))
+SketcherPointType::SketcherPointType(SketcherWindow *gui, int x, int y, int arc)
+ : BC_PopupMenu(x,y,64,_(pt_type[arc]))
 {
        this->gui = gui;
+       this->type = arc;
 }
 void SketcherPointType::create_objects()
 {
-       for( int pty=0; pty<PT_SZ; ++pty )
-               add_item(new SketcherPointTypeItem(pty));
+       for( int arc=0; arc<PT_SZ; ++arc )
+               add_item(new SketcherPointTypeItem(arc));
 }
-void SketcherPointType::update(int pty)
+void SketcherPointType::update(int arc)
 {
-       set_text(_(pt_type[pty]));
+       set_text(_(pt_type[this->type=arc]));
 }
 
 
@@ -1155,7 +1191,7 @@ void SketcherPointList::set_selected(int k)
                SketcherCurve *cv = plugin->config.curves[ci];
                pt = k >= 0 && k < cv->points.size() ? cv->points[pi=k] : 0;
        }
-       gui->point_type->update(pt ? pt->pty : PTY_OFF);
+       gui->point_type->update(pt ? pt->arc : ARC_OFF);
        gui->point_x->update(pt ? pt->x : 0.f);
        gui->point_y->update(pt ? pt->y : 0.f);
        gui->point_id->update(pt ? pt->id : 0);
@@ -1180,7 +1216,7 @@ void SketcherPointList::update(int k)
                for( int i=0; i<sz; ++i ) {
                        SketcherPoint *pt = points[i];
                        char itxt[BCSTRLEN];  sprintf(itxt,"%d", pt->id);
-                       char ttxt[BCSTRLEN];  sprintf(ttxt,"%s", _(pt_type[pt->pty]));
+                       char ttxt[BCSTRLEN];  sprintf(ttxt,"%s", _(pt_type[pt->arc]));
                        char xtxt[BCSTRLEN];  sprintf(xtxt,"%0.1f", pt->x);
                        char ytxt[BCSTRLEN];  sprintf(ytxt,"%0.1f", pt->y);
                        add_point(itxt, ttxt, xtxt, ytxt);
@@ -1319,7 +1355,8 @@ SketcherNewPoint::~SketcherNewPoint()
 int SketcherNewPoint::handle_event()
 {
        int pi = plugin->config.pt_selected;
-       int k = plugin->new_point(pi+1);
+       int arc = gui->point_type->type;
+       int k = plugin->new_point(pi+1, arc);
        gui->point_list->update(k);
        gui->send_configure_change();
        return 1;
index d15cf9c1776c31c5eb85244f9e1c8a488466909f..55dc4f4ef38169a5ee689a7daf31597c3f891511 100644 (file)
@@ -95,6 +95,7 @@ public:
        void update(int pen);
 
        SketcherWindow *gui;
+       int pen;
 };
 
 class SketcherCurveColor : public BC_Button
@@ -192,11 +193,12 @@ public:
 class SketcherCurveWidth : public SketcherNum
 {
 public:
-       SketcherCurveWidth(SketcherWindow *gui, int x, int y, float output)
-        : SketcherNum(gui, x, y, output, 0, 255) {}
-       ~SketcherCurveWidth() {}
+       SketcherCurveWidth(SketcherWindow *gui, int x, int y, int width);
+       ~SketcherCurveWidth();
 
        int handle_event();
+       void update(int width);
+       int width;
 };
 
 class SketcherCurveList : public BC_ListBox
@@ -266,19 +268,20 @@ public:
 class SketcherPointTypeItem : public BC_MenuItem
 {
 public:
-       SketcherPointTypeItem(int pty);
+       SketcherPointTypeItem(int arc);
        int handle_event();
-       int pty;
+       int arc;
 };
 
 class SketcherPointType : public BC_PopupMenu
 {
 public:
-       SketcherPointType(SketcherWindow *gui, int x, int y, int pty);
+       SketcherPointType(SketcherWindow *gui, int x, int y, int arc);
        void create_objects();
-       void update(int pty);
+       void update(int arc);
 
        SketcherWindow *gui;
+       int type;
 };
 
 
@@ -389,10 +392,9 @@ public:
        void update_gui();
        void start_color_thread(SketcherCurveColor *curve_color);
        int grab_event(XEvent *event);
-       int grab_button_press(XEvent *event);
-       int grab_cursor_motion(XEvent *event);
        int do_grab_event(XEvent *event);
-       void done_event(int result);
+       int grab_button_press(XEvent *event);
+       int grab_cursor_motion();
        void send_configure_change();
        int keypress_event();
 
@@ -433,7 +435,7 @@ public:
        int pending_motion, pending_config;
        XEvent motion_event;
        float last_x, last_y;
-       BC_Title *notes0, *notes1, *notes2;
+       BC_Title *notes0, *notes1, *notes2, *notes3;
 };
 #endif