Author Topic: PJSR - Is layout workaround code required?  (Read 4196 times)

Offline bitli

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 513
PJSR - Is layout workaround code required?
« on: 2013 February 10 13:03:12 »
As some issues with layout on Mac was reported for my scripts, and the layout/fonts on Linux are bizarre too, I investigated some existing code to try to find best practices.

I found this in NumericControl (in includes):
Code: [Select]
#ifeq __PI_PLATFORM__ MACOSX
// ### FIXME: This is an ugly work around to some rendering problems on Mac OS X
   this.setFixedHeight( Math.trunc( this.edit.font.height * 1.7 ) );
#else
   this.setFixedHeight();
#endif

Do I have to take this into account in my scripts too ?

Also in the BatchPreprocessing, some components directly extending Control has:
Code: [Select]
this.styleSheet =
"QWidget {"
+ "font-size: " + this.dialog.font.pointSize.toString() + "pt;"
+ "font-family: " + this.dialog.font.face + ";"
+ "}";

Apparently to ensure that proper fonts are used.  Is this something I should do too if I derive Control ?

Thanks
-- bitli

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: PJSR - Is layout workaround code required?
« Reply #1 on: 2013 February 11 02:53:05 »
You should not need to use any of these workarounds in newly produced script code for PixInsight 1.8.0 RC3 or later. In fact, the fix for Mac OS X in NumericControl should not be present because it isn't required anymore, now that we have a uniform GUI style on all platforms, which does not depend on platform-specific quirks.

The style sheet in BatchPreprocessing is a special case. The same should be achieved with more 'traditional' code like this:

this.font = this.dialog.font;

or even:

this.font = new Font( this.dialog.font );

However, for some strange reason (probably a Qt bug) this doesn't work reliably in the BatchPreprocessing script. You can try it if you want, and you'll see how the first Image Integration panel (on the Bias tab sheet) ignores the font, while the rest of the interface works correctly. Fortunately, a simple Qt style sheet fixes this problem.

Please note that this is a very special case. You shouldn't need to use a similar workaround unless you experience similar problems. In such case, please report them here.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/