From d01d99481d1f630cbb91cfe50a607e03effa8e51 Mon Sep 17 00:00:00 2001 From: Hombre57 Date: Thu, 11 Apr 2019 22:23:07 +0200 Subject: [PATCH] Suppress baseDPI and baseHiDPI hardcoded values Should fix the issue reported here : https://discuss.pixls.us/t/test-rawtherapee-5-6-rc1/12073/13 --- rtgui/cursormanager.cc | 2 +- rtgui/editwindow.cc | 10 +++++----- rtgui/rtscalable.cc | 2 +- rtgui/rtscalable.h | 8 ++++---- rtgui/rtwindow.cc | 8 ++++---- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/rtgui/cursormanager.cc b/rtgui/cursormanager.cc index 9a28eb061..3181d288e 100644 --- a/rtgui/cursormanager.cc +++ b/rtgui/cursormanager.cc @@ -56,7 +56,7 @@ void CursorManager::init (Glib::RefPtr mainWindow) Glib::RefPtr rotate = RTImage::createPixbufFromFile("rotate-aroundnode-hicontrast.png"); Glib::RefPtr wait = RTImage::createPixbufFromFile("gears.png"); // Currently unused, create *-hicontrast once used. - double s = RTScalable::getTweakedDPI() / 96.; // RTScalable::getDPI() might be preferable, however it imply a lot of work to support this option + double s = RTScalable::getTweakedDPI() / RTScalable::baseDPI; // RTScalable::getDPI() might be preferable, however it imply a lot of work to support this option cAdd = add ? Gdk::Cursor::create(display, add, (int)(8.*s), (int)(8.*s)) : Gdk::Cursor::create(display, Gdk::PLUS); cAddPicker = colPickAdd ? Gdk::Cursor::create(display, colPickAdd, (int)(4.*s), (int)(21.*s)) : Gdk::Cursor::create(display, Gdk::PLUS); diff --git a/rtgui/editwindow.cc b/rtgui/editwindow.cc index 8ba829b26..ec7201f84 100644 --- a/rtgui/editwindow.cc +++ b/rtgui/editwindow.cc @@ -51,7 +51,7 @@ EditWindow* EditWindow::getInstance(RTWindow* p, bool restore) return &instance_.editWnd; } -EditWindow::EditWindow (RTWindow* p) : resolution(96.), parent(p) , isFullscreen(false), isClosed(true) +EditWindow::EditWindow (RTWindow* p) : resolution(RTScalable::baseDPI), parent(p) , isFullscreen(false), isClosed(true) { updateResolution(); @@ -128,7 +128,7 @@ bool EditWindow::updateResolution() double res = get_screen()->get_resolution(); if (scale == 2) { // from Windows' behavior : if scale==2, resolution = 192. (Gtk shows 96 dpi !?), there's no higher value - res = 192.; + res = RTScalable::baseHiDPI; } bool retVal = res != resolution; resolution = res; @@ -141,11 +141,11 @@ void EditWindow::setAppIcon() bool downsize = false; // findIconAbsolutePath won't be able to select the image based on resolution with the // storage of the images, we're doing the selection here - if (resolution == 96.) { + if (resolution == RTScalable::baseDPI) { fName = "rawtherapee-logo-24.png"; } else { fName = "rawtherapee-logo-48.png"; - if (resolution < 192.) { + if (resolution < RTScalable::baseHiDPI) { downsize = true; } } @@ -155,7 +155,7 @@ void EditWindow::setAppIcon() return; } if (downsize) { - int size = int((48. * resolution) / 192.); + int size = int((48. * resolution) / RTScalable::baseHiDPI); pixbuf->scale_simple(size, size, Gdk::InterpType::INTERP_BILINEAR); } diff --git a/rtgui/rtscalable.cc b/rtgui/rtscalable.cc index 7aa3c82c8..e497e3f08 100644 --- a/rtgui/rtscalable.cc +++ b/rtgui/rtscalable.cc @@ -225,7 +225,7 @@ Cairo::RefPtr RTScalable::loadImage(const Glib::ustring &fn RsvgDimensionData dim; rsvg_handle_get_dimensions(handle, &dim); - double r = dpi / 96.; + double r = dpi / baseDPI; Cairo::RefPtr surf = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, (int)(dim.width * r + 0.499), (int)(dim.height * r + 0.499)); Cairo::RefPtr c = Cairo::Context::create(surf); c->set_source_rgba (0., 0., 0., 0.); diff --git a/rtgui/rtscalable.h b/rtgui/rtscalable.h index c3ff19e60..a182dd2e0 100644 --- a/rtgui/rtscalable.h +++ b/rtgui/rtscalable.h @@ -40,11 +40,11 @@ protected: public: #ifdef __APPLE__ - static constexpr double baseDPI = 72; - static constexpr double baseHiDPI = 144; + static constexpr double baseDPI = 72.; + static constexpr double baseHiDPI = 144.; #else - static constexpr double baseDPI = 96; - static constexpr double baseHiDPI = 192; + static constexpr double baseDPI = 96.; + static constexpr double baseHiDPI = 192.; #endif static void init(Gtk::Window *window); diff --git a/rtgui/rtwindow.cc b/rtgui/rtwindow.cc index 0d9017fbd..ce1d5151a 100644 --- a/rtgui/rtwindow.cc +++ b/rtgui/rtwindow.cc @@ -109,7 +109,7 @@ RTWindow::RTWindow () #if defined(__APPLE__) // This will force screen resolution regarding font, but I don't think it's compliant with Gtk guidelines... // Do not confuse with screen scaling, where everything is scaled up ! - screen->set_resolution (96.); + screen->set_resolution (RTScalable::baseDPI); #endif Glib::RefPtr regex = Glib::Regex::create (THEMEREGEXSTR, Glib::RegexCompileFlags::REGEX_CASELESS); @@ -184,15 +184,15 @@ RTWindow::RTWindow () int resolution = (int)style->get_screen()->get_resolution(); if (isPix) { // HOMBRE: guessing here... - // if resolution is lower than 192ppi, we're supposing that it's already expressed in a scale==1 scenario + // if resolution is lower than baseHiDPI, we're supposing that it's already expressed in a scale==1 scenario if (resolution >= int(RTScalable::baseHiDPI)) { // converting the resolution to a scale==1 scenario resolution /= 2; } // 1pt = 1/72in @ 96 ppi // HOMBRE: If the font unit is px, is it already scaled up to match the resolution ? - // px >inch >pt >"scaled pt" - pt = (int)(double(fontSize) / RTScalable::baseDPI * 72. * (RTScalable::baseHiDPI / resolution) + 0.49); + // px >inch >pt >"scaled pt" + pt = (int)(double(fontSize) / RTScalable::baseDPI * 72. * (RTScalable::baseDPI / resolution) + 0.49); } else { pt = fontSize / Pango::SCALE; }