Skip to content

Commit dfa1024

Browse files
committed
magnification display accounts for display scale
1 parent 27de730 commit dfa1024

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

src/imageui.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ enum {
125125
PROP_ZOOM,
126126
PROP_X,
127127
PROP_Y,
128+
PROP_PIXEL_SIZE,
128129

129130
PROP_LAST
130131
};
@@ -194,6 +195,10 @@ imageui_property_name(guint prop_id)
194195
return "Y";
195196
break;
196197

198+
case PROP_PIXEL_SIZE:
199+
return "PIXEL_SIZE";
200+
break;
201+
197202
default:
198203
return "<unknown>";
199204
}
@@ -253,6 +258,11 @@ imageui_set_property(GObject *object,
253258
"y", value);
254259
break;
255260

261+
case PROP_PIXEL_SIZE:
262+
g_object_set_property(G_OBJECT(imageui->imagedisplay),
263+
"pixel-size", value);
264+
break;
265+
256266
default:
257267
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
258268
break;
@@ -296,6 +306,11 @@ imageui_get_property(GObject *object,
296306
g_object_get_property(G_OBJECT(imageui->imagedisplay), "y", value);
297307
break;
298308

309+
case PROP_PIXEL_SIZE:
310+
g_object_get_property(G_OBJECT(imageui->imagedisplay),
311+
"pixel-size", value);
312+
break;
313+
299314
default:
300315
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
301316
break;
@@ -1011,6 +1026,13 @@ imageui_class_init(ImageuiClass *class)
10111026
-VIPS_MAX_COORD, VIPS_MAX_COORD, 0,
10121027
G_PARAM_READWRITE));
10131028

1029+
g_object_class_install_property(gobject_class, PROP_PIXEL_SIZE,
1030+
g_param_spec_double("pixel_size",
1031+
_("Pixel size"),
1032+
_("Size of hardware display pixels in gtk coordinates"),
1033+
0.0, 10.0, 0.0,
1034+
G_PARAM_READWRITE));
1035+
10141036
imageui_signals[SIG_CHANGED] = g_signal_new("changed",
10151037
G_TYPE_FROM_CLASS(class),
10161038
G_SIGNAL_RUN_LAST,

src/imagewindow.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,19 +377,29 @@ imagewindow_files_set(Imagewindow *win, char **files, int n_files)
377377
}
378378
}
379379

380+
/* Get the effective zoom, ie. the zoom considering the hardware pixel display
381+
* density.
382+
*/
380383
double
381384
imagewindow_get_zoom(Imagewindow *win)
382385
{
383386
double zoom;
384-
385387
if (win->imageui)
386388
g_object_get(win->imageui,
387389
"zoom", &zoom,
388390
NULL);
389391
else
390392
zoom = 1.0;
391393

392-
return zoom;
394+
double pixel_size;
395+
if (win->imageui)
396+
g_object_get(win->imageui,
397+
"pixel_size", &pixel_size,
398+
NULL);
399+
else
400+
pixel_size = 1.0;
401+
402+
return zoom / pixel_size;
393403
}
394404

395405
void

0 commit comments

Comments
 (0)