165 lines
4.2 KiB
TypeScript
165 lines
4.2 KiB
TypeScript
/// <reference types="node" />
|
|
import { Container, Graphics, Point, Rectangle, Text } from 'pixi.js';
|
|
import { IGraphicScene } from '../app';
|
|
import { OutOfBound } from '../utils';
|
|
import { MenuCompletionItemStyle, MenuCompletionOptions, MenuCompletionStyleOptions, MenuGroupOptions, MenuItemOptions, MenuOptions } from './Menu';
|
|
export declare class ContextMenuPlugin {
|
|
app: IGraphicScene;
|
|
contextMenuMap: Map<string, ContextMenu>;
|
|
constructor(app: IGraphicScene);
|
|
registerMenu(menu: ContextMenu): void;
|
|
/**
|
|
* 获取视口屏幕宽度
|
|
*/
|
|
get screenWidth(): number;
|
|
/**
|
|
* 获取视口屏幕高度
|
|
*/
|
|
get screenHeight(): number;
|
|
/**
|
|
* 打开菜单
|
|
* @param menu
|
|
* @param global
|
|
*/
|
|
open(menu: ContextMenu, global: Point): void;
|
|
/**
|
|
* 关闭菜单
|
|
* @param menu
|
|
*/
|
|
close(menu: ContextMenu): void;
|
|
/**
|
|
* 关闭所有菜单
|
|
*/
|
|
closeAll(): void;
|
|
/**
|
|
* 越界检查
|
|
* @param menu
|
|
* @param global
|
|
* @returns
|
|
*/
|
|
oob(menu: ContextMenu, global: Point): OutOfBound;
|
|
}
|
|
/**
|
|
* 上下文菜单,多级嵌套
|
|
*/
|
|
export declare class ContextMenu extends Container {
|
|
_plugin?: ContextMenuPlugin;
|
|
parentMenuItem?: ContextMenuItem;
|
|
openedSubMenu?: ContextMenu;
|
|
menuOptions: MenuCompletionOptions;
|
|
opened: boolean;
|
|
bg: Graphics;
|
|
title?: Text;
|
|
groups: MenuGroup[];
|
|
private padding;
|
|
_active: boolean;
|
|
timeoutCloseHandle?: NodeJS.Timeout;
|
|
constructor(menuOptions: MenuOptions, parentMenuItem?: ContextMenuItem);
|
|
static init(options: MenuOptions): ContextMenu;
|
|
get style(): MenuCompletionStyleOptions;
|
|
/**
|
|
* 父级菜单
|
|
*/
|
|
get parentMenu(): ContextMenu | undefined;
|
|
/**
|
|
* 最顶级菜单
|
|
*/
|
|
get rootMenu(): ContextMenu;
|
|
/**
|
|
* 是否存在激活的菜单项
|
|
* @returns
|
|
*/
|
|
hasActiveItem(): boolean;
|
|
get active(): boolean;
|
|
set active(v: boolean);
|
|
onActiveChanged(): void;
|
|
setOptions(menuOptions: MenuOptions): void;
|
|
/**
|
|
* 初始化
|
|
*/
|
|
init(): void;
|
|
initGroups(): void;
|
|
initTitle(): void;
|
|
private calculateBorderInfo;
|
|
updateBg(): void;
|
|
update(): void;
|
|
get menuName(): string;
|
|
get plugin(): ContextMenuPlugin;
|
|
set plugin(v: ContextMenuPlugin);
|
|
/**
|
|
* 显示菜单
|
|
*/
|
|
open(global: Point): void;
|
|
/**
|
|
* 关闭菜单
|
|
*/
|
|
close(): void;
|
|
/**
|
|
* 打开子菜单
|
|
* @param subMenu
|
|
* @param global
|
|
*/
|
|
private openSub;
|
|
}
|
|
declare class MenuGroup extends Container {
|
|
private gutter;
|
|
config: MenuGroupOptions;
|
|
menu: ContextMenu;
|
|
items: ContextMenuItem[];
|
|
constructor(menu: ContextMenu, config: MenuGroupOptions);
|
|
private init;
|
|
hasActiveItem(): boolean;
|
|
get maxItemNameWidth(): number;
|
|
get maxShortcutWidth(): number;
|
|
get totalGutter(): number;
|
|
get totalHeight(): number;
|
|
update(): void;
|
|
updateItemBox(maxItemWidth: number): void;
|
|
}
|
|
/**
|
|
* 菜单项
|
|
*/
|
|
declare class ContextMenuItem extends Container {
|
|
menu: ContextMenu;
|
|
config: MenuItemOptions;
|
|
/**
|
|
* 名称文本
|
|
*/
|
|
nameText: Text;
|
|
/**
|
|
* 快捷键文本
|
|
*/
|
|
shortcutKeyText?: Text;
|
|
private gutter;
|
|
arrowText?: Text;
|
|
box: Graphics;
|
|
subMenu?: ContextMenu;
|
|
_active: boolean;
|
|
constructor(menu: ContextMenu, config: MenuItemOptions);
|
|
registerEventHandler(): void;
|
|
get active(): boolean;
|
|
set active(v: boolean);
|
|
onActiveChanged(): void;
|
|
get textWidth(): number;
|
|
get nameGraphic(): Text;
|
|
get totalHeight(): number;
|
|
get nameBounds(): Rectangle;
|
|
get shortcutKeyBounds(): Rectangle;
|
|
get style(): MenuCompletionItemStyle;
|
|
private checkPadding;
|
|
private toWholePadding;
|
|
get paddingTop(): number;
|
|
get paddingBottom(): number;
|
|
get paddingLeft(): number;
|
|
get paddingRight(): number;
|
|
get hoverColor(): string;
|
|
get fontSize(): number;
|
|
get fontColor(): string;
|
|
initShortcutKeyText(): Text | undefined;
|
|
initSubMenu(): void;
|
|
updateBackground(width: number, height: number): void;
|
|
updateBox(width: number, height: number): void;
|
|
update(): void;
|
|
}
|
|
export {};
|