|
@ -22,33 +22,9 @@ class Box extends NodeBase { |
|
|
this.left = x - this.width / 2; |
|
|
this.left = x - this.width / 2; |
|
|
this.top = y - this.height / 2; |
|
|
this.top = y - this.height / 2; |
|
|
|
|
|
|
|
|
ctx.strokeStyle = values.borderColor; |
|
|
|
|
|
ctx.lineWidth = values.borderWidth; |
|
|
|
|
|
ctx.lineWidth /= this.body.view.scale; |
|
|
|
|
|
ctx.lineWidth = Math.min(this.width, ctx.lineWidth); |
|
|
|
|
|
|
|
|
|
|
|
ctx.fillStyle = values.color; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.initContextForDraw(ctx, values); |
|
|
ctx.roundRect(this.left, this.top, this.width, this.height, values.borderRadius); |
|
|
ctx.roundRect(this.left, this.top, this.width, this.height, values.borderRadius); |
|
|
|
|
|
|
|
|
// draw shadow if enabled
|
|
|
|
|
|
this.enableShadow(ctx, values); |
|
|
|
|
|
// draw the background
|
|
|
|
|
|
ctx.fill(); |
|
|
|
|
|
// disable shadows for other elements.
|
|
|
|
|
|
this.disableShadow(ctx, values); |
|
|
|
|
|
|
|
|
|
|
|
//draw dashed border if enabled, save and restore is required for firefox not to crash on unix.
|
|
|
|
|
|
ctx.save(); |
|
|
|
|
|
// if borders are zero width, they will be drawn with width 1 by default. This prevents that
|
|
|
|
|
|
if (values.borderWidth > 0) { |
|
|
|
|
|
this.enableBorderDashes(ctx, values); |
|
|
|
|
|
//draw the border
|
|
|
|
|
|
ctx.stroke(); |
|
|
|
|
|
//disable dashed border for other elements
|
|
|
|
|
|
this.disableBorderDashes(ctx, values); |
|
|
|
|
|
} |
|
|
|
|
|
ctx.restore(); |
|
|
|
|
|
|
|
|
this.performFill(ctx, values); |
|
|
|
|
|
|
|
|
this.updateBoundingBox(x, y, ctx, selected, hover); |
|
|
this.updateBoundingBox(x, y, ctx, selected, hover); |
|
|
this.labelModule.draw(ctx, this.left + this.textSize.width / 2 + this.margin.left, |
|
|
this.labelModule.draw(ctx, this.left + this.textSize.width / 2 + this.margin.left, |
|
@ -56,15 +32,10 @@ class Box extends NodeBase { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
updateBoundingBox(x, y, ctx, selected, hover) { |
|
|
updateBoundingBox(x, y, ctx, selected, hover) { |
|
|
this.resize(ctx, selected, hover); |
|
|
|
|
|
this.left = x - this.width / 2; |
|
|
|
|
|
this.top = y - this.height / 2; |
|
|
|
|
|
|
|
|
this._updateBoundingBox(x, y, ctx, selected, hover); |
|
|
|
|
|
|
|
|
let borderRadius = this.options.shapeProperties.borderRadius; // only effective for box
|
|
|
let borderRadius = this.options.shapeProperties.borderRadius; // only effective for box
|
|
|
this.boundingBox.left = this.left - borderRadius; |
|
|
|
|
|
this.boundingBox.top = this.top - borderRadius; |
|
|
|
|
|
this.boundingBox.bottom = this.top + this.height + borderRadius; |
|
|
|
|
|
this.boundingBox.right = this.left + this.width + borderRadius; |
|
|
|
|
|
|
|
|
this._addBoundingBoxMargin(borderRadius); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
distanceToBorder(ctx, angle) { |
|
|
distanceToBorder(ctx, angle) { |
|
|