Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Make removePin do slightly more
Browse files Browse the repository at this point in the history
  • Loading branch information
DrJosh9000 committed Apr 27, 2018
1 parent 8941c0b commit de07907
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 48 deletions.
82 changes: 43 additions & 39 deletions dev/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -130317,14 +130317,12 @@ $packages["github.com/google/shenzhen-go/dev/client/view"] = (function() {
/* */ $s = 7; continue;
/* if (!(c.potentialPin === ptrType$1.nil)) { */ case 6:
$r = c.removePin(c.potentialPin); /* */ $s = 8; case 8: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = c.potentialPin.SetColour("#000"); /* */ $s = 9; case 9: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
c.potentialPin = ptrType$1.nil;
/* } */ case 7:
/* */ if (!(c.subsumeInto === ptrType.nil)) { $s = 10; continue; }
/* */ $s = 11; continue;
/* if (!(c.subsumeInto === ptrType.nil)) { */ case 10:
$r = c.unsubsume(); /* */ $s = 12; case 12: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
/* } */ case 11:
/* */ if (!(c.subsumeInto === ptrType.nil)) { $s = 9; continue; }
/* */ $s = 10; continue;
/* if (!(c.subsumeInto === ptrType.nil)) { */ case 9:
$r = c.unsubsume(); /* */ $s = 11; case 11: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
/* } */ case 10:
$s = -1; return;
/* */ } return; } if ($f === undefined) { $f = { $blk: Channel.ptr.prototype.noSnap }; } $f.c = c; $f.x = x; $f.y = y; $f.$s = $s; $f.$r = $r; return $f;
};
Expand Down Expand Up @@ -130371,45 +130369,42 @@ $packages["github.com/google/shenzhen-go/dev/client/view"] = (function() {
/* */ $s = 16; continue;
/* if (!(c.potentialPin === ptrType$1.nil) && !(c.potentialPin === z)) { */ case 15:
$r = c.removePin(c.potentialPin); /* */ $s = 17; case 17: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = c.potentialPin.SetColour("#000"); /* */ $s = 18; case 18: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
/* } */ case 16:
/* */ if (!(z.channel === ptrType.nil) && !(z.channel === c)) { $s = 19; continue; }
/* */ $s = 20; continue;
/* if (!(z.channel === ptrType.nil) && !(z.channel === c)) { */ case 19:
$r = z.channel.subsume(c); /* */ $s = 21; case 21: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
/* */ if (!(z.channel === ptrType.nil) && !(z.channel === c)) { $s = 18; continue; }
/* */ $s = 19; continue;
/* if (!(z.channel === ptrType.nil) && !(z.channel === c)) { */ case 18:
$r = z.channel.subsume(c); /* */ $s = 20; case 20: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$s = -1; return;
/* } */ case 20:
$r = c.errors.clearError(); /* */ $s = 22; case 22: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
/* } */ case 19:
$r = c.errors.clearError(); /* */ $s = 21; case 21: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
c.potentialPin = z;
$r = c.addPin(z); /* */ $s = 23; case 23: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = c.SetColour("#09f"); /* */ $s = 24; case 24: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = c.hideDrag(); /* */ $s = 25; case 25: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = c.layout($ifaceNil); /* */ $s = 26; case 26: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = c.addPin(z); /* */ $s = 22; case 22: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = c.SetColour("#09f"); /* */ $s = 23; case 23: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = c.hideDrag(); /* */ $s = 24; case 24: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = c.layout($ifaceNil); /* */ $s = 25; case 25: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$s = 8; continue;
/* } else if ($assertType(_ref, ptrType, true)[1]) { */ case 7:
z$1 = _ref.$val;
if (c.subsumeInto === z$1) {
$s = -1; return;
}
/* */ if (c === z$1) { $s = 27; continue; }
/* */ $s = 28; continue;
/* if (c === z$1) { */ case 27:
$r = c.noSnap(x, y); /* */ $s = 29; case 29: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
/* */ if (c === z$1) { $s = 26; continue; }
/* */ $s = 27; continue;
/* if (c === z$1) { */ case 26:
$r = c.noSnap(x, y); /* */ $s = 28; case 28: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$s = -1; return;
/* } */ case 28:
/* */ if (!(c.potentialPin === ptrType$1.nil)) { $s = 30; continue; }
/* */ $s = 31; continue;
/* if (!(c.potentialPin === ptrType$1.nil)) { */ case 30:
$r = c.removePin(c.potentialPin); /* */ $s = 32; case 32: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = c.potentialPin.SetColour("#000"); /* */ $s = 33; case 33: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
c.potentialPin = ptrType$1.nil;
/* } */ case 31:
/* */ if (!(c.subsumeInto === ptrType.nil) && !(c.subsumeInto === z$1)) { $s = 34; continue; }
/* */ $s = 35; continue;
/* if (!(c.subsumeInto === ptrType.nil) && !(c.subsumeInto === z$1)) { */ case 34:
$r = c.unsubsume(); /* */ $s = 36; case 36: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
/* } */ case 35:
$r = z$1.subsume(c); /* */ $s = 37; case 37: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
/* } */ case 27:
/* */ if (!(c.potentialPin === ptrType$1.nil)) { $s = 29; continue; }
/* */ $s = 30; continue;
/* if (!(c.potentialPin === ptrType$1.nil)) { */ case 29:
$r = c.removePin(c.potentialPin); /* */ $s = 31; case 31: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
/* } */ case 30:
/* */ if (!(c.subsumeInto === ptrType.nil) && !(c.subsumeInto === z$1)) { $s = 32; continue; }
/* */ $s = 33; continue;
/* if (!(c.subsumeInto === ptrType.nil) && !(c.subsumeInto === z$1)) { */ case 32:
$r = c.unsubsume(); /* */ $s = 34; case 34: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
/* } */ case 33:
$r = z$1.subsume(c); /* */ $s = 35; case 35: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
/* } */ case 8:
$s = -1; return;
/* */ } return; } if ($f === undefined) { $f = { $blk: Channel.ptr.prototype.drag }; } $f._r = _r; $f._ref = _ref; $f._tuple = _tuple; $f.c = c; $f.d = d; $f.q = q; $f.x = x; $f.y = y; $f.z = z; $f.z$1 = z$1; $f.$s = $s; $f.$r = $r; return $f;
Expand Down Expand Up @@ -130458,10 +130453,20 @@ $packages["github.com/google/shenzhen-go/dev/client/view"] = (function() {
var _entry, c, p, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _entry = $f._entry; c = $f.c; p = $f.p; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
c = this;
/* */ if (!(p.channel === c)) { $s = 1; continue; }
/* */ $s = 2; continue;
/* if (!(p.channel === c)) { */ case 1:
$r = log.Print(new sliceType$2([new $String("c.removePin(p) but p.channel != c")])); /* */ $s = 3; case 3: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$s = -1; return;
/* } */ case 2:
if (p === c.potentialPin) {
c.potentialPin = ptrType$1.nil;
}
$r = p.SetColour("#000"); /* */ $s = 4; case 4: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
p.channel = ptrType.nil;
$r = (_entry = c.Pins[ptrType$1.keyFor(p)], _entry !== undefined ? _entry.v : ptrType$2.nil).Remove(); /* */ $s = 1; case 1: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = (_entry = c.Pins[ptrType$1.keyFor(p)], _entry !== undefined ? _entry.v : ptrType$2.nil).Remove(); /* */ $s = 5; case 5: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
delete c.Pins[ptrType$1.keyFor(p)];
$r = c.cc.Detach(p.pc); /* */ $s = 2; case 2: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = c.cc.Detach(p.pc); /* */ $s = 6; case 6: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$s = -1; return;
/* */ } return; } if ($f === undefined) { $f = { $blk: Channel.ptr.prototype.removePin }; } $f._entry = _entry; $f.c = c; $f.p = p; $f.$s = $s; $f.$r = $r; return $f;
};
Expand All @@ -130478,7 +130483,6 @@ $packages["github.com/google/shenzhen-go/dev/client/view"] = (function() {
var _entry, _i, _key, _keys, _ref, c, ch, p, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _entry = $f._entry; _i = $f._i; _key = $f._key; _keys = $f._keys; _ref = $f._ref; c = $f.c; ch = $f.ch; p = $f.p; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
c = this;
ch.potentialPin = ptrType$1.nil;
ch.subsumeInto = c;
ch.presubsumption = {};
_ref = ch.Pins;
Expand Down
2 changes: 1 addition & 1 deletion dev/client/client.js.map

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions dev/client/view/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ func (c *Channel) noSnap(x, y float64) {
c.layout(Pt(x, y))
if c.potentialPin != nil {
c.removePin(c.potentialPin)
c.potentialPin.SetColour(normalColour)
c.potentialPin = nil
}
if c.subsumeInto != nil {
c.unsubsume()
Expand Down Expand Up @@ -161,7 +159,6 @@ func (c *Channel) drag(x, y float64) {
// Was considering connecting to a pin, but now connecting to a different pin.
if c.potentialPin != nil && c.potentialPin != z {
c.removePin(c.potentialPin)
c.potentialPin.SetColour(normalColour)
}

// Trying to snap to a different channel via a pin.
Expand Down Expand Up @@ -193,8 +190,6 @@ func (c *Channel) drag(x, y float64) {
// Was connecting to a pin before?
if c.potentialPin != nil {
c.removePin(c.potentialPin)
c.potentialPin.SetColour(normalColour)
c.potentialPin = nil
}

// Was subsumed into another channel?
Expand Down Expand Up @@ -234,6 +229,14 @@ func (c *Channel) addPin(p *Pin) {
}

func (c *Channel) removePin(p *Pin) {
if p.channel != c {
log.Print("c.removePin(p) but p.channel != c")
return
}
if p == c.potentialPin {
c.potentialPin = nil
}
p.SetColour(normalColour)
p.channel = nil
c.Pins[p].Remove()
delete(c.Pins, p)
Expand All @@ -246,7 +249,6 @@ func (c *Channel) hasPin(p *Pin) bool {
}

func (c *Channel) subsume(ch *Channel) {
ch.potentialPin = nil
ch.subsumeInto = c
ch.presubsumption = make(map[*Pin]struct{})
for p := range ch.Pins {
Expand Down
4 changes: 2 additions & 2 deletions dev/server/view/static-client.go

Large diffs are not rendered by default.

0 comments on commit de07907

Please sign in to comment.