Skip to content

Commit

Permalink
Allow moving group node from outer group
Browse files Browse the repository at this point in the history
  • Loading branch information
StefansArya committed Jan 9, 2024
1 parent 895557a commit 4a19e9b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
15 changes: 13 additions & 2 deletions nodes/Decoration/Group/Default.panel.sf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</div>
<div class="field color-pick color-2">
<span class="name">Font Color:</span>
<input sf-bind="fontColor" placeholder="#b8b8ff">
<input sf-bind="fontColor" placeholder="black">
</div>
</bppc-decoration-group-default>

Expand All @@ -25,8 +25,19 @@ bppc-decoration-group-default {
border-radius: 100%;
height: 22px;
width: 22px;
box-shadow: 0 0 7px 0px white;
outline: 1px solid #ffffff61;
background-image: unset;
}
}

.color-1 button {
background: #b8b8ff;
}

.color-2 button {
background: black;
}

.clr-field{
width: 98%;
Expand All @@ -52,7 +63,7 @@ class extends sf.Model {
themeMode: 'dark',
format: 'hex',
clearButton: true,
defaultColor: '#b8b8ffe1',
defaultColor: '#b8b8ff',
alpha: false,
swatches: [
'#abffb0',
Expand Down
27 changes: 24 additions & 3 deletions nodes/Decoration/Group/Default.sf
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class extends Blackprint.Interface{
constructor(node){
super(node);

this._groups = []; // Other decoration group references
this._ifaces = []; // Object references
this._cables = []; // Object references
this.data = new DecorationGroupDefaultData(this);
Expand Down Expand Up @@ -176,7 +177,7 @@ class extends Blackprint.Interface{
let temp = _ifaces[i];

// Avoid maximum call stack
if(temp.namespace === "Decoration/Group/Default") continue;
// if(temp.namespace === "Decoration/Group/Default") continue;

temp.moveNode(ev, true);
}
Expand All @@ -193,8 +194,8 @@ class extends Blackprint.Interface{
let ex = this.x + this.data.width;
let ey = this.y + this.data.height;

let { _ifaces, _cables } = this;
_ifaces.length = _cables.length = 0;
let { _groups, _ifaces, _cables } = this;
_groups.length = _ifaces.length = _cables.length = 0;

for (var i = 0, n = cableList.length; i < n; i++) {
let temp = cableList[i];
Expand Down Expand Up @@ -232,6 +233,13 @@ class extends Blackprint.Interface{
1; // ToDo: fix z-index when it's in front of another group node
}

if(temp.namespace === "Decoration/Group/Default") {
// Skip outer group
let isInnerGroup = (temp.x > this.x && temp.w < this.w) || (temp.y > this.y && temp.h < this.h);
if(!isInnerGroup) continue;

_groups.push(temp);
}
_ifaces.push(temp);
}
}
Expand All @@ -245,6 +253,19 @@ class extends Blackprint.Interface{

if(!_isSync)
this.node.syncOut('trigger', 'refreshContent');

// Remove any node/cable that contained on inner group
for (let i=0; i < _groups.length; i++) {
let temp = _groups[i];

let { _ifaces: A, _cables: B } = temp;
for (let i=_cables.length-1; i >= 0; i--) {
if(B.includes(_cables[i])) _cables.splice(i, 1);
}
for (let i=_ifaces.length-1; i >= 0; i--) {
if(A.includes(_ifaces[i])) _ifaces.splice(i, 1);
}
}
}

// Refresh content and disable changing index
Expand Down

0 comments on commit 4a19e9b

Please sign in to comment.