px scaling support on the way + some styles updates
This commit is contained in:
parent
f1e384ecc2
commit
60bd47465d
11 changed files with 50 additions and 35 deletions
|
|
@ -24,6 +24,14 @@ MISC = {
|
|||
///////////////////////
|
||||
|
||||
$ = jQuery = require('./jquery/jquery.min')
|
||||
|
||||
///////////////////////
|
||||
|
||||
PXSCALE = 1
|
||||
$('html').css('font-size',PXSCALE+'px')
|
||||
|
||||
///////////////////////
|
||||
|
||||
require('./jquery/jquery.ui')
|
||||
require('./jquery/jquery.drag')
|
||||
require('./jquery/jquery.resize')
|
||||
|
|
@ -44,4 +52,7 @@ for (i in callbacks) {
|
|||
}
|
||||
|
||||
|
||||
///////////////////////
|
||||
|
||||
|
||||
IPC.send('ready')
|
||||
|
|
|
|||
|
|
@ -205,8 +205,8 @@ var editObject = function(container, data, refresh){
|
|||
handleTarget = $(event.originalEvent.target)
|
||||
},
|
||||
stop: function( event, ui ) {
|
||||
if (handleTarget.hasClass('ui-resizable-se') || handleTarget.hasClass('ui-resizable-s')) data.height = Math.max(ui.size.height,30)
|
||||
if (handleTarget.hasClass('ui-resizable-se') || handleTarget.hasClass('ui-resizable-e')) data.width = Math.max(ui.size.width,30)
|
||||
if (handleTarget.hasClass('ui-resizable-se') || handleTarget.hasClass('ui-resizable-s')) data.height = Math.max(ui.size.height,30)/PXSCALE
|
||||
if (handleTarget.hasClass('ui-resizable-se') || handleTarget.hasClass('ui-resizable-e')) data.width = Math.max(ui.size.width,30)/PXSCALE
|
||||
updateDom(container,data)
|
||||
},
|
||||
snap:'.tab.on .widget, .tab.on',
|
||||
|
|
@ -218,8 +218,8 @@ var editObject = function(container, data, refresh){
|
|||
container.draggable({
|
||||
stop: function( event, ui ) {
|
||||
event.preventDefault()
|
||||
data.top = ui.helper.position().top + container.parent().scrollTop()
|
||||
data.left = ui.helper.position().left + container.parent().scrollLeft()
|
||||
data.top = (ui.helper.position().top + container.parent().scrollTop())/PXSCALE
|
||||
data.left = (ui.helper.position().left + container.parent().scrollLeft())/PXSCALE
|
||||
ui.helper.remove()
|
||||
updateDom(container,data)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ module.exports.create = function(widgetData,container) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
if (typeof widgetData.points=='string') {
|
||||
|
||||
widget.linkedWidgets.push(widgetData.points)
|
||||
|
|
@ -115,13 +116,13 @@ module.exports.create = function(widgetData,container) {
|
|||
for (i in widget.data) {
|
||||
var newpoint = widget.data[i].length?
|
||||
[
|
||||
mapToScale(widget.data[i][0],[widgetData.rangeX.min,widgetData.rangeX.max],[15,widget.width-15],0,widgetData.logScaleX,true),
|
||||
mapToScale(widget.data[i][1],[widgetData.rangeY.min,widgetData.rangeY.max],[widget.height-15,15],0,widgetData.logScaleY,true),
|
||||
mapToScale(widget.data[i][0],[widgetData.rangeX.min,widgetData.rangeX.max],[15*PXSCALE,widget.width-15*PXSCALE],0,widgetData.logScaleX,true),
|
||||
mapToScale(widget.data[i][1],[widgetData.rangeY.min,widgetData.rangeY.max],[widget.height-15*PXSCALE,15*PXSCALE],0,widgetData.logScaleY,true),
|
||||
]
|
||||
:
|
||||
[
|
||||
mapToScale(i,[0,widget.data.length-1],[15,widget.width-15],0,widgetData.logScaleX,true),
|
||||
mapToScale(widget.data[i],[widgetData.rangeY.min,widgetData.rangeY.max],[widget.height-15,15],0,widgetData.logScaleY,true),
|
||||
mapToScale(i,[0,widget.data.length-1],[15*PXSCALE,widget.width-15*PXSCALE],0,widgetData.logScaleX,true),
|
||||
mapToScale(widget.data[i],[widgetData.rangeY.min,widgetData.rangeY.max],[widget.height-15*PXSCALE,15*PXSCALE],0,widgetData.logScaleY,true),
|
||||
]
|
||||
|
||||
|
||||
|
|
@ -144,17 +145,17 @@ module.exports.create = function(widgetData,container) {
|
|||
point = newpoint
|
||||
}
|
||||
|
||||
ctx.lineWidth = 1.5
|
||||
ctx.lineWidth = 1.5*PXSCALE
|
||||
ctx.strokeStyle= widget.lineColor
|
||||
ctx.stroke()
|
||||
|
||||
ctx.font = '10px sans-serif'
|
||||
ctx.font = PXSCALE * 10 + 'px sans-serif'
|
||||
ctx.fillStyle = widget.textColor
|
||||
|
||||
|
||||
ctx.textBaseline = "bottom"
|
||||
ctx.textAlign = 'left'
|
||||
ctx.fillText(widget.pips.x.min,12,widget.height)
|
||||
ctx.fillText(widget.pips.x.min,12*PXSCALE,widget.height)
|
||||
ctx.textAlign = 'right'
|
||||
ctx.fillText(widget.pips.x.max,widget.width-10,widget.height)
|
||||
|
||||
|
|
@ -164,9 +165,9 @@ module.exports.create = function(widgetData,container) {
|
|||
|
||||
ctx.textBaseline = "top"
|
||||
ctx.textAlign = 'left'
|
||||
ctx.fillText(widget.pips.y.min,12,2)
|
||||
ctx.fillText(widget.pips.y.min,12*PXSCALE,2*PXSCALE)
|
||||
ctx.textAlign = 'right'
|
||||
ctx.fillText(widget.pips.y.max,widget.height-10,2)
|
||||
ctx.fillText(widget.pips.y.max,widget.height-10*PXSCALE,2*PXSCALE)
|
||||
ctx.rotate(Math.PI/2)
|
||||
ctx.restore()
|
||||
|
||||
|
|
|
|||
|
|
@ -109,8 +109,8 @@ module.exports.create = function(widgetData,container) {
|
|||
|
||||
for (var i=widget.length-1;i>=0;i=i-1) {
|
||||
var newpoint = [
|
||||
mapToScale(i,[0,widget.length-1],[15,widget.width-15],1),
|
||||
mapToScale(widget.data[i],[widgetData.range.min,widgetData.range.max],[widget.height-15,15],1,widgetData.logScale,true),
|
||||
mapToScale(i,[0,widget.length-1],[15*PXSCALE,widget.width-15*PXSCALE],1),
|
||||
mapToScale(widget.data[i],[widgetData.range.min,widgetData.range.max],[widget.height-15*PXSCALE,15*PXSCALE],1,widgetData.logScale,true),
|
||||
]
|
||||
if (first) {
|
||||
ctx.moveTo(newpoint[0],newpoint[1])
|
||||
|
|
@ -126,11 +126,11 @@ module.exports.create = function(widgetData,container) {
|
|||
point = newpoint
|
||||
}
|
||||
|
||||
ctx.lineWidth = 1.5
|
||||
ctx.lineWidth = 1.5*PXSCALE
|
||||
ctx.strokeStyle= widget.lineColor
|
||||
ctx.stroke()
|
||||
|
||||
ctx.font = '10px sans-serif'
|
||||
ctx.font = PXSCALE * 10 + 'px sans-serif'
|
||||
ctx.fillStyle = widget.textColor
|
||||
|
||||
|
||||
|
|
@ -140,9 +140,9 @@ module.exports.create = function(widgetData,container) {
|
|||
|
||||
ctx.textBaseline = "top"
|
||||
ctx.textAlign = 'left'
|
||||
ctx.fillText(widget.pips.min,12,2)
|
||||
ctx.fillText(widget.pips.min,12*PXSCALE,2*PXSCALE)
|
||||
ctx.textAlign = 'right'
|
||||
ctx.fillText(widget.pips.max,widget.height-10,2)
|
||||
ctx.fillText(widget.pips.max,widget.height-10*PXSCALE,2*PXSCALE)
|
||||
ctx.rotate(Math.PI/2)
|
||||
ctx.restore()
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@
|
|||
if (!self.height || !self.width || (self.height==100 && self.width==100)) return
|
||||
|
||||
ctx.clearRect(0,0,self.width,self.height)
|
||||
ctx.font = '13px Droid Sans'
|
||||
ctx.font = PXSCALE * 13 + 'px Droid Sans'
|
||||
ctx.textBaseline = "top"
|
||||
ctx.fillStyle = self.color
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue