merge with dev

This commit is contained in:
Desmis 2019-04-16 10:59:38 +02:00
commit c9af6109ab
12 changed files with 59 additions and 34 deletions

View File

@ -1036,6 +1036,7 @@ PREFERENCES_APPEARANCE_COLORPICKERFONT;Police des ancres de vérification couleu
PREFERENCES_APPEARANCE_CROPMASKCOLOR;Couleur du masque de recadrage
PREFERENCES_APPEARANCE_MAINFONT;Police principale
PREFERENCES_APPEARANCE_NAVGUIDECOLOR;Couleur du cadre dans le Navigateur
PREFERENCES_APPEARANCE_PSEUDOHIDPI;Mode pseudo-HiDPI
PREFERENCES_APPEARANCE_THEME;Thème
PREFERENCES_APPLNEXTSTARTUP;appliqué au prochain lancement
PREFERENCES_AUTOMONPROFILE;Utiliser automatiquement le profil de l'écran principal

View File

@ -1237,6 +1237,7 @@ PREFERENCES_APPEARANCE_COLORPICKERFONT;Color picker font
PREFERENCES_APPEARANCE_CROPMASKCOLOR;Crop mask color
PREFERENCES_APPEARANCE_MAINFONT;Main font
PREFERENCES_APPEARANCE_NAVGUIDECOLOR;Navigator guide color
PREFERENCES_APPEARANCE_PSEUDOHIDPI;Pseudo-HiDPI mode
PREFERENCES_APPEARANCE_THEME;Theme
PREFERENCES_APPLNEXTSTARTUP;restart required
PREFERENCES_AUTOMONPROFILE;Use operating system's main monitor color profile

View File

@ -56,7 +56,7 @@ void CursorManager::init (Glib::RefPtr<Gdk::Window> mainWindow)
Glib::RefPtr<Gdk::Pixbuf> rotate = RTImage::createPixbufFromFile("rotate-aroundnode-hicontrast.png");
Glib::RefPtr<Gdk::Pixbuf> 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);

View File

@ -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);
}

View File

@ -376,14 +376,6 @@ int main (int argc, char **argv)
Glib::init(); // called by Gtk::Main, but this may be important for thread handling, so we call it ourselves now
Gio::init ();
// Reading/updating GDK_SCALE early if it exists
const gchar *gscale = g_getenv("GDK_SCALE");
if (gscale && gscale[0] == '2') {
initialGdkScale = 2;
}
// HOMBRE: On Windows, if resolution is set to 200%, Gtk internal variables are SCALE=2 and DPI=96
g_setenv("GDK_SCALE", "1", true);
#ifdef WIN32
if (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == 0x0003) {
// started from msys2 console => do not buffer stdout
@ -537,6 +529,16 @@ int main (int argc, char **argv)
int ret = 0;
if (options.pseudoHiDPISupport) {
// Reading/updating GDK_SCALE early if it exists
const gchar *gscale = g_getenv("GDK_SCALE");
if (gscale && gscale[0] == '2') {
initialGdkScale = 2;
}
// HOMBRE: On Windows, if resolution is set to 200%, Gtk internal variables are SCALE=2 and DPI=96
g_setenv("GDK_SCALE", "1", true);
}
gdk_threads_set_lock_functions (G_CALLBACK (myGdkLockEnter), (G_CALLBACK (myGdkLockLeave)));
gdk_threads_init();
gtk_init (&argc, &argv); // use the "--g-fatal-warnings" command line flag to make warnings fatal

View File

@ -349,6 +349,7 @@ void Options::setDefaults()
fontSize = 10;
CPFontFamily = "default";
CPFontSize = 8;
pseudoHiDPISupport = false;
lastScale = 5;
lastShowAllExif = false;
panAccelFactor = 5;
@ -1284,6 +1285,10 @@ void Options::readFromFile(Glib::ustring fname)
CPFontSize = keyFile.get_integer("GUI", "CPFontSize");
}
if (keyFile.has_key("GUI", "PseudoHiDPISupport")) {
pseudoHiDPISupport = keyFile.get_boolean("GUI", "PseudoHiDPISupport");
}
if (keyFile.has_key("GUI", "LastPreviewScale")) {
lastScale = keyFile.get_integer("GUI", "LastPreviewScale");
}
@ -2129,6 +2134,7 @@ void Options::saveToFile(Glib::ustring fname)
keyFile.set_integer("GUI", "FontSize", fontSize);
keyFile.set_string("GUI", "CPFontFamily", CPFontFamily);
keyFile.set_integer("GUI", "CPFontSize", CPFontSize);
keyFile.set_boolean("GUI", "PseudoHiDPISupport", pseudoHiDPISupport);
keyFile.set_integer("GUI", "LastPreviewScale", lastScale);
keyFile.set_boolean("GUI", "LastShowAllExif", lastShowAllExif);
keyFile.set_integer("GUI", "PanAccelFactor", panAccelFactor);

