Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Question on setAutoWidth()/setAutoHeight()

    This may just be a clarification.

    We are seeing some problems in some (admittedly suspect) code that worked fine against SmartGWT 5.0 when using against SmartGWT 6.0.

    We subclass window and in the constructor call the following:

    Code:
            setAutoWidth();
            setAutoHeight();
            setAutoSize(true);
    The intention is to have the window size itself according to its contents. The primary child of the Window is a VLayout on which we call:

    Code:
            vLoMain.setWidth100();
            vLoMain.setHeight100();
    Yes, I can see the potential stalemate here where the Window wants to size to its contents, and the contents want to fill whatever space is made available by its parent. And indeed, the console shows an error as follows during execution:

    Code:
    18:23:50.468:WARN:drawing:isc_VLayout_1:negative or zero area: height: 48, width: -1, refusing to draw
        readyToDraw() on [VLayout ID:isc_VLayout_1] @ ISC_Core.js:53628:54
        draw(showing=>undef) on [VLayout ID:isc_VLayout_1] @ ISC_Core.js:53780:15
        layoutChildren(reason=>"initial draw", deltaX=>undef, deltaY=>undef) on [Layout ID:isc_BuiltInDS_MyWin_0_body] @ ISC_Foundation.js:6904:20
        drawChildren() on [Layout ID:isc_BuiltInDS_MyWin_0_body] @ ISC_Foundation.js:5768:14
        draw(<no args: recursion>)  on [Layout ID:isc_BuiltInDS_MyWin_0_body] @ ISC_Core.js:53944:14
        _matchBodyWidth() on [Window ID:isc_BuiltInDS_MyWin_0] @ ISC_Containers.js:3536:41
        layoutChildren(a=>"initial draw", b=>undef, c=>undef, d=>undef) on [Window ID:isc_BuiltInDS_MyWin_0] @ ISC_Containers.js:3508:29
        drawChildren(<no args: recursion>)  on [Window ID:isc_BuiltInDS_MyWin_0] @ ISC_Foundation.js:5768:14
        draw(<no args: recursion>)  on [Window ID:isc_BuiltInDS_MyWin_0] @ ISC_Core.js:53944:14
        invokeSuper(clazz=>[Class Window], methodName=>"draw", a=>true, b=>undef, c=>undef, d=>undef, e=>undef, f=>undef, g=>undef, h=>undef, i=>undef, j=>undef, lastArg=>undef) on [Window ID:isc_BuiltInDS_MyWin_0] @ ISC_Core.js:6699:40
        draw(a=>true, b=>undef, c=>undef, d=>undef) on [Window ID:isc_BuiltInDS_MyWin_0] @ ISC_Containers.js:2356:17
        show() on [Window ID:isc_BuiltInDS_MyWin_0] @ ISC_Core.js:68014:14
        invokeSuper(<no args: recursion>)  on [Window ID:isc_BuiltInDS_MyWin_0] @ ISC_Core.js:6699:40
        show(a=>undef, b=>undef, c=>undef, d=>undef) on [Window ID:isc_BuiltInDS_MyWin_0] @ ISC_Containers.js:3714:10
        $show(this$static=>Window{showHeaderIcon: false,
    autoCenter: true,
    width: 1,
    height: 1,
    autoSize: true,
    items: Array[1],
    AUTOIDClass: "BuiltInDS_MyWin",
    ID: "isc_BuiltInDS_MyWin_0",
    members: Array[2],
    position: "absolute",
    className: "windowBackground",
    top: -1000,
    vPolicy: "none",
    overflow: "visible",
    vertical: true,
    children: Array[2],
    header: [HLayout ID:isc_BuiltInDS_MyWin_0_header],
    headerLabelParent: [Canvas ID:isc_BuiltInDS_MyWin_0_headerLabelParent],
    canDragReposition: false,
    headerLabel: [Label ID:isc_BuiltInDS_MyWin_0_headerLabel],
    minimizeButton: [ImgButton ID:isc_BuiltInDS_MyWin_0_minimizeButton],
    closeButton: [ImgButton ID:isc_BuiltInDS_MyWin_0_closeButton],
    bodyConstructor: "Layout",
    bodyProperties: Obj,
    body: [Layout ID:isc_BuiltInDS_MyWin_0_body],
    ruleScope: "isc_BuiltInDS_MyWin_0",
    cacheOffsetCoords: true,
    zIndex: 200018,
    tabIndex: 1050}) @ 3370BEE0EF4CEF6826CCB7D5AC372BAC.cache.js:10267:10
        BuiltInDS$MyWin_0(this$0=>com.smartgwt.sample.client.BuiltInDS@5) @ 3370BEE0EF4CEF6826CCB7D5AC372BAC.cache.js:23181:3
        $onModuleLoad_2(this$static=>com.smartgwt.sample.client.BuiltInDS@5) @ 3370BEE0EF4CEF6826CCB7D5AC372BAC.cache.js:23118:3
        init() @ 3370BEE0EF4CEF6826CCB7D5AC372BAC.cache.js:3304:3
        apply_0(jsFunction=>init(), thisObj=>Obj{length:0}, args=>[object Arguments]) @ 3370BEE0EF4CEF6826CCB7D5AC372BAC.cache.js:461:23
        entry0(jsFunction=>init(), thisObj=>Obj{length:0}, args=>[object Arguments]) @ 3370BEE0EF4CEF6826CCB7D5AC372BAC.cache.js:536:14
        <anonymous>() @ 3370BEE0EF4CEF6826CCB7D5AC372BAC.cache.js:504:14
        gwtOnLoad(errFn=>undef, modName=>"builtinds", modBase=>"http://localhost:9876/builtinds/", softPermutationId=>undef) @ 3370BEE0EF4CEF6826CCB7D5AC372BAC.cache.js:27404:17
        <anonymous>('moduleStartup'=>undef, 'moduleEvalStart'=>undef) @ 3370BEE0EF4CEF6826CCB7D5AC372BAC.cache.js:27410:1
    
    18:23:50.480:WARN:drawing:isc_VLayout_1:negative or zero area: height: 48, width: -1, refusing to draw
        readyToDraw() on [VLayout ID:isc_VLayout_1] @ ISC_Core.js:53628:54
        draw(showing=>undef) on [VLayout ID:isc_VLayout_1] @ ISC_Core.js:53780:15
        layoutChildren(reason=>"initial draw", deltaX=>undef, deltaY=>undef) on [Layout ID:isc_BuiltInDS_MyWin_0_body] @ ISC_Foundation.js:6937:20
        drawChildren() on [Layout ID:isc_BuiltInDS_MyWin_0_body] @ ISC_Foundation.js:5768:14
        draw(<no args: recursion>)  on [Layout ID:isc_BuiltInDS_MyWin_0_body] @ ISC_Core.js:53944:14
        _matchBodyWidth() on [Window ID:isc_BuiltInDS_MyWin_0] @ ISC_Containers.js:3536:41
        layoutChildren(a=>"initial draw", b=>undef, c=>undef, d=>undef) on [Window ID:isc_BuiltInDS_MyWin_0] @ ISC_Containers.js:3508:29
        drawChildren(<no args: recursion>)  on [Window ID:isc_BuiltInDS_MyWin_0] @ ISC_Foundation.js:5768:14
        draw(<no args: recursion>)  on [Window ID:isc_BuiltInDS_MyWin_0] @ ISC_Core.js:53944:14
        invokeSuper(clazz=>[Class Window], methodName=>"draw", a=>true, b=>undef, c=>undef, d=>undef, e=>undef, f=>undef, g=>undef, h=>undef, i=>undef, j=>undef, lastArg=>undef) on [Window ID:isc_BuiltInDS_MyWin_0] @ ISC_Core.js:6699:40
        draw(a=>true, b=>undef, c=>undef, d=>undef) on [Window ID:isc_BuiltInDS_MyWin_0] @ ISC_Containers.js:2356:17
        show() on [Window ID:isc_BuiltInDS_MyWin_0] @ ISC_Core.js:68014:14
        invokeSuper(<no args: recursion>)  on [Window ID:isc_BuiltInDS_MyWin_0] @ ISC_Core.js:6699:40
        show(a=>undef, b=>undef, c=>undef, d=>undef) on [Window ID:isc_BuiltInDS_MyWin_0] @ ISC_Containers.js:3714:10
        $show(this$static=>Window{showHeaderIcon: false,
    autoCenter: true,
    width: 1,
    height: 1,
    autoSize: true,
    items: Array[1],
    AUTOIDClass: "BuiltInDS_MyWin",
    ID: "isc_BuiltInDS_MyWin_0",
    members: Array[2],
    position: "absolute",
    className: "windowBackground",
    top: -1000,
    vPolicy: "none",
    overflow: "visible",
    vertical: true,
    children: Array[2],
    header: [HLayout ID:isc_BuiltInDS_MyWin_0_header],
    headerLabelParent: [Canvas ID:isc_BuiltInDS_MyWin_0_headerLabelParent],
    canDragReposition: false,
    headerLabel: [Label ID:isc_BuiltInDS_MyWin_0_headerLabel],
    minimizeButton: [ImgButton ID:isc_BuiltInDS_MyWin_0_minimizeButton],
    closeButton: [ImgButton ID:isc_BuiltInDS_MyWin_0_closeButton],
    bodyConstructor: "Layout",
    bodyProperties: Obj,
    body: [Layout ID:isc_BuiltInDS_MyWin_0_body],
    ruleScope: "isc_BuiltInDS_MyWin_0",
    cacheOffsetCoords: true,
    zIndex: 200018,
    tabIndex: 1050}) @ 3370BEE0EF4CEF6826CCB7D5AC372BAC.cache.js:10267:10
        BuiltInDS$MyWin_0(this$0=>com.smartgwt.sample.client.BuiltInDS@5) @ 3370BEE0EF4CEF6826CCB7D5AC372BAC.cache.js:23181:3
        $onModuleLoad_2(this$static=>com.smartgwt.sample.client.BuiltInDS@5) @ 3370BEE0EF4CEF6826CCB7D5AC372BAC.cache.js:23118:3
        init() @ 3370BEE0EF4CEF6826CCB7D5AC372BAC.cache.js:3304:3
        apply_0(jsFunction=>init(), thisObj=>Obj{length:0}, args=>[object Arguments]) @ 3370BEE0EF4CEF6826CCB7D5AC372BAC.cache.js:461:23
        entry0(jsFunction=>init(), thisObj=>Obj{length:0}, args=>[object Arguments]) @ 3370BEE0EF4CEF6826CCB7D5AC372BAC.cache.js:536:14
        <anonymous>() @ 3370BEE0EF4CEF6826CCB7D5AC372BAC.cache.js:504:14
        gwtOnLoad(errFn=>undef, modName=>"builtinds", modBase=>"http://localhost:9876/builtinds/", softPermutationId=>undef) @ 3370BEE0EF4CEF6826CCB7D5AC372BAC.cache.js:27404:17
        <anonymous>('moduleStartup'=>undef, 'moduleEvalStart'=>undef) @ 3370BEE0EF4CEF6826CCB7D5AC372BAC.cache.js:27410:1
    However, the VLayout contains an HLayout which, although it has no width defined explicitly, contains a couple of buttons which do have widths explicitly defined on them.

    If I remove the calls to setAutoWidth() and setAutoHeight() the problem does not occur, but my question is whether this is expected (i.e. our usage of the properties in combination is invalid), or whether we should expect the HLayout to be sized according to its contents, thus affecting the size of the VLayout until finally the Window sizes itself accordingly? Remembering, of course, that this worked for us in 5.0...


    Example is based on BuiltIndDS:
    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.types.Alignment;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.Window;
    import com.smartgwt.client.widgets.layout.HLayout;
    import com.smartgwt.client.widgets.layout.LayoutSpacer;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    /**
     * Entry point classes define <code>onModuleLoad()</code>.
     */
    public final class BuiltInDS implements EntryPoint {
    
        @Override
        public void onModuleLoad() {
            new MyWin();
            
        }
    
        private class MyWin extends Window {
    
            private HLayout                myHLoTop        = null;
            private VLayout                myVLoBot        = null;
            private final static int    HgtTop            = 60;    // Top pane height.
            private IButton myBtnOK;
            private IButton myBtnCancel;
    
            
            public MyWin() {
                super();
    
                final VLayout     vLoMain = new VLayout();
    
                setAutoCenter(true);
    
                setAutoWidth();
                setAutoHeight();
                setAutoSize(true);
                vLoMain.setWidth100();
                vLoMain.setHeight100();
    
                getHLoTop().setHeight(HgtTop);    
                getVLoBot().setAutoHeight();
    
                getHLoTop().setAlign(Alignment.CENTER);
                getHLoTop().setDefaultLayoutAlign(Alignment.CENTER);        
                getHLoTop().setMembers(getBtnOK(), new LayoutSpacer(), getBtnCancel());
                
                vLoMain.setMembers(getHLoTop(), getVLoBot(), new LayoutSpacer()); 
                
                addItem(vLoMain);
    
                show();
            }
    
            private HLayout getHLoTop() {
                if (myHLoTop == null) {
                    myHLoTop = new HLayout();
                    myHLoTop.setWidth(500);
                }
    
                return myHLoTop;
            }
    
            private VLayout getVLoBot() {
                if (myVLoBot == null) {
                    myVLoBot = new VLayout();
                }
    
                return myVLoBot;
            }
    
            private final IButton getBtnOK() {
                if (myBtnOK == null) {
                    myBtnOK = new IButton("OK");
                    myBtnOK.setWidth(100);
                }
    
                return myBtnOK;
            }
    
            private final IButton getBtnCancel() {
                if (myBtnCancel == null) {
                    myBtnCancel = new IButton("Cancel");
                    myBtnOK.setWidth(100);
                }
    
                return myBtnCancel;
            }
    
        }
    }

    #2
    These circular size settings are indeed invalid, and whatever result you got before is basically a random result from invalid usage.

    Since what you seem to want is just to auto-size, just remove the settings where you are also trying to set percent sizes, and the result will be auto-sizing.

    Comment


      #3
      Thank you - I thought that might be the answer. Your suggestion does the trick and we'll modify our code accordingly.

      Regards,
      Gary O'Donnell

      Comment

      Working...
      X