allocation text fix; props&points suppressed during drag

This commit is contained in:
Tim
2024-05-06 15:24:47 -04:00
parent 613cb7d7f5
commit c3c5db9c23
5 changed files with 38 additions and 26 deletions

View File

@@ -1,7 +1,7 @@
// noinspection JSPotentiallyInvalidUsageOfThis
import {invokeCallback, mixin} from "@/common.js";
import {chart, createShape, deleteShapeId, draggingShapeIds, drawShape, widget} from "@/charts/chart.js";
import {chart, createShape, deleteShapeId, dragging, draggingShapeIds, drawShape, widget} from "@/charts/chart.js";
import {pointsToOhlcStart, unique} from "@/misc.js";
import {allocationText} from "@/orderbuild.js";
import Color from "color";
@@ -57,7 +57,7 @@ export class Shape {
// lineColor, textColor, color, // lineColor and textColor default to color
// }
this.debug = true
this.debug = false
this.id = null // TradingView shapeId, or null if no TV shape created yet (drawing mode)
this.type = type // ShapeType
this.model = {} // set to nothing at first
@@ -95,8 +95,6 @@ export class Shape {
//
setModel(model) {
console.log('shape setModel', model)
if (model.color)
this.model.color = model.color
if (model.allocation !== null && model.allocation !== undefined)
@@ -376,19 +374,22 @@ class ShapeTVCallbacks {
if (!this.enabled) return // possible when shape is deleted and re-created
this.shape.id = shapeId
invokeCallback(this.shape, 'onCreate', points, props)
invokeCallback(this.shape, 'onPoints', points)
}
onPoints(shapeId, _tvShape, points) {
if (!this.enabled) return // possible when shape is deleted and re-created
if (this.shape.debug) console.log('tvcb onPoints', points)
this.shape.onPoints(points)
if (!dragging || this.shape.beingDragged())
this.shape.onPoints(points)
this.shape.tvPoints = points
}
onProps(shapeId, _tvShape, props) {
if (!this.enabled) return // possible when shape is deleted and re-created
if (this.shape.debug) console.error('tvOnProps', props)
this.shape.onProps(props)
if (!dragging) // do not listen to props during redraw
this.shape.onProps(props)
this.shape.tvProps = props
}
@@ -563,7 +564,6 @@ export class DLine extends Line {
}
setModel(model) {
console.log("DLine setModel", {...this.model}, {...model})
super.setModel(model)
if (model.pointA === null && model.pointB === null)
this.delete()
@@ -584,7 +584,6 @@ export class DLine extends Line {
if( points[i].time !== this.tvPoints[i].time || points[i].price !== this.tvPoints[i].price )
dirty = true
}
console.log('DLine onPoints', dirty, this.tvPoints, points)
if (dirty) {
console.log('DLine points were dirty', this.tvPoints, points)
super.onPoints(points);