From 3fd098981077e40841c013a8ac305036d08a215b Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 27 Mar 2012 15:40:37 -0700 Subject: added cursors to the pen tool UI AND change cursor when the user hovers over an anchor point or handles of thte selected anchor --- images/cursors/penAdd.png | Bin 3043 -> 0 bytes images/cursors/penCursors/Pen_.png | Bin 0 -> 182 bytes images/cursors/penCursors/Pen_anchorSelect.png | Bin 0 -> 268 bytes images/cursors/penCursors/Pen_append.png | Bin 0 -> 210 bytes images/cursors/penCursors/Pen_closePath.png | Bin 0 -> 211 bytes images/cursors/penCursors/Pen_minus.png | Bin 0 -> 204 bytes images/cursors/penCursors/Pen_newPath.png | Bin 0 -> 215 bytes images/cursors/penCursors/Pen_plus.png | Bin 0 -> 211 bytes images/cursors/penCursors/penAdd_OLD.png | Bin 0 -> 3043 bytes js/lib/geom/sub-path.js | 51 ++++++++++++++++--------- js/tools/PenTool.js | 11 +++--- 11 files changed, 38 insertions(+), 24 deletions(-) delete mode 100644 images/cursors/penAdd.png create mode 100644 images/cursors/penCursors/Pen_.png create mode 100644 images/cursors/penCursors/Pen_anchorSelect.png create mode 100644 images/cursors/penCursors/Pen_append.png create mode 100644 images/cursors/penCursors/Pen_closePath.png create mode 100644 images/cursors/penCursors/Pen_minus.png create mode 100644 images/cursors/penCursors/Pen_newPath.png create mode 100644 images/cursors/penCursors/Pen_plus.png create mode 100644 images/cursors/penCursors/penAdd_OLD.png diff --git a/images/cursors/penAdd.png b/images/cursors/penAdd.png deleted file mode 100644 index c306cc85..00000000 Binary files a/images/cursors/penAdd.png and /dev/null differ diff --git a/images/cursors/penCursors/Pen_.png b/images/cursors/penCursors/Pen_.png new file mode 100644 index 00000000..fea41116 Binary files /dev/null and b/images/cursors/penCursors/Pen_.png differ diff --git a/images/cursors/penCursors/Pen_anchorSelect.png b/images/cursors/penCursors/Pen_anchorSelect.png new file mode 100644 index 00000000..c05c2312 Binary files /dev/null and b/images/cursors/penCursors/Pen_anchorSelect.png differ diff --git a/images/cursors/penCursors/Pen_append.png b/images/cursors/penCursors/Pen_append.png new file mode 100644 index 00000000..1dbb959f Binary files /dev/null and b/images/cursors/penCursors/Pen_append.png differ diff --git a/images/cursors/penCursors/Pen_closePath.png b/images/cursors/penCursors/Pen_closePath.png new file mode 100644 index 00000000..8447ddbc Binary files /dev/null and b/images/cursors/penCursors/Pen_closePath.png differ diff --git a/images/cursors/penCursors/Pen_minus.png b/images/cursors/penCursors/Pen_minus.png new file mode 100644 index 00000000..41fe47d8 Binary files /dev/null and b/images/cursors/penCursors/Pen_minus.png differ diff --git a/images/cursors/penCursors/Pen_newPath.png b/images/cursors/penCursors/Pen_newPath.png new file mode 100644 index 00000000..547731f3 Binary files /dev/null and b/images/cursors/penCursors/Pen_newPath.png differ diff --git a/images/cursors/penCursors/Pen_plus.png b/images/cursors/penCursors/Pen_plus.png new file mode 100644 index 00000000..192c71fe Binary files /dev/null and b/images/cursors/penCursors/Pen_plus.png differ diff --git a/images/cursors/penCursors/penAdd_OLD.png b/images/cursors/penCursors/penAdd_OLD.png new file mode 100644 index 00000000..c306cc85 Binary files /dev/null and b/images/cursors/penCursors/penAdd_OLD.png differ diff --git a/js/lib/geom/sub-path.js b/js/lib/geom/sub-path.js index 7046673e..9bd9ad9a 100755 --- a/js/lib/geom/sub-path.js +++ b/js/lib/geom/sub-path.js @@ -567,37 +567,50 @@ GLSubpath.prototype._isWithinBoundingBox = function(point, ctrlPts, radius) { return true; }; +GLSubpath.prototype._checkAnchorIntersection = function(pickX, pickY, pickZ, radSq, anchorIndex, minDistance) { + var distSq = this._Anchors[anchorIndex].getDistanceSq(pickX, pickY, pickZ); + //check the anchor point + if (distSq < radSq && distSq=0 && this._selectedAnchorIndexx || this._BBoxMin[1]>y || this._BBoxMin[2]>z){ return false; } diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 779b7f16..39a1b15a 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -348,16 +348,17 @@ exports.PenTool = Montage.create(ShapeTool, { var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY); if (currMousePos && this._selectedSubpath ){ - var selAnchor = this._selectedSubpath.pickAnchor(currMousePos[0], currMousePos[1], currMousePos[2], this._PICK_POINT_RADIUS); - if (selAnchor >=0) { - this._hoveredAnchorIndex = selAnchor; + var selAnchorRetCode = this._selectedSubpath.pickAnchor(currMousePos[0], currMousePos[1], currMousePos[2], this._PICK_POINT_RADIUS); + if (selAnchorRetCode[0] >=0) { + this._hoveredAnchorIndex = selAnchorRetCode[0]; + var cursor = "url('images/cursors/penCursors/Pen_anchorSelect.png') 0 0, default"; + this.application.ninja.stage.drawingCanvas.style.cursor = cursor; } else { //detect if the current mouse position will hit the path var pathHitTestData = this._selectedSubpath.pathHitTest(currMousePos[0], currMousePos[1], currMousePos[2], this._PICK_POINT_RADIUS); if (pathHitTestData[0]!==-1){ //change the cursor - var cursor = "url('images/cursors/penAdd.png') 10 10,default"; - this.application.ninja.stage.drawingCanvas.style.cursor = cursor; + } } } -- cgit v1.2.3