import { observable, action, makeObservable } from 'mobx'; import { Gestures } from '../../pen-gestures/GestureTypes'; export enum freeformScrollMode { Pan = 'pan', Zoom = 'zoom', } export class SnappingManager { // eslint-disable-next-line no-use-before-define private static _manager: SnappingManager; private static get Instance() { return SnappingManager._manager ?? new SnappingManager(); } @observable _longPress = false; @observable _shiftKey = false; @observable _ctrlKey = false; @observable _metaKey = false; @observable _hideUI = false; @observable _showPresPaths = false; @observable _isLinkFollowing = false; @observable _isDragging: boolean = false; @observable _isResizing: string | undefined = undefined; // the string is the Id of the document being resized @observable _canEmbed: boolean = false; @observable _horizSnapLines: number[] = []; @observable _vertSnapLines: number[] = []; @observable _exploreMode = false; @observable _userPanned = false; @observable _serverVersion: string = ''; @observable _lastBtnId: string = ''; @observable _propertyWid: number = 0; @observable _printToConsole: boolean = false; @observable _hideDecorations: boolean = false; @observable _keepGestureMode: boolean = false; // for whether primitive selection enters a one-shot or persistent mode @observable _inkShape: Gestures | undefined = undefined; @observable _chatVisible: boolean = false; @observable _userBackgroundColor: string | undefined = undefined; @observable _userVariantColor: string | undefined = undefined; @observable _userColor: string | undefined = undefined; private constructor() { SnappingManager._manager = this; makeObservable(this); } @action public static clearSnapLines = () => { this.Instance._vertSnapLines.length = this.Instance._horizSnapLines.length = 0; }; @action public static addSnapLines = (horizLines: number[], vertLines: number[]) => { this.Instance._horizSnapLines.push(...horizLines); this.Instance._vertSnapLines.push(...vertLines); }; public static get userBackgroundColor() { return this.Instance._userBackgroundColor; } // prettier-ignore public static get userVariantColor() { return this.Instance._userVariantColor; } // prettier-ignore public static get userColor() { return this.Instance._userColor; } // prettier-ignore public static get HorizSnapLines() { return this.Instance._horizSnapLines; } // prettier-ignore public static get VertSnapLines() { return this.Instance._vertSnapLines; } // prettier-ignore public static get LongPress() { return this.Instance._longPress; } // prettier-ignore public static get ShiftKey() { return this.Instance._shiftKey; } // prettier-ignore public static get CtrlKey() { return this.Instance._ctrlKey; } // prettier-ignore public static get MetaKey() { return this.Instance._metaKey; } // prettier-ignore public static get HideUI() { return this.Instance._hideUI; } // prettier-ignore public static get ShowPresPaths() { return this.Instance._showPresPaths; } // prettier-ignore public static get IsLinkFollowing(){ return this.Instance._isLinkFollowing; } // prettier-ignore public static get IsDragging() { return this.Instance._isDragging; } // prettier-ignore public static get IsResizing() { return this.Instance._isResizing; } // prettier-ignore public static get CanEmbed() { return this.Instance._canEmbed; } // prettier-ignore public static get ExploreMode() { return this.Instance._exploreMode; } // prettier-ignore public static get UserPanned() { return this.Instance._userPanned; } // prettier-ignore public static get ServerVersion() { return this.Instance._serverVersion; } // prettier-ignore public static get LastPressedBtn() { return this.Instance._lastBtnId; } // prettier-ignore public static get PropertiesWidth(){ return this.Instance._propertyWid; } // prettier-ignore public static get PrintToConsole() { return this.Instance._printToConsole; } // prettier-ignore public static get HideDecorations(){ return this.Instance._hideDecorations; } // prettier-ignore public static get KeepGestureMode(){ return this.Instance._keepGestureMode; } // prettier-ignore public static get InkShape() { return this.Instance._inkShape; } // prettier-ignore public static get ChatVisible() { return this.Instance._chatVisible; } // prettier-ignore public static SetUserBackgroundColor = action((color: string) => (this.Instance._userBackgroundColor = color)); // prettier-ignore public static SetUserVariantColor = action((color: string) => (this.Instance._userVariantColor = color)); // prettier-ignore public static SetUserColor = action((color: string) => (this.Instance._userColor = color)); // prettier-ignore public static SetLongPress = action((press: boolean)=> (this.Instance._longPress = press)); // prettier-ignore public static SetShiftKey = action((down: boolean) => (this.Instance._shiftKey = down)); // prettier-ignore public static SetCtrlKey = action((down: boolean) => (this.Instance._ctrlKey = down)); // prettier-ignore public static SetMetaKey = action((down: boolean) => (this.Instance._metaKey = down)); // prettier-ignore public static SetHideUI = action((vis: boolean) => (this.Instance._hideUI = vis)); // prettier-ignore public static SetShowPresPaths = action((paths:boolean) => (this.Instance._showPresPaths = paths)); // prettier-ignore public static SetIsLinkFollowing = action((follow:boolean)=> (this.Instance._isLinkFollowing = follow)); // prettier-ignore public static SetIsDragging = action((drag: boolean) => (this.Instance._isDragging = drag)); // prettier-ignore public static SetIsResizing = action((docid?:string) => (this.Instance._isResizing = docid)); // prettier-ignore public static SetCanEmbed = action((embed:boolean) => (this.Instance._canEmbed = embed)); // prettier-ignore public static SetExploreMode = action((state:boolean) => (this.Instance._exploreMode = state)); // prettier-ignore public static TriggerUserPanned = action(() => (this.Instance._userPanned = !this.Instance._userPanned)); // prettier-ignore public static SetServerVersion = action((version:string)=> (this.Instance._serverVersion = version)); // prettier-ignore public static SetLastPressedBtn = action((id:string) => (this.Instance._lastBtnId = id)); // prettier-ignore public static SetPropertiesWidth = action((wid:number) => (this.Instance._propertyWid = wid)); // prettier-ignore public static SetPrintToConsole = action((state:boolean) => (this.Instance._printToConsole = state)); // prettier-ignore public static SetHideDecorations = action((state:boolean) => (this.Instance._hideDecorations = state)); // prettier-ignore public static SetKeepGestureMode = action((state:boolean) => (this.Instance._keepGestureMode = state)); // prettier-ignore public static SetInkShape = action((shape?:Gestures)=>(this.Instance._inkShape = shape)); // prettier-ignore public static SetChatVisible = action((vis:boolean) => (this.Instance._chatVisible = vis)); // prettier-ignore public static SettingsStyle: CSSStyleSheet | null; }