[Laszlo-user] Is zooming in on views possible?
Julien Lépine
julien.lepine at free.fr
Sat Jan 5 10:34:04 PST 2008
Hi Anthony,
Basically you create a transparent image the size of your parent view not
zoomed. (for simplicity say we have a 100x100px transparent png file).
Attached you will find a zip containing a 100x100px png file, a small png
file with content, and a lzx test case for presenting what zooming looks
like.
The main principles are :
Get the parent view with stretches="both"
Define an attribute called "zoomfactor".
Bind the width and height of the parent view to the basewidth and baseheight
custom attributes multiplied by the zoom factor (height and width can be the
bound to the size of the inner view).
Define an inner view, that will take the full width and height of the parent
view without the zoom factor.
---CODE
<canvas debug="false" proxied="false" width="300" height="300">
<simplelayout axis="y" inset="10"/>
<resource name="zoomresource" src="background-fill.png"/>
<slider width="200" align="center" minvalue="50" maxvalue="300"
value="100">
<handler name="onvalue">
<![CDATA[
// access via zoomable because it is at the canvas level.
zoomable.setAttribute("zoomfactor", (0.0 + this.value) /
100.0);
]]>
</handler>
</slider>
<view name="zoomable" resource="zoomresource" stretches="both"
align="center">
<attribute name="zoomfactor" type="number" value="1.0"/>
<attribute name="baseheight" type="number" value="100.0"/>
<attribute name="basewidth" type="number" value="100.0"/>
<attribute name="height" value="${this.baseheight *
this.zoomfactor}"/>
<attribute name="width" value="${this.basewidth *
this.zoomfactor}"/>
<view height="${parent.baseheight}" width="${parent.basewidth}"
clip="true">
<view width="20" height="20" bgcolor="red"/>
<view align="right" width="20" height="20" bgcolor="green"/>
<view align="left" valign="bottom" resource="http:content.png"/>
<text resize="true" align="center" y="35" text="${'Inner : ' +
parent.height + 'x' + parent.width }"/>
<text resize="true" align="center" y="50" text="${'Outer : ' +
zoomable.height + 'x' + zoomable.width }"/>
</view>
</view>
</canvas>
---CODE
Get anything you want inside this inner view, it will be zoomed like a
charm.
Note, for pngs files to load at run time instead of compile time, you have
to be in swf8 mode (this is just for the small image inside).
Cheers,
Julien
_____
De : Anthony Bargnesi [mailto:abargnesi at gmail.com]
Envoyé : samedi 5 janvier 2008 17:18
À : Julien Lépine
Cc : laszlo-user at openlaszlo.org
Objet : Re: [Laszlo-user] Is zooming in on views possible?
Julien,
Thanks for the info, it sounds like that might achieve the affect I wanted.
In order to get a better understanding of what you're saying, how would that
look in the laszlo code? I'm not sure what you mean by transparent resource
and what you would have to declare on the child views within the parent.
Thanks again.
- Anthony
On Jan 5, 2008 5:51 AM, Julien Lépine <julien.lepine at free.fr> wrote:
Hi Anthony,
You can first try playing with a view that would have stretches="both"
defined (for the parent view, and that would have a transparent resource the
initial size of that view).
When you will change the size of that view, it will zoom on the resource,
and on the side effect (or maybe a desired one, but the fact is that it
happens), all the child views will be zoomed along.
So I guess this can achieve the effect you want.
++
Julien
_____
De : laszlo-user-bounces at openlaszlo.org
[mailto:laszlo-user-bounces at openlaszlo.org] De la part de Anthony Bargnesi
Envoyé : samedi 5 janvier 2008 06:51
À : laszlo-user at openlaszlo.org
Objet : [Laszlo-user] Is zooming in on views possible?
I was wondering if I have a parent view that has child views that can be
moved around, can I zoom in on the parent view and have the children resize
with it? I would like it to work similarly to how something like GoogleMaps
works.
It could certainly be possible to accomplish this by resizing the individual
child views based on the zoom levels, but I was just curious if openlaszlo
supported this out of the box. Any direction would certainly help at this
point.
Thanks,
Anthony
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.openlaszlo.org/pipermail/laszlo-user/attachments/20080105/8921a4bf/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testzoom.zip
Type: application/x-zip-compressed
Size: 5719 bytes
Desc: not available
Url : http://www.openlaszlo.org/pipermail/laszlo-user/attachments/20080105/8921a4bf/testzoom-0001.bin
More information about the Laszlo-user
mailing list