|
|
@@ -2,42 +2,28 @@ import { inRevise, onlyId } from "@/utils/shared";
|
|
|
import type { InteractiveFix, InteractiveTo } from "..";
|
|
|
import { LineData, generateUseDraw } from "../line";
|
|
|
import { getBaseItem } from "../util";
|
|
|
-import { getMouseColors } from "@/utils/colors";
|
|
|
-import { SelectionManageBus, UseGetSelectionManage } from "@/core/hook/use-selection";
|
|
|
+import {
|
|
|
+ SelectionManageBus,
|
|
|
+ UseGetSelectionManage,
|
|
|
+} from "@/core/hook/use-selection";
|
|
|
import { useStore } from "@/core/store";
|
|
|
import { EntityShape } from "@/deconstruction";
|
|
|
import { Group } from "konva/lib/Group";
|
|
|
import mitt from "mitt";
|
|
|
import { watch } from "vue";
|
|
|
import { ui18n } from "@/lang";
|
|
|
-import { installGlobalStyle } from "@/core/hook/use-global-style";
|
|
|
+import { defaultStyle } from './attrib'
|
|
|
|
|
|
-export const shapeName = ui18n.t('shape.line.name');
|
|
|
-export const defaultStyle = installGlobalStyle('lineChunk', {
|
|
|
- strokeWidth: 3,
|
|
|
- stroke: "#000000",
|
|
|
- fixed: true,
|
|
|
- dash: [30, 0],
|
|
|
-});
|
|
|
+export const shapeName = ui18n.t("shape.line.name");
|
|
|
|
|
|
export { fixedStrokeOptions } from "./attrib";
|
|
|
-export const useDraw = generateUseDraw('lineChunk');
|
|
|
+export const useDraw = generateUseDraw("lineChunk");
|
|
|
+export { defaultStyle, getMouseStyle } from "./attrib";
|
|
|
|
|
|
-export const getMouseStyle = (data: LineData) => {
|
|
|
- const strokeStatus = getMouseColors(data.stroke || defaultStyle.stroke);
|
|
|
- const strokeWidth = data.strokeWidth || defaultStyle.strokeWidth;
|
|
|
-
|
|
|
- console.log(strokeStatus.hover)
|
|
|
- return {
|
|
|
- default: { stroke: data.stroke || defaultStyle.stroke, strokeWidth },
|
|
|
- hover: { stroke: strokeStatus.hover },
|
|
|
- select: { stroke: strokeStatus.select },
|
|
|
- focus: { stroke: strokeStatus.hover },
|
|
|
- press: { stroke: strokeStatus.press },
|
|
|
- };
|
|
|
-};
|
|
|
-
|
|
|
-export const interactiveFixData: InteractiveFix<'lineChunk'> = ({ data, info }) => {
|
|
|
+export const interactiveFixData: InteractiveFix<"lineChunk"> = ({
|
|
|
+ data,
|
|
|
+ info,
|
|
|
+}) => {
|
|
|
const nv = [...info.consumed, info.cur!];
|
|
|
|
|
|
data.points.length = nv.length;
|
|
|
@@ -72,7 +58,7 @@ export const interactiveFixData: InteractiveFix<'lineChunk'> = ({ data, info })
|
|
|
return data;
|
|
|
};
|
|
|
|
|
|
-export const interactiveToData: InteractiveTo<'lineChunk'> = ({
|
|
|
+export const interactiveToData: InteractiveTo<"lineChunk"> = ({
|
|
|
info,
|
|
|
preset = {},
|
|
|
...args
|
|
|
@@ -94,14 +80,17 @@ export const interactiveToData: InteractiveTo<'lineChunk'> = ({
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-
|
|
|
export const useGetSelectionManage: UseGetSelectionManage = () => {
|
|
|
const store = useStore();
|
|
|
|
|
|
const canSelect = (shape: EntityShape) => {
|
|
|
const id = shape.id();
|
|
|
- const line = store.getTypeItems('lineChunk')[0];
|
|
|
- return !!(id && line.lines.some((item) => item.id === id) && !(shape instanceof Group));
|
|
|
+ const line = store.getTypeItems("lineChunk")[0];
|
|
|
+ return !!(
|
|
|
+ id &&
|
|
|
+ line.lines.some((item) => item.id === id) &&
|
|
|
+ !(shape instanceof Group)
|
|
|
+ );
|
|
|
};
|
|
|
const listener = (shape: EntityShape) => {
|
|
|
const bus: SelectionManageBus = mitt();
|
|
|
@@ -112,7 +101,7 @@ export const useGetSelectionManage: UseGetSelectionManage = () => {
|
|
|
bus.emit("del", shape);
|
|
|
}
|
|
|
},
|
|
|
- { immediate: true }
|
|
|
+ { immediate: true },
|
|
|
);
|
|
|
return { stop, bus };
|
|
|
};
|
|
|
@@ -120,6 +109,5 @@ export const useGetSelectionManage: UseGetSelectionManage = () => {
|
|
|
return { canSelect, listener };
|
|
|
};
|
|
|
|
|
|
-
|
|
|
export type LineChunkData = LineData;
|
|
|
export * from "../line";
|