• 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 get desired field size in Layout forms

Stats

  • Replies 5
  • Subscribers 142
  • Views 301
  • Members are here 0

How to get desired field size in Layout forms

RK56
RK56 6 days ago

Hi,

I'm new to Layout forms. For long time I have been sticking with Appforms and felt convenient with coordinates (except when I'm using frames). Mostly because its a onetime effort.  Now I tried to use Layout forms for one of my GUI and found it easier to bring it on screen. But I'm not satisfied with the outcome as I dont know how to control the individual field sizes. I tried combination of verticalBoxLayout, horizontalBoxLayout and gridLayout and all resulted with fields of equal size.

Can anyone point me how to control the field sizes? I tried min_width, col_span, col_stretch. What am I missing?

Thanks

Ram

  • Cancel
  • Sign in to reply
Parents
  • Aurel B
    Aurel B 6 days ago

    Hi,

    Inside hiCreateVerticalBoxLayout and hiCreateHorizontalBoxLayout, you can set the "stretchiness" ratio of each field by doing this

    instead of providing ?items (list field)

    You can do ?items (list (list field 'stretch 1))  

    You can also add 'stretch_item and 'spacer_item

    You can also set the minimum field dimensions with hiSetFieldMinSize.

    Once used to this, you will normally never use an AppForm again. (Or only for legacy purposes...)

    I did not have the time yet (and I'm trying to answer before Andrew) but I can provide you with examples if you need.

    Hope this helps,

    Aurel

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • RK56
    RK56 5 days ago in reply to Aurel B

    Hi Aurel,

    Thanks. Should we mention the min size using pixel counts for hiSetFieldMinSize? That is how I read in the documents which is kind of going back to AppForms.

    I tried 'stretch 0 so that the items will not stretch but it did.

    Could you also clarify between  'stretch <int> vs 'stretch_item <int> ?

    Thanks a lot

    Ram

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • RK56
    RK56 5 days ago in reply to Aurel B

    Hi Aurel,

    Thanks. Should we mention the min size using pixel counts for hiSetFieldMinSize? That is how I read in the documents which is kind of going back to AppForms.

    I tried 'stretch 0 so that the items will not stretch but it did.

    Could you also clarify between  'stretch <int> vs 'stretch_item <int> ?

    Thanks a lot

    Ram

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • Andrew Beckett
    Andrew Beckett 5 days ago in reply to RK56

    Ram,

    Seeing your code would help here, otherwise we're having to guess. The documentation explains that 'stretch controls the stretchiness of a field, whereas 'stretch_item allows you to add a stretchable spacer between the fields (so this can absorb the extra space rather than fields getting wider). 

    An easy way to control the minimum width is to use 'col_min_width in a grid layout - this example uses this (column 0 just has labels in my case, but I am able to specify the minimum width of that column nevertheless. It's in pixels.

    procedure(ExGrid()
      let((grid)
        grid=hiCreateGridLayout(
          'grid
          ?items
            list(
              list(
                hiCreateLabel(
                  ?name 'enableLabel
                  ?labelText "Enable"
                )
                'row 0 'col 0
              )
              list(
                hiCreateBooleanButton(
                  ?name 'enable
                  ?buttonText " "
                )
                'row 0 'col 1
              )
              list(
                hiCreateLabel(
                  ?name 'libLabel
                  ?labelText "Lib"
                )
                'row 1 'col 0
              )
              list(
                hiCreateStringField(
                  ?name 'lib
                )
                'row 1 'col 1
              )
              list(
                hiCreateLabel(
                  ?name 'cellLabel
                  ?labelText "Cell"
                )
                'row 2 'col 0
              )
              list(
                hiCreateStringField(
                  ?name 'cell
                )
                'row 2 'col 1
              )
              list(
                hiCreateLabel(
                  ?name 'viewLabel
                  ?labelText "View"
                )
                'row 3 'col 0
              )
              list(
                hiCreateStringField(
                  ?name 'view
                )
                'row 3 'col 1
              )
              list(
                hiCreateLabel(
                  ?name 'explanation
                  ?labelText "Fields can also span across multiple columns or rows"
                )
                'row 4 'col 0 'col_span 2
              )
              ; only the entry fields are stretchable
              ; the labels do not stretch
              list('col_stretch 0 0)
              list('col_stretch 1 1)
    ; if you comment this out, you'll get the default width needed to fit the labels
              list('col_min_width 0 100)
            )
          ?frame "Grid Layout"
        )
        hiCreateLayoutForm(
          'ExGridLayout
          "Grid"
          ; surround the grid with a vertical box layout
          ; to provide a stretch_item below to prevent fields
          ; spreading vertically when the form is stretched
          hiCreateVerticalBoxLayout(
            'vbox
            ?items
              list(
                grid
                list('stretch_item 1)
              )
          )
    ;      ?dialogStyle 'modal
        )
        hiDisplayForm(ExGridLayout)
      )
    )
    

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Aurel B
    Aurel B 5 days ago in reply to RK56
    RK56 said:
    Thanks. Should we mention the min size using pixel counts for hiSetFieldMinSize? That is how I read in the documents which is kind of going back to AppForms.

    Yes, you should provide the same values to hiSetFieldMinSize as you would do for an AppForm.
    But I cannot let you say that it's "kind of going back to AppForms" !

    You can specify the minimum width in case you need it, to correct the display of a field, align some stuff, etc.
    But you don't lose the stretchiness and all the other dynamic parameters that layout forms calculate for you.

    I made an example of what you can achieve using layout forms with stretch and spacer items.

    The code is a bit dense, but if you load it, you will get a visual feedback and see how stretchiness works.

    (defun placeholder_field ( text @key min_h_size min_v_size )
      "Create a custom placeholder field to highlight stretching and return it."
      (letseq ( ( name  (gensym 'placeholder_layout)                   )
                ( field (hiCreateHorizontalBoxLayout name ?frame text) )
                )
        ;; Set minimum dimensions when provided
        (when (or min_h_size min_v_size)
          (hiSetFieldMinSize field name ?widgetWidth (or min_h_size 0) ?widgetHeight (or min_v_size 0))
          )
        field))
    
    (hiDisplayForm
      (hiCreateLayoutForm (gensym 'custom_form) "Custom Form"
        (hiCreateVerticalBoxLayout 'main_layout ?items (list
    
            (list
              (hiCreateHorizontalBoxLayout 'h0 ?frame "Vertical Stretch 5" ?items (list
                  (placeholder_field "No Stretch")
                  (list (placeholder_field "Stretch 1") 'stretch 1)
                  (list (placeholder_field "Stretch 0") 'stretch 0)
                  (list (placeholder_field "Stretch 4") 'stretch 4)
                  ))
              'stretch 5)
            '(spacer_item 50)
    
            (list
              (hiCreateHorizontalBoxLayout 'h1 ?frame "Vertical Stretch 2" ?items (list
                  (placeholder_field "No Stretch")
                  (list (placeholder_field "Stretch 1") 'stretch 1)
                  '(stretch_item 2)
                  (list (placeholder_field "Stretch 0") 'stretch 0)
                  '(spacer_item 30)
                  (list (placeholder_field "Stretch 4") 'stretch 4)
                  ))
              'stretch 2)
    
            '(stretch_item 1)
    
            (list
              (hiCreateHorizontalBoxLayout 'h2 ?frame "Vertical Stretch 3" ?items (list
                  (placeholder_field "No Stretch")
                  (list (placeholder_field "Stretch 1 - MinWidth 50" ?min_h_size 50) 'stretch 1)
                  '(stretch_item 1)
                  (list (placeholder_field "Stretch 0 - MinWidth 100" ?min_h_size 100) 'stretch 0)
                  '(spacer_item 30)
                  (list (placeholder_field "Stretch 1") 'stretch 1)
                  ))
              'stretch 3)
            ))
        ?buttonLayout 'Empty
        ))
    
    

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • RK56
    RK56 5 days ago in reply to Aurel B

    Thanks Aurel and Andrew. Your code and the comments in those are helpful. I'm getting a hold of these now.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • 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