Button for swithing between automatic scales implemented
This commit is contained in:
1 parent
aa1828ec1d
commit
276b23f823
4 files changed
+149
-4
No files matched your search
@@ -539,7 +539,9 @@ function newCanvas () {
|
||||
containerBeingDragged.eventHandler.raiseEvent('onDragStarted', point)
|
||||
return
|
||||
} else {
|
||||
viewPortBeingDragged = true
|
||||
if (container.isClickeable === false) {
|
||||
viewPortBeingDragged = true
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -565,6 +567,7 @@ function newCanvas () {
|
||||
|
||||
function onMouseClick (event) {
|
||||
try {
|
||||
console.log('ignoreNextClick', ignoreNextClick)
|
||||
if (ignoreNextClick === true) {
|
||||
ignoreNextClick = false
|
||||
return
|
||||
@@ -613,7 +616,7 @@ function newCanvas () {
|
||||
|
||||
/* If it is not, then we check if it is over any of the existing containers at the Chart Space. */
|
||||
|
||||
container = thisObject.chartSpace.getContainer(point)
|
||||
container = thisObject.chartSpace.getContainer(point, GET_CONTAINER_PURPOSE.MOUSE_CLICK)
|
||||
|
||||
if (container !== undefined && container.isClickeable === true) {
|
||||
container.eventHandler.raiseEvent('onMouseClick', point)
|
||||
|
||||
@@ -249,6 +249,10 @@ function newTimeMachine () {
|
||||
if (container !== undefined) {
|
||||
if (container.isForThisPurpose(purpose)) {
|
||||
return container
|
||||
} else {
|
||||
if (purpose === GET_CONTAINER_PURPOSE.DRAGGING && container.isClickeable === true) {
|
||||
return container
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -274,10 +278,17 @@ function newTimeMachine () {
|
||||
for (let i = 0; i < thisObject.timelineCharts.length; i++) {
|
||||
container = thisObject.timelineCharts[i].getContainer(point, purpose)
|
||||
if (container !== undefined) {
|
||||
console.log('IN TIME MACHINE GOT THIS CONTAINER: ' + container.name)
|
||||
if (container.isForThisPurpose(purpose)) {
|
||||
if (thisObject.container.frame.isThisPointHere(point) === true) {
|
||||
return container
|
||||
}
|
||||
} else {
|
||||
if (purpose === GET_CONTAINER_PURPOSE.DRAGGING && container.isClickeable === true) {
|
||||
if (thisObject.container.frame.isThisPointHere(point) === true) {
|
||||
return container
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
function newAutoScaleButton () {
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
fitFunction: undefined,
|
||||
parentContainer: undefined,
|
||||
autoMinScale: undefined,
|
||||
autoMaxScale: undefined,
|
||||
draw: draw,
|
||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
/* Cointainer stuff */
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.name = 'Auto Scale Button'
|
||||
thisObject.container.initialize()
|
||||
thisObject.container.isClickeable = true
|
||||
thisObject.container.isDraggeable = false
|
||||
thisObject.container.frame.containerName = 'Auto Scale Button'
|
||||
|
||||
let onMouseClickEventSuscriptionId
|
||||
let coordinateSystem
|
||||
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
thisObject.container.eventHandler.stopListening(onMouseClickEventSuscriptionId)
|
||||
thisObject.container.finalize()
|
||||
thisObject.container = undefined
|
||||
thisObject.fitFunction = undefined
|
||||
thisObject.parentContainer = undefined
|
||||
thisObject.panels = undefined
|
||||
|
||||
coordinateSystem = undefined
|
||||
}
|
||||
|
||||
function initialize (pCoordinateSystem) {
|
||||
coordinateSystem = pCoordinateSystem
|
||||
thisObject.autoMinScale = coordinateSystem.autoMinScale
|
||||
thisObject.autoMaxScale = coordinateSystem.autoMaxScale
|
||||
|
||||
thisObject.container.frame.width = 25
|
||||
thisObject.container.frame.height = 25
|
||||
|
||||
let position = {
|
||||
x: thisObject.container.parentContainer.frame.width * 5 / 8,
|
||||
y: thisObject.container.parentContainer.frame.height / 2 - thisObject.container.frame.height / 2
|
||||
}
|
||||
|
||||
thisObject.container.frame.position = position
|
||||
|
||||
/* Lets listen to our own events to react when we have a Mouse Click */
|
||||
onMouseClickEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick)
|
||||
}
|
||||
|
||||
function onMouseClick (event) {
|
||||
if (thisObject.autoMinScale === false && thisObject.autoMaxScale === false) {
|
||||
thisObject.autoMinScale = true
|
||||
thisObject.autoMaxScale = false
|
||||
update()
|
||||
return
|
||||
}
|
||||
if (thisObject.autoMinScale === true && thisObject.autoMaxScale === false) {
|
||||
thisObject.autoMinScale = false
|
||||
thisObject.autoMaxScale = true
|
||||
update()
|
||||
return
|
||||
}
|
||||
if (thisObject.autoMinScale === false && thisObject.autoMaxScale === true) {
|
||||
thisObject.autoMinScale = true
|
||||
thisObject.autoMaxScale = true
|
||||
update()
|
||||
return
|
||||
}
|
||||
if (thisObject.autoMinScale === true && thisObject.autoMaxScale === true) {
|
||||
thisObject.autoMinScale = false
|
||||
thisObject.autoMaxScale = false
|
||||
update()
|
||||
return
|
||||
}
|
||||
|
||||
function update () {
|
||||
coordinateSystem.autoMinScale = thisObject.autoMinScale
|
||||
coordinateSystem.autoMaxScale = thisObject.autoMaxScale
|
||||
coordinateSystem.recalculateScale()
|
||||
}
|
||||
}
|
||||
|
||||
function getContainer (point, purpose) {
|
||||
console.log('INSIDE BUTTON')
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
console.log('RETURNING BUTTON FROM BUTTON')
|
||||
return thisObject.container
|
||||
}
|
||||
}
|
||||
|
||||
function draw () {
|
||||
let icon
|
||||
if (thisObject.autoMinScale === false && thisObject.autoMaxScale === false) {
|
||||
icon = canvas.designerSpace.iconCollection.get('plotter-panel')
|
||||
}
|
||||
if (thisObject.autoMinScale === true && thisObject.autoMaxScale === false) {
|
||||
icon = canvas.designerSpace.iconCollection.get('shapes-polygon-body')
|
||||
}
|
||||
if (thisObject.autoMinScale === false && thisObject.autoMaxScale === true) {
|
||||
icon = canvas.designerSpace.iconCollection.get('social-bot')
|
||||
}
|
||||
if (thisObject.autoMinScale === true && thisObject.autoMaxScale === true) {
|
||||
icon = canvas.designerSpace.iconCollection.get('startup')
|
||||
}
|
||||
|
||||
drawIcon(icon, 1 / 2, 1 / 2, 0, 0, 14, thisObject.container)
|
||||
}
|
||||
}
|
||||
+18
-2
@@ -55,6 +55,7 @@ function newRateScale () {
|
||||
}
|
||||
|
||||
let scaleDisplayTimer = 0
|
||||
let autoScaleButton
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
@@ -72,6 +73,9 @@ function newRateScale () {
|
||||
limitingContainer = undefined
|
||||
rateCalculationsContainer = undefined
|
||||
mouse = undefined
|
||||
|
||||
autoScaleButton.finalize()
|
||||
autoScaleButton = undefined
|
||||
}
|
||||
|
||||
function initialize (pCoordinateSystem, pLimitingContainer, pRateCalculationsContainer) {
|
||||
@@ -88,6 +92,10 @@ function newRateScale () {
|
||||
onScaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
|
||||
|
||||
readObjectState()
|
||||
|
||||
autoScaleButton = newAutoScaleButton()
|
||||
autoScaleButton.container.connectToParent(thisObject.container)
|
||||
autoScaleButton.initialize(coordinateSystem)
|
||||
}
|
||||
|
||||
function onMouseOverSomeTimeMachineContainer (event) {
|
||||
@@ -142,7 +150,15 @@ function newRateScale () {
|
||||
}
|
||||
|
||||
function getContainer (point, purpose) {
|
||||
console.log(purpose, point.x, point.y)
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
console.log('INSIDE')
|
||||
let container = autoScaleButton.getContainer(point, purpose)
|
||||
if (container !== undefined) {
|
||||
console.log('RETURNING BUTTON FROM SCALE')
|
||||
return container
|
||||
}
|
||||
|
||||
if (purpose === GET_CONTAINER_PURPOSE.DRAGGING) {
|
||||
return draggeableContainer
|
||||
}
|
||||
@@ -152,7 +168,6 @@ function newRateScale () {
|
||||
}
|
||||
|
||||
function saveObjectState () {
|
||||
return
|
||||
try {
|
||||
let code = JSON.parse(thisObject.payload.node.code)
|
||||
code.minValue = coordinateSystem.min.y
|
||||
@@ -166,7 +181,6 @@ function newRateScale () {
|
||||
}
|
||||
|
||||
function readObjectState () {
|
||||
return
|
||||
try {
|
||||
let code = JSON.parse(thisObject.payload.node.code)
|
||||
|
||||
@@ -346,6 +360,7 @@ function newRateScale () {
|
||||
|
||||
function draw () {
|
||||
drawScaleBox()
|
||||
autoScaleButton.draw()
|
||||
if (visible === false) {
|
||||
drawScaleDisplayCover(thisObject.container)
|
||||
}
|
||||
@@ -354,6 +369,7 @@ function newRateScale () {
|
||||
function drawForeground () {
|
||||
if (isMouseOver === true) {
|
||||
drawScaleBox()
|
||||
autoScaleButton.draw()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user