Merge pull request #2533 from Smidy13/develop

Improvement: Create Reference Left Menu Icon and Function
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2021-11-07 05:36:30 -04:00
commit 3f05e1b00a
7 files changed
+354 -14

No files matched your search

@@ -0,0 +1,258 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Layer_1"
x="0px"
y="0px"
viewBox="96 11 512 512"
style="enable-background:new 96 11 512 512;"
xml:space="preserve"
sodipodi:docname="create-reference.svg"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
inkscape:export-filename="E:\Superalgos\Projects\Foundations\Icons-SVG-Sources\menu\create-reference.png"
inkscape:export-xdpi="100"
inkscape:export-ydpi="100"><metadata
id="metadata53"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs51" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1017"
id="namedview49"
showgrid="false"
inkscape:zoom="0.42382813"
inkscape:cx="-330.802"
inkscape:cy="797.57683"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="g968-1" />
<style
type="text/css"
id="style2">
.st0{fill:#FD6A33;}
.st1{fill:none;stroke:#4ACFD9;stroke-width:35;stroke-linecap:round;stroke-miterlimit:10;}
.st2{fill:#9BAAAB;}
.st3{fill:#4ACFD9;}
.st4{fill:#0295AA;}
.st5{fill:#FF8C29;}
.st6{fill:#365558;}
</style>
<path
class="st1"
d="m 660.14266,606.29562 c -10,-50.1 -21.3,-115.2 -65.1,-149 -43.8,-33.8 -90.4,-37.6 -117.9,-77.6"
id="path16" />
<circle
class="st2"
cx="488.82132"
cy="397.94778"
r="37.799999"
id="circle18" />
<path
class="st0"
d="m 390.62133,264.74781 -52.2,-52.1 c -2.7,-2.7 -2.7,-7.2 0,-9.9 l 2.5,-2.5 c 2.7,-2.7 7.2,-2.7 9.9,0 l 52.1,52.1 c 2.7,2.7 2.7,7.2 0,9.9 l -2.5,2.5 c -2.7,2.7 -7.1,2.7 -9.8,0 z"
id="path26" />
<path
class="st5"
d="m 355.92133,279.44781 -52.1,-52.1 c -2.7,-2.7 -2.7,-7.2 0,-9.9 l 2.5,-2.5 c 2.7,-2.7 7.2,-2.7 9.9,0 l 52.1,52.1 c 2.7,2.7 2.7,7.2 0,9.9 l -2.5,2.5 c -2.8,2.7 -7.2,2.7 -9.9,0 z"
id="path28" />
<path
class="st0"
d="m 348.62133,304.24781 -49.7,-49.6 c -3.4,-3.4 -9,-3.4 -12.4,0 v 0 c -3.4,3.4 -3.4,9 0,12.4 l 49.6,49.6 c 3.4,3.4 9,3.4 12.4,0 v 0 c 3.5,-3.5 3.5,-9 0.1,-12.4 z"
id="path30" />
<path
class="st3"
d="m 534.12133,351.14781 c 12.2,-12.2 12.2,-32.1 0,-44.3 l -62,-62 c -12.2,-12.2 -32.1,-12.2 -44.3,0 l -47.8,47.8 106.3,106.3 z"
id="path32" />
<path
class="st4"
d="m 332.22133,384.74781 62,62 c 12.2,12.2 32.1,12.2 44.3,0 l 47.8,-47.8 -106.3,-106.3 -47.8,47.8 c -12.2,12.2 -12.2,32.1 0,44.3 z"
id="path34" />
<path
class="st4"
d="m 422.52133,271.44781 c 5.8,-5.8 5.8,-15.4 0,-21.3 l -8.9,-8.9 c -5.8,-5.8 -15.4,-5.8 -21.3,0 l -31.9,31.9 30.1,30.1 z"
id="path36" />
<path
class="st6"
d="m 328.62133,326.34781 8.9,8.9 c 5.8,5.8 15.4,5.8 21.3,0 l 31.9,-31.9 -30.1,-30.1 -31.9,31.9 c -5.9,5.8 -5.9,15.3 -0.1,21.2 z"
id="path38" />
<path
class="st1"
d="m 50.821333,-83.352191 c 10,50.1 21.3,115.2 65.099997,149 43.8,33.8 90.4,37.600001 117.9,77.700001"
id="path12" /><circle
class="st2"
cx="233.82133"
cy="143.34781"
r="37.799999"
id="circle14" /><g
id="g24"
transform="translate(46.321333,41.647809)">
<path
class="st3"
d="m 310.3,165.8 c 5.8,-5.8 15.4,-5.8 21.3,0 l 3.5,3.5 6.2,-6.2 c 12.2,-12.2 12.2,-32.1 0,-44.3 l -62,-62 C 267.1,44.6 247.2,44.6 235,56.8 l -48.7,48.7 92.1,92.1 z"
id="path20" />
<path
class="st4"
d="m 139.4,196.8 62,62 c 12.2,12.2 32.1,12.2 44.3,0 l 4.4,-4.4 -3.5,-3.5 c -5.8,-5.8 -5.8,-15.4 0,-21.3 l 31.9,-31.9 -92.1,-92.1 -46.9,46.9 c -12.3,12.2 -12.3,32.2 -0.1,44.3 z"
id="path22" />
</g><rect
x="-484.92621"
y="12.338773"
class="st1"
width="128"
height="128"
id="rect14"
style="fill:#f0353d" /><rect
x="-356.92621"
y="12.338773"
class="st2"
width="128"
height="128"
id="rect16"
style="fill:#fd6a33" /><rect
x="-228.92621"
y="12.338773"
class="st3"
width="128"
height="128"
id="rect18"
style="fill:#ff8c29" /><rect
x="-100.9262"
y="12.338773"
class="st4"
width="128"
height="128"
id="rect20"
style="fill:#ffd1a9" /><rect
x="-484.92621"
y="140.33878"
class="st5"
width="128"
height="128"
id="rect22"
style="fill:#365558" /><rect
x="-356.92621"
y="140.33878"
class="st6"
width="128"
height="128"
id="rect24"
style="fill:#0295aa" /><rect
x="-228.92621"
y="140.33878"
class="st7"
width="128"
height="128"
id="rect26"
style="fill:#4acfd9" /><rect
x="-484.92621"
y="268.33878"
class="st8"
width="128"
height="128"
id="rect28"
style="fill:#9baaab" /><rect
x="-356.92621"
y="268.33878"
class="st9"
width="128"
height="128"
id="rect30"
style="fill:#cdd4d5" /><rect
x="-228.92621"
y="268.33878"
class="st10"
width="128"
height="128"
id="rect32"
style="fill:#e6eaea" /><rect
x="-100.9262"
y="268.33878"
class="st11"
width="128"
height="128"
id="rect34"
style="fill:#ffffff" /><rect
x="-484.92621"
y="396.33878"
class="st12"
width="128"
height="128"
id="rect36"
style="fill:#bcd643" /><g
id="g968-1"
transform="rotate(-135,714.30035,166.0977)"><g
id="g1082"
transform="translate(407.00461,-154.54378)"><g
id="g1043"
transform="rotate(135,481.3645,166.52488)"><g
id="g1049"
transform="translate(-1.7695853,17.474654)"><path
id="path26-5-5"
style="fill:#365558;fill-opacity:1"
sodipodi:type="inkscape:offset"
inkscape:radius="9.437788"
inkscape:original="M 103 11 C 99.18163 11 96 14.18162 96 18 L 96.070312 91.751953 C 96.070312 95.570333 99.18163 98.681641 103 98.681641 L 106.53516 98.681641 C 110.35353 98.681641 113.53711 95.500021 113.53711 91.681641 L 113.53711 18 C 113.53711 14.18162 110.35353 11 106.53516 11 L 103 11 z "
d="M 103,1.5625 C 93.938999,1.5625 86.5625,8.9389867 86.5625,18 a 9.4387318,9.4387318 0 0 0 0,0.0098 l 0.07031,73.751953 C 86.638291,100.70245 94.058161,108.11914 103,108.11914 h 3.53516 c 9.061,0 16.43945,-7.37327 16.43945,-16.437499 V 18 c 0,-9.0642265 -7.37845,-16.4375 -16.43945,-16.4375 z"
transform="translate(363.35484,24.774194)" /><path
class="st0"
d="m 459.42554,116.52578 -0.0707,-73.751226 c 0,-3.81838 3.18198,-7.00036 7.00035,-7.00036 h 3.53554 c 3.81837,0 7.00035,3.18198 7.00035,7.00036 v 73.680516 c 0,3.81838 -3.18198,7.00036 -7.00035,7.00036 h -3.53554 c -3.81837,0 -6.92964,-3.11127 -6.92964,-6.92965 z"
id="path26-5"
style="fill:#bcd643;fill-opacity:1" /></g></g><g
id="g968-3"
transform="rotate(180,491.97327,156.41818)"><path
id="path26-5-5-5-5"
style="fill:#365558;fill-opacity:1"
sodipodi:type="inkscape:offset"
inkscape:radius="9.437788"
inkscape:original="M 103 11 C 99.18163 11 96 14.18162 96 18 L 96.070312 91.751953 C 96.070312 95.570333 99.18163 98.681641 103 98.681641 L 106.53516 98.681641 C 110.35353 98.681641 113.53711 95.500021 113.53711 91.681641 L 113.53711 18 C 113.53711 14.18162 110.35353 11 106.53516 11 L 103 11 z "
d="M 103,1.5625 C 93.938999,1.5625 86.5625,8.9389867 86.5625,18 a 9.4387318,9.4387318 0 0 0 0,0.0098 l 0.07031,73.751953 C 86.638291,100.70245 94.058161,108.11914 103,108.11914 h 3.53516 c 9.061,0 16.43945,-7.37327 16.43945,-16.437499 V 18 c 0,-9.0642265 -7.37845,-16.4375 -16.43945,-16.4375 z"
transform="rotate(45,258.34465,606.85962)" /><path
class="st0"
d="m 507.83601,127.87824 52.10001,-52.199996 c 2.7,-2.700002 7.2,-2.700006 9.9,-1e-5 l 2.5,2.500004 c 2.7,2.699995 2.69999,7.199998 -10e-6,9.9 l -52.09999,52.099992 c -2.7,2.7 -7.2,2.7 -9.9,0 l -2.5,-2.5 c -2.7,-2.7 -2.70001,-7.09999 0,-9.79999 z"
id="path26-5-7-9"
style="fill:#bcd643;fill-opacity:1" /></g><g
id="g968-9"
transform="rotate(-90,492.63263,156.46704)"><path
id="path26-5-5-5-8"
style="fill:#365558;fill-opacity:1"
sodipodi:type="inkscape:offset"
inkscape:radius="9.437788"
inkscape:original="M 103 11 C 99.18163 11 96 14.18162 96 18 L 96.070312 91.751953 C 96.070312 95.570333 99.18163 98.681641 103 98.681641 L 106.53516 98.681641 C 110.35353 98.681641 113.53711 95.500021 113.53711 91.681641 L 113.53711 18 C 113.53711 14.18162 110.35353 11 106.53516 11 L 103 11 z "
d="M 103,1.5625 C 93.938999,1.5625 86.5625,8.9389867 86.5625,18 a 9.4387318,9.4387318 0 0 0 0,0.0098 l 0.07031,73.751953 C 86.638291,100.70245 94.058161,108.11914 103,108.11914 h 3.53516 c 9.061,0 16.43945,-7.37327 16.43945,-16.437499 V 18 c 0,-9.0642265 -7.37845,-16.4375 -16.43945,-16.4375 z"
transform="rotate(45,258.34465,606.85962)" /><path
class="st0"
d="m 507.83601,127.87824 52.10001,-52.199996 c 2.7,-2.700002 7.2,-2.700006 9.9,-1e-5 l 2.5,2.500004 c 2.7,2.699995 2.69999,7.199998 -10e-6,9.9 l -52.09999,52.099992 c -2.7,2.7 -7.2,2.7 -9.9,0 l -2.5,-2.5 c -2.7,-2.7 -2.70001,-7.09999 0,-9.79999 z"
id="path26-5-7-34"
style="fill:#bcd643;fill-opacity:1" /></g><path
id="path26-5-5-5-07"
style="fill:#365558;fill-opacity:1"
sodipodi:type="inkscape:offset"
inkscape:radius="9.437788"
inkscape:original="M 103 11 C 99.18163 11 96 14.18162 96 18 L 96.070312 91.751953 C 96.070312 95.570333 99.18163 98.681641 103 98.681641 L 106.53516 98.681641 C 110.35353 98.681641 113.53711 95.500021 113.53711 91.681641 L 113.53711 18 C 113.53711 14.18162 110.35353 11 106.53516 11 L 103 11 z "
d="M 103,1.5625 C 93.938999,1.5625 86.5625,8.9389867 86.5625,18 a 9.4387318,9.4387318 0 0 0 0,0.0098 l 0.07031,73.751953 C 86.638291,100.70245 94.058161,108.11914 103,108.11914 h 3.53516 c 9.061,0 16.43945,-7.37327 16.43945,-16.437499 V 18 c 0,-9.0642265 -7.37845,-16.4375 -16.43945,-16.4375 z"
transform="rotate(45,258.34465,606.85962)" /><path
class="st0"
d="m 507.83601,127.87824 52.10001,-52.199996 c 2.7,-2.700002 7.2,-2.700006 9.9,-1e-5 l 2.5,2.500004 c 2.7,2.699995 2.69999,7.199998 -10e-6,9.9 l -52.09999,52.099992 c -2.7,2.7 -7.2,2.7 -9.9,0 l -2.5,-2.5 c -2.7,-2.7 -2.70001,-7.09999 0,-9.79999 z"
id="path26-5-7-7"
style="fill:#bcd643;fill-opacity:1" /></g></g></svg>

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

@@ -47,8 +47,8 @@ function newListSelector() {
const SIZE = 36
const FONT_SIZE = 24
const VISIBLE_LABELS = 7
let selected = Math.ceil(VISIBLE_LABELS / 2) - 1
let VISIBLE_LABELS = 7
let selected = 0
let wheelDeltaDirection
let wheelDeltaCounter = 0
@@ -102,6 +102,15 @@ function newListSelector() {
optionsList = listValues
if (optionsList.length < 1) {
thisObject.payload.uiObject.setErrorMessage("No Valid List Entries Found")
deactivate()
}
if (optionsList.length < VISIBLE_LABELS) {
VISIBLE_LABELS = optionsList.length
}
EDITOR_ON_FOCUS = true
}
@@ -150,8 +159,8 @@ function newListSelector() {
}
selected = selected - event.delta
if (selected < Math.ceil(VISIBLE_LABELS / 2)) { selected = Math.ceil(VISIBLE_LABELS / 2) - 1 }
if (selected > optionsList.length - Math.ceil(VISIBLE_LABELS / 2)) { selected = optionsList.length - Math.ceil(VISIBLE_LABELS / 2) }
if (selected < 0) { selected = 0 }
if (selected > optionsList.length - VISIBLE_LABELS) { selected = optionsList.length - VISIBLE_LABELS }
if (selected !== lastSelected) {
lastSelected = selected
@@ -180,7 +189,7 @@ function newListSelector() {
if (pPoint.y >= upperBoundary && pPoint.y <= lowerBoundary) {
let clickedValue = (i - Math.floor(VISIBLE_LABELS / 2) + selected)
let clickedValue = (i + selected)
let event = {
point: pPoint,
@@ -261,6 +270,7 @@ function newListSelector() {
}
}
}
function drawForeground() {
if (thisObject.visible === true) {
@@ -271,10 +281,19 @@ function newListSelector() {
for (let i = 0; i < VISIBLE_LABELS; i++) {
let index = i - Math.floor(VISIBLE_LABELS / 2) + selected
let index = i + selected
let label = ''
if (index >= 0 && index < optionsList.length) {
label = optionsList[index]
if (typeof(optionsList[index]) !== "string") {
label = optionsList[index].name
if (optionsList[index].payload.uiObject.icon !== undefined) {
icon = optionsList[index].payload.uiObject.icon
}
} else {
label = optionsList[index]
}
}
fontColor = UI_COLOR.BLACK
fontSize = FONT_SIZE
@@ -311,9 +330,14 @@ function newListSelector() {
browserCanvasContext.fill();
let middleValue = Math.floor(VISIBLE_LABELS / 2)
let evenOffset = 0
UI.projects.foundations.utilities.drawPrint.drawIcon(icon, 1 / 2, 1 / 2, - offset + SIZE, (i - middleValue) * rowHeight, SIZE, thisObject.container)
UI.projects.foundations.utilities.drawPrint.drawLabel(label, 1 / 2, 1 / 2, 0, (SIZE - fontSize) / 2 + (i - middleValue) * rowHeight, fontSize, thisObject.container, fontColor, undefined, undefined, opacity)
if (VISIBLE_LABELS % 2 === 0) {
evenOffset = rowHeight / 2
}
UI.projects.foundations.utilities.drawPrint.drawIcon(icon, 1 / 2, 1 / 2, - offset + SIZE, (i - middleValue) * rowHeight + evenOffset, SIZE, thisObject.container)
UI.projects.foundations.utilities.drawPrint.drawLabel(label, 1 / 2, 1 / 2, 0, (SIZE - fontSize) / 2 + (i - middleValue) * rowHeight + evenOffset, fontSize, thisObject.container, fontColor, undefined, undefined, opacity)
}
}
}
@@ -224,7 +224,7 @@ function newUiObjectConstructor() {
return
}
function addLeftIcons(menuItemsInitialValues, floatingObject, isPersonalData) {
function addLeftIcons(menuItemsInitialValues, floatingObject, schemaDocument) {
menuItemsInitialValues.push(
{
action: 'Pin / Unpin',
@@ -348,7 +348,7 @@ function newUiObjectConstructor() {
ring: 2
}
)
if (isPersonalData !== true) {
if (schemaDocument.isPersonalData !== true) {
menuItemsInitialValues.push(
{
action: 'Share',
@@ -431,6 +431,23 @@ function newUiObjectConstructor() {
ring: 3
}
)
if (schemaDocument.referencingRules !== undefined) {
menuItemsInitialValues.push(
{
action: 'Create Reference',
actionFunction: floatingObject.payload.executeAction,
actionProject: 'Visual-Scripting',
label: undefined,
visible: true,
iconPathOn: 'create-reference',
iconPathOff: 'create-reference',
rawRadius: 12,
targetRadius: 0,
currentRadius: 0,
ring: 3
}
)
}
menuItemsInitialValues.push(
{
@@ -486,8 +503,14 @@ function newUiObjectConstructor() {
uiObject.conditionEditor.initialize()
}
}
if (schemaDocument.referencingRules !== undefined) {
uiObject.listSelector = newListSelector()
uiObject.listSelector.isVisibleFunction = uiObject.isVisibleFunction
uiObject.listSelector.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false)
uiObject.listSelector.initialize()
}
if (schemaDocument.addLeftIcons === true) {
addLeftIcons(menuItemsInitialValues, floatingObject, schemaDocument.isPersonalData)
addLeftIcons(menuItemsInitialValues, floatingObject, schemaDocument)
}
if (schemaDocument.isPinned === true) {
floatingObject.isPinned = true
@@ -29,7 +29,7 @@ function newGovernanceFunctionLibraryPluginsFunctions() {
}
function addSpecifiedUserProfile(node, rootNodes) {
let action = { node: node}
let action = { node: node }
let projectName = UI.projects.communityPlugins.utilities.plugins.getProjectName(node)
if (projectName === "" || projectName === undefined) {
@@ -193,6 +193,11 @@ function newVisualScriptingActionSwitch() {
UI.projects.visualScripting.functionLibraries.attachDetach.referenceDetachNode(action.node)
}
break
case 'Create Reference':
{
UI.projects.visualScripting.functionLibraries.attachDetach.createReference(action.node, action.rootNodes)
}
break
default: {
console.log("[WARN] Action sent to Visual-Scripting Action Switch does not belong here. Verify at the App Schema file of the node that triggered this action that the actionProject is pointing to the right project. -> Action = " + action.name + " -> Action Node Name = " + action.node.name)
@@ -2,7 +2,8 @@
function newVisualScriptingFunctionLibraryReferenceAttachDetach() {
let thisObject = {
referenceDetachNode: referenceDetachNode,
referenceAttachNode: referenceAttachNode
referenceAttachNode: referenceAttachNode,
createReference: createReference
}
return thisObject
@@ -18,6 +19,35 @@ function newVisualScriptingFunctionLibraryReferenceAttachDetach() {
completeAttachment(node, attachToNode)
}
function createReference(node, rootNodes) {
let action = { node: node }
let allNodesFound = []
let schemaDocument = getSchemaDocument(node)
let workspaceRootNodes = UI.projects.foundations.spaces.designSpace.workspace.workspaceNode.rootNodes
let compatibleTypes = schemaDocument.referencingRules.compatibleTypes.split('->').filter(i => i)
for (let i = 0; i < compatibleTypes.length; i++) {
for (let j = 0; j < workspaceRootNodes.length; j++) {
let rootNode = workspaceRootNodes[j]
if (rootNode !== null) {
let nodeArray = UI.projects.visualScripting.utilities.branches.nodeBranchToArray(rootNode, compatibleTypes[i])
allNodesFound = allNodesFound.concat(nodeArray)
}
}
}
let eventSubscriptionId = node.payload.uiObject.container.eventHandler.listenToEvent('listSelectorClicked', onListSelect)
node.payload.uiObject.listSelector.activate(action, allNodesFound, eventSubscriptionId)
function onListSelect(event) {
referenceAttachNode(node, event.selectedNode)
node.payload.uiObject.container.eventHandler.stopListening('listSelectorClicked')
}
}
// Store the path to the reference parent to make restoring it possible if the reference parent is updated and given a new id
function storeAttachNodePath(node, attachToNode) {
if (node === undefined) { return }