classes.lzx
<library>
<class name="verticalindent">
<view width="1" height="${parent.height}" bgcolor="0x2b2ba2"/>
<view width="1" x="1" height="${parent.height}" bgcolor="0xffffff"/>
</class>
<class name="buttonrepeater" extends="view" clickable="true">
<attribute name="_lasttime" value="0
"/>
<attribute name="stillDownDelegate" value="0
"/>
<attribute name="onmousestilldown" value="null
"/>
<method name="stillDownEventGenerator">
var now = (new Date()).getTime();
var diff = now - this._lasttime;
this._lasttime = now;
if (this.isMouseDown) {
var next;
if (diff > 600) {
next = 500;
} else {
next = 50;
this.onmousestilldown.sendEvent();
}
lz.Timer.resetTimer( this.stillDownDelegate, next );
}
</method>
<handler name="onmousedown">
var now = new Date();
this._lasttime = now.getTime();
this.isMouseDown = true;
if (!this.stillDownDelegate) {
this.stillDownDelegate = new LzDelegate( this, "stillDownEventGenerator");
}
lz.Timer.addTimer( this.stillDownDelegate, 500 );
</handler>
<handler name="onmouseup">
this.isMouseDown=false;
lz.Timer.removeTimer( this.stillDownDelegate );
</handler>
</class>
<class name="photoother" bgcolor="white" width="77" height="${width}">
<attribute name="defaultplacement" value="interior
" type="text"/>
<view x="2" y="2" bgcolor="black" opacity=".5" width="${parent.width}" height="${parent.height}"/>
<view bgcolor="white" width="${parent.width}" height="${parent.height}"/>
<view name="interior" x="2" y="2" bgcolor="black" clip="true" width="${parent.width - 4}" height="${parent.height - 4}"/>
</class>
<class name="favoriteslayout" extends="layout">
<attribute name="axis" value="x
" setter="this.setAxis( axis )" type="string"/>
<attribute name="inset" value="0
" setter="this.inset = inset; if( this.subviews && this.subviews.length ) this.update(); if (this['oninset']) this.oninset.sendEvent(this.inset)"/>
<attribute name="spacing" value="0
" setter="this.spacing = spacing; if( this.subviews && this.subviews.length ) this.update(); if (this['onspacing']) this.onspacing.sendEvent(this.spacing)"/>
<method name="setAxis" args="a">
this.axis = a;
this.sizeAxis = a == "x" ? "width" : "height"
this.updateDelegate.register( parent, "onheight" );
</method>
<method name="addSubview" args="newsub">
//this.updateDelegate.register( newsub, "on" + this.sizeAxis);
this.updateDelegate.register( newsub, "onvisible" );
//this is an optimization to avoid calling update in the simple case
//where a single subview was just added
if ( ! this.locked && this.subviews.length ){
var s= this.subviews[ this.subviews.length-1 ];
var p = s[ this.axis ] + s[ this.sizeAxis ] + this.spacing;
newsub.setAttribute( this.axis , p ) ;
}
super.addSubview( newsub );
</method>
<method name="update" args="ignore=null">
if ( this.locked ) return;
this.locked = true;
var l = this.subviews.length;
var c = this.inset;
for(var i=0; i < l; i++) {
var s = this.subviews[i];
s.setAttribute('height', parent.height );
s.setAttribute('width', s.height);
if ( !s.visible ) continue;
if ( s[ this.axis ] != c ){
s.setAttribute( this.axis , c );
}
c += this.spacing + s[ this.sizeAxis ];
}
this.locked = false;
</method>
</class>
<class name="albumlayout" extends="layout">
<attribute name="axis" value="x
" setter="this.setAxis( axis )" type="string"/>
<attribute name="spacing" value="1
"/>
<attribute name="xinset" value="0
"/>
<attribute name="yinset" value="0
"/>
<attribute name="xspacing" value="${this.spacing}"/>
<attribute name="yspacing" value="${this.spacing}"/>
<attribute name="photoscale" value="1
"/>
<attribute name="photodimension" value="70
"/>
<attribute name="duration" value="0
"/>
<method name="setAxis" args="a">
this.axis = a;
this.otherAxis = a == "x" ? "y" : "x"
this.sizeAxis = a == "x" ? "width" : "height"
this.otherSizeAxis = a == "x" ? "height" : "width"
</method>
<method name="addSubview" args="newsub">
this.updateDelegate.register( newsub, 'onwidth');
this.updateDelegate.register( newsub, 'onheight');
this.updateDelegate.register( this.immediateparent, 'onwidth');
this.updateDelegate.register( this, 'onphotoscale');
super.addSubview( newsub );
this.update();
</method>
<method name="update" args="ignore=null">
if ( this.locked ) return;
this.locked = true;
var l = 0;
if (this.subviews) var l = this.subviews.length;
var limit = this.immediateparent[this.sizeAxis];
// position along this.axis
var pos = this[this.axis + 'inset'];
// position along this.otherAxis
var otherpos = this[this.otherAxis + 'inset'];
var maxdimension = 0;
var space = this[this.axis + 'spacing']; // spacing in axis dimension
var otherspace = this[this.otherAxis + 'spacing']; // spacing in other axis dimension
for(var i=0; i < l; i++) {
var s = this.subviews[i];
s.setAttribute(this.axis,pos);
s.setAttribute(this.otherAxis,otherpos);
s.setAttribute('width', Math.round(photodimension*photoscale));
s.setAttribute('height', Math.round(photodimension*photoscale));
pos += s[this.sizeAxis];
if ( i < (l - 1)) {
pos += space;
maxdimension = Math.max(maxdimension,s[this.otherSizeAxis]);
if (( pos > limit) ||
(pos + this.subviews[i+1][this.sizeAxis] > limit)) {
pos = this[this.axis + 'inset'];
otherpos += maxdimension + otherspace;
maxdimension = 0; // Reset the height/width after every row/column
}
}
}
this.locked = false;
</method>
<method name="toString">
return 'wrappinglayout for ' + this.immediateparent;
</method>
</class>
<class name="albumlayout2" extends="layout">
<attribute name="axis" value="x
" setter="this.setAxis( axis )" type="string"/>
<attribute name="spacing" value="59
"/>
<attribute name="xinset" value="0
"/>
<attribute name="yinset" value="0
"/>
<attribute name="skew" value="1
" setter="this.setSkew( skew )"/>
<attribute name="skewStep" value="1000
"/>
<attribute name="xspacing" value="${this.spacing}"/>
<attribute name="yspacing" value="${this.spacing}"/>
<attribute name="duration" value="0
"/>
<method name="setAxis" args="a">
this.axis = a;
this.otherAxis = a == "x" ? "y" : "x"
this.sizeAxis = a == "x" ? "width" : "height"
this.otherSizeAxis = a == "x" ? "height" : "width"
</method>
<method name="setSkew" args="s">
if ( !this.skewarray ) this.skewarray = [s];
else this.skewarray.push( this.skew );
this.skew = s;
this['onskew'].sendEvent();
</method>
<method name="addSubview" args="newsub">
this.updateDelegate.register( newsub, 'onwidth');
this.updateDelegate.register( newsub, 'onheight');
this.updateDelegate.register( this.immediateparent, 'onwidth');
this.updateDelegate.register( this, 'onskew');
super.addSubview( newsub );
this.update();
</method>
<method name="update" args="ignore=null">
if ( this.locked ) return;
this.locked = true;
var l = this.subviews.length;
var limit = this.immediateparent[this.sizeAxis];
var rowinset = 1000;
var skewindex = this.skewarray.length - 1;
//Debug.write("array =", this.skewarray);
// position along this.axis
var pos = this[this.axis + 'inset'];
// position along this.otherAxis
var otherpos = this[this.otherAxis + 'inset'];
var maxdimension = 0;
var space = this[this.axis + 'spacing']; // spacing in axis dimension
var otherspace = this[this.otherAxis + 'spacing']; // spacing in other axis dimension
for(var i=0; i < l; i++) {
//selecte the view
var s = this.subviews[i];
// set its's poistion
s.setAttribute(this.axis,pos);
s.setAttribute(this.otherAxis,otherpos);
s.setAttribute('opacity',1 - this.skewarray[skewindex]);
// update values for next view
pos += s[this.sizeAxis]; //start the next postion at the postion of the current view
if ( i < (l - 1)) {
// add the spacing
pos += space;
// what is this?
maxdimension = Math.max(maxdimension,s[this.otherSizeAxis]);
if (( pos > limit + rowinset) ||
(pos + this.subviews[i+1][this.sizeAxis] > limit)) {
Debug.write("skewindex, skewarray[skewindex], rowinset",skewindex, this.skewarray[skewindex],rowinset);
pos = this[this.axis + 'inset'] + this.skewarray[skewindex]*rowinset;
otherpos += maxdimension + otherspace;
maxdimension = 0; // Reset the height/width after every row/column
skewindex -= 2;
skewindex = Math.max(skewindex,0);
}
}
}
this.locked = false;
</method>
<method name="toString">
return 'wrappinglayout for ' + this.immediateparent;
</method>
</class>
</library>