Re: Widgets margins relative to character size (high DPI issue)



Hi Stefan,

High-DPI infrastructure was introduced to GTK+3 last cycle:

http://blogs.gnome.org/alexl/2013/06/28/hidpi-support-in-gnome/

It should be completely transparent to your application. It works like HTML5 does, by making the "drawing pixel" different from the "device pixel".

You can test on a low-DPI display by setting the GDK_SCALE envvar. Try running:

  $ GDK_SCALE=2 ./your-app

and see if it's any different.

Happy hacking!


On Mon, Feb 10, 2014 at 11:59 AM, Stefan Salewski <mail ssalewski de> wrote:
Recently I ported an Ruby application to GTK3. It is working fine so
far, but it seems that for GTK3 still stuff like widget margins and
window borders are specified in pixels. (some sizes, like text entry
size, can be specified already in characters, which is fine)

My application is in area of CAD
(http://www.ssalewski.de/PetEd.html.en), so it may be used with displays
of 200 DPI or more. Problem is, when a user has scaled text and widgets
sizes up, i.e. double the ordinary size. When I specify borders and
margins in pixesl, then it may look not really nice for 200 DPI with
scaled up widgets. I can offer the user a way to manually scale that
spaces, some sort of that scaling is already offered for cairo drawing
in my application, i.e. line width. But generally I would prefer
automatic scaling of widgets margins. LaTeX has sizes em and ex relative
to current font -- I think I can do something similar when I query users
default font size or users custom widgets size. For GTK3 label there
seems to be a method gtk_label_get_layout() and Pango offers methods to
query pixel size of that layout. That may work, I can calculate some
kind of ex and em values at program startup. (Unfortunately I am not
notified when user changes font size in gnome control center...)

Are there betters solution? I.e direct access to users default font size
in x and y pixels?

Best regards,

Stefan Salewski


_______________________________________________
gtk-list mailing list
gtk-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-list



--
  Jasper


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]