Bin
2025-12-16 9e0b2ba2c317b1a86212f24cbae3195ad1f3dbfa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import type { KonvaEventObject } from "konva/lib/Node";
import type { BezierPoint, Point, GhostPoint } from "../types";
import type { PointType } from "../types";
 
export interface EventHandlerProps {
  instanceId?: string; // Add instanceId for tracker integration
  initialPoints: BezierPoint[];
  width: number;
  height: number;
  pixelSnapping?: boolean;
  selectedPoints: Set<number>;
  selectedPointIndex: number | null;
  setSelectedPointIndex: (index: number | null) => void;
  setSelectedPoints: (points: Set<number> | ((prev: Set<number>) => Set<number>)) => void;
  setDraggedPointIndex: (index: number | null) => void;
  setDraggedControlPoint: (point: { pointIndex: number; controlIndex: number } | null) => void;
  setIsDisconnectedMode: (mode: boolean) => void;
  isDisconnectedMode: boolean;
  setGhostPoint: (point: GhostPoint | null) => void;
  setNewPointDragIndex: (index: number | null) => void;
  setIsDraggingNewBezier: (dragging: boolean) => void;
  setGhostPointDragInfo: (
    info:
      | {
          ghostPoint: GhostPoint;
          isDragging: boolean;
          dragDistance: number;
        }
      | null
      | ((
          prev: {
            ghostPoint: GhostPoint;
            isDragging: boolean;
            dragDistance: number;
          } | null,
        ) => {
          ghostPoint: GhostPoint;
          isDragging: boolean;
          dragDistance: number;
        } | null),
  ) => void;
  // setCursorPosition: (position: Point | null) => void; // Removed - now handled via ref
  setVisibleControlPoints: (points: Set<number> | ((prev: Set<number>) => Set<number>)) => void;
  setIsPathClosed: (closed: boolean) => void;
  isDragging: React.MutableRefObject<boolean>;
  lastPos: React.MutableRefObject<{
    x: number;
    y: number;
    originalX?: number;
    originalY?: number;
    originalControlPoint1?: { x: number; y: number };
    originalControlPoint2?: { x: number; y: number };
  } | null>;
  lastCallbackTime: React.MutableRefObject<number>;
  isDrawingMode: boolean;
  allowClose: boolean;
  allowBezier: boolean;
  isPathClosed: boolean;
  transform: { zoom: number; offsetX: number; offsetY: number };
  fitScale: number;
  x: number;
  y: number;
  ghostPoint: GhostPoint | null;
  ghostPointDragInfo: {
    ghostPoint: GhostPoint;
    isDragging: boolean;
    dragDistance: number;
  } | null;
  draggedPointIndex: number | null;
  draggedControlPoint: { pointIndex: number; controlIndex: number } | null;
  isDraggingNewBezier: boolean;
  newPointDragIndex: number | null;
  cursorPosition: Point | null;
  visibleControlPoints: Set<number>;
  onPointsChange?: (points: BezierPoint[]) => void;
  onPointAdded?: (point: BezierPoint, index: number) => void;
  onPointRemoved?: (point: BezierPoint, index: number) => void;
  onPointEdited?: (point: BezierPoint, index: number) => void;
  onPointRepositioned?: (point: BezierPoint, index: number) => void;
  onPointConverted?: (point: BezierPoint, index: number, toBezier: boolean) => void;
  onPathShapeChanged?: (points: BezierPoint[]) => void;
  onPointSelected?: (pointIndex: number | null) => void;
  onFinish?: (e: KonvaEventObject<MouseEvent>) => void;
  onGhostPointClick?: (ghostPoint: { x: number; y: number; prevPointId: string; nextPointId: string }) => void;
  onMouseDown?: (e: KonvaEventObject<MouseEvent>) => void;
  onMouseMove?: (e: KonvaEventObject<MouseEvent>) => void;
  onMouseUp?: (e?: KonvaEventObject<MouseEvent>) => void;
  onClick?: (e: KonvaEventObject<MouseEvent>) => void;
  notifyTransformationComplete?: () => void;
  canAddMorePoints?: () => boolean;
  maxPoints?: number;
  minPoints?: number; // Add minPoints property
  skeletonEnabled?: boolean;
  getAllPoints?: () => BezierPoint[];
  getPointInfo?: (globalIndex: number) => {
    pathType: "main" | "branch" | "drawing";
    pathIndex: number;
    point: BezierPoint;
    branchId?: string;
  } | null;
  updatePointByGlobalIndex?: (globalIndex: number, updatedPoint: BezierPoint) => void;
  lastAddedPointId?: string | null;
  activePointId?: string | null;
  setActivePointId?: (id: string | null) => void;
  setLastAddedPointId?: (pointId: string | null) => void;
  isTransforming?: boolean;
  selected?: boolean;
  disabled?: boolean;
  transformMode?: boolean;
  disableInternalPointAddition?: boolean;
  handleTransformStart?: () => void;
  handleTransformEnd?: (e?: KonvaEventObject<MouseEvent>) => void;
  pointCreationManager?: {
    isCreating: () => boolean;
    createRegularPointAt: (x: number, y: number, prevPointId?: string) => boolean;
    createBezierPointAt: (
      x: number,
      y: number,
      controlPoint1?: { x: number; y: number },
      controlPoint2?: { x: number; y: number },
      prevPointId?: string,
      isDisconnected?: boolean,
    ) => boolean;
    insertPointBetween: (
      x: number,
      y: number,
      prevPointId: string,
      nextPointId: string,
      type?: PointType,
      controlPoint1?: { x: number; y: number },
      controlPoint2?: { x: number; y: number },
    ) => { success: boolean; newPointIndex?: number };
    createPointFromGhostDrag: (
      ghostPoint: { x: number; y: number; segmentIndex: number },
      dragDistance: number,
    ) => boolean;
  };
}
 
export interface EventHandlers {
  handleLayerMouseDown: (e: KonvaEventObject<MouseEvent>) => void;
  handleLayerClick: (e: KonvaEventObject<MouseEvent>) => void;
  handleLayerMouseMove: (e: KonvaEventObject<MouseEvent>) => void;
  handleLayerMouseUp: (e?: KonvaEventObject<MouseEvent>) => void;
}