datafeed fixes; line drawing fix

This commit is contained in:
tim
2024-09-03 23:34:03 -04:00
parent bdad4c7257
commit 5afdc83957
9 changed files with 80 additions and 68 deletions

View File

@@ -3,6 +3,7 @@ import {invokeCallbacks, prototype} from "@/common.js";
import {DataFeed, initFeeDropdown, lookupSymbol} from "@/charts/datafeed.js";
import {intervalToSeconds, SingletonCoroutine} from "@/misc.js";
import {useStore} from "@/store/store.js";
import {dirtyPoints} from "@/charts/chart-misc.js";
export let widget = null
export let chart = null
@@ -213,6 +214,7 @@ function onSelectedLineToolChanged() {
}
export let dragging = false
export let draggingShapeIds = []
function mouseDown() {
// console.log('mouseDown')
// todo push into drawing event queue instead, then set dragging there
@@ -226,9 +228,6 @@ function mouseUp() {
}
export let draggingShapeIds = []
function handleCrosshairMovement(point) {
crosshairHandler.invoke(point) // delayed invocation to await selection to register later in the tv loop
}
@@ -255,11 +254,10 @@ function doHandleCrosshairMovement(point) {
catch (e) {
continue
}
const points = shape.getPoints();
// console.log('dragging', shapeId)
// invokeCallbacks(shapeCallbacks[shapeId], 'onDrag', shapeId, shape, points)
// console.log('calling onPoints')
const points = structuredClone(shape.getPoints());
const lpbe = shape._model._linePointBeingEdited
points[lpbe] = point
// console.log('drag calling onPoints', points, shape, lpbe)
invokeCallbacks(shapeCallbacks[shapeId], 'onPoints', shapeId, shape, points)
}
}
@@ -281,7 +279,7 @@ function handleDrawingEvent(id, event) {
// it's important to decouple our actions from the TV thread. we must wait until the TV loop is completed
// before interacting with the chart
if (drawingEventQueue.length===0)
setTimeout(drawingEventWorker,1)
setTimeout(drawingEventWorker,0)
drawingEventQueue.push([id,event])
}
@@ -337,7 +335,7 @@ function doHandleDrawingEvent(id, event) {
if (dragging) return
if (id in shapeCallbacks) {
const points = shape.getPoints()
// console.log('points', points)
// console.log('points', id, points, dragStartPoints)
invokeCallbacks(shapeCallbacks[id], 'onPoints', id, shape, points)
}
} else if (event === 'properties_changed') {