View File

@ -212,6 +212,7 @@ public:
int fontSize; // RT's main font size (units: pt)
Glib::ustring CPFontFamily; // ColorPicker font family
int CPFontSize; // ColorPicker font size (units: pt)
bool pseudoHiDPISupport;
bool fbOnlyRaw;
bool fbShowDateTime;
bool fbShowBasicExif;

View File

@ -1055,13 +1055,16 @@ Gtk::Widget* Preferences::getGeneralPanel()
navGuideColorCB = Gtk::manage(new Gtk::ColorButton());
navGuideColorCB->set_use_alpha(true);
pseudoHiDPI = Gtk::manage(new Gtk::CheckButton(M("PREFERENCES_APPEARANCE_PSEUDOHIDPI") + Glib::ustring (" (") + M ("PREFERENCES_APPLNEXTSTARTUP") + ")"));
setExpandAlignProperties(pseudoHiDPI, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE);
Gtk::VSeparator *vSep = Gtk::manage(new Gtk::VSeparator());
appearanceGrid->attach(*themeLbl, 0, 0, 1, 1);
appearanceGrid->attach(*themeCBT, 1, 0, 1, 1);
appearanceGrid->attach(*themeRestartLbl, 2, 0, 2, 1);
appearanceGrid->attach(*vSep, 2, 1, 1, 3);
appearanceGrid->attach(*vSep, 2, 1, 1, 2);
appearanceGrid->attach(*mainFontLbl, 0, 1, 1, 1);
appearanceGrid->attach(*mainFontFB, 1, 1, 1, 1);
appearanceGrid->attach(*cropMaskColorLbl, 3, 1, 1, 1);
@ -1070,6 +1073,7 @@ Gtk::Widget* Preferences::getGeneralPanel()
appearanceGrid->attach(*colorPickerFontFB, 1, 2, 1, 1);
appearanceGrid->attach(*navGuideColorLbl, 3, 2, 1, 1);
appearanceGrid->attach(*navGuideColorCB, 4, 2, 1, 1);
appearanceGrid->attach(*pseudoHiDPI, 0, 3, 5, 1);
appearanceFrame->add(*appearanceGrid);
vbGeneral->attach_next_to(*appearanceFrame, *flang, Gtk::POS_BOTTOM, 2, 1);
@ -1649,6 +1653,8 @@ void Preferences::storePreferences()
moptions.CPFontSize = cpfd.get_size() / Pango::SCALE;
}
moptions.pseudoHiDPISupport = pseudoHiDPI->get_active();
#ifdef WIN32
moptions.gimpDir = gimpDir->get_filename();
moptions.psDir = psDir->get_filename();
@ -1913,6 +1919,8 @@ void Preferences::fillPreferences()
colorPickerFontFB->set_font_name (Glib::ustring::compose ("%1 %2", options.CPFontFamily, options.CPFontSize));
}
pseudoHiDPI->set_active(options.pseudoHiDPISupport);
showDateTime->set_active(moptions.fbShowDateTime);
showBasicExif->set_active(moptions.fbShowBasicExif);
showExpComp->set_active(moptions.fbShowExpComp);

View File

