• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. How to properly use the horiz_align arguments for an UI...

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 143
  • Views 4564
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to properly use the horiz_align arguments for an UI form ?

PiR
PiR over 1 year ago

Hello, 

I'm writing my first SKILL program. So far so good, but I now running into some trouble with the application form. Especially one of the frame within the form:

The frame consist of:

  • One radio field with 2 choices.
  • Two verticalBoxLayout with 4 fields each (boolean buttons on the left, float fields on the right side). They are wrapped together within an horizontalBoxLayout. 

First problem is that the float fields are either too large or too small. Only 2-3 digits will be entered there so I don't need the fields to extend when the form is stretched by the user.

Secondly the horiz_align arguments do not seem to have any effect.



Ideally I would want the buttons and fields centered and close together. Un-ticking the button would disable the corresponding field (still need to make the proper callbacks for that).

Here is the code :

findFrame = hiCreateFormLayout(

'findFormLayout
?frame "Find Vias"
?items
list(

hiCreateRadioField(

?name 'searchFor
?choices '("Vias derived from techfile" "Customized vias")
?prompt "Look for :"
?callback list("println(\"Techvias selecetd\")" "println(\"Custom via selected\")")

)

hiCreateHorizontalBoxLayout(

'boolsAndValues
?items
list(
hiCreateVerticalBoxLayout(

'bools
?items
list(

hiCreateBooleanButton( ?name 'bool0 ?buttonText "cutWidth" ?callback nil )
hiCreateBooleanButton( ?name 'bool1 ?buttonText "cutHeight" ?callback nil )
hiCreateBooleanButton( ?name 'bool2 ?buttonText "cutRows" ?callback nil )
hiCreateBooleanButton( ?name 'bool3 ?buttonText "cutColums" ?callback nil )

)
?spacing list( 0 0 )
?horiz_align 'right ; trying to align the elements within the V-box??

)
hiCreateVerticalBoxLayout(

'values
?items
list(

list( hiCreateFloatField( ?name 'param0 ?callback nil ) 'horiz_align 'right )
hiCreateFloatField( ?name 'param1 ?callback nil )
hiCreateFloatField( ?name 'param2 ?callback nil )
hiCreateFloatField( ?name 'param3 ?callback nil )

)
?spacing list( 0 0 )
?horiz_align 'left

)
)
)
)
)


gridTest = hiCreateLayoutForm(

'gridTest
"Grid Test"
findFrame
?sizePolicy 'expanding
?buttonLayout 'Close
)

hiDisplayForm( gridTest )

I have also tried replacing the hiCreateHorizontalBoxLayout() function above with a Grid Layout, but the result is rather similar :

hiCreateGridLayout(

'findViaParams
?frame nil
?items
list(

list( hiCreateBooleanButton( ?name 'bool0 ?buttonText "cutWidth" ?callback nil ) 'row 0 'col 0 'horiz_align 'right )
list( hiCreateBooleanButton( ?name 'bool1 ?buttonText "cutHeight" ?callback nil ) 'row 1 'col 0 )
list( hiCreateBooleanButton( ?name 'bool2 ?buttonText "cutRows" ?callback nil ) 'row 2 'col 0 )
list( hiCreateBooleanButton( ?name 'bool3 ?buttonText "cutColums" ?callback nil ) 'row 3 'col 0 )
list( hiCreateFloatField( ?name 'param0 ?callback nil ) 'row 0 'col 1 'horiz_align 'left )
list( hiCreateFloatField( ?name 'param1 ?callback nil ) 'row 1 'col 1 )
list( hiCreateFloatField( ?name 'param2 ?callback nil ) 'row 2 'col 1 )
list( hiCreateFloatField( ?name 'param3 ?callback nil ) 'row 3 'col 1 )

;list( 'col_stretch 0 1 )
;list( 'col_stretch 1 0 )
;list( 'col_min_width 1 40)
)
)

When de-comenting the last 3 lists I can achieve fixed size for the float fields but they move to the left edge of the form for some reason.

Any Idea why the horiz_align has no effect in this case ? (button and field of the first row)

PS: sorry for the weird formatting of the code but I couldn't find how to make proper code quotation.

Regards,

Pierre

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago

    Pierre,

    I would do this with a grid layout, but rather than having the Boolean Button fields with a buttonText with the prompt you want, use ?buttonText " " (it has to be a non-empty string) and create a separate label field for the prompt. Then you can have the label in the first column (column 0), the boolean buttons in the second column (column 1) and the fioats in the third (column 2). Then everything aligns beautifully.

    Using form layouts and hoping the contents of each sub-layout to have alignment between them is hard to do - it's much cleaner to put everything in the same grid layout and then you have full control.

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • PiR
    PiR over 1 year ago in reply to Andrew Beckett

    Hello Andrew, 

    Thanks for your advice. Adding and extra column for labels seems to be the way to go.

    This led me to think I could use the same trick on the right side of the grid, with a dummy column containing " " labels (?invisible set to t also works). Then by setting 'col_stretch argument I can have only the outer columns (labels and dummy col) to change when  the form is stretched. And the important fields  (button and float fields) remain packed together in the middle so this is great !

     

    (I made some blank buttons in the last row to see the actual size of fields in each column)

    For the 'horiz_align argument I believe it was not effective because the fields were already as large as the columns. It would probably only work with fields of various size within each column.
    Thanks again !

    Pierre

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago in reply to PiR

    Pierre,

    Rather than creating dummy labels to provide extra stretch, the usual approach is to use hiCreateHorizontalBoxLayout or hiCreateVerticalBoxLayout with a list('stretch_item 1) entry to provide the extra stretch. Here's an example (with additional stretch on left and right to allow the fields to be centred - not something I'm a big fan of, but each to their own; also has additional stretch at the bottom so that the fields don't spread out as the form height is stretched).

    hiCreateLayoutForm(
      'TestForm
      "Test Form"
      hiCreateVerticalBoxLayout(
        'vbox
        ?items list(
          hiCreateHorizontalBoxLayout(
            'hbox
            ?items list(
              list('stretch_item 1) ; stretchable padding
              hiCreateGridLayout(
                'findViaParams
                ?frame nil
                ?items
                  list(
                    list( hiCreateLabel(?name 'lab1 ?labelText "cutWidth" ?justification 'right) 'row 0 'col 0 )
                    list( hiCreateLabel(?name 'lab2 ?labelText "cutHeight" ?justification 'right) 'row 1 'col 0 'horiz_align 'right)
                    list( hiCreateLabel(?name 'lab3 ?labelText "cutRows" ?justification 'right) 'row 2 'col 0 'horiz_align 'right)
                    list( hiCreateLabel(?name 'lab4 ?labelText "cutColumns" ?justification 'right) 'row 3 'col 0 'horiz_align 'right)
                    list( hiCreateBooleanButton( ?name 'bool0 ?buttonText " " ?callback nil ) 'row 0 'col 1 )
                    list( hiCreateBooleanButton( ?name 'bool1 ?buttonText " " ?callback nil ) 'row 1 'col 1 )
                    list( hiCreateBooleanButton( ?name 'bool2 ?buttonText " " ?callback nil ) 'row 2 'col 1 )
                    list( hiCreateBooleanButton( ?name 'bool3 ?buttonText " " ?callback nil ) 'row 3 'col 1 )
                    list( hiCreateFloatField( ?name 'param0 ?callback nil ) 'row 0 'col 2 )
                    list( hiCreateFloatField( ?name 'param1 ?callback nil ) 'row 1 'col 2 )
                    list( hiCreateFloatField( ?name 'param2 ?callback nil ) 'row 2 'col 2 )
                    list( hiCreateFloatField( ?name 'param3 ?callback nil ) 'row 3 'col 2 )
    
                    ;list( 'col_stretch 0 1 )
                    ;list( 'col_stretch 1 0 )
                    list( 'col_min_width 2 40)
                  )
              )
              list('stretch_item 1) ; stretchable padding
            )
          )
        list('stretch_item 1) ; stretchable padding
        )
      )
    )
    hiDisplayForm(TestForm)

    Regards,

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • PiR
    PiR over 1 year ago in reply to Andrew Beckett

    I see, this way you avoid creating dummy labels which overloads the code for a not so good reason..
    It's all starting to make sense for me how grid and box layouts can be combine to achieve the desired output. I surely overlooked this 'spacer_item when reading the docs.

    This is really helpful, thank you Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago in reply to PiR

    I tend to commonly use the hiCreateVerticalBoxLayout trick around an hiCreateGridLayout as often I want the width of some of the fields within the grid to stretch to fill the space, but I want the height to stay as-is and not have the fields spread out - this use of a stretch_item really helps for that.

    Anyway, glad it helped!

    Andrew 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information