@itwin/core-frontend
Version:
iTwin.js frontend components
232 lines • 10.1 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Tools
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToolAssistance = exports.ToolAssistanceInputMethod = exports.ToolAssistanceImage = void 0;
const IModelApp_1 = require("../IModelApp");
const Tool_1 = require("./Tool");
/** Tool Assistance known images
* @public
* @extensions
*/
var ToolAssistanceImage;
(function (ToolAssistanceImage) {
/** When Keyboard is specified, ToolAssistanceInstruction.keyboardInfo should be set. */
ToolAssistanceImage[ToolAssistanceImage["Keyboard"] = 0] = "Keyboard";
/** Plus sign */
ToolAssistanceImage[ToolAssistanceImage["AcceptPoint"] = 1] = "AcceptPoint";
/** Cursor image with click symbol */
ToolAssistanceImage[ToolAssistanceImage["CursorClick"] = 2] = "CursorClick";
/** Mouse image with darkened left button */
ToolAssistanceImage[ToolAssistanceImage["LeftClick"] = 3] = "LeftClick";
/** Mouse image with darkened right button */
ToolAssistanceImage[ToolAssistanceImage["RightClick"] = 4] = "RightClick";
/** Mouse image with darkened scroll wheel */
ToolAssistanceImage[ToolAssistanceImage["MouseWheel"] = 5] = "MouseWheel";
/** Mouse image with darkened left button and left/right arrows */
ToolAssistanceImage[ToolAssistanceImage["LeftClickDrag"] = 6] = "LeftClickDrag";
/** Mouse image with darkened right button and left/right arrows */
ToolAssistanceImage[ToolAssistanceImage["RightClickDrag"] = 7] = "RightClickDrag";
/** Mouse image with darkened scroll wheel and left/right arrows */
ToolAssistanceImage[ToolAssistanceImage["MouseWheelClickDrag"] = 8] = "MouseWheelClickDrag";
/** Touch image with single finger tapping once */
ToolAssistanceImage[ToolAssistanceImage["OneTouchTap"] = 9] = "OneTouchTap";
/** Touch image with single finger tapping twice */
ToolAssistanceImage[ToolAssistanceImage["OneTouchDoubleTap"] = 10] = "OneTouchDoubleTap";
/** Touch image with single finger dragging */
ToolAssistanceImage[ToolAssistanceImage["OneTouchDrag"] = 11] = "OneTouchDrag";
/** Touch image with two fingers tapping once */
ToolAssistanceImage[ToolAssistanceImage["TwoTouchTap"] = 12] = "TwoTouchTap";
/** Touch image with two fingers dragging */
ToolAssistanceImage[ToolAssistanceImage["TwoTouchDrag"] = 13] = "TwoTouchDrag";
/** Touch image with two fingers pinching */
ToolAssistanceImage[ToolAssistanceImage["TwoTouchPinch"] = 14] = "TwoTouchPinch";
/** Touch cursor image with single finger tapping once */
ToolAssistanceImage[ToolAssistanceImage["TouchCursorTap"] = 15] = "TouchCursorTap";
/** Touch cursor image with single finger dragging */
ToolAssistanceImage[ToolAssistanceImage["TouchCursorDrag"] = 16] = "TouchCursorDrag";
})(ToolAssistanceImage || (exports.ToolAssistanceImage = ToolAssistanceImage = {}));
/** Input Method for Tool Assistance instruction
* @public
* @extensions
*/
var ToolAssistanceInputMethod;
(function (ToolAssistanceInputMethod) {
/** Instruction applies to both touch & mouse input methods */
ToolAssistanceInputMethod[ToolAssistanceInputMethod["Both"] = 0] = "Both";
/** Instruction applies to only mouse input method */
ToolAssistanceInputMethod[ToolAssistanceInputMethod["Mouse"] = 1] = "Mouse";
/** Instruction applies to only touch input method */
ToolAssistanceInputMethod[ToolAssistanceInputMethod["Touch"] = 2] = "Touch";
})(ToolAssistanceInputMethod || (exports.ToolAssistanceInputMethod = ToolAssistanceInputMethod = {}));
/** Tool Assistance helper methods.
* @public
* @extensions
*/
class ToolAssistance {
/** Up key symbol. */
static upSymbol = "\u2bc5";
/** Down key symbol. */
static downSymbol = "\u2bc6";
/** Left key symbol. */
static leftSymbol = "\u2bc7";
/** Right key symbol. */
static rightSymbol = "\u2bc8";
/** Keyboard info for Arrow keys. */
static arrowKeyboardInfo = {
keys: [ToolAssistance.upSymbol],
bottomKeys: [ToolAssistance.leftSymbol, ToolAssistance.downSymbol, ToolAssistance.rightSymbol],
};
static translateKey(key) { return IModelApp_1.IModelApp.localization.getLocalizedString(`${Tool_1.CoreTools.namespace}:toolAssistance.${key}`); }
static translateTouch(cursor) { return IModelApp_1.IModelApp.localization.getLocalizedString(`${Tool_1.CoreTools.namespace}:touchCursor.${cursor}`); }
/** Return the translated string for the specified main instruction key */
static translatePrompt(key) {
return IModelApp_1.IModelApp.localization.getLocalizedString(`${Tool_1.CoreTools.tools}ElementSet.Prompts.${key}`);
}
/** Return the translated string for the specified input instruction key */
static translateInput(key) {
return IModelApp_1.IModelApp.localization.getLocalizedString(`${Tool_1.CoreTools.tools}ElementSet.Inputs.${key}`);
}
/** Alt key text. */
static get altKey() {
return this.translateKey("altKey");
}
/** Ctrl key text. */
static get ctrlKey() {
return this.translateKey("ctrlKey");
}
/** Shift key text. */
static get shiftKey() {
return this.translateKey("shiftKey");
}
/** Inputs text. */
static get inputsLabel() {
return this.translateKey("inputs");
}
/** Keyboard info for Alt key. */
static get altKeyboardInfo() {
return { keys: [ToolAssistance.altKey] };
}
/** Keyboard info for Ctrl key. */
static get ctrlKeyboardInfo() {
return { keys: [ToolAssistance.ctrlKey] };
}
/** Shift key symbol. */
static shiftSymbol = "\u21e7";
/** Keyboard info for Shift key with symbol. */
static get shiftKeyboardInfo() {
return { keys: [`${ToolAssistance.shiftSymbol} ${ToolAssistance.shiftKey}`] };
}
/** Keyboard info for Shift key without symbol. */
static get shiftKeyboardInfoNoSymbol() {
return { keys: [ToolAssistance.shiftKey] };
}
/** Keyboard info for Shift key symbol. */
static get shiftSymbolKeyboardInfo() {
return { keys: [` ${ToolAssistance.shiftKey} `] };
}
/** Ctrl key symbol. */
static ctrlSymbol = "\u2038";
/** Keyboard info for Ctrl key symbol. */
static get ctrlSymbolKeyboardInfo() {
return { keys: [ToolAssistance.ctrlSymbol] };
}
/** Alt key symbol. */
static altSymbol = "\u2387";
/** Keyboard info for Alt key symbol. */
static get altSymbolKeyboardInfo() {
return { keys: [ToolAssistance.altSymbol] };
}
/** Creates a [[ToolAssistanceInstruction]].
*/
static createInstruction(image, text, isNew, inputMethod, keyboardInfo) {
if (inputMethod === undefined)
inputMethod = ToolAssistanceInputMethod.Both;
const instruction = {
image,
text,
keyboardInfo,
isNew,
inputMethod,
};
return instruction;
}
/** Creates a [[ToolAssistanceInstruction]] with a [[ToolAssistanceKeyboardInfo]].
*/
static createKeyboardInstruction(keyboardInfo, text, isNew, inputMethod) {
if (inputMethod === undefined)
inputMethod = ToolAssistanceInputMethod.Mouse;
const instruction = {
image: ToolAssistanceImage.Keyboard,
text,
keyboardInfo,
isNew,
inputMethod,
};
return instruction;
}
/** Creates a [[ToolAssistanceInstruction]] with a modifier key and an image.
*/
static createModifierKeyInstruction(modifierKey, image, text, isNew, inputMethod) {
if (inputMethod === undefined)
inputMethod = ToolAssistanceInputMethod.Both;
const keyboardInfo = { keys: [modifierKey] };
const instruction = {
image,
text,
keyboardInfo,
isNew,
inputMethod,
};
return instruction;
}
/** Creates a [[ToolAssistanceKeyboardInfo]].
*/
static createKeyboardInfo(keys, bottomKeys) {
const keyboardInfo = {
keys,
bottomKeys,
};
return keyboardInfo;
}
/** Creates instructions for interaction with the touch cursor that are appended to the supplied [[ToolAssistanceInstruction]] array.
*/
static createTouchCursorInstructions(instructions) {
const accuSnap = IModelApp_1.IModelApp.accuSnap;
if (undefined === accuSnap.touchCursor && accuSnap.wantVirtualCursor) {
instructions.push(ToolAssistance.createInstruction(ToolAssistanceImage.OneTouchTap, this.translateTouch("Activate"), false, ToolAssistanceInputMethod.Touch));
return true;
}
else if (undefined !== accuSnap.touchCursor) {
instructions.push(ToolAssistance.createInstruction(ToolAssistanceImage.TouchCursorDrag, this.translateTouch("IdentifyPoint"), false, ToolAssistanceInputMethod.Touch));
instructions.push(ToolAssistance.createInstruction(ToolAssistanceImage.TouchCursorTap, this.translateTouch("AcceptPoint"), false, ToolAssistanceInputMethod.Touch));
return true;
}
return false;
}
/** Creates a [[ToolAssistanceSection]].
*/
static createSection(instructions, label) {
const section = {
instructions,
label,
};
return section;
}
/** Creates a [[ToolAssistanceInstructions]].
*/
static createInstructions(mainInstruction, sections) {
const instructions = {
mainInstruction,
sections,
};
return instructions;
}
}
exports.ToolAssistance = ToolAssistance;
//# sourceMappingURL=ToolAssistance.js.map
;