Angles automatically generated for menu items
This commit is contained in:
1 parent
375dad7e1d
commit
932548f702
3 files changed
+56
-11
No files matched your search
@@ -47,6 +47,9 @@ function newCircularMenu () {
|
||||
function initialize (menuItemsInitialValues, payload) {
|
||||
/* Create the array of Menu Items */
|
||||
|
||||
let iconAndTextArray = []
|
||||
let iconOnlyArray = []
|
||||
|
||||
for (let i = 0; i < menuItemsInitialValues.length; i++) {
|
||||
let menuItem = newCircularMenuItem()
|
||||
let menuItemInitialValue = menuItemsInitialValues[i]
|
||||
@@ -81,8 +84,10 @@ function newCircularMenu () {
|
||||
|
||||
if (menuItem.label === undefined) {
|
||||
menuItem.type = 'Icon Only'
|
||||
iconOnlyArray.push(menuItem)
|
||||
} else {
|
||||
menuItem.type = 'Icon & Text'
|
||||
iconAndTextArray.push(menuItem)
|
||||
}
|
||||
|
||||
menuItem.initialize(payload)
|
||||
@@ -90,6 +95,36 @@ function newCircularMenu () {
|
||||
menuItems.push(menuItem)
|
||||
}
|
||||
|
||||
/* Here we calculate the angles for each menu item, and then apply it if it was not previously defined. */
|
||||
let amplitud = 100
|
||||
let initialAngle = 230
|
||||
let step = amplitud / (iconOnlyArray.length - 1)
|
||||
|
||||
for (let i = 0; i < iconOnlyArray.length; i++) {
|
||||
let menuItem = iconOnlyArray[i]
|
||||
let angle = initialAngle - step * i
|
||||
if (menuItem.angle === undefined) {
|
||||
menuItem.angle = angle
|
||||
}
|
||||
}
|
||||
|
||||
amplitud = 140
|
||||
initialAngle = -70
|
||||
step = amplitud / 7
|
||||
let currentItem = (7 - iconAndTextArray.length) / 2 + 1
|
||||
for (let i = 0; i < iconAndTextArray.length; i++) {
|
||||
let menuItem = iconAndTextArray[i]
|
||||
let angle = initialAngle + step * (currentItem - 0.5)
|
||||
currentItem++
|
||||
if (menuItem.angle === undefined) {
|
||||
menuItem.angle = angle
|
||||
}
|
||||
}
|
||||
|
||||
iconOnlyArray = undefined
|
||||
iconAndTextArray = undefined
|
||||
|
||||
/* Listen to events */
|
||||
selfFocusEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onFocus', onFocus)
|
||||
selfNotFocuskEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onNotFocus', onNotFocus)
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ function newUiObjectConstructor () {
|
||||
let menuItems = schemaNode.menuItems
|
||||
for (let j = 0; j < menuItems.length; j++) {
|
||||
let item = menuItems[j]
|
||||
item.angle = undefined
|
||||
if (item.action.indexOf('Add ') >= 0) {
|
||||
// item.action = 'Add UI Object'
|
||||
}
|
||||
@@ -137,8 +138,7 @@ function newUiObjectConstructor () {
|
||||
iconPathOff: 'menu-fix-unpinned',
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
angle: -130
|
||||
currentRadius: 0
|
||||
}
|
||||
)
|
||||
menuItemsInitialValues.push(
|
||||
@@ -153,8 +153,7 @@ function newUiObjectConstructor () {
|
||||
iconPathOff: 'menu-tensor-free-angles',
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
angle: -155
|
||||
currentRadius: 0
|
||||
}
|
||||
)
|
||||
menuItemsInitialValues.push(
|
||||
@@ -169,8 +168,7 @@ function newUiObjectConstructor () {
|
||||
iconPathOff: 'menu-mobility-freeze',
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
angle: 180
|
||||
currentRadius: 0
|
||||
}
|
||||
)
|
||||
menuItemsInitialValues.push(
|
||||
@@ -185,8 +183,7 @@ function newUiObjectConstructor () {
|
||||
iconPathOff: 'menu-tree-minus',
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
angle: 155
|
||||
currentRadius: 0
|
||||
}
|
||||
)
|
||||
menuItemsInitialValues.push(
|
||||
@@ -199,10 +196,22 @@ function newUiObjectConstructor () {
|
||||
iconPathOff: 'menu-backup',
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
angle: 130
|
||||
currentRadius: 0
|
||||
}
|
||||
)
|
||||
menuItemsInitialValues.push(
|
||||
{
|
||||
action: 'Clone',
|
||||
actionFunction: floatingObject.payload.onMenuItemClick,
|
||||
label: undefined,
|
||||
visible: true,
|
||||
iconPathOn: 'clone',
|
||||
iconPathOff: 'clone',
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
function getMenuItemsInitialValues (uiObject, floatingObject, payload) {
|
||||
|
||||
@@ -247,7 +247,8 @@ function newDesignerSpace () {
|
||||
'style-condition',
|
||||
'shapes-polygon',
|
||||
'data-entry',
|
||||
'data-formula'
|
||||
'data-formula',
|
||||
'clone'
|
||||
]
|
||||
|
||||
for (let i = 0; i < iconsNames.length; i++) {
|
||||
|
||||
Reference in new issue
Block a user