Update CircularMenuItem.js

This commit is contained in:
Luis Fernando Molina committed 2021-10-06 12:37:00 +02:00
1 parent 540f18cd69
commit 2905730db6
1 file changed
+38 -24
@@ -39,6 +39,7 @@ function newCircularMenuItem() {
container: undefined,
payload: undefined,
relatedUiObject: undefined,
relatedUiObjectProject: undefined,
dontShowAtFullscreen: undefined,
isEnabled: true,
shorcutNumber: undefined,
@@ -267,12 +268,22 @@ function newCircularMenuItem() {
thisObject.iconOn = UI.projects.foundations.spaces.designSpace.getIconByProjectAndName('Foundations', thisObject.secondaryIcon)
thisObject.iconOff = UI.projects.foundations.spaces.designSpace.getIconByProjectAndName('Foundations', thisObject.secondaryIcon)
} else {
/*
TODO : This code needs to be cleaned and reorganized. It is not clear how a menu item icon is going to be selected.
*/
if (thisObject.relatedUiObject !== undefined && thisObject.iconProject !== undefined) {
thisObject.iconOn = UI.projects.foundations.spaces.designSpace.getIconByProjectAndType(thisObject.iconProject, thisObject.relatedUiObject)
thisObject.iconOff = UI.projects.foundations.spaces.designSpace.getIconByProjectAndType(thisObject.iconProject, thisObject.relatedUiObject)
} else if (thisObject.relatedUiObject !== undefined && thisObject.iconProject === undefined) {
thisObject.iconOn = UI.projects.foundations.spaces.designSpace.getIconByProjectAndType(thisObject.payload.node.project, thisObject.relatedUiObject)
thisObject.iconOff = UI.projects.foundations.spaces.designSpace.getIconByProjectAndType(thisObject.payload.node.project, thisObject.relatedUiObject)
if (thisObject.relatedUiObjectProject !== undefined) {
thisObject.iconOn = UI.projects.foundations.spaces.designSpace.getIconByProjectAndType(thisObject.relatedUiObjectProject, thisObject.relatedUiObject)
thisObject.iconOff = UI.projects.foundations.spaces.designSpace.getIconByProjectAndType(thisObject.relatedUiObjectProject, thisObject.relatedUiObject)
} else {
thisObject.iconOn = UI.projects.foundations.spaces.designSpace.getIconByProjectAndType(thisObject.payload.node.project, thisObject.relatedUiObject)
thisObject.iconOff = UI.projects.foundations.spaces.designSpace.getIconByProjectAndType(thisObject.payload.node.project, thisObject.relatedUiObject)
}
} else {
if (thisObject.iconPathOn !== undefined && thisObject.iconPathOff !== undefined && thisObject.iconProject !== undefined) {
thisObject.iconOn = UI.projects.foundations.spaces.designSpace.getIconByProjectAndName(thisObject.iconProject, thisObject.iconPathOn)
@@ -306,7 +317,7 @@ function newCircularMenuItem() {
if (thisObject.container.frame.isThisPointHere(point, true, false) === true) {
let text = thisObject.action
if(thisObject.payload.uiObject.payload.referenceParent !== undefined && thisObject.action === 'Reference Detach'){
if (thisObject.payload.uiObject.payload.referenceParent !== undefined && thisObject.action === 'Reference Detach') {
text = text + ' -> [Existing Reference] Type : [' + thisObject.payload.uiObject.payload.referenceParent.type + '] , Name : [' + thisObject.payload.uiObject.payload.referenceParent.name + ']'
}
@@ -491,31 +502,34 @@ function newCircularMenuItem() {
if (thisObject.icon === undefined) {
thisObject.icon = UI.projects.foundations.spaces.designSpace.getIconByProjectAndName('Foundations', 'missing-image')
}
if (thisObject.icon.canDrawIcon === true && thisObject.currentRadius > 1 && thisObject.isDeployed === true) {
browserCanvasContext.drawImage(thisObject.icon, menuPosition.x - iconSize, menuPosition.y - iconSize, iconSize * 2, iconSize * 2)
if (thisObject.icon !== undefined) {
if (thisObject.icon.canDrawIcon === true && thisObject.currentRadius > 1 && thisObject.isDeployed === true) {
browserCanvasContext.drawImage(thisObject.icon, menuPosition.x - iconSize, menuPosition.y - iconSize, iconSize * 2, iconSize * 2)
}
}
/* Menu Label */
if (thisObject.type === 'Icon & Text') {
label = labelToPrint
if (thisObject.shorcutNumber !== undefined) {
label = '' + thisObject.shorcutNumber + '- ' + labelToPrint
/* Menu Label */
if (thisObject.type === 'Icon & Text') {
label = labelToPrint
if (thisObject.shorcutNumber !== undefined) {
label = '' + thisObject.shorcutNumber + '- ' + labelToPrint
}
let labelPoint
let fontSize = UI.projects.foundations.spaces.floatingSpace.style.node.menuItem.fontSize
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
if (thisObject.currentRadius >= thisObject.targetRadius) {
labelPoint = {
x: menuPosition.x + thisObject.currentRadius + 25,
y: menuPosition.y + fontSize * FONT_ASPECT_RATIO
}
let labelPoint
let fontSize = UI.projects.foundations.spaces.floatingSpace.style.node.menuItem.fontSize
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
if (thisObject.currentRadius >= thisObject.targetRadius) {
labelPoint = {
x: menuPosition.x + thisObject.currentRadius + 25,
y: menuPosition.y + fontSize * FONT_ASPECT_RATIO
}
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
browserCanvasContext.fillStyle = 'rgba(' + UI.projects.foundations.spaces.floatingSpace.style.node.menuItem.fontColor + ', 1)'
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y)
}
browserCanvasContext.fillStyle = 'rgba(' + UI.projects.foundations.spaces.floatingSpace.style.node.menuItem.fontColor + ', 1)'
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y)
}
}
}