• 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. fileds not aligned as defined byhoriz_align

Stats

  • Locked Locked
  • Replies 6
  • Subscribers 142
  • Views 4266
  • 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

fileds not aligned as defined byhoriz_align

kkdesbois
kkdesbois over 1 year ago

Hello,
I can't understand why the toggle items are not left aligned in their grid column.

with the following code :

(let (familyList l_familiesLayout)
(setq familyList
   (list (list "MOS" (list "TYP" "SLOW" "FAST"))
   (list "BIP" (list "BTYP" "BMIN" "BMAX"))
   (list "RES" (list "RTYP" "RMIN" "RMAX"))
   (list "UNIQ" (list "one")) ))

(foreach family familyList
   (setq l_familiesLayout (cons
      (hiCreateGridLayout (concat "grid_" (car family))
                          ?frame t
                          ?items (list (list (hiCreateLabel ?name (concat "label_" (car family)) ?labelText (car family)) 'row 0 'col 0)
                                       (list (hiCreateToggleField ?name (concat "pdc_" (car family))
                                                                  ?choices (foreach mapcar pdc (cadr family) (list (concat pdc))))
                                             'row 0 'col 1 'horiz_align 'left) ))
      l_familiesLayout))
)


(hiCreateLayoutForm
   'test
   "TEST"
   (hiCreateVerticalBoxLayout 'vbox ?items l_familiesLayout) ?buttonLayout `(OKCancelDefApply)
)
(hiDisplayForm 'test)
)

Can someone enlighten me please? I read many posts related to horiz_align but I'm still lost.

Laurent.

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago

    Laurent,

    You have four separate grids. There's no alignment between grid locations between different grids, so this isn't going to work. You could combine as follows:

    (let (familyList familyItems familiesLayout (row -1))
      ; might want to reverse the order of this list?
      (setq familyList
            (list (list "MOS" (list "TYP" "SLOW" "FAST"))
                  (list "BIP" (list "BTYP" "BMIN" "BMAX"))
                  (list "RES" (list "RTYP" "RMIN" "RMAX"))
                  (list "UNIQ" (list "one")) ))
    
      ; create items for a single grid, with a row for each label
      ; and toggle field. Note that the toggle items won't align perfectly
      ; this way though... but it's simpler
      (setq familyItems
            (foreach mapcan family familyList
                     (postincrement row)
                     (list 
                       (list 
                         (hiCreateLabel 
                           ?name (concat "label_" (car family))
                           ?labelText (car family))
                         'row row 'col 0)
                       (list 
                         (hiCreateToggleField 
                           ?name (concat "pdc_" (car family))
                           ?choices (foreach mapcar pdc (cadr family) (list (concat pdc)))
                           )
                         'row row 'col 1 'horiz_align 'left)
                       )))
      (setq familiesLayout 
            (hiCreateGridLayout 
              'grid
              ?frame t
              ?items familyItems
              ))
      (hiCreateLayoutForm
        'test
        "TEST"
        (hiCreateVerticalBoxLayout 
          'vbox 
          ?items (list familiesLayout (list 'stretch_item 1))
          )
        ?buttonLayout `(OKCancelDefApply)
        )
      (hiDisplayForm 'test)
    )

    However, even then there's not going to be alignment between the members of the toggle field. See this:

    I have a second approach which I'll post in a moment.

    Andrew

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

    This approach uses boolean buttons instead of a toggle field. This allows me to place each boolean button in a separate column in a single grid, and hence have everything aligned.

    (let (familyList familyItems familiesLayout (row -1) col)
      ; might want to reverse the order of this list?
      (setq familyList
            (list (list "MOS" (list "TYP" "SLOW" "FAST"))
                  (list "BIP" (list "BTYP" "BMIN" "BMAX"))
                  (list "RES" (list "RTYP" "RMIN" "RMAX"))
                  (list "UNIQ" (list "one")) ))
    
      ;----------------------------------------------------------------------
      ; Create items for a single grid, with a boolean button for
      ; every checkbox
      ;----------------------------------------------------------------------
      (setq familyItems
            (foreach mapcan family familyList
                     (postincrement row)
                     (setq col 0)
                     (cons 
                     (list 
                       (hiCreateLabel 
                         ?name (concat "label_" (car family))
                         ?labelText (car family))
                       'row row 'col (postincrement col)
                       )
                     (foreach mapcar pdc (cadr family) 
                              (list
                                (hiCreateBooleanButton
                                  ?name (concat "pdc_" (car family) "_" pdc)
                                  ?buttonText pdc
                                  ?buttonLocation 'left
                                  )
                                'row row 'col (postincrement col)
                                ))
                     )))
      (setq familiesLayout 
            (hiCreateGridLayout 
              'grid
              ?frame t
              ?items familyItems
              ))
      (hiCreateLayoutForm
        'test
        "TEST"
        (hiCreateVerticalBoxLayout 
          'vbox 
          ?items (list familiesLayout (list 'stretch_item 1))
          )
        ?buttonLayout `(OKCancelDefApply)
        )
      (hiDisplayForm 'test)
    )
    

    Here's the output:

    Andrew

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

    Thanks Andrew for the different replies and suggestions.

    I probably misunderstood (not the first time!) what the option 'horiz_align does. As it is defined at the same time as the grid field (I call grid field a pair row/column), I thought horiz_align was defining how the item placed in that grid field would be aligned.

    I enjoy your usage of foreach mapcan to build the new list! And I'm fond of the functions post/pre increment (and plus, times,...), so much litteral ;)

    Nevertheless I'm attached to the separate grids. Because my next goal is to make visible/unvisible one or several grids according to an external callback that will modifiy the grid(s) argument ?unvisible.

    I'm rebuilding an already existing form created without the hiFormLayout (old method with coordonates/spacer/width for each field). In this already existing form, it's complicated to make unvisible some fields unless recreating the form

    Each grid will have (in my example) two columns. I can fix the minimum width of the 1st colum, and ensure it will be the same width for all the grids. And the width of the second column will depend on how many toggles are in it.

    But It doesn't matter as long as the toggle is left aligned in its grid field

    It's not a problem if the toggles are not vertically aligned because some families may have corner names longer than 4 characters

    I'm going to try different vbox/hbox combinations and see if it can be more flexible than grids.

    Laurent.

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

    Laurent,

    You could of course just set the visibility on all the items in a row. For example:

    (defun CCFsetRowVisibility (form row invisible)
      (foreach rowField
               (setof field form->fieldList
                      (equal
                        (cadr (hiGetGridLayoutItemLocation form field))
                        row))
               (putpropq (get form rowField) invisible invisible))
      t
      )
    
    

    Then use:

    (CCFsetRowVisibility test 1 t) ; or nil if you want to make visible again

    Andrew

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

    I note it.

    In the real code, each grid is composed of several rows that will have to (dis)appear.

    But by using your previous code suggestion, I should be able to make invisible every items of several rows.
    You make a row invisible by using its number. i need to access to the fields in the row thanks to the family name.

    Let me digest all the informations and see how to use them in my project.

    Thanks again.

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

    You could either use the family name part of the field name to do the filtering, or you could store an explicit property on each field to say which family it belongs to - that would allow a similar approach - it's just a matter of identifying the relevant fields somehow.

    Anyway, hopefully you now have a few ideas of approaches that you might consider!

    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