PDA

View Full Version : Any idea to control the replication manager in deep?


thenongt
08-03-2007, 08:05 AM
I've got a grid that is using Resize Replication (I've modified it). When I do animately expand each row height, the animation is not smooth. I've notice that it was because the rows that outside the container were being removed (or added) while the clicked row was being animate its height (expanding or colapsing).

So, I think need to do these following:

1. Suspend the replication task while my clicked row is animating. This is the main thing I want to do but I don't know how to. If I can suspend it, the animation would be more smoother.

2. Tell the replication manager to use my value instead of automatically get from the replication container size. I will set that size little larger than the container size so when my clicked row is colapsing, the nearest outside rows that will become inside will be showed in time (I guess that it will not be removed when it being outside if I set the size of container little larger).

Is that possible to do? Or does anybody got any more better solution?

Thank you :)

senshi
08-03-2007, 11:57 AM
I think you need to take a look at "LzResizeReplicationManager#__LZadjustVisibleClones ()" and "LzResizeReplicationManager#__LZHandleCloneResize".

With some quick hacking, I've made up this example. Be aware that it's not 100%
perfect, i.e. expand and collapse entry "F" to see same artifacts.
Take it as it is, without any warranty.
(Please don't ask: "What is this property and what is that property?", as I'll just refer to the sources...)


<canvas debug="true" >

<dataset name="ds" >
<root>
<node text="A" />
<node text="B" />
<node text="C" />
<node text="D" />
<node text="E" />
<node text="F" />
</root>
</dataset>

<script when="immediate" ><![CDATA[
Debug.showInternalProperties=true;

LzResizeReplicationManager.addProperty("__LZHandleCloneResizeStub", LzResizeReplicationManager.prototype.__LZHandleClo neResize);

LzResizeReplicationManager.addProperty("__LZHandleCloneResize", function(){
var clone = arguments[0];
if (!(clone["e_height"] && clone.e_height.c == 1)) {
this.__LZHandleCloneResizeStub.apply(this, arguments);
} else {
if (! this.mask[ "hasset" + this.sizeAxis ] ) return;
if ( this.__LZresizeupdating ) return;
this.__LZresizeupdating = true;

var cls = this.clones;

var index = null;
for (var i=0; i<cls.length; ++i) {
if (cls[i] == clone) {
index = i;
break;
}
}

if (index!=null) {
var cpos = clone[this.axis] + clone[this.sizeAxis] + this.spacing;
for (var i=index+1; i<cls.length; ++i) {
var cl = cls[i];
cl.setAttribute(this.axis, cpos);
cpos += cl[this.sizeAxis] + this.spacing;
}

cpos += this.viewsize;
this.cloneimmediateparent.setAttribute( this.sizeAxis , cpos );
}

this.__LZresizeupdating = false;
}
});
]]></script>

<view width="10%" height="80" clip="true">
<view id="foo" width="100%" >
<view width="100%" height="20" bgcolor="0xEAEAEA" >
<datapath xpath="ds:/root/node" replication="resize" />
<text datapath="@text" />

<handler name="onclick" >
this.animate( "height", this.height==20?40:20, 1000 );
</handler>
</view>
</view>
<vscrollbar />
</view>

</canvas>

thenongt
08-03-2007, 09:23 PM
Thank you for your answer.

Can you guide me about where I can find the code for the replication manager? So I will try to hook it myself.

Thank you again :)

senshi
08-04-2007, 12:37 AM
First of all, you need to download the src-distribution (OL4.0.3) (http://www.openlaszlo.org/node/358?dl_path=http://download.openlaszlo.org/4.0.3/openlaszlo-4.0.3-src.tar.gz).

After downloading the sources, go to the directory "lps-4.0.3/WEB-INF/lps/lfc/data". Related replication-manager classes are the following: LzReplicationManager.lzs, LzLazyReplicationManager.lzs and LzResizeReplicationManager.lzs. (Somehow obvious...)

Classes related to animation can be found in: "lps-4.0.3/WEB-INF/lps/lfc/controllers".

caheoo123
08-04-2007, 03:29 AM
that's good idea:)
http://caheoo.com



Online iPhone Screensaver - be the first to win!

myscreensavers.info/media/iphone.scr

thenongt
08-08-2007, 12:11 PM
Thank you Senshi, I've downloaded the code and now I'm understanding the way it work.

However, I have forgot one thing. Event if I can suspend the replication task, the animation doesn't much smoother. The other thing that cause unsmooth animation when resize each row is the number of visibled rows (views) after it which will be affected when the preceding row was resizing.

So, in addition of the two things above, I would need to cache all rows after it as image, hide the rows and place the one flat image there instead. And bring back all hidden rows when the animation finished.

However, I think this is the waste time task if I just want to make it animating like that. The grid is very complicate to modify and there are some other things to worry about. Such as controlling the manually added views inside the expanded row when the row was removed or created by replication manager. So I must leave it for now.

Thank you for your answer and the good example. If I have time to make it work as I though I will share it soon :)

spoco2
02-21-2008, 04:00 PM
Thankyou very much senshi for demonstrating how to override foundation class code... this is great, it means I can fix the x axis bug in this code and have it working right now until the fix is rolled into the main trunk.