mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-28 03:24:43 +08:00
Mergin better performance branch
This commit is contained in:
@@ -1,38 +1,47 @@
|
||||
// @ts-check
|
||||
|
||||
import FastSelectionModel from "../selection/FastSelectionModel"
|
||||
import IElement from "./IElement"
|
||||
import IFromToPositionedElement from "./IFromToPositionedElement"
|
||||
import SelectorTemplate from "../template/SelectorTemplate"
|
||||
|
||||
/**
|
||||
* @extends {IElement<Object, SelectorTemplate>}
|
||||
* @extends {IFromToPositionedElement<Object, SelectorTemplate>}
|
||||
*/
|
||||
export default class SelectorElement extends IElement {
|
||||
export default class SelectorElement extends IFromToPositionedElement {
|
||||
|
||||
constructor() {
|
||||
super({}, new SelectorTemplate())
|
||||
this.selectionModel = null
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Number[]} initialPosition
|
||||
*/
|
||||
startSelecting(initialPosition) {
|
||||
this.template.applyStartSelecting(this, initialPosition)
|
||||
this.selectionModel = new FastSelectionModel(initialPosition, this.blueprint.getNodes(), this.blueprint.nodeBoundariesSupplier, this.blueprint.nodeSelectToggleFunction)
|
||||
beginSelect(initialPosition) {
|
||||
this.blueprint.selecting = true
|
||||
this.setBothLocations(initialPosition)
|
||||
this.selectionModel = new FastSelectionModel(
|
||||
initialPosition,
|
||||
this.blueprint.getNodes(),
|
||||
this.blueprint.nodeBoundariesSupplier,
|
||||
this.blueprint.nodeSelectToggleFunction
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Number[]} finalPosition
|
||||
*/
|
||||
doSelecting(finalPosition) {
|
||||
this.template.applyDoSelecting(this, finalPosition)
|
||||
this.selectionModel.selectTo(finalPosition)
|
||||
selectTo(finalPosition) {
|
||||
/** @type {FastSelectionModel} */ (this.selectionModel)
|
||||
.selectTo(finalPosition)
|
||||
this.finaPositionX = finalPosition[0]
|
||||
this.finaPositionY = finalPosition[1]
|
||||
}
|
||||
|
||||
finishSelecting() {
|
||||
this.template.applyFinishSelecting(this)
|
||||
endSelect() {
|
||||
this.blueprint.selecting = false
|
||||
this.selectionModel = null
|
||||
this.initialPositionX = 0
|
||||
this.initialPositionY = 0
|
||||
this.finaPositionX = 0
|
||||
this.finaPositionY = 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user