Re-added ability to adjust cabinet width in detail view with scale
Re-added ability to adjust cabinet width in detail view with scale
locking.

--- a/source/lib/scripts/CabinetEditor/CabinetEditor.js
+++ b/source/lib/scripts/CabinetEditor/CabinetEditor.js
@@ -564,7 +564,8 @@
 	 */

 	CabinetEditor.prototype.renderDetailView = function(){

 

-		var cabinet_info = null;

+		var cabinet_info = null,

+			scaleFactor;

 

 		// Clear Canvas

 		this.dv_buffer_ctx.clearRect(0, 0, this.dv_canvas.width, this.dv_canvas.height);

@@ -581,8 +582,19 @@
 

 		} else {

 

+			scaleFactor = cabinet_info.calculateDetailViewScaleFactor(this.dv_buffer_layer);

+

+			if(this.active_pick != null && this.detailViewScaleFactor)

+				scaleFactor = this.detailViewScaleFactor;

+			else

+				this.detailViewScaleFactor = scaleFactor;

+

 			// Draw Detail View

-			cabinet_info.renderDetailView(this.dv_buffer_ctx, this.dv_buffer_layer);

+			cabinet_info.renderDetailView(

+				this.dv_buffer_ctx,

+				this.dv_buffer_layer,

+				scaleFactor

+			);

 			if(this.active_pick != null) this.active_pick.renderDetailView(this.dv_buffer_ctx, this);

 

 		}


--- /dev/null
+++ b/source/lib/scripts/CabinetEditor/Picks/Item/Detail/DetailScalePick.js
@@ -1,1 +1,77 @@
+/**
+ * @file Pick to scale cabinets
+ * @author Michael Marques <dryerzinia@gmail.com>
+ * @module pick/DragPick/DetailScalePick
+ */
 
+define(
+	[
+	 	'CabinetEditor/Picks/Item/Top/ScalePick',
+	 	'CabinetEditor/Defines/Cardinal',
+	 	'CabinetEditor/Defines/Cursors',
+	 	'Util/Class'
+	 ],
+	 function(
+		ScalePick,
+		Cardinal,
+		cursors,
+		Class
+	){
+
+	/**
+	 * Class for handling scaling related actions
+	 * @constructor
+	 * @augments DragPick
+	 * @param {Number} init_x Pick initial X Coordinate
+	 * @param {Number} init_y Pick initial Y Coordinate
+	 * @param {Number} direction Cardinal direction of pick
+	 * @param {SchematicObject} object Object modified by pick
+	 * @property {Number} obj_w Object Width in Inches
+	 * @property {Number} obj_h Object Height in Inches
+	 * @property {Number} direction Cardinal direction of pick
+	 * @property {Line} side Line that is the side of object pick is on
+	 */
+	function DetailScalePick(init_x, init_y, direction, object){
+
+		ScalePick.call(this, init_x, init_y, direction, object);
+
+		this.objInitX = object.x;
+
+	};
+
+	Class.extend(ScalePick, DetailScalePick);
+
+	DetailScalePick.prototype.pickAction = function(x, y, editor){
+
+		var shift_angle = 0;
+
+		if(this.direction == Cardinal.W)
+			x -= this.object.x - this.objInitX;
+
+		if(this.direction == Cardinal.E)	shift_angle = 0;
+		else if(this.direction == Cardinal.W)	shift_angle = Math.PI;
+
+		var scaling_mag = editor.snapDistance(x-this.init_x);
+		if(this.direction == Cardinal.W)
+			scaling_mag *= -1;
+
+		if(this.obj_w - scaling_mag >= editor.schematic.distance_snap) this.object.w = this.obj_w - scaling_mag;
+		else {
+			this.object.w = editor.schematic.distance_snap;
+			scaling_mag = this.obj_w-editor.schematic.distance_snap;
+		}
+
+		this.object.x = this.obj_x + scaling_mag*Math.cos(this.object.angle+shift_angle)/2;
+
+	};
+
+	ScalePick.prototype.updateCursor = function(clicking, editor){
+
+		editor.dv_canvas.style.cursor = 'ew-resize';
+
+	};
+
+	return DetailScalePick;
+
+});
+

