knob: make gauge's width proportionnal to widget's size in compact mode
This commit is contained in:
parent
c4c5577997
commit
86f427dbfd
2 changed files with 22 additions and 7 deletions
|
|
@ -3,8 +3,9 @@
|
|||
## 0.11.1
|
||||
|
||||
- bug fixes
|
||||
- meters in faders were not always properly positionned
|
||||
|
||||
- meters in faders were not always properly positionned
|
||||
- widgets
|
||||
- knob: gauge's width is proportionnal to the knob's size in `compact` mode
|
||||
## 0.11.0
|
||||
|
||||
- bug fixes
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ Knob.prototype.percentToAngle = function(percent) {
|
|||
Knob.prototype.resizeHandle = function() {
|
||||
_sliders_base.prototype.resizeHandle.call(this)
|
||||
this.minDimension = Math.min(this.width, this.height)
|
||||
this.gaugeWidth = this.minDimension / 8
|
||||
this.canvas[0].style.top = (this.minDimension / 2 - 15) * this.lostHeightFactor + 'px'
|
||||
if (this.widgetData.compact) {
|
||||
this.input[0].style.marginTop = (this.minDimension / 2 - 15) * this.lostHeightFactor + 'px'
|
||||
|
|
@ -155,19 +156,32 @@ Knob.prototype.draw = function(){
|
|||
|
||||
if (this.widgetData.compact) {
|
||||
|
||||
this.ctx.lineWidth = 10 * PXSCALE
|
||||
this.ctx.lineWidth = this.gaugeWidth * PXSCALE
|
||||
this.ctx.globalAlpha = 0.3
|
||||
this.ctx.beginPath()
|
||||
this.ctx.strokeStyle = this.colors.track
|
||||
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - (10 + this.margin) * PXSCALE, min, max)
|
||||
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - (this.gaugeWidth + this.margin) * PXSCALE, min, max)
|
||||
this.ctx.stroke()
|
||||
|
||||
this.ctx.globalAlpha = 0.5
|
||||
this.ctx.beginPath()
|
||||
this.ctx.strokeStyle = this.colors.gauge
|
||||
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - (10 + this.margin) * PXSCALE, Math.min(o,d), Math.max(o,d))
|
||||
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - (this.gaugeWidth + this.margin) * PXSCALE, Math.min(o,d), Math.max(o,d))
|
||||
this.ctx.stroke()
|
||||
|
||||
this.ctx.lineWidth = 1 * PXSCALE
|
||||
this.ctx.beginPath()
|
||||
this.ctx.strokeStyle = this.colors.track
|
||||
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - (this.gaugeWidth/2 + this.margin) * PXSCALE, min, max)
|
||||
this.ctx.stroke()
|
||||
|
||||
this.ctx.globalAlpha = 1
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.strokeStyle = this.colors.gauge
|
||||
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - (this.gaugeWidth/2 + this.margin) * PXSCALE, Math.min(o,d), Math.max(o,d))
|
||||
this.ctx.stroke()
|
||||
|
||||
|
||||
this.ctx.save()
|
||||
|
||||
|
|
@ -179,8 +193,8 @@ Knob.prototype.draw = function(){
|
|||
|
||||
this.ctx.strokeStyle = this.colors.knob
|
||||
this.ctx.lineWidth = 1 * PXSCALE
|
||||
this.ctx.moveTo(this.width / 2 + this.minDimension / 2 - (10 + this.margin - 5) * PXSCALE, this.height / 2)
|
||||
this.ctx.lineTo(this.width / 2 + this.minDimension / 2 - (10 + this.margin + 5) * PXSCALE, this.height / 2)
|
||||
this.ctx.moveTo(this.width / 2 + this.minDimension / 2 - (this.gaugeWidth/2 + this.margin) * PXSCALE, this.height / 2)
|
||||
this.ctx.lineTo(this.width / 2 + this.minDimension / 2 - (this.gaugeWidth * 1.5 + this.margin) * PXSCALE, this.height / 2)
|
||||
this.ctx.stroke()
|
||||
|
||||
this.ctx.restore()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue