框架代码同步
This commit is contained in:
parent
73379f4bd3
commit
cc077e3f21
@ -1 +1 @@
|
||||
Subproject commit 7e9c9eb31176294726103306dcca61b80b896cf7
|
||||
Subproject commit c66f841526d22af7dcb8ce768ad96488f13468c3
|
@ -15,6 +15,7 @@ import {
|
||||
IGraphicStorage,
|
||||
IJlCanvas,
|
||||
} from './JlGraphicApp';
|
||||
import { GraphicDataUpdateOperation } from './BasicOperation';
|
||||
|
||||
/**
|
||||
* 实例化图形app
|
||||
@ -34,7 +35,7 @@ export function newDrawApp(options: DrawAppOptions): IDrawApp {
|
||||
return new JlDrawApp(options);
|
||||
}
|
||||
|
||||
export { AppConsts, GraphicDrawAssistant };
|
||||
export { AppConsts, GraphicDrawAssistant, GraphicDataUpdateOperation };
|
||||
export type {
|
||||
DrawAssistant,
|
||||
ICanvasProperties,
|
||||
|
@ -1,5 +1,11 @@
|
||||
import { DisplayObject, FederatedMouseEvent, Graphics, Point } from 'pixi.js';
|
||||
import { IGraphicScene } from '../app';
|
||||
import {
|
||||
Color,
|
||||
DisplayObject,
|
||||
FederatedMouseEvent,
|
||||
Graphics,
|
||||
Point,
|
||||
} from 'pixi.js';
|
||||
import { ICanvasProperties, IGraphicScene } from '../app';
|
||||
import { JlGraphic } from '../core';
|
||||
import {
|
||||
AppDragEvent,
|
||||
@ -14,10 +20,6 @@ export interface IMouseToolOptions {
|
||||
* 是否启用框选,默认启用
|
||||
*/
|
||||
boxSelect?: boolean;
|
||||
/**
|
||||
* 框选框的颜色--默认黑色
|
||||
*/
|
||||
boxSelectColor?: string;
|
||||
/**
|
||||
* 是否启用视口拖拽(默认右键),默认启用
|
||||
*/
|
||||
@ -36,7 +38,6 @@ class CompleteMouseToolOptions implements IMouseToolOptions {
|
||||
boxSelect: boolean;
|
||||
viewportDrag: boolean;
|
||||
wheelZoom: boolean;
|
||||
boxSelectColor?: string;
|
||||
selectFilter?: GraphicSelectFilter | undefined;
|
||||
constructor() {
|
||||
this.boxSelect = true;
|
||||
@ -53,7 +54,6 @@ class CompleteMouseToolOptions implements IMouseToolOptions {
|
||||
if (options.wheelZoom != undefined) {
|
||||
this.wheelZoom = options.wheelZoom;
|
||||
}
|
||||
this.boxSelectColor = options.boxSelectColor;
|
||||
this.selectFilter = options.selectFilter;
|
||||
}
|
||||
}
|
||||
@ -66,6 +66,7 @@ export class CommonMouseTool extends AppInteractionPlugin {
|
||||
static SelectBox = '__select_box';
|
||||
options: CompleteMouseToolOptions;
|
||||
box: Graphics;
|
||||
_boxLineColor: Color;
|
||||
leftDownTarget: DisplayObject | null = null;
|
||||
|
||||
drag = false;
|
||||
@ -73,16 +74,19 @@ export class CommonMouseTool extends AppInteractionPlugin {
|
||||
|
||||
rightTarget: DisplayObject | null = null;
|
||||
|
||||
constructor(graphicApp: IGraphicScene) {
|
||||
super(CommonMouseTool.Name, graphicApp);
|
||||
constructor(scene: IGraphicScene) {
|
||||
super(CommonMouseTool.Name, scene);
|
||||
this.options = new CompleteMouseToolOptions();
|
||||
|
||||
this.box = new Graphics();
|
||||
this._boxLineColor = new Color();
|
||||
|
||||
scene.canvas.on('dataupdate', this.updateBoxLineColor, this);
|
||||
this.box.name = CommonMouseTool.SelectBox;
|
||||
this.box.visible = false;
|
||||
this.app.canvas.addAssistantAppends(this.box);
|
||||
|
||||
graphicApp.on('options-update', (options) => {
|
||||
scene.on('options-update', (options) => {
|
||||
if (options.mouseToolOptions) {
|
||||
this.options.update(options.mouseToolOptions);
|
||||
if (this.isActive()) {
|
||||
@ -97,6 +101,13 @@ export class CommonMouseTool extends AppInteractionPlugin {
|
||||
return new CommonMouseTool(app);
|
||||
}
|
||||
|
||||
private updateBoxLineColor(cp: ICanvasProperties) {
|
||||
// 根据画布背景调整线色
|
||||
const color = new Color(cp.backgroundColor);
|
||||
const cn = color.toNumber() ^ 0xffffff;
|
||||
this._boxLineColor.setValue(cn);
|
||||
}
|
||||
|
||||
bind(): void {
|
||||
const canvas = this.app.canvas;
|
||||
canvas.on('mousedown', this.onMouseDown, this);
|
||||
@ -294,7 +305,7 @@ export class CommonMouseTool extends AppInteractionPlugin {
|
||||
if (!this.drag) return;
|
||||
// 绘制框选矩形框
|
||||
this.box.clear();
|
||||
this.box.lineStyle({ width: 1, color: this.options.boxSelectColor });
|
||||
this.box.lineStyle({ width: 1, color: this._boxLineColor });
|
||||
const dsx = end.x - start.x;
|
||||
const dsy = end.y - start.y;
|
||||
let { x, y } = start;
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit a65253b7a3685dabe0376caa36bda8b47d675ff7
|
||||
Subproject commit 7aebba13bf04bf2c59df3595c5650a96e616bef4
|
Loading…
Reference in New Issue
Block a user