reverted dragging to old method
This commit is contained in:
@@ -4,7 +4,6 @@ import {DataFeed, feelessTickerKey, getAllSymbols, lookupSymbol} from "@/charts/
|
|||||||
import {intervalToSeconds, SingletonCoroutine} from "@/misc.js";
|
import {intervalToSeconds, SingletonCoroutine} from "@/misc.js";
|
||||||
import {usePrefStore, useStore} from "@/store/store.js";
|
import {usePrefStore, useStore} from "@/store/store.js";
|
||||||
import {tvCustomThemes} from "../../theme.js";
|
import {tvCustomThemes} from "../../theme.js";
|
||||||
import {copyPoints} from "@/charts/chart-misc.js";
|
|
||||||
|
|
||||||
export let widget = null
|
export let widget = null
|
||||||
export let chart = null
|
export let chart = null
|
||||||
@@ -316,14 +315,10 @@ function onSelectedLineToolChanged() {
|
|||||||
|
|
||||||
export let dragging = false
|
export let dragging = false
|
||||||
export let draggingShapeIds = []
|
export let draggingShapeIds = []
|
||||||
let draggingShapeStartPoints = null
|
|
||||||
let mouseClickPoint = null
|
|
||||||
|
|
||||||
function mouseDown() {
|
function mouseDown() {
|
||||||
// console.log('mouseDown')
|
// console.log('mouseDown')
|
||||||
// todo push into drawing event queue instead, then set dragging there
|
// todo push into drawing event queue instead, then set dragging there
|
||||||
dragging = true
|
dragging = true
|
||||||
mouseClickPoint = {time: crosshairPoint.time, price: crosshairPoint.price}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mouseUp() {
|
function mouseUp() {
|
||||||
@@ -351,11 +346,7 @@ function doHandleCrosshairMovement(point) {
|
|||||||
if (selection.length)
|
if (selection.length)
|
||||||
draggingShapeIds = selection
|
draggingShapeIds = selection
|
||||||
// console.log('dragging selected', draggingShapeIds)
|
// console.log('dragging selected', draggingShapeIds)
|
||||||
const initStartPoints = draggingShapeStartPoints === null
|
for (const shapeId of draggingShapeIds) {
|
||||||
if (initStartPoints)
|
|
||||||
draggingShapeStartPoints = []
|
|
||||||
for (const i in draggingShapeIds) {
|
|
||||||
const shapeId = draggingShapeIds[i]
|
|
||||||
let shape
|
let shape
|
||||||
try {
|
try {
|
||||||
shape = chart.getShapeById(shapeId);
|
shape = chart.getShapeById(shapeId);
|
||||||
@@ -363,33 +354,15 @@ function doHandleCrosshairMovement(point) {
|
|||||||
catch (e) {
|
catch (e) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
const shapePoints = shape.getPoints();
|
const points = structuredClone(shape.getPoints());
|
||||||
const lpbe = shape._model._linePointBeingEdited
|
const lpbe = shape._model._linePointBeingEdited
|
||||||
const points = [];
|
points[lpbe] = point
|
||||||
const dt = point.time - mouseClickPoint.time
|
|
||||||
const dp = point.price - mouseClickPoint.price
|
|
||||||
if (initStartPoints)
|
|
||||||
draggingShapeStartPoints.push(copyPoints(shapePoints))
|
|
||||||
for (const j in shapePoints) {
|
|
||||||
if (lpbe!==null)
|
|
||||||
// if this is the point being dragged, set it to the cursor position. otherwise pass it unchanged.
|
|
||||||
points.push(j===lpbe ? {time: point.time, price: point.price} : shapePoints[j])
|
|
||||||
else {
|
|
||||||
// lpbe is null if the user is dragging the entire object (translation,) meaning all points are affected
|
|
||||||
// todo use the origin of any selected point
|
|
||||||
const startPoint = draggingShapeStartPoints[i][j];
|
|
||||||
// push a point that applies the cursor delta to the starting position of the shape
|
|
||||||
points.push({time: startPoint.time + dt, price: startPoint.price + dp})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//console.log('lpbe', lpbe)
|
|
||||||
// console.log('drag calling onPoints', points, shape, lpbe)
|
// console.log('drag calling onPoints', points, shape, lpbe)
|
||||||
invokeCallbacks(shapeCallbacks[shapeId], 'onPoints', shapeId, shape, points)
|
invokeCallbacks(shapeCallbacks[shapeId], 'onPoints', shapeId, shape, points)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (draggingShapeIds.length > 0) {
|
else if (draggingShapeIds.length > 0) {
|
||||||
draggingShapeIds = []
|
draggingShapeIds = []
|
||||||
draggingShapeStartPoints = []
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,12 +24,13 @@
|
|||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
<v-dialog v-model="showWarnings" max-width="300">
|
<v-dialog v-model="showWarnings" max-width="300">
|
||||||
<v-card prepend-icon="mdi-warning" title="Order Warnings" text="Your order has the following warnings:">
|
<v-card prepend-icon="mdi-warning" title="Order Warnings">
|
||||||
<v-card-text>
|
<v-card-item>
|
||||||
<v-list>
|
<ul class="ml-5">
|
||||||
<v-list-item v-for="w of orderWarnings">{{w}}</v-list-item>
|
<li v-for="w of orderWarnings">{{w}}</li>
|
||||||
</v-list>
|
</ul>
|
||||||
</v-card-text>
|
</v-card-item>
|
||||||
|
<v-card-text>Continue placing this order?</v-card-text>
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
<v-spacer/>
|
<v-spacer/>
|
||||||
<v-btn @click="()=>showWarnings=false">Back</v-btn>
|
<v-btn @click="()=>showWarnings=false">Back</v-btn>
|
||||||
|
|||||||
Reference in New Issue
Block a user