Comparing version 0.12.0-next.9241c35.0 to 0.12.0
@@ -19,3 +19,3 @@ /******************************************************************************** | ||
import { Bounds, Point } from "sprotty-protocol/lib/utils/geometry"; | ||
import { SChildElement, SModelElement, SModelRoot } from "./smodel"; | ||
import { SChildElement, SModelElement, SModelRoot, SParentElement } from "./smodel"; | ||
import { CustomFeatures } from "./smodel-factory"; | ||
@@ -72,2 +72,6 @@ /** | ||
export declare function containsSome(root: SModelRoot, element: SChildElement): boolean; | ||
/** | ||
* Transforms the local bounds all the way up to the root. | ||
*/ | ||
export declare function transformToRootBounds(parent: SParentElement, bounds: Bounds): Bounds; | ||
//# sourceMappingURL=smodel-utils.d.ts.map |
@@ -165,2 +165,13 @@ "use strict"; | ||
exports.containsSome = containsSome; | ||
/** | ||
* Transforms the local bounds all the way up to the root. | ||
*/ | ||
function transformToRootBounds(parent, bounds) { | ||
while (parent instanceof smodel_1.SChildElement) { | ||
bounds = parent.localToParent(bounds); | ||
parent = parent.parent; | ||
} | ||
return bounds; | ||
} | ||
exports.transformToRootBounds = transformToRootBounds; | ||
//# sourceMappingURL=smodel-utils.js.map |
@@ -41,2 +41,3 @@ /******************************************************************************** | ||
wheel(model: SModelRoot, event: WheelEvent): void; | ||
contextMenu(model: SModelRoot, event: MouseEvent): void; | ||
doubleClick(model: SModelRoot, event: MouseEvent): void; | ||
@@ -50,3 +51,3 @@ decorate(vnode: VNode, element: SModelElement): VNode; | ||
} | ||
export declare type MouseEventKind = 'mouseOver' | 'mouseOut' | 'mouseEnter' | 'mouseLeave' | 'mouseDown' | 'mouseMove' | 'mouseUp' | 'wheel' | 'doubleClick'; | ||
export declare type MouseEventKind = 'mouseOver' | 'mouseOut' | 'mouseEnter' | 'mouseLeave' | 'mouseDown' | 'mouseMove' | 'mouseUp' | 'wheel' | 'doubleClick' | 'contextMenu'; | ||
export declare class MouseListener { | ||
@@ -62,2 +63,3 @@ mouseOver(target: SModelElement, event: MouseEvent): (Action | Promise<Action>)[]; | ||
doubleClick(target: SModelElement, event: MouseEvent): (Action | Promise<Action>)[]; | ||
contextMenu(target: SModelElement, event: MouseEvent): (Action | Promise<Action>)[]; | ||
decorate(vnode: VNode, element: SModelElement): VNode; | ||
@@ -64,0 +66,0 @@ } |
@@ -130,2 +130,6 @@ "use strict"; | ||
}; | ||
MouseTool.prototype.contextMenu = function (model, event) { | ||
event.preventDefault(); | ||
this.handleEvent('contextMenu', model, event); | ||
}; | ||
MouseTool.prototype.doubleClick = function (model, event) { | ||
@@ -144,5 +148,3 @@ this.handleEvent('doubleClick', model, event); | ||
vnode_utils_1.on(vnode, 'wheel', this.wheel.bind(this, element)); | ||
vnode_utils_1.on(vnode, 'contextmenu', function (event) { | ||
event.preventDefault(); | ||
}); | ||
vnode_utils_1.on(vnode, 'contextmenu', this.contextMenu.bind(this, element)); | ||
vnode_utils_1.on(vnode, 'dblclick', this.doubleClick.bind(this, element)); | ||
@@ -217,2 +219,5 @@ } | ||
}; | ||
MouseListener.prototype.contextMenu = function (target, event) { | ||
return []; | ||
}; | ||
MouseListener.prototype.decorate = function (vnode, element) { | ||
@@ -219,0 +224,0 @@ return vnode; |
@@ -25,5 +25,5 @@ /******************************************************************************** | ||
constructor(contextMenuService: IContextMenuServiceProvider, menuProvider: ContextMenuProviderRegistry); | ||
mouseDown(target: SModelElement, event: MouseEvent): (Action | Promise<Action>)[]; | ||
contextMenu(target: SModelElement, event: MouseEvent): (Action | Promise<Action>)[]; | ||
protected showContextMenu(target: SModelElement, event: MouseEvent): Promise<void>; | ||
} | ||
//# sourceMappingURL=mouse-listener.d.ts.map |
@@ -93,6 +93,4 @@ "use strict"; | ||
} | ||
ContextMenuMouseListener.prototype.mouseDown = function (target, event) { | ||
if (event.button === 2) { | ||
this.showContextMenu(target, event); | ||
} | ||
ContextMenuMouseListener.prototype.contextMenu = function (target, event) { | ||
this.showContextMenu(target, event); | ||
return []; | ||
@@ -99,0 +97,0 @@ }; |
@@ -20,9 +20,10 @@ /******************************************************************************** | ||
import { SModelExtension } from '../../base/model/smodel-extension'; | ||
import { BoundsAware } from '../bounds/model'; | ||
/** | ||
* Model elements implementing this interface can be displayed on a projection bar. | ||
* _Note:_ Model elements also have to be `BoundsAware` so their projections can be shown. | ||
* _Note:_ If set, the projectedBounds property will be prefered over the model element bounds. | ||
* Otherwise model elements also have to be `BoundsAware` so their projections can be shown. | ||
*/ | ||
export interface Projectable extends SModelExtension { | ||
projectionCssClasses: string[]; | ||
projectedBounds?: Bounds; | ||
} | ||
@@ -45,3 +46,3 @@ export declare function isProjectable(arg: unknown): arg is Projectable; | ||
*/ | ||
export declare function getProjectedBounds(model: Readonly<SChildElement & BoundsAware>): Bounds; | ||
export declare function getProjectedBounds(model: Readonly<SChildElement & Projectable>): Bounds | undefined; | ||
/** | ||
@@ -48,0 +49,0 @@ * Determine the total bounds of a model; this takes the viewport into consideration |
@@ -20,3 +20,3 @@ "use strict"; | ||
var object_1 = require("sprotty-protocol/lib/utils/object"); | ||
var smodel_1 = require("../../base/model/smodel"); | ||
var smodel_utils_1 = require("../../base/model/smodel-utils"); | ||
var model_1 = require("../bounds/model"); | ||
@@ -34,14 +34,17 @@ function isProjectable(arg) { | ||
var child = _a[_i]; | ||
if (isProjectable(child) && model_1.isBoundsAware(child) && child.projectionCssClasses.length > 0) { | ||
var projection = { | ||
elementId: child.id, | ||
projectedBounds: getProjectedBounds(child), | ||
cssClasses: child.projectionCssClasses | ||
}; | ||
if (result) { | ||
result.push(projection); | ||
if (isProjectable(child) && child.projectionCssClasses.length > 0) { | ||
var projectedBounds = getProjectedBounds(child); | ||
if (projectedBounds) { | ||
var projection = { | ||
elementId: child.id, | ||
projectedBounds: projectedBounds, | ||
cssClasses: child.projectionCssClasses | ||
}; | ||
if (result) { | ||
result.push(projection); | ||
} | ||
else { | ||
result = [projection]; | ||
} | ||
} | ||
else { | ||
result = [projection]; | ||
} | ||
} | ||
@@ -67,9 +70,16 @@ if (child.children.length > 0) { | ||
function getProjectedBounds(model) { | ||
var bounds = model.bounds; | ||
var parent = model.parent; | ||
while (parent instanceof smodel_1.SChildElement) { | ||
bounds = parent.localToParent(bounds); | ||
parent = parent.parent; | ||
if (model.projectedBounds) { | ||
var bounds = model.projectedBounds; | ||
if (model_1.isBoundsAware(parent)) { | ||
bounds = smodel_utils_1.transformToRootBounds(parent, bounds); | ||
} | ||
return bounds; | ||
} | ||
return bounds; | ||
else if (model_1.isBoundsAware(model)) { | ||
var bounds = model.bounds; | ||
bounds = smodel_utils_1.transformToRootBounds(parent, bounds); | ||
return bounds; | ||
} | ||
return undefined; | ||
} | ||
@@ -76,0 +86,0 @@ exports.getProjectedBounds = getProjectedBounds; |
{ | ||
"name": "sprotty", | ||
"version": "0.12.0-next.9241c35.0", | ||
"version": "0.12.0", | ||
"description": "A next-gen framework for graphical views", | ||
@@ -58,5 +58,5 @@ "license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)", | ||
"file-saver": "^2.0.2", | ||
"inversify": "^5.0.1", | ||
"inversify": "^5.1.1", | ||
"snabbdom": "^3.0.3", | ||
"sprotty-protocol": "0.12.0-next.9241c35.0", | ||
"sprotty-protocol": "~0.12.0", | ||
"tinyqueue": "^2.0.3" | ||
@@ -107,3 +107,3 @@ }, | ||
], | ||
"gitHead": "9241c351a69f1c37a8de2aaae5e0fdbef2c176b2" | ||
"gitHead": "476071fa5aa38a8bc25e97e0f27a51c0577d6d69" | ||
} |
@@ -21,3 +21,3 @@ /******************************************************************************** | ||
import { TYPES } from "../types"; | ||
import { SChildElement, SModelElement, SModelRoot } from "./smodel"; | ||
import { SChildElement, SModelElement, SModelRoot, SParentElement } from "./smodel"; | ||
import { SModelElementRegistration, CustomFeatures } from "./smodel-factory"; | ||
@@ -169,1 +169,12 @@ | ||
} | ||
/** | ||
* Transforms the local bounds all the way up to the root. | ||
*/ | ||
export function transformToRootBounds(parent: SParentElement, bounds: Bounds) { | ||
while (parent instanceof SChildElement) { | ||
bounds = parent.localToParent(bounds); | ||
parent = parent.parent; | ||
} | ||
return bounds; | ||
} |
@@ -122,2 +122,7 @@ /******************************************************************************** | ||
contextMenu(model: SModelRoot, event: MouseEvent) { | ||
event.preventDefault(); | ||
this.handleEvent('contextMenu', model, event); | ||
} | ||
doubleClick(model: SModelRoot, event: MouseEvent) { | ||
@@ -137,5 +142,3 @@ this.handleEvent('doubleClick', model, event); | ||
on(vnode, 'wheel', this.wheel.bind(this, element)); | ||
on(vnode, 'contextmenu', (event: Event) => { | ||
event.preventDefault(); | ||
}); | ||
on(vnode, 'contextmenu', this.contextMenu.bind(this, element)); | ||
on(vnode, 'dblclick', this.doubleClick.bind(this, element)); | ||
@@ -160,3 +163,3 @@ } | ||
export type MouseEventKind = 'mouseOver' | 'mouseOut' | 'mouseEnter' | 'mouseLeave' | 'mouseDown' | 'mouseMove' | 'mouseUp' | 'wheel' | 'doubleClick'; | ||
export type MouseEventKind = 'mouseOver' | 'mouseOut' | 'mouseEnter' | 'mouseLeave' | 'mouseDown' | 'mouseMove' | 'mouseUp' | 'wheel' | 'doubleClick' | 'contextMenu'; | ||
@@ -202,2 +205,6 @@ @injectable() | ||
contextMenu(target: SModelElement, event: MouseEvent): (Action | Promise<Action>)[] { | ||
return []; | ||
} | ||
decorate(vnode: VNode, element: SModelElement): VNode { | ||
@@ -204,0 +211,0 @@ return vnode; |
@@ -35,6 +35,4 @@ /******************************************************************************** | ||
mouseDown(target: SModelElement, event: MouseEvent): (Action | Promise<Action>)[] { | ||
if (event.button === 2) { | ||
this.showContextMenu(target, event); | ||
} | ||
contextMenu(target: SModelElement, event: MouseEvent): (Action | Promise<Action>)[] { | ||
this.showContextMenu(target, event); | ||
return []; | ||
@@ -41,0 +39,0 @@ } |
@@ -22,10 +22,13 @@ /******************************************************************************** | ||
import { SModelExtension } from '../../base/model/smodel-extension'; | ||
import { BoundsAware, isBoundsAware } from '../bounds/model'; | ||
import { transformToRootBounds } from '../../base/model/smodel-utils'; | ||
import { isBoundsAware } from '../bounds/model'; | ||
/** | ||
* Model elements implementing this interface can be displayed on a projection bar. | ||
* _Note:_ Model elements also have to be `BoundsAware` so their projections can be shown. | ||
* _Note:_ If set, the projectedBounds property will be prefered over the model element bounds. | ||
* Otherwise model elements also have to be `BoundsAware` so their projections can be shown. | ||
*/ | ||
export interface Projectable extends SModelExtension { | ||
projectionCssClasses: string[] | ||
projectionCssClasses: string[], | ||
projectedBounds?: Bounds, | ||
} | ||
@@ -52,12 +55,15 @@ | ||
for (const child of parent.children) { | ||
if (isProjectable(child) && isBoundsAware(child) && child.projectionCssClasses.length > 0) { | ||
const projection: ViewProjection = { | ||
elementId: child.id, | ||
projectedBounds: getProjectedBounds(child), | ||
cssClasses: child.projectionCssClasses | ||
}; | ||
if (result) { | ||
result.push(projection); | ||
} else { | ||
result = [projection]; | ||
if (isProjectable(child) && child.projectionCssClasses.length > 0) { | ||
const projectedBounds = getProjectedBounds(child); | ||
if (projectedBounds) { | ||
const projection: ViewProjection = { | ||
elementId: child.id, | ||
projectedBounds, | ||
cssClasses: child.projectionCssClasses | ||
}; | ||
if (result) { | ||
result.push(projection); | ||
} else { | ||
result = [projection]; | ||
} | ||
} | ||
@@ -82,10 +88,16 @@ } | ||
*/ | ||
export function getProjectedBounds(model: Readonly<SChildElement & BoundsAware>): Bounds { | ||
let bounds = model.bounds; | ||
let parent = model.parent; | ||
while (parent instanceof SChildElement) { | ||
bounds = parent.localToParent(bounds); | ||
parent = parent.parent; | ||
export function getProjectedBounds(model: Readonly<SChildElement & Projectable>): Bounds | undefined { | ||
const parent = model.parent; | ||
if (model.projectedBounds) { | ||
let bounds = model.projectedBounds; | ||
if (isBoundsAware(parent)) { | ||
bounds = transformToRootBounds(parent, bounds); | ||
} | ||
return bounds; | ||
} else if (isBoundsAware(model)) { | ||
let bounds = model.bounds; | ||
bounds = transformToRootBounds(parent, bounds); | ||
return bounds; | ||
} | ||
return bounds; | ||
return undefined; | ||
} | ||
@@ -92,0 +104,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 8 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 8 instances in 1 package
2961769
49734
+ Addedsprotty-protocol@0.12.0(transitive)
- Removedsprotty-protocol@0.12.0-next.9241c35.0(transitive)
Updatedinversify@^5.1.1
Updatedsprotty-protocol@~0.12.0