Sketch and Grid Layout
The Form Editor provides two layout modes for positioning form objects: sketch layout mode and grid layout mode:
Sketch Layout
Switch between sketch and grid layout mode by clicking Sketch or Grid in the Layout group in the ribbon Form tab.
The Sketch section in the Form tab has two options: Show Grid Lines and Arrange. The Arrange menu allows you to align groups of form objects relative to each other.
Sketch Grid
The Show Grid Lines option displays a sketch grid to which objects are snapped. Note that the grid used in sketch layout mode is different from the grid used in grid layout mode. The default setting for sketch layout mode is to show no grid lines. Without grid lines visible, a form object being dragged is snapped relative to the position of the other form objects.
If the Show Grid Lines option is selected, the upper left corner of a form object being dragged is snapped to the grid line intersection points.
In the Settings window of the form, you can change the settings for the sketch grid:
-
-
Position and Size
The sketch layout mode is pixel based, and the positioning of form objects is indicated as the coordinates of the top-left corner of the form object measured from the top-left corner of the screen. The x-coordinate increases as the object moves to the right, and the y-coordinate increases as the object moves from the top of the screen to the bottom. You can set the absolute position of a form object in the Position and Size section of its Settings window.
Form objects are allotted as much space as required or as specified by their Width and Height values. Form objects are allowed to overlap, when working in sketch layout mode.
Button and toggle button form objects, with their Size setting set to Large, have an Automatic and Manual option for the Width and Height values. The Manual option allows for pixel-based input and the Automatic option adapts the size of the button to the size of the Text string.
Grid Layout
Switch to grid layout mode by clicking Grid in the Layout group in the ribbon.
The buttons and menus in the ribbon Grid group give you easy access to commands for:
Changing the row and column growth rules between Fit, Grow, and Fixed, which determine the layout when the user interface is resized (Row Settings and Column Settings).
Merging and splitting cells (Merge Cells and Split Cells).
The Form Settings Window and the Grid
After switching to grid layout mode, the form window shows blue grid lines.
To review the example shown here, open the Tuning Fork application from the Application Libraries under COMSOL Multiphysics > Applications.
To define the number of rows and columns, click the Rows & Columns button in the ribbon.
The section Grid Layout for Contained Form Objects in the Settings window shows column widths and row heights.
To interactively select a form, as displayed in the Form Editor, click the top-left corner of the form, or select the form in the application tree.
A blue frame is now shown. To interactively change the overall size of a form, you can drag its right and bottom border. The form does not need to be selected for this to work.
Note that if you switch from sketch to grid layout mode, all rows and columns will have the setting Fit and the handles for the frame will not be displayed. If any of the rows and columns have the Height or Width setting set to Grow, then the frame will display handles for resizing in the vertical or horizontal direction, respectively.
The size of the interactively resized frame will affect the initial size of the form only if the Initial size setting is set to Automatic. The size of the frame will also affect the initial size of the Main Window if its Initial size setting is set to Use main form’s size.
Rows and Columns
Click the leftmost cell of a row to select it. The leftmost cells are only used for selecting rows; form objects cannot be inserted there. When a row is selected, the Row Settings menu as well as the Insert and Remove commands are enabled in the ribbon tab. The figure below shows the fourth row highlighted.
Similarly, to select a column, click the cell at the top. This cell cannot contain any form objects. The figure below shows the third column highlighted. In this case, the Column Settings menu is enabled in the ribbon tab.
The Row Settings and the Column Settings have the same three options:
Fit sets the row height or column width to the smallest possible value given the size of the form objects in that row or column.
Grow sets the row height or column width to grow proportionally to the overall size of the form.
Fixed sets a fixed value for the number of pixels for the row height or column width.
You can interactively change the row height and column width by dragging the grid lines.
In this case, the number of pixels will be displayed and the Row Settings or Column Settings growth policy will be changed automatically to Fixed.
As an alternative to changing the Row Settings or Column Settings from the ribbon, you can right-click in a row or column (the light-blue area to the left or at the top of the form) and select from a menu.
The menu shown when right-clicking a row or column also gives you options for inserting, removing, copying, pasting, and duplicating rows or columns.
Cells
Click an individual cell to select it. A selected cell is shown with deeper blue grid lines.
You can select Merge Cells and Split Cells to adjust the cell size and layout of your form objects.
When in grid layout mode, you can specify the margins that are added between the form object and the borders of its containing cell.
In the Settings window of a form object, the Position and Size section has the following options for Cell margin:
-
-
-
If the Horizontal alignment or Vertical alignment is set to Fill and the growth policy of the column or row allows the form object to be resized, then you can specify a minimum width or height, respectively. The minimum size can be set to Manual or Automatic. The Manual option lets you specify a pixel value for the minimum size. The Automatic option allows for a minimum size of zero pixels, unless the form object contents require a higher value. The minimum size setting is used at runtime to ensure that scroll bars are shown before the form object shrinks below its minimum size.
Depending on the type of form object contained in a cell, the Width and Height values can be set to Automatic or Manual, as described in Position and Size.
You can click and drag a rubber box to select multiple cells.
Aligning Form Objects
The Align menu gives you options for aligning form objects within a cell. You can also let a form object dynamically fill a cell horizontally or vertically.
As an alternative, you can right-click a form object and select from a context menu.
Drag and Drop Form Objects
You can drag and drop form objects to move them. Click a form object to select it, and then drag it to another cell that is not already occupied with another form object.
If you drop the object in an already occupied cell, then the objects switch places.
Automatic Resizing of Graphics Objects
If you use one of the more sophisticated Form Wizard templates you will automatically get a layout with a resizable graphics object.
If you do not use these templates, then, in order to make the graphics object of an application resizable, follow these steps:
Change the Height setting for any row covering the graphics object to Grow. To change this, click the leftmost column of the row you would like to access. Then, change the Height setting in the Settings window of the form. Alternatively, right-click and select Grow Row.
Change the Width for any column covering the graphics object to Grow. To change this, right-click the uppermost row of the column you would like to access and select Grow Column.
Select the graphics object and change both the Horizontal alignment and Vertical alignment to Fill. You can do this from the Settings window or by right-clicking the graphics object and selecting Align > Fill Horizontally and Align > Fill Vertically.
Following the steps above, you may find it easier to make graphics objects resizable by performing grid layout mode operations, such as adding empty rows and columns as well as merging cells. If you are already in grid layout mode, then a graphics object will default to Fill in both directions.
Extracting Subforms
You can select a rectangular array of cells in a form and move it to a new form. First, select the cells by using Ctrl+click or Shift+click.
Then, click the Extract Subform button in the ribbon.
This operation creates a new form with the selected cells and replaces the original cells with a form object of type Form. In the Settings window of the subform, the Form reference points to the new form containing the original cells.
Inherit Columns and Cell Margins
By using form collections, forms, and subforms, you can organize your user interface, for example, by grouping sets of input forms. The figure below shows part of a running application with a form collection using sections, forms, and subforms for Mixer properties, Blade properties, Operating Conditions, Results, and Information.
For more information on adding subforms to a form, see the previous section and the section “Form”.
To review the example shown here, open the Helical Static Mixer application from the Application Libraries under COMSOL Multiphysics > Applications. In this example, the Application theme setting, available in the Themes node in the application tree, is set to Default, whereas in the saved example it is set to Dark.
When aligning forms vertically, as in the example above, you may want to ensure that all columns are of equal width. For this purpose, you can use the Inherit columns option in the Settings window of a subform. The figure below shows part of the Settings window for the Operating Conditions form (left) with Name operatingConditions and for the Mixer properties form (right) with Name mixerProperties. The mixerProperties form has its Inherit columns set to the form operatingConditions.
In the subsection Cell margins, you can specify the Horizontal and Vertical margins that are added between form objects and the borders of their containing cells. These settings will affect all form objects contained in the form, with their individual Cell margins set to From parent form; See Cells.