--- a/source/lib/scripts/CabinetEditor/Picks/Item/Top/ScalePick.js
+++ b/source/lib/scripts/CabinetEditor/Picks/Item/Top/ScalePick.js
@@ -34,9 +34,11 @@
 	function ScalePick(init_x, init_y, direction, object){
 
 		DragPick.call(this, init_x, init_y, object);
-		this.obj_w = object.w;
-		this.obj_h = object.h;
-		this.side = object.getLine(direction);
+		if(object){
+			this.obj_w = object.w;
+			this.obj_h = object.h;
+			this.side = object.getLine(direction);
+		}
 		this.direction = direction;
 
 	};
@@ -64,7 +66,7 @@
 			if(this.obj_w - scaling_mag >= editor.schematic.distance_snap) this.object.w = this.obj_w - scaling_mag;
 			else {
 				this.object.w = editor.schematic.distance_snap;
-				scaling_max = this.obj_w-editor.schematic.distance_snap;
+				scaling_mag = this.obj_w-editor.schematic.distance_snap;
 			}
 		}
 
@@ -75,7 +77,7 @@
 
 	ScalePick.prototype.updateCursor = function(clicking, editor){
 
-		editor.updateCursor(this.object.angle, this.direction, cursors.scale_cursors);
+		editor.updateCursor(0, this.direction, cursors.scale_cursors);
 
 	};
 

--- a/source/lib/scripts/CabinetEditor/Schematic/Cabinet/Cabinet.js
+++ b/source/lib/scripts/CabinetEditor/Schematic/Cabinet/Cabinet.js
@@ -283,26 +283,33 @@
 
 	};
 
-	Cabinet.prototype.renderDetailView = function(ctx, cvs){
-
-		Cabinet.renderDetailView_start(ctx, cvs, this.getFrameWidth(), this.z, this.d, this.getLayer(), this.faces);
+	Cabinet.prototype.renderDetailView = function(ctx, cvs, scaleFactor){
+
+		Cabinet.renderDetailView_start(ctx, cvs, this.getFrameWidth(), this.z, this.d, this.getLayer(), this.faces, scaleFactor);
 
 		ctx.restore();
 		
 	};
 
-	Cabinet.renderDetailView_start = function(ctx, cvs, frame_width, z, d, layer, faces){
+	Cabinet.prototype.calculateDetailViewScaleFactor = function(cvs){
+
+		return Helper.calculateDetailViewScaleFactor(cvs, this.getFrameWidth(), this.d);
+
+	}
+
+	Cabinet.renderDetailView_start = function(ctx, cvs, frame_width, z, d, layer, faces, scaleFactor){
 
 		ctx.save();
 
-		var scale_factor, x, y,
+		var x, y,
 		txt, txt_size;
 
-		scale_factor = Helper.calculateDetailViewScaleFactor(cvs, frame_width, d);
-		x = cvs.width/2/scale_factor;
-		y = cvs.height/2/scale_factor;
-
-		ctx.scale(scale_factor, scale_factor);
+		if(scaleFactor === undefined)
+			scaleFactor = Helper.calculateDetailViewScaleFactor(cvs, frame_width, d);
+		x = cvs.width/2/scaleFactor;
+		y = cvs.height/2/scaleFactor;
+
+		ctx.scale(scaleFactor, scaleFactor);
 		ctx.translate(x, y);
 
 		ctx.lineWidth = 0.5;
@@ -315,7 +322,7 @@
 		 * TODO not force front face
 		 */
 		if(faces.front_face != null)
-			faces.front_face.render_detail_view(ctx, d, frame_width, scale_factor);
+			faces.front_face.render_detail_view(ctx, d, frame_width, scaleFactor);
 
 		//if(cab.face != undefined) Cabinet.render_face(cab, ctx, true, s);
 
@@ -325,14 +332,14 @@
 		if(layer == Layer.UPPER){
 			txt = '▼'+Helper.nearestMultiple(z, 0.0625)+'"▼';	// TODO: global variable for number precision
 			txt_size = ctx.measureText(txt).width;
-			ctx.fillText(txt, -txt_size/2, d/2+16.0/scale_factor+(5/scale_factor));
+			ctx.fillText(txt, -txt_size/2, d/2+16.0/scaleFactor+(5/scaleFactor));
 		}
 
 	};
 
 	Cabinet.prototype.getPickDetailView = function(x, y, selected_face){
 
-		return this.faces[selected_face].getPicks_detail_view(x, y, this);
+		return this.faces[selected_face].getPicksDetailView(x, y, this);
 
 	};
 

--- a/source/lib/scripts/CabinetEditor/Schematic/Cabinet/Face/FrameFace.js
+++ b/source/lib/scripts/CabinetEditor/Schematic/Cabinet/Face/FrameFace.js
@@ -18,9 +18,11 @@
 	 	'CabinetEditor/Schematic/Cabinet/Face/DoubleDoorFront',
 	 	'CabinetEditor/Schematic/Cabinet/Face/DoubleDrawerFront',
 	 	'CabinetEditor/Schematic/Cabinet/Face/ApplianceFront',
+
 	 	'CabinetEditor/Picks/Item/Detail/RailLengthPick',
 	 	'CabinetEditor/Picks/Item/Detail/FaceDragPick',
 	 	'CabinetEditor/Picks/Item/Detail/StyleAdjustPick',
+	 	'CabinetEditor/Picks/Item/Detail/DetailScalePick',
 
 	 	'Util/Class'
 	],
@@ -40,6 +42,7 @@
 		RailLengthPick,
 		FaceDragPick,
 		StyleAdjustPick,
+		DetailScalePick,
 
 		Class
 	){
@@ -177,7 +180,7 @@
 
 	};
 
