From 5bd467fa17be55397f433dddc065b57cbb7a0615 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Thu, 25 Feb 2021 11:06:54 +0100 Subject: Add fl_remove_scale()/fl_restore_scale() to transiently draw without scaling factor. This new API is a response to this message in fltk.general : Can custom box type functions handle their own high-DPI screen scaling? --- src/fl_draw.cxx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/fl_draw.cxx') diff --git a/src/fl_draw.cxx b/src/fl_draw.cxx index 72a117df0..538e63f2a 100644 --- a/src/fl_draw.cxx +++ b/src/fl_draw.cxx @@ -458,3 +458,20 @@ int fl_height(int font, int size) { fl_font(tf,ts); // restore return(height); } + +/** Removes any GUI scaling factor in subsequent drawing operations. + This must be matched by a later call to fl_restore_scale(). + This function can be used to transiently perform drawing operations + that are not rescaled by the current value of the GUI scaling factor. + The resulting drawing context has no clipping region. + \return The GUI scaling factor value that was applied when the function started. + */ +float fl_remove_scale() { + return fl_graphics_driver->remove_scale(); +} + +/** Restores the GUI scaling factor and the clipping region in subsequent drawing operations. + \param s Value returned by a previous call to fl_remove_scale(). */ +void fl_restore_scale(float s) { + fl_graphics_driver->restore_scale(s); +} -- cgit v1.2.3