@ -145,6 +145,8 @@ class Preferences : public Gtk::Dialog, public ProfileStoreListener
Gtk::FontButton* colorPickerFontFB;
Gtk::ColorButton* cropMaskColorCB;
Gtk::ColorButton* navGuideColorCB;
Gtk::CheckButton* pseudoHiDPI;
Gtk::SpinButton* maxRecentFolders;
Gtk::SpinButton* maxThumbHeightSB;

View File

@ -36,6 +36,12 @@ Gtk::TextDirection RTScalable::direction = Gtk::TextDirection::TEXT_DIR_NONE;
void RTScalable::setDPInScale (const double newDPI, const int newScale)
{
if (!options.pseudoHiDPISupport) {
scale = 1;
dpi = baseDPI;
return;
}
if (scale != newScale || (scale == 1 && dpi != newDPI)) {
// reload all images
scale = newScale;
@ -225,7 +231,7 @@ Cairo::RefPtr<Cairo::ImageSurface> RTScalable::loadImage(const Glib::ustring &fn
RsvgDimensionData dim;
rsvg_handle_get_dimensions(handle, &dim);
double r = dpi / 96.;
double r = dpi / baseDPI;
Cairo::RefPtr<Cairo::ImageSurface> surf = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, (int)(dim.width * r + 0.499), (int)(dim.height * r + 0.499));
Cairo::RefPtr<Cairo::Context> c = Cairo::Context::create(surf);
c->set_source_rgba (0., 0., 0., 0.);

View File

@ -40,11 +40,13 @@ protected:
public:
#ifdef __APPLE__
static constexpr double baseDPI = 72;
static constexpr double baseHiDPI = 144;
static constexpr double baseDPI = 72.;
static constexpr double baseHiDPI = 144.;
static constexpr int baseFontSize = 12;
#else
static constexpr double baseDPI = 96;
static constexpr double baseHiDPI = 192;
static constexpr double baseDPI = 96.;
static constexpr double baseHiDPI = 192.;
static constexpr int baseFontSize = 9;
#endif
static void init(Gtk::Window *window);

View File

@ -106,12 +106,6 @@ RTWindow::RTWindow ()
Gtk::Settings::get_for_screen (screen)->property_gtk_theme_name() = "Adwaita";
Gtk::Settings::get_for_screen (screen)->property_gtk_application_prefer_dark_theme() = true;
#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.);
#endif
Glib::RefPtr<Glib::Regex> regex = Glib::Regex::create (THEMEREGEXSTR, Glib::RegexCompileFlags::REGEX_CASELESS);
Glib::ustring filename;
Glib::MatchInfo mInfo;
@ -170,7 +164,9 @@ RTWindow::RTWindow ()
css = Glib::ustring::compose ("* { font-family: %1; font-size: %2pt}", options.fontFamily, options.fontSize * (int)initialGdkScale);
#endif
//GTK318
fontScale = options.fontSize / 9.f;
if (options.pseudoHiDPISupport) {
fontScale = options.fontSize / (float)RTScalable::baseFontSize;
}
if (options.rtSettings.verbose) {
printf("\"Non-Default\" font size(%d) * scale(%d) / fontScale(%.3f)\n", options.fontSize, (int)initialGdkScale, fontScale);
}
@ -184,27 +180,27 @@ 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. * (96. / (double)resolution) + 0.49);
} else {
pt = fontSize / Pango::SCALE;
}
fontScale = (float)pt / 9.f;
if ((int)initialGdkScale > 1 || pt != 9) {
if (options.pseudoHiDPISupport) {
fontScale = (float)pt / (float)RTScalable::baseFontSize;
}
if ((int)initialGdkScale > 1 || pt != RTScalable::baseFontSize) {
css = Glib::ustring::compose ("* { font-size: %1pt}", pt * (int)initialGdkScale);
if (options.rtSettings.verbose) {
printf("\"Default\" font size(%d) * scale(%d) / fontScale(%.3f)\n", pt, (int)initialGdkScale, fontScale);
}
}
} else {
fontScale = 1.f;
}
}
if (!css.empty()) {