-	FrameFace.prototype.getPicks_detail_view = function(x, y, cabinet){
+	FrameFace.prototype.getPicksDetailView = function(x, y, cabinet){
 
 		var cur_h, i,
 		rrlen = 1.5;// TODO: GLOBAL variable for distance of 1.5 from rail for rail length pick
@@ -193,34 +196,47 @@
 					if(i == 0 || i == this.fronts.length-1)
 						return null; // Ignore first and last items
 
-					else if(this.fronts[i] instanceof Rail && i > 1 && i < this.fronts.length-1)
+					if(this.fronts[i] instanceof Rail && i > 1 && i < this.fronts.length-1)
 						return new FaceDragPick(y, 1, i, cabinet, this);
 
-					else if(y < cur_h+rrlen)
+					if(y < cur_h+rrlen)
 						return new RailLengthPick(y, i, Cardinal.N, cabinet, this);
 
-					else if(y > cur_h+this.fronts[i].getHeight()-rrlen)
+					if(y > cur_h+this.fronts[i].getHeight()-rrlen)
 						return new RailLengthPick(y, i, Cardinal.S, cabinet, this);
 
-					else if(i > 1 && i < this.fronts.length-2)
+					if(i > 1 && i < this.fronts.length-2)
 						return new FaceDragPick(y, 2, i, cabinet, this);
 				}
 				cur_h += this.fronts[i].getHeight();
 			}
 		}
 		// Left Style adjust
-		else if(x > -rrlen
-				&& x < this.left_style_width+rrlen
+		if(x > 0
+				&& x < this.left_style_width + rrlen
 				&& y > 0
 				&& y < cabinet.d)
 			return new StyleAdjustPick(x, 'l', cabinet, this);
 
 		// Right Style adjust
-		else if(x > cabinet.getFrameWidth() - this.right_style_width - rrlen
+		if(x > cabinet.getFrameWidth() - this.right_style_width - rrlen
+				&& x < cabinet.getFrameWidth()
+				&& y > 0
+				&& y < cabinet.d)
+			return new StyleAdjustPick(x, 'r', cabinet, this);
+
+		// Increase Width Left adjust
+		if(x > -rrlen
+				&& x < 0
+				&& y > 0
+				&& y < cabinet.d)
+			return new DetailScalePick(x, y, Cardinal.E, cabinet);
+		// Increase Width Right adjust
+		if(x > cabinet.getFrameWidth()
 				&& x < cabinet.getFrameWidth() + rrlen
 				&& y > 0
 				&& y < cabinet.d)
-			return new StyleAdjustPick(x, 'r', cabinet, this);
+			return new DetailScalePick(x, y, Cardinal.W, cabinet);
 
 		return null;