import { BasePanel } from "../components/BasePanel"; import { BimViewer } from "../core"; import { ToolbarConfig, ToolbarMenuConfig, ToolbarMenuId } from "./Toolbar.config"; /** * @class Toolbar * @description A customized toolbar. * * For example: * #### Example 1: * Using {@link updateMenu} to modify the toolbar configuration * ```typescript * const toolbar = this.bimViewer.toolbar; * toolbar.updateMenu(ToolbarMenuId.Viewpoint, { onActive: this.handleActive }); * toolbar.updateMenu(ToolbarMenuId.Annotation, { visible: false }); * ``` * * #### Example 2: * Using {@link addMenu} to add a new menu to the toolbar with specific position. * ```typescript * const toolbar = this.bimViewer.toolbar; * toolbar.addMenu( * "newMenu", * { icon: { default: "icon-new" }, menuName: "新菜单", controller: BimTreeController }, * [2, 5] * ); * ``` * * #### Example 3: * Modify the configuration in to custmize the toolbar directly, and then {@link refresh} the whole toolbar. * ```typescript * const toolbar = this.bimViewer.toolbar; * const toolbarGroupConfig = [ * [ToolbarMenuId.OrthoMode, ToolbarMenuId.FullScreen], * [ToolbarMenuId.Measure, ToolbarMenuId.Section], * [ToolbarMenuId.BimTree, ToolbarMenuId.Viewpoint, ToolbarMenuId.Annotation, ToolbarMenuId.Property], * [ToolbarMenuId.Setting, "newMenu"], * ]; * toolbar.toolbarGroupConfig = toolbarGroupConfig; * toolbar.refresh(); * ``` * @internal */ declare class Toolbar { private readonly bimViewer; groupConfig: ToolbarMenuId[][] | string[][]; private element; menuList: Map; menuConfig: ToolbarConfig; constructor(bimViewer: BimViewer, groupConfig?: ToolbarMenuId[][] | string[][]); private init; private initMenuConfig; private createToolbarMenu; /** * @description Modify the menu configuration and update the toolbar. * @param {ToolbarMenuId} menuId * @param {Partial} config * @memberof Toolbar */ updateMenu(menuId: ToolbarMenuId, config: Partial): void; /** * @description Modify the menu configuration and update the toolbar. * @param {{ menuId: ToolbarMenuId; config: Partial }[]} configs * @memberof Toolbar */ updateMenus(configs: { menuId: ToolbarMenuId; config: Partial; }[]): void; /** * @description Add a custmized menu to toolbar. * @param {string} menuId * @param {ToolbarMenuConfig} config * @param {[number, number]} [insertPosition] * @return {*} * @memberof Toolbar */ addMenu(menuId: string, config: ToolbarMenuConfig, insertPosition?: [number, number]): void; setVisibility(visible: boolean): void; isVisible(): boolean; /** * @description Update the whole toolbar element with the current configuration. * @memberof Toolbar */ refresh(): void; destroy(): void; } /** * @internal */ export declare class ToolbarMenu { readonly bimViewer: BimViewer; private readonly menuId; readonly cfg: ToolbarMenuConfig; private eventBus; active: boolean; element: HTMLDivElement; popPanel?: BasePanel; constructor(bimViewer: BimViewer, menuId: string, cfg: ToolbarMenuConfig, parent?: ToolbarMenu); private setTitle; private createButton; setActive(active: boolean): void; } export { Toolbar };