widgets: knobs compact mode, default widgets input's height reduced
This commit is contained in:
parent
4def266315
commit
2407e37922
8 changed files with 177 additions and 53 deletions
File diff suppressed because one or more lines are too long
|
|
@ -20,6 +20,8 @@ var _sliders_base = module.exports = function(){
|
|||
this.value = undefined
|
||||
this.percent = 0
|
||||
|
||||
this.unit = this.widgetData.unit ? ' ' + this.widgetData.unit : ''
|
||||
|
||||
|
||||
this.rangeKeys = []
|
||||
this.rangeVals = []
|
||||
|
|
@ -170,5 +172,5 @@ _sliders_base.prototype.sendValue = function(value) {
|
|||
}
|
||||
|
||||
_sliders_base.prototype.showValue = function() {
|
||||
this.input.val(this.value + ' ' + this.widgetData.unit)
|
||||
this.input.val(this.value + this.unit)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,13 @@ Knob = function(widgetData) {
|
|||
|
||||
this.widget.addClass('knob')
|
||||
|
||||
this.margin = 5
|
||||
|
||||
if (widgetData.compact) {
|
||||
this.widget.addClass('compact')
|
||||
this.margin = 0
|
||||
}
|
||||
|
||||
this.lastOffsetX = 0
|
||||
this.lastOffsetY = 0
|
||||
this.minDimension = 0
|
||||
|
|
@ -121,6 +128,10 @@ Knob.prototype.resizeHandle = function() {
|
|||
_sliders_base.prototype.resizeHandle.call(this)
|
||||
this.minDimension = Math.min(this.width, this.height)
|
||||
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'
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -133,37 +144,81 @@ Knob.prototype.draw = function(){
|
|||
|
||||
this.ctx.clearRect(0,0,this.width,this.height)
|
||||
|
||||
this.ctx.lineWidth = 2 * PXSCALE
|
||||
this.ctx.beginPath()
|
||||
this.ctx.strokeStyle = this.colors.track
|
||||
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - 15 * PXSCALE, min, max)
|
||||
this.ctx.stroke()
|
||||
if (this.widgetData.compact) {
|
||||
|
||||
this.ctx.lineWidth = 10 * PXSCALE
|
||||
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.stroke()
|
||||
|
||||
this.ctx.save()
|
||||
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.stroke()
|
||||
this.ctx.restore()
|
||||
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.strokeStyle = this.colors.custom
|
||||
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - 15 * PXSCALE, Math.min(o,d), Math.max(o,d))
|
||||
this.ctx.stroke()
|
||||
this.ctx.save()
|
||||
|
||||
this.ctx.translate(this.width / 2, this.height / 2)
|
||||
this.ctx.rotate(d)
|
||||
this.ctx.translate(-this.width / 2, -this.height / 2)
|
||||
|
||||
this.ctx.beginPath()
|
||||
|
||||
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.stroke()
|
||||
|
||||
this.ctx.restore()
|
||||
|
||||
|
||||
this.ctx.save()
|
||||
} else {
|
||||
|
||||
this.ctx.translate(this.width / 2, this.height / 2)
|
||||
this.ctx.rotate(d)
|
||||
this.ctx.translate(-this.width / 2, -this.height / 2)
|
||||
this.ctx.beginPath()
|
||||
this.ctx.fillStyle = this.colors.raised
|
||||
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - (30 + this.margin), 0, Math.PI * 2)
|
||||
this.ctx.fill()
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.lineWidth = 2 * PXSCALE
|
||||
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.stroke()
|
||||
|
||||
|
||||
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.stroke()
|
||||
|
||||
this.ctx.save()
|
||||
|
||||
this.ctx.translate(this.width / 2, this.height / 2)
|
||||
this.ctx.rotate(d)
|
||||
this.ctx.translate(-this.width / 2, -this.height / 2)
|
||||
|
||||
this.ctx.beginPath()
|
||||
|
||||
this.ctx.fillStyle = this.colors.knob
|
||||
this.ctx.arc(this.width / 2 + this.minDimension / 2 - (10 + this.margin) * PXSCALE, this.height / 2, 4 * PXSCALE, 0, Math.PI * 2)
|
||||
this.ctx.fill()
|
||||
|
||||
this.ctx.globalAlpha = 0.3
|
||||
this.ctx.fillStyle = this.colors.knob
|
||||
this.ctx.arc(this.width / 2 + this.minDimension / 2 - (10 + this.margin) * PXSCALE, this.height / 2, 10 * PXSCALE, 0, Math.PI * 2)
|
||||
this.ctx.fill()
|
||||
|
||||
this.ctx.restore()
|
||||
}
|
||||
|
||||
this.ctx.fillStyle = this.colors.gauge
|
||||
this.ctx.arc(this.width / 2 + this.minDimension / 2 - 15 * PXSCALE, this.height / 2, 4 * PXSCALE, 0, Math.PI * 2)
|
||||
this.ctx.fill()
|
||||
|
||||
this.ctx.globalAlpha = 0.3
|
||||
this.ctx.fillStyle = this.colors.knob
|
||||
this.ctx.arc(this.width / 2 + this.minDimension / 2 - 15 * PXSCALE, this.height / 2, 10 * PXSCALE, 0, Math.PI * 2)
|
||||
this.ctx.fill()
|
||||
|
||||
this.ctx.restore()
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3253,6 +3253,8 @@ var _sliders_base = module.exports = function(){
|
|||
this.value = undefined
|
||||
this.percent = 0
|
||||
|
||||
this.unit = this.widgetData.unit ? ' ' + this.widgetData.unit : ''
|
||||
|
||||
|
||||
this.rangeKeys = []
|
||||
this.rangeVals = []
|
||||
|
|
@ -3403,7 +3405,7 @@ _sliders_base.prototype.sendValue = function(value) {
|
|||
}
|
||||
|
||||
_sliders_base.prototype.showValue = function() {
|
||||
this.input.val(this.value + ' ' + this.widgetData.unit)
|
||||
this.input.val(this.value + this.unit)
|
||||
}
|
||||
|
||||
},{"../common/_canvas_base":15,"../utils":37}],32:[function(require,module,exports){
|
||||
|
|
@ -3717,6 +3719,13 @@ Knob = function(widgetData) {
|
|||
|
||||
this.widget.addClass('knob')
|
||||
|
||||
this.margin = 5
|
||||
|
||||
if (widgetData.compact) {
|
||||
this.widget.addClass('compact')
|
||||
this.margin = 0
|
||||
}
|
||||
|
||||
this.lastOffsetX = 0
|
||||
this.lastOffsetY = 0
|
||||
this.minDimension = 0
|
||||
|
|
@ -3794,6 +3803,10 @@ Knob.prototype.resizeHandle = function() {
|
|||
_sliders_base.prototype.resizeHandle.call(this)
|
||||
this.minDimension = Math.min(this.width, this.height)
|
||||
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'
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -3806,37 +3819,81 @@ Knob.prototype.draw = function(){
|
|||
|
||||
this.ctx.clearRect(0,0,this.width,this.height)
|
||||
|
||||
this.ctx.lineWidth = 2 * PXSCALE
|
||||
this.ctx.beginPath()
|
||||
this.ctx.strokeStyle = this.colors.track
|
||||
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - 15 * PXSCALE, min, max)
|
||||
this.ctx.stroke()
|
||||
if (this.widgetData.compact) {
|
||||
|
||||
this.ctx.lineWidth = 10 * PXSCALE
|
||||
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.stroke()
|
||||
|
||||
this.ctx.save()
|
||||
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.stroke()
|
||||
this.ctx.restore()
|
||||
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.strokeStyle = this.colors.custom
|
||||
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - 15 * PXSCALE, Math.min(o,d), Math.max(o,d))
|
||||
this.ctx.stroke()
|
||||
this.ctx.save()
|
||||
|
||||
this.ctx.translate(this.width / 2, this.height / 2)
|
||||
this.ctx.rotate(d)
|
||||
this.ctx.translate(-this.width / 2, -this.height / 2)
|
||||
|
||||
this.ctx.beginPath()
|
||||
|
||||
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.stroke()
|
||||
|
||||
this.ctx.restore()
|
||||
|
||||
|
||||
this.ctx.save()
|
||||
} else {
|
||||
|
||||
this.ctx.translate(this.width / 2, this.height / 2)
|
||||
this.ctx.rotate(d)
|
||||
this.ctx.translate(-this.width / 2, -this.height / 2)
|
||||
this.ctx.beginPath()
|
||||
this.ctx.fillStyle = this.colors.raised
|
||||
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - (30 + this.margin), 0, Math.PI * 2)
|
||||
this.ctx.fill()
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.lineWidth = 2 * PXSCALE
|
||||
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.stroke()
|
||||
|
||||
|
||||
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.stroke()
|
||||
|
||||
this.ctx.save()
|
||||
|
||||
this.ctx.translate(this.width / 2, this.height / 2)
|
||||
this.ctx.rotate(d)
|
||||
this.ctx.translate(-this.width / 2, -this.height / 2)
|
||||
|
||||
this.ctx.beginPath()
|
||||
|
||||
this.ctx.fillStyle = this.colors.knob
|
||||
this.ctx.arc(this.width / 2 + this.minDimension / 2 - (10 + this.margin) * PXSCALE, this.height / 2, 4 * PXSCALE, 0, Math.PI * 2)
|
||||
this.ctx.fill()
|
||||
|
||||
this.ctx.globalAlpha = 0.3
|
||||
this.ctx.fillStyle = this.colors.knob
|
||||
this.ctx.arc(this.width / 2 + this.minDimension / 2 - (10 + this.margin) * PXSCALE, this.height / 2, 10 * PXSCALE, 0, Math.PI * 2)
|
||||
this.ctx.fill()
|
||||
|
||||
this.ctx.restore()
|
||||
}
|
||||
|
||||
this.ctx.fillStyle = this.colors.gauge
|
||||
this.ctx.arc(this.width / 2 + this.minDimension / 2 - 15 * PXSCALE, this.height / 2, 4 * PXSCALE, 0, Math.PI * 2)
|
||||
this.ctx.fill()
|
||||
|
||||
this.ctx.globalAlpha = 0.3
|
||||
this.ctx.fillStyle = this.colors.knob
|
||||
this.ctx.arc(this.width / 2 + this.minDimension / 2 - 15 * PXSCALE, this.height / 2, 10 * PXSCALE, 0, Math.PI * 2)
|
||||
this.ctx.fill()
|
||||
|
||||
this.ctx.restore()
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -49,12 +49,12 @@
|
|||
}
|
||||
.input {
|
||||
width:100%;
|
||||
height:30rem;
|
||||
height:24rem;
|
||||
border:0;
|
||||
background:transparent;
|
||||
color:var(--color-text-fade);
|
||||
display:block;
|
||||
padding:7rem 5rem;
|
||||
padding:4rem 5rem;
|
||||
position: relative;
|
||||
display: var(--display-input);
|
||||
|
||||
|
|
@ -64,7 +64,7 @@
|
|||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
padding:7rem 5rem;
|
||||
padding:4rem 5rem;
|
||||
width: 100%;
|
||||
font: inherit;
|
||||
text-align:center;
|
||||
|
|
|
|||
|
|
@ -163,6 +163,9 @@
|
|||
}
|
||||
}
|
||||
&.compact {
|
||||
.wrapper canvas {
|
||||
background: var(--color-faded)
|
||||
}
|
||||
.input {
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
|
|
@ -173,7 +176,7 @@
|
|||
margin-left: -50rem;
|
||||
left:50%;
|
||||
z-index: 3;
|
||||
margin-top: -15rem;
|
||||
margin-top: -12rem;
|
||||
}
|
||||
.meter-container {
|
||||
top: 0;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,13 @@
|
|||
position: relative;
|
||||
}
|
||||
}
|
||||
&.compact {
|
||||
.input {
|
||||
position: absolute;
|
||||
top:calc(50% - 12rem);
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.knob-container {
|
||||
|
|
@ -28,7 +35,7 @@
|
|||
--color-knob: var(--color-custom);
|
||||
|
||||
width: 100rem;
|
||||
height: 150rem;
|
||||
height: 120rem;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
.input {
|
||||
width:50%;
|
||||
float:left;
|
||||
height: 30rem;
|
||||
height: 24rem;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue