|
|
|
The LZX reference claims:
unstretchedheight If stretches is not set to none, the height that this view would be if it weren't stretched. This attribute can be used to scale a view by a percentage of its original size, or to determine the aspect ratio for a view. unstretchedwidth If stretches is not set to none, the width that this view would be if it weren't stretched. This attribute can be used to scale a view by a percentage of its original size, or to determine the aspect ratio for a view. Well, I can make unstretched* return the correct value, but what I don't understand:
1) What is the expected behavior when the view has no resource (and hence has nothing to take its dimensions from)? 2) What is the expected behavior of views nested in a view that stretches? Should they stretch along with the parent, or should they maintain their size? If I run my amended example in 3.x, when there is no resource, the inner view expands to fill the outer view. When there is a resource, the inner view is warped to the same aspect ratio as the resource. Is this what we expect? 1) and 2) I don't know. I just know that what we have doesn't jive with what we've documented, and yes, what you saw when you ran in 3.x is what I would expect.
Also this test case from the dev guide examples page
This test case is derived from an example that used to work (i.e., display text which scaled with preserved aspect ratio when clicked) in 3.4, and just displays a red rectangle in 4.0.5 and trunk. <canvas width="1200" height="600"> <font src="helmetb.ttf" name="helmet"/> <view height="100" bgcolor="red" id="v1" stretches="both" onclick="this.animate('height', -10, 1000 , true )"> <attribute name="aspect" value="${unstretchedwidth/unstretchedheight}"/> <attribute name="width" value="${ height * aspect}"/> <text font="helmet" fontsize="22" resize="true" id="t1"> This is some text </text> </view> </canvas> Pablo Kang:
> Also the subviews inside a stretched view aren't stretched correctly. P T Withington: > What is the expected behavior here? If I try your example in trunk, the inner view is stretched to the size of the outer view. (I guess PTW speaks about "old" trunk) When I try this example in trunk rev. #7112 ("new" trunk), the inner view is initially unstretched and after toggling the outer view's width, the inner view is stretched too far and its width exceeds the canvas. Behaviour in OL3.x: the inner view is always stretched to the size of the outer view. to 1) and 2) view without resource and without subview: stretches does not affect size view without resource and with subview: stretches does only affect subview -> subview is stretched to the size of its parent view with resource and without subview: stretches affect view -> view is stretched to the resource-size view with resource and with subview: illegal / undefined (see LPP-781) (Just doing some research related to "http://forum.openlaszlo.org/showthread.php?t=11067") See
Test case <canvas height="500" width="500"> <view width="200" height="100" bgcolor="red" stretches="both"> <view width="30" height="30" bgcolor="blue"> <text text="this is a test"/> </view> </view> </canvas> Expected result: Blue area stretched over red This only works in the 3.X line Oddly enough if you set the source in the stretched view (view.setSource('someImage')) the view then behaves properly So, it sounds like if you set stretches and a dimension on a view and _don't_ have a resource, the view should take its subview's dimension as the dimension to scale.
|
||||||||||||||||||||||||||||||||||||||||||||||||
<canvas debug="true">
<simplelayout spacing="10"/>
<view layout="axis: x">
<button text="toggle 'noSubview' width" onclick="noSubview.toggleStretch()"/>
<button text="toggle 'withSubview' width" onclick="withSubview.toggleStretch()"/>
<button text="toggle 'noSubviewResource' width" onclick="noSubviewResource.toggleStretch()"/>
<button text="toggle 'withSubviewResource' width" onclick="withSubviewResource.toggleStretch()"/>
</view>
<class name="stretchview" stretches="both" width="300" height="200"
x="20" y="20" bgcolor="red"
oninit="this.showSizeAttributes()">
<method name="toggleStretch">
this.setWidth(this.width == 300 ? 500 : 300);
this.showSizeAttributes();
</method>
<method name="showSizeAttributes">
Debug.write("----- " + this.id + " -----");
Debug.write("width:", this.width);
// would expect orig width value for unstretchedwidth, but is 0
Debug.write("unstretchedwidth:", this.unstretchedwidth);
Debug.write("height:", this.height);
// would expect origh height value for unstretchedheight, but is 0
Debug.write("unstretchedheight:", this.unstretchedheight);
</method>
</class>
<view layout="axis: 'x'; spacing: 10">
<stretchview id="noSubview"/>
<stretchview id="withSubview">
<view width="100" height="100" bgcolor="green"/>
</stretchview>
</view>
<view layout="axis: 'x'; spacing: 10">
<stretchview id="noSubviewResource" resource="image/food_is_large.jpg"/>
<stretchview id="withSubviewResource" resource="image/food_is_large.jpg">
<view width="100" height="100" bgcolor="green"/>
</stretchview>
</view>
</canvas>