Cadence Breadcrumbs
CommunityForums Custom IC SKILL how to use form stretch items and spacer items?

how to use form stretch items and spacer items?

Is there an example of how to use the 'optional field controls' and 'spacer items' that are spelled out in the docs under the ?items argument for certain layout creation functions like hiCreateHorizontalBoxLayout?  Basically I'd like to stick with relative sizing only for a form that has several levels of nested layouts, and I'd like to specify the relative stretch factors of various fields within a certain layout, much like you would do in Qt.  The 'optional field controls' sound promising but I can't figure out how you actually implement that in code.

  • This may actually be the same question: can you specify what percentage of a layout is taken up by a given field, with those percentages / proportions preserved as the form is resized?  Can you specify a minimum or maximum size for a given field, also to be preserved as the form is resized?

  • I had the same question...and no answers.  But I found something and it seems the correct syntax.  So in your ?items you can have hiCreate* but you can also include a list of hiCreate* and the optional field controls and spacer items.

  • I had the same question...and no answers.  But I found something and it seems the correct syntax.  So in your ?items you can have hiCreate* but you can also include a list of hiCreate* and the optional field controls and spacer items.

    I didn't see the original post or I may have been too busy at the time to respond.

    I've recently been working with our documentation team on the layout forms section of the documentation with an expanded introduction and some better examples which would give a clearer idea of the structure of the ?items list. I've also just given some suggestions on how the ?items argument could be worded better to make it clear that each item in the items list can be a fields/hiLayouts, a list of the field/hiLayout followed by the optional field controls, or a list of the spacer items.

    The field controls don't allow percentages to be specified, but you can control the relative stretchiness of each field (usually you'd specify the values between 0 and 1) via the 'stretch stretch_factor field control. With a horizontal box layout, there's no minimum size control - you do have that with hiCreateGridLayout though (I think grid layouts tend to be the most useful and flexible of the layouts, although I often wrap the hiCreateGridLayout with a vertical box layout to give me additional stretchiness if the form is resized vertically if I just have rows of simple fields). 

    Here's an example (I had an older version of this in another post, but I made some changes last year to be a bit more flexible):

    /* abLibCellViewComboExample.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Jan 12, 2019 
    Modified   Oct 15, 2021 
    By         A.D.Beckett
    
    Example of using the enhanced lib/cell/view combo fields that support
    type-in completion.
    
    Simply call abLibCellViewComboExample() to create and display the form.
    
    If you want, you can override certain things. For example:
    
    libCell=abLibCellViewComboExample(
        ?buttonLayout 'OKCancel 
        ?dialogStyle 'modal
        ?omitView t
        ?formTitle "Choose Library and Cell"
        ?name 'MyChooseLibCell
    )
    
    or with callbacks (rather than being modal):
    
    procedure(MyCallback(lib cell view)
        geOpen(?lib lib ?cell cell ?view view)
    )
    abLibCellViewComboExample(
        ?callback 'MyCallback
        ?formTitle "Open Design"
    )
    
    ***************************************************
    
    SCCS Info: @(#) abLibCellViewComboExample.il 10/15/21.18:08:54 1.4
    
    */
    
    /****************************************************************
    *                                                               *
    *   abLibCellViewComboExample(@key (libName "") (cellName "")   *
    *        (viewName "") (buttonLayout 'OKCancelDefApply)         *
    *      (dialogStyle 'modeless) omitView callback formTitle      *
    *                             name)                             *
    *                                                               *
    *   Create an example form with a lib/cell/view combo-box and   *
    *  library browse button. Arguments are all keyword arguments,  *
    *  and can default the libName/cellName/viewName as you wish.   *
    *  The buttonLayout can be overridden, as can the dialogStyle   *
    *    (if modal, will return the lib/cell or lib/cell/view as    *
    *   a list). If ?omitView t is passed, the form only has lib    *
    * and cell on it. The formTitle and form name can be overridden *
    *                                                               *
    ****************************************************************/
    
    procedure(abLibCellViewComboExample(@key (libName "") (cellName "") 
            (viewName "") (buttonLayout 'OKCancelDefApply) 
            (dialogStyle 'modeless) omitView callback formTitle name)
        let((grid lib cell view libLabel cellLabel viewLabel 
                browse form formOK)
            libLabel=hiCreateLabel(
                ?name 'libLabel ?labelText "Library"
                ?justification 'right
            )
            cellLabel=hiCreateLabel( 
                ?name 'cellLabel ?labelText "Cell"
                ?justification 'right
            )
            lib=ddHiCreateLibraryComboField( 
                ?name 'lib ?callback "(ddsUpdateSyncWithForm)"
                ?value libName
            )
            cell=ddHiCreateCellComboField( 
                ?name 'cell ?callback "(ddsUpdateSyncWithForm)"
                ?value cellName
            )
            unless(omitView
                viewLabel=hiCreateLabel(
                    ?name 'viewLabel ?labelText "View"
                    ?justification 'right
                )
                view=ddHiCreateViewComboField( 
                    ?name 'view ?callback "(ddsUpdateSyncWithForm)"
                    ?value viewName
                )
            )
            browse=hiCreateFormButton(
                ?name 'browse
                ?buttonText "Browse..."
                ?callback 
                    if(omitView then
                        "(ddsSyncWithForm (hiGetCurrentForm) 'browse 'lib 'cell)"
                    else
                        "(ddsSyncWithForm (hiGetCurrentForm) 'browse 'lib 'cell 'view)"
                    )
            )
            grid=hiCreateGridLayout(
                'grid
                ?items setof(row
                    list(
                        list( libLabel 'row 0 'col 0)
                        list( cellLabel 'row 1 'col 0)
                        unless(omitView
                            list( viewLabel 'row 2 'col 0)
                        )
                        list( lib 'row 0 'col 1)
                        list( cell 'row 1 'col 1)
                        unless(omitView
                            list( view 'row 2 'col 1)
                        )
                        list( browse 'row 0 'col 2)
                        list( 'col_stretch 0 0)
                        list( 'col_stretch 1 1)
                        list( 'col_stretch 2 0)
                    )
                    row
                )
            )
            form=hiCreateLayoutForm(
                name || 'abLibCellViewComboExampleForm
                cond(
                    (formTitle formTitle)
                    (omitView "Lib Cell Example")
                    (t "Lib Cell View Example")
                )
                ;------------------------------------------------------------
                ; Vertical box layout is to add vertical stretchiness
                ; so that the fields don't spread vertically
                ;------------------------------------------------------------
                hiCreateVerticalBoxLayout(
                    'vbox
                    ?items list(
                        grid
                        list('stretch_item 1)
                    )
                )
                ?sizePolicy 'horizontalExpanding
                ?dialogStyle dialogStyle
                ?buttonLayout buttonLayout
                ?initialSize 300:60
                ;------------------------------------------------------------
                ; Create a wrapper callback that just passes lib cell view
                ; rather than the form
                ;------------------------------------------------------------
                ?callback 
                    when(callback
                        lambda((form)
                            funcall(
                                form->userCallback form->lib->value 
                                form->cell->value form->view->value
                            )
                        )
                    )
            )
            ;----------------------------------------------------------------
            ; Need to both instantiate the form and link the fields so that
            ; the combo-boxes use the other fields to inform the choices
            ;----------------------------------------------------------------
            hiInstantiateForm(form)
            if(omitView then
                ddHiLinkFields(
                    form->lib
                    form->cell
                )
            else
                ddHiLinkFields(
                    form->lib
                    form->cell
                    form->view
                )
            )
            form->userCallback=callback
            formOK=hiDisplayForm(form)
            ;----------------------------------------------------------------
            ; Return the lib/cell/view in a list if the form is modal
            ;----------------------------------------------------------------
            unless(dialogStyle=='modeless || !formOK
                if(omitView then
                    list(form->lib->value form->cell->value)
                else
                    list(form->lib->value form->cell->value form->view->value)
                )
            )
        )
    )
    

    Andrew

Related