From f48750b0f482a2155ec5d66b19110d2ac22ce87c Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Wed, 17 May 2017 11:54:18 +0000 Subject: Introduce HiDPI + rescaling support for the X11 platform (+ partial support for WIN32) Corresponds to STR #3320 1) HiDPI support consists in detecting the adequate scaling factor for the screen on which FLTK maps a window, and scaling all FLTK units by this factor. FLTK tries to detect the correct value of this factor at startup (see more details below). Environment variable FLTK_SCALING_FACTOR can also be used to set this value. 2) Rescaling support consists in changing the scaling factor of all FLTK windows in reply to ctrl/+/-/0/ keystrokes. More details for the various platforms : - X11: Support is very advanced. Some details need still to be improved. Automatic detection of the correct starting value of the scaling factor works well with the gnome desktop. The present code contains no support for this on other desktops. FLTK_SCALING_FACTOR provides a workaround. -WIN32: Support is incomplete at this point, although many test applications have partial or complete HiDPI and scaling support. The current value of the system's scaling factor is correctly detected at application startup. Apps respond to changes of this value in real time. Support needs to define the FLTK_HIDPI_SUPPORT preprocessor variable at compile time. This way, standard builds produce a code with the default WIN32 HiDPI support, that is, where all graphics goes to an internal buffer that gets enlarged by the system and then mapped to the HiDPI display. To experiment with (or develop) the new HiDPI support requires a modified build procedure in which FLTK_HIDPI_SUPPORT is defined at compile time. When the support will be complete, the requirement for the definition of this preprocessor variable will be removed. The present commit contains support for a single scaling factor. Eventually, per-screen scaling factors should be implemented, as done for X11. - MacOS: this commit does not give new HiDPI for this platform. Eventually, window rescaling in reply to command/+/-/0/ is desirable. Per-screen scaling factor makes no sense on this platform because the OS itself takes care of the difference between the resolutions of traditional and retina displays. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12239 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- .../Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx | 23 ++++++---------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx') diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx index 05c58eb8d..d36b540e7 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx @@ -3,7 +3,7 @@ // // Portable drawing routines for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2016 by Bill Spitzak and others. +// Copyright 1998-2017 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -30,14 +30,6 @@ #include -void Fl_Xlib_Graphics_Driver::transformed_vertex(double xf, double yf) { - transformed_vertex0(short(rint(xf)), short(rint(yf))); -} - -void Fl_Xlib_Graphics_Driver::vertex(double x,double y) { - transformed_vertex0(short(x*m.a + y*m.c + m.x), short(x*m.b + y*m.d + m.y)); -} - void Fl_Xlib_Graphics_Driver::end_points() { if (n>1) XDrawPoints(fl_display, fl_window, gc_, (XPoint*)p, n, 0); } @@ -52,7 +44,9 @@ void Fl_Xlib_Graphics_Driver::end_line() { void Fl_Xlib_Graphics_Driver::end_loop() { fixloop(); - if (n>2) transformed_vertex((short)p[0].x, (short)p[0].y); + if (n>2) { + transformed_vertex0(p[0].x, p[0].y); + } end_line(); } @@ -73,7 +67,7 @@ void Fl_Xlib_Graphics_Driver::begin_complex_polygon() { void Fl_Xlib_Graphics_Driver::gap() { while (n>gap_+2 && p[n-1].x == p[gap_].x && p[n-1].y == p[gap_].y) n--; if (n > gap_+2) { - transformed_vertex((short)p[gap_].x, (short)p[gap_].y); + transformed_vertex0(p[gap_].x, p[gap_].y); gap_ = n; } else { n = gap_; @@ -92,12 +86,7 @@ void Fl_Xlib_Graphics_Driver::end_complex_polygon() { // shortcut the closed circles so they use XDrawArc: // warning: these do not draw rotated ellipses correctly! // See fl_arc.c for portable version. - -void Fl_Xlib_Graphics_Driver::circle(double x, double y,double r) { - double xt = transform_x(x,y); - double yt = transform_y(x,y); - double rx = r * (m.c ? sqrt(m.a*m.a+m.c*m.c) : fabs(m.a)); - double ry = r * (m.b ? sqrt(m.b*m.b+m.d*m.d) : fabs(m.d)); +void Fl_Xlib_Graphics_Driver::ellipse_unscaled(double xt, double yt, double rx, double ry) { int llx = (int)rint(xt-rx); int w = (int)rint(xt+rx)-llx; int lly = (int)rint(yt-ry); -- cgit v1.2.3