Hi Sean,
Welcome to PixInsight development!
Nice work. If you don't mind, I'd like to include this script in the standard set released with the next version.
I have attached a modified version of your script that fixes all screen alignment and sizing problems. The most important modifications include the following:
- When you create a NumericControl control, it already includes a Label subcontrol (its label property) that you must use. There's no need to define an independent Label and a HorizontalSizer to group it with the NumericControl.
- To visually align all controls on a dialog, use the font property of Dialog to compute a minimum width in pixels for the longest label. Then use that value to set the minWidth property of all labels.
- You can (should) define the width of all Edit controls in the same way. in this case you must force a fixed width for the edit subcontrols of all NumericControl items, as Edit controls shouldn't be resizable in general. However, you must call edit.setFixedWidth() after calling the setPrecision() and setRange() methods of NumericControl, as these methods reset the edit's width automatically.
- There is no need to set the label.textAlignment property, as it is already set to TextAlign_Right|TextAlign_VertCenter by NumericControl's constructor.
- Try to avoid leaving potentially unrooted child controls in a dialog's constructor. For example, if you write:
function MyDialog()
{
...
var foo = new Label( this );
...
}
this code should normally work as expected, i.e. foo will be a child control of MyDialog, and in most cases it won't give problems. However, by doing that you take one risk: under certain conditions, the JavaScript garbage collector may decide that foo has become out-of-scope and is unreferenced, and if that happens, foo will eventually be destroyed behind the scenes, with catastrophic results. Although I have been very careful to prevent that to happen with all GUI objects, JavaScript's internals are too complex as to ensure that no unexpected garbage collection may happen sometimes.
To prevent these side effects, always define all subcontrols as properties of their parent controls. In the case above:
function MyDialog()
{
...
this.foo = new Label( this );
...
}
is safer because as long as an instance of MyDialog is referenced, its foo child control will also be referenced.
- When a dialog must be user-resizable, always try to force at least one fixed dimension —either the width or the height, as appropriate— whenever possible. In your script, I have set a fixed width of 420 pixels:
this.setFixedWidth( 420 );
this.adjustToContents();
which allows only changing the dialog's height. This ensures that a valid geometry will be set on all supported platforms (Mac OS X is particularly problematic in this regard).
Hope this helps.