Adding HiDPI support (WIP)
This commit is contained in:
@@ -50,18 +50,11 @@ EditWindow* EditWindow::getInstance(RTWindow* p, bool restore)
|
||||
return &instance_.editWnd;
|
||||
}
|
||||
|
||||
EditWindow::EditWindow (RTWindow* p) : parent(p) , isFullscreen(false), isClosed(true)
|
||||
EditWindow::EditWindow (RTWindow* p) : resolution(96.), parent(p) , isFullscreen(false), isClosed(true)
|
||||
{
|
||||
|
||||
Glib::ustring fName = "rawtherapee-logo-24.png";
|
||||
Glib::ustring fullPath = rtengine::findIconAbsolutePath(fName);
|
||||
|
||||
try {
|
||||
set_default_icon_from_file (fullPath);
|
||||
} catch(Glib::Exception& ex) {
|
||||
printf ("%s\n", ex.what().c_str());
|
||||
}
|
||||
|
||||
updateResolution();
|
||||
setAppIcon();
|
||||
set_title_decorated("");
|
||||
set_modal(false);
|
||||
set_resizable(true);
|
||||
@@ -128,8 +121,59 @@ void EditWindow::on_realize ()
|
||||
editWindowCursorManager.init (get_window());
|
||||
}
|
||||
|
||||
bool EditWindow::updateResolution()
|
||||
{
|
||||
int scale = get_scale_factor();
|
||||
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.;
|
||||
}
|
||||
bool retVal = res != resolution;
|
||||
resolution = res;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void EditWindow::setAppIcon()
|
||||
{
|
||||
Glib::ustring fName;
|
||||
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.) {
|
||||
fName = "rawtherapee-logo-24.png";
|
||||
} else {
|
||||
fName = "rawtherapee-logo-48.png";
|
||||
if (resolution < 192.) {
|
||||
downsize = true;
|
||||
}
|
||||
}
|
||||
double resolution2 = resolution;
|
||||
Glib::ustring fullPath = rtengine::findIconAbsolutePath(fName, resolution2);
|
||||
if (!fullPath.empty()) {
|
||||
const Glib::RefPtr<Gdk::Pixbuf> pixbuf = Gdk::Pixbuf::create_from_file(fullPath);
|
||||
if (!pixbuf) {
|
||||
return;
|
||||
}
|
||||
if (downsize) {
|
||||
int size = int((48. * resolution) / 192.);
|
||||
pixbuf->scale_simple(size, size, Gdk::InterpType::INTERP_BILINEAR);
|
||||
}
|
||||
|
||||
try {
|
||||
set_default_icon(pixbuf);
|
||||
} catch(Glib::Exception& ex) {
|
||||
printf ("%s\n", ex.what().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool EditWindow::on_configure_event(GdkEventConfigure* event)
|
||||
{
|
||||
if (updateResolution()) {
|
||||
setAppIcon();
|
||||
}
|
||||
|
||||
if (get_realized() && is_visible()) {
|
||||
if(!is_maximized()) {
|
||||
get_position(options.meowX, options.meowY);
|
||||
@@ -142,7 +186,7 @@ bool EditWindow::on_configure_event(GdkEventConfigure* event)
|
||||
}
|
||||
|
||||
/* HOMBRE: Disabling this since it's maximized when opened anyway.
|
||||
* Someday, the EditorWindow migh save it own position and state, so it'll have to be uncommented
|
||||
* Someday, the EditorWindow might save its own position and state, so it'll have to be uncommented
|
||||
bool EditWindow::on_window_state_event(GdkEventWindowState* event)
|
||||
{
|
||||
if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) {
|
||||
|
Reference in New Issue
Block a user