UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 3.85 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Evented.js";import"../../core/has.js";import"../../core/Logger.js";import{createResolver as i}from"../../core/promiseUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{EditableFlag as s}from"./interfaces.js";import{ManipulatorCollection as r}from"./ManipulatorCollection.js";let n=class extends e.EventedAccessor{constructor(t){super(t),this.manipulators=new r,this.automaticManipulatorSelection=!0,this.hasGrabbedManipulators=!1,this.hasHoveredManipulators=!1,this.firstGrabbedManipulator=null,this.created=!1,this.removeIncompleteOnCancel=!0,this._editableFlags=new Map([[s.MANAGER,!0],[s.USER,!0]]),this._creationFinishedResolver=i()}get active(){return null!=this.view&&this.view.activeTool===this}set visible(t){this._get("visible")!==t&&(this._set("visible",t),this._syncVisible())}get editable(){return this.getEditableFlag(s.USER)}set editable(t){this.setEditableFlag(s.USER,t)}get updating(){return!1}get cursor(){return null}get hasFocusedManipulators(){return this.hasGrabbedManipulators||this.hasHoveredManipulators}destroy(){this.manipulators.destroy(),this._set("view",null)}onAdd(){this._syncVisible()}activate(){null!=this.view&&(this.view.focus(),this.onActivate())}deactivate(){this.onDeactivate()}cancel(){this.emit("cancel")}handleInputEvent(t){this.onInputEvent(t)}handleInputEventAfter(t){this.onInputEventAfter(t)}setEditableFlag(t,e){this._editableFlags.set(t,e),this.manipulators.isToolEditable=this.internallyEditable,this._updateManipulatorAttachment(),t===s.USER&&this.notifyChange("editable"),this.onEditableChange(),this.onManipulatorSelectionChanged()}getEditableFlag(t){return this._editableFlags.get(t)??!1}endDrag(){const t=this.view.inputManager.latestPointerLocation;if(!t)return;let e=!1;this.manipulators.forEach((({manipulator:i})=>{i.dragging&&(e=!0,i.events.emit("drag",{action:"end",start:t,screenPoint:t}))})),e&&(this.view.toolViewManager.activeTool=null)}whenCreated(){return this._creationFinishedResolver.promise}onManipulatorSelectionChanged(){}onActivate(){}onDeactivate(){}onShow(){}onHide(){}onEditableChange(){}onInputEvent(t){}onInputEventAfter(t){}get internallyEditable(){return this.getEditableFlag(s.USER)&&this.getEditableFlag(s.MANAGER)}finishToolCreation(){this.created||this._creationFinishedResolver.resolve(this),this._set("created",!0)}_syncVisible(){if(this.initialized)if(this.visible)this._show();else if(this._hide(),this.active)return void(this.view.activeTool=null)}_show(){this._updateManipulatorAttachment(),this.onShow()}_hide(){this._updateManipulatorAttachment(),this.onHide()}_updateManipulatorAttachment(){this.visible?this.manipulators.attach():this.manipulators.detach()}};t([a({constructOnly:!0})],n.prototype,"view",void 0),t([a({readOnly:!0})],n.prototype,"active",null),t([a({value:!0})],n.prototype,"visible",null),t([a({value:!0})],n.prototype,"editable",null),t([a({readOnly:!0})],n.prototype,"manipulators",void 0),t([a({readOnly:!0})],n.prototype,"updating",null),t([a()],n.prototype,"cursor",null),t([a({readOnly:!0})],n.prototype,"automaticManipulatorSelection",void 0),t([a()],n.prototype,"hasFocusedManipulators",null),t([a()],n.prototype,"hasGrabbedManipulators",void 0),t([a()],n.prototype,"hasHoveredManipulators",void 0),t([a()],n.prototype,"firstGrabbedManipulator",void 0),t([a({readOnly:!0})],n.prototype,"created",void 0),t([a({readOnly:!0})],n.prototype,"removeIncompleteOnCancel",void 0),n=t([o("esri.views.interactive.InteractiveToolBase")],n);export{n as InteractiveToolBase};