mirror of https://github.com/GNOME/gimp.git
Remove macros SCREEN_XRES() and SCREEN_YRES()
and add gimp_display_shell_get_screen_resolution() instead. The times when these macros were used in inner loops have long passed.
This commit is contained in:
parent
36551daa19
commit
b6ce5d075d
|
@ -338,6 +338,29 @@ gimp_display_shell_scale_set_dot_for_dot (GimpDisplayShell *shell,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_display_shell_get_screen_resolution (GimpDisplayShell *shell,
|
||||
gdouble *xres,
|
||||
gdouble *yres)
|
||||
{
|
||||
gdouble x, y;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
|
||||
if (shell->dot_for_dot)
|
||||
{
|
||||
gimp_image_get_resolution (shell->display->image, &x, &y);
|
||||
}
|
||||
else
|
||||
{
|
||||
x = shell->monitor_xres;
|
||||
y = shell->monitor_yres;
|
||||
}
|
||||
|
||||
if (xres) *xres = x;
|
||||
if (yres) *yres = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_display_shell_scale:
|
||||
* @shell: the #GimpDisplayShell
|
||||
|
@ -699,14 +722,16 @@ gimp_display_shell_scale_resize (GimpDisplayShell *shell,
|
|||
*
|
||||
**/
|
||||
void
|
||||
gimp_display_shell_calculate_scale_x_and_y (const GimpDisplayShell *shell,
|
||||
gdouble scale,
|
||||
gdouble *scale_x,
|
||||
gdouble *scale_y)
|
||||
gimp_display_shell_calculate_scale_x_and_y (GimpDisplayShell *shell,
|
||||
gdouble scale,
|
||||
gdouble *scale_x,
|
||||
gdouble *scale_y)
|
||||
{
|
||||
GimpImage *image;
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
gdouble screen_xres;
|
||||
gdouble screen_yres;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
|
||||
|
@ -715,9 +740,10 @@ gimp_display_shell_calculate_scale_x_and_y (const GimpDisplayShell *shell,
|
|||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
|
||||
gimp_image_get_resolution (image, &xres, &yres);
|
||||
gimp_display_shell_get_screen_resolution (shell, &screen_xres, &screen_yres);
|
||||
|
||||
if (scale_x) *scale_x = scale * SCREEN_XRES (shell) / xres;
|
||||
if (scale_y) *scale_y = scale * SCREEN_YRES (shell) / yres;
|
||||
if (scale_x) *scale_x = scale * screen_xres / xres;
|
||||
if (scale_y) *scale_y = scale * screen_yres / yres;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -19,45 +19,49 @@
|
|||
#define __GIMP_DISPLAY_SHELL_SCALE_H__
|
||||
|
||||
|
||||
void gimp_display_shell_update_scrollbars_and_rulers (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_scale_update_scrollbars (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_scale_update_rulers (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_update_scrollbars_and_rulers (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_scale_update_scrollbars (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_scale_update_rulers (GimpDisplayShell *shell);
|
||||
|
||||
gboolean gimp_display_shell_scale_revert (GimpDisplayShell *shell);
|
||||
gboolean gimp_display_shell_scale_can_revert (GimpDisplayShell *shell);
|
||||
gboolean gimp_display_shell_scale_revert (GimpDisplayShell *shell);
|
||||
gboolean gimp_display_shell_scale_can_revert (GimpDisplayShell *shell);
|
||||
|
||||
void gimp_display_shell_scale_set_dot_for_dot (GimpDisplayShell *shell,
|
||||
gboolean dot_for_dot);
|
||||
void gimp_display_shell_scale_set_dot_for_dot (GimpDisplayShell *shell,
|
||||
gboolean dot_for_dot);
|
||||
|
||||
void gimp_display_shell_scale (GimpDisplayShell *shell,
|
||||
GimpZoomType zoom_type,
|
||||
gdouble scale,
|
||||
GimpZoomFocus zoom_focus);
|
||||
void gimp_display_shell_scale_fit_in (GimpDisplayShell *shell);
|
||||
gboolean gimp_display_shell_scale_image_is_within_viewport (GimpDisplayShell *shell,
|
||||
gboolean *horizontally,
|
||||
gboolean *vertically);
|
||||
void gimp_display_shell_scale_fill (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_scale_handle_zoom_revert (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_scale_by_values (GimpDisplayShell *shell,
|
||||
gdouble scale,
|
||||
gint offset_x,
|
||||
gint offset_y,
|
||||
gboolean resize_window);
|
||||
void gimp_display_shell_scale_shrink_wrap (GimpDisplayShell *shell,
|
||||
gboolean grow_only);
|
||||
void gimp_display_shell_get_screen_resolution (GimpDisplayShell *shell,
|
||||
gdouble *xres,
|
||||
gdouble *yres);
|
||||
|
||||
void gimp_display_shell_scale_resize (GimpDisplayShell *shell,
|
||||
gboolean resize_window,
|
||||
gboolean grow_only);
|
||||
void gimp_display_shell_calculate_scale_x_and_y (const GimpDisplayShell *shell,
|
||||
gdouble scale,
|
||||
gdouble *scale_x,
|
||||
gdouble *scale_y);
|
||||
void gimp_display_shell_set_initial_scale (GimpDisplayShell *shell,
|
||||
gdouble scale,
|
||||
gint *display_width,
|
||||
gint *display_height);
|
||||
void gimp_display_shell_scale (GimpDisplayShell *shell,
|
||||
GimpZoomType zoom_type,
|
||||
gdouble scale,
|
||||
GimpZoomFocus zoom_focus);
|
||||
void gimp_display_shell_scale_fit_in (GimpDisplayShell *shell);
|
||||
gboolean gimp_display_shell_scale_image_is_within_viewport (GimpDisplayShell *shell,
|
||||
gboolean *horizontally,
|
||||
gboolean *vertically);
|
||||
void gimp_display_shell_scale_fill (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_scale_handle_zoom_revert (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_scale_by_values (GimpDisplayShell *shell,
|
||||
gdouble scale,
|
||||
gint offset_x,
|
||||
gint offset_y,
|
||||
gboolean resize_window);
|
||||
void gimp_display_shell_scale_shrink_wrap (GimpDisplayShell *shell,
|
||||
gboolean grow_only);
|
||||
|
||||
void gimp_display_shell_scale_resize (GimpDisplayShell *shell,
|
||||
gboolean resize_window,
|
||||
gboolean grow_only);
|
||||
void gimp_display_shell_calculate_scale_x_and_y (GimpDisplayShell *shell,
|
||||
gdouble scale,
|
||||
gdouble *scale_x,
|
||||
gdouble *scale_y);
|
||||
void gimp_display_shell_set_initial_scale (GimpDisplayShell *shell,
|
||||
gdouble scale,
|
||||
gint *display_width,
|
||||
gint *display_height);
|
||||
|
||||
|
||||
#endif /* __GIMP_DISPLAY_SHELL_SCALE_H__ */
|
||||
|
|
|
@ -23,12 +23,6 @@
|
|||
#define PROJ_ROUND(coord) ((gint) RINT (coord))
|
||||
#define PROJ_ROUND64(coord) ((gint64) RINT (coord))
|
||||
|
||||
/* finding the effective screen resolution (double) */
|
||||
#define SCREEN_XRES(s) ((s)->dot_for_dot ? \
|
||||
(s)->display->image->xresolution : (s)->monitor_xres)
|
||||
#define SCREEN_YRES(s) ((s)->dot_for_dot ? \
|
||||
(s)->display->image->yresolution : (s)->monitor_yres)
|
||||
|
||||
/* scale values */
|
||||
#define SCALEX(s,x) PROJ_ROUND ((x) * (s)->scale_x)
|
||||
#define SCALEY(s,y) PROJ_ROUND ((y) * (s)->scale_y)
|
||||
|
|
|
@ -224,13 +224,17 @@ gimp_magnify_tool_button_release (GimpTool *tool,
|
|||
|
||||
if (new_scale != current_scale)
|
||||
{
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
gint offset_x = 0;
|
||||
gint offset_y = 0;
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
gdouble screen_xres;
|
||||
gdouble screen_yres;
|
||||
|
||||
gimp_image_get_resolution (gimp_display_get_image (display),
|
||||
&xres, &yres);
|
||||
gimp_display_shell_get_screen_resolution (shell,
|
||||
&screen_xres, &screen_yres);
|
||||
|
||||
switch (options->zoom_type)
|
||||
{
|
||||
|
@ -245,11 +249,11 @@ gimp_magnify_tool_button_release (GimpTool *tool,
|
|||
* offset
|
||||
*/
|
||||
offset_x = RINT (new_scale * ((x1 + x2) / 2.0) *
|
||||
SCREEN_XRES (shell) / xres -
|
||||
screen_xres / xres -
|
||||
(shell->disp_width / 2.0));
|
||||
|
||||
offset_y = RINT (new_scale * ((y1 + y2) / 2.0) *
|
||||
SCREEN_YRES (shell) / yres -
|
||||
screen_yres / yres -
|
||||
(shell->disp_height / 2.0));
|
||||
break;
|
||||
|
||||
|
@ -266,14 +270,14 @@ gimp_magnify_tool_button_release (GimpTool *tool,
|
|||
offset_x = RINT (new_scale * UNSCALEX (shell,
|
||||
shell->offset_x +
|
||||
shell->disp_width / 2.0) *
|
||||
SCREEN_XRES (shell) / xres -
|
||||
screen_xres / xres -
|
||||
(SCALEX (shell, (x1 + x2) / 2.0) -
|
||||
shell->offset_x));
|
||||
|
||||
offset_y = RINT (new_scale * UNSCALEY (shell,
|
||||
shell->offset_y +
|
||||
shell->disp_height / 2.0) *
|
||||
SCREEN_YRES (shell) / yres -
|
||||
screen_yres / yres -
|
||||
(SCALEY (shell, (y1 + y2) / 2.0) -
|
||||
shell->offset_y));
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue