P5-1417: Dragbar and rulers should work with inches

This commit is contained in:
Ruslan Getmansky
2017-06-21 15:08:20 +03:00
parent 2b4bb8ba37
commit e79245e14e
4 changed files with 11 additions and 8 deletions
+3 -3
View File
@@ -74,7 +74,7 @@ var DragHandle = function (handler) {
this.__handles.y.set({left: handler.getTracks().y.left}).setCoords();
this.__handles.x.set({top: handler.getTracks().x.top}).setCoords();
return this;
}
};
this.init = function () {
var viewportData = this.getCanvas().getViewport().getData();
@@ -86,8 +86,8 @@ var DragHandle = function (handler) {
}
this.__handles = {
x: getRect(viewportData.dim.width + ' cm', viewportData.width),
y: getRect(viewportData.dim.height + ' cm', viewportData.height)
x: getRect(viewportData.dim.width + ' ' + viewportData.dim.units, viewportData.width),
y: getRect(viewportData.dim.height + ' ' + viewportData.dim.units, viewportData.height)
};
this.__handles.x.addTo(this.getCanvas()).centerH().set({ top: tracks.x.top }).setCoords();
+3 -2
View File
@@ -76,12 +76,13 @@ function ImageEditor(canvasId, args) {
* Crops image to desired dimensions
* @param {int} width [description]
* @param {int} height [description]
* @param {string} units cm|inch
* @return {ImageEditor}
*/
this.crop = function (width, height) {
this.crop = function (width, height, units) {
_canvas.getImage().__cropped = false;
_canvas.getImageData().removeCropData();
_canvas.getViewport().set(width, height);
_canvas.getViewport().set(width, height, units);
return this;
};
+1 -1
View File
@@ -24,7 +24,7 @@ function RulerHandler(viewport) {
dim = viewport.getData().dim.height - dim;
}
this.setText(Math.round(dim * 100) / 100 + ' cm');
this.setText(Math.round(dim * 100) / 100 + ' ' + viewport.getData().dim.units);
}
};
+4 -2
View File
@@ -119,7 +119,7 @@ function Viewport(canvas) {
*/
this.reset = function () {
if (_data) {
return this.set(_data.dim.width, _data.dim.height);
return this.set(_data.dim.width, _data.dim.height, _data.dim.units);
}
return this;
};
@@ -127,10 +127,12 @@ function Viewport(canvas) {
/**
* @param {Number} width
* @param {Number} height
* @param {string} units
* @return {Viewport}
*/
this.set = function (width, height) {
this.set = function (width, height, units) {
_data = util.calcCrop(canvas.getImage(), width, height);
_data.dim.units = units;
apply();
this.getGores().reset();
this.getRulers().reset();