Lively Kernel canvas
// general spec of location?
if (submorph.isEpimorph) return;
this.layout(supermorph);
this.adjustShapeBoundsToSubmorphBounds(supermorph)
},
afterRemoveMorph: function($super, supermorph, submorph) {
if (submorph.isEpimorph) return;
this.layout(supermorph);
this.adjustShapeBoundsToSubmorphBounds(supermorph)
supermorph.layoutChanged();
},
submorphExtentChanged: function(supermorph, submorph) {
if (submorph.isEpimorph) return;
var newExtent = submorph.getExtent();
var cachedExtent = this.getCachedExtent(supermorph, submorph)
if (!cachedExtent || !(cachedExtent.eqPt(newExtent))) {
this.setCachedExtent(supermorph, submorph, newExtent)
this.layout(supermorph);
this.adjustShapeBoundsToSubmorphBounds(supermorph);
}
},
layout: function($super, supermorph, submorph) {
// console.log('full layout ' + supermorph.id());
// logStack();
$super(supermorph, submorph)
}
}
VerticalLayout.subclass('VerticalShrinkLayout', ShrinkTrait);
Object.extend(VerticalShrinkLayout, {
fromLiteral: function(literal) { return new this() }
})
HorizontalLayout.subclass('HorizontalShrinkLayout', ShrinkTrait)
Object.extend(HorizontalShrinkLayout, {
fromLiteral: function(literal) { return new this() }
})
BoxMorph.subclass("ResourceNodeMorph", {
defaultExtent: pt(120,40),
padding: new Rectangle(5,5,0,0),
margin: new Rectangle(5,3,0,0),
initialize: function($super, url, optPosition) {
var pos = optPosition || pt(0,0);
$super(pos.extent(this.defaultExtent))
this.setFill(Color.blue.darker());
this.setFillOpacity(0.3)
this.setBorderColor(Color.darkGray)
this.label = new TextMorph(new Rectangle(0,0,100,20)).beLabel();
this.addMorph(this.label)
this.url = url
this.setupConnections()
this.layoutManager = new VerticalShrinkLayout();
// this.layoutManager = new HorizontalShrinkLayout();
},
setupConnections: function() {
connect(this, "url", this.label, 'setTextString', {converter: function(value) {
if (value instanceof URL)
return value.filename()
else
return "no valid url"
}}).update(this.url)
},
expand: function() {
if (!this.url) return;
var children = new WebResource(this.url).getSubElements(1).subCollections
children.each(function(ea) {
var m = new ResourceNodeMorph(ea.getURL())
this.addMorph(m)
}, this)
},
layoutChanged: function($super) {
$super();
if (this.owner && this.owner.submorphExtentChanged)
this.owner.submorphExtentChanged(this);
},
submorphExtentChanged: function(submorph) {
if (this.layoutManager && this.layoutManager.submorphExtentChanged)
this.layoutManager.submorphExtentChanged(this, submorph)
},
})
]]>
DraftShrinkLayout40
Wikicontroltruetrue
webwerkstatt.xhtmlfalsenulltrue
demos/falsenulltrue
PresentationDemo/falsenulltrue
contextjs/falsenulltrue
lively/falsenulltrue
squeakev/falsenulltrue
March2010/falsenulltrue
demos/falsenulltrue
PresentationDemo/falsenulltrue
contextjs/falsenulltrue
lively/falsenulltrue
squeakev/falsenulltrue
March2010/falsenulltrue
console.log("a)-----------------------")if($morph('testResourceNode'))$morph('testResourceNode').remove()varurl=newURL('http://lively-kernel.org/repository/webwerkstatt/webwerkstatt.xhtml')varm=newResourceNodeMorph(url,pt(100,100));m.name='testResourceNode';m.openInWorld()console.log("c)-----------------------")if($morph('testResourceNode2'))$morph('testResourceNode2').remove()varurl=newURL('http://lively-kernel.org/repository/webwerkstatt/demos/')varm=newResourceNodeMorph(url,pt(230,100));m.name='testResourceNode2';m.expand();m.openInWorld()console.log("c)-----------------------")if($morph('testResourceNode3'))$morph('testResourceNode3').remove()varurl=newURL('http://lively-kernel.org/repository/webwerkstatt/demos/')varm=newResourceNodeMorph(url,pt(380,100));m.name='testResourceNode3';m.layoutManager=newHorizontalShrinkLayout()m.expand();m.openInWorld()truetruefalse16truetrue
false00.11truefalsetruetrue
nullfalsetruenull
VerticalShrinkLayoutfalsenulltruefalse
false
false
falsenullfalsefalsenullnullnullnullfalse
dismissallfalsenulltruefalsetrue
Xfalsenulltruefalsetrue
serializing....16nullnull80