Author Topic: Label.styleSheet for UI scaling?  (Read 4367 times)

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
Label.styleSheet for UI scaling?
« on: 2015 September 22 16:06:13 »
Hi Juan,

For value labels I have been using the QLabel stylesheet you provided below. Is this still valid for all UI scaling? In particular, I am wondering about the 1px usages.

Thanks,
Mike

Code: [Select]
      var value = new Label(this);
      value.styleSheet = "QLabel {" +
         "border-top: 1px solid gray;" +
         "border-left: 1px solid gray;" +
         "border-bottom: 1px solid white;" +
         "border-right: 1px solid white;" +
         "}";

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Label.styleSheet for UI scaling?
« Reply #1 on: 2015 September 23 01:23:04 »
Hi Mike,

The following method:

String Control.scaledStyleSheet( String cssCode[, int fontDPI=0] )

returns the specified CSS source code fragment transformed with scaled dimensions in pixels and scaled resource file paths, and optionally point sizes converted to scaled pixel sizes. See the PCL documentation entry for pcl::Control::ScaledStyleSheet for a detailed description.

In the example you have included, the corresponding code would be:

Code: [Select]
      var value = new Label(this);
      value.styleSheet = this.scaledStyleSheet( "QLabel {" +
         "border-top: 1px solid gray;" +
         "border-left: 1px solid gray;" +
         "border-bottom: 1px solid white;" +
         "border-right: 1px solid white;" +
         "}" );

See also the User Interface Scaling Functions section of PCL documentation for more information about automatic UI scaling on PCL/PJSR. Let me know if this helps.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
Re: Label.styleSheet for UI scaling?
« Reply #2 on: 2015 September 23 10:59:24 »
Hi Juan,

Thanks. Two issues:

- In Win7 1171, at UI scaling 1.45, Edit control borders are 2px, but scaledStyleSheet on the value label style maps 1px to 1px. The layout looks bad IMO, value label borders are too thin. Is this a bug? On the other hand, at UI scaling 1.5 and also 2.0, both are 2px, which looks good. (My laptop display is too small to test UI scalings larger than 2).

- In your PCL documentation for pcl::Control::ScaledStyleSheet, the parameter scalingFactor is specified. Looks like a typo. No such parameter on this variant.

Mike