diff --git a/core/component_manager.ts b/core/component_manager.ts index b9654c94e..fb89c38ae 100644 --- a/core/component_manager.ts +++ b/core/component_manager.ts @@ -224,6 +224,16 @@ export class ComponentManager { } export namespace ComponentManager { + export enum ComponentWeight { + // The toolbox weight is lower (higher precedence) than the flyout, so that + // if both are under the pointer, the toolbox takes precedence even though + // the flyout's drag target area is large enough to include the toolbox. + TOOLBOX_WEIGHT = 0, + FLYOUT_WEIGHT = 1, + TRASHCAN_WEIGHT = 2, + ZOOM_CONTROLS_WEIGHT = 3, + } + /** An object storing component information. */ export interface ComponentDatum { component: IComponent; @@ -232,4 +242,6 @@ export namespace ComponentManager { } } +export type ComponentWeight = ComponentManager.ComponentWeight; +export const ComponentWeight = ComponentManager.ComponentWeight; export type ComponentDatum = ComponentManager.ComponentDatum; diff --git a/core/flyout_base.ts b/core/flyout_base.ts index 18f84480c..27ad0abf5 100644 --- a/core/flyout_base.ts +++ b/core/flyout_base.ts @@ -427,7 +427,7 @@ export abstract class Flyout targetWorkspace.getComponentManager().addComponent({ component: this, - weight: 1, + weight: ComponentManager.ComponentWeight.FLYOUT_WEIGHT, capabilities: [ ComponentManager.Capability.AUTOHIDEABLE, ComponentManager.Capability.DELETE_AREA, diff --git a/core/toolbox/toolbox.ts b/core/toolbox/toolbox.ts index e0fb62e23..578a62b0e 100644 --- a/core/toolbox/toolbox.ts +++ b/core/toolbox/toolbox.ts @@ -157,7 +157,7 @@ export class Toolbox themeManager.subscribe(this.HtmlDiv, 'toolboxForegroundColour', 'color'); this.workspace_.getComponentManager().addComponent({ component: this, - weight: 1, + weight: ComponentManager.ComponentWeight.TOOLBOX_WEIGHT, capabilities: [ ComponentManager.Capability.AUTOHIDEABLE, ComponentManager.Capability.DELETE_AREA, diff --git a/core/trashcan.ts b/core/trashcan.ts index 050f506a4..d4629dcae 100644 --- a/core/trashcan.ts +++ b/core/trashcan.ts @@ -247,7 +247,7 @@ export class Trashcan } this.workspace.getComponentManager().addComponent({ component: this, - weight: 1, + weight: ComponentManager.ComponentWeight.TRASHCAN_WEIGHT, capabilities: [ ComponentManager.Capability.AUTOHIDEABLE, ComponentManager.Capability.DELETE_AREA, diff --git a/core/zoom_controls.ts b/core/zoom_controls.ts index 6534c7322..c93d99de4 100644 --- a/core/zoom_controls.ts +++ b/core/zoom_controls.ts @@ -116,7 +116,7 @@ export class ZoomControls implements IPositionable { init() { this.workspace.getComponentManager().addComponent({ component: this, - weight: 2, + weight: ComponentManager.ComponentWeight.ZOOM_CONTROLS_WEIGHT, capabilities: [ComponentManager.Capability.POSITIONABLE], }); this.initialized = true;