History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: LPP-4684
Type: Bug Bug
Status: New New
Priority: P1 P1
Assignee: P T Withington
Reporter: Pablo Kang
Votes: 0
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
OpenLaszlo

Stretch views don't set unstretchedwidth and unstretchedheight correctly

Created: 07/Sep/07 04:29 PM   Updated: 04/Nov/08 04:22 PM
Component/s: Laszlo Foundation Classes (LFC)
Affects Version/s: 4.0.3
Fix Version/s: MisterDonut (4.2 Final)

Time Tracking:
Not Specified

Severity: Major
Runtime: N/A
Fix in hand: False


 Description  « Hide
Also the subviews inside a stretched view aren't stretched correctly.

<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()"/>
    </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>

    <stretchview id="noSubview"/>

    <stretchview id="withSubview">
        <view width="100" height="100" bgcolor="green"/>
    </stretchview>

</canvas>


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
P T Withington - 10/Sep/07 05:47 AM
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. If I add a resource to the outer view, then the inner view is scaled the same way the resource is scaled.

<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>


Pablo Kang - 10/Sep/07 11:24 AM
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.

P T Withington - 10/Sep/07 01:04 PM
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?

Pablo Kang - 11/Sep/07 10:39 AM
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.

P T Withington - 28/Sep/07 11:48 AM
See also LPP-4769

Henry Minsky - 28/Sep/07 02:44 PM
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>


André Bargull - 05/Nov/07 03:50 AM
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")

P T Withington - 09/Jan/08 10:28 AM
See LPP-5344 for another test case:

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


P T Withington - 31/Jan/08 09:06 AM
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.