mirror of https://github.com/GNOME/gimp.git
app: move the "get scaled image size" functions from shell-draw to -scale
This commit is contained in:
parent
afddcce4e5
commit
c3b53b8b66
|
@ -28,7 +28,7 @@
|
|||
#include "gimpcanvas-style.h"
|
||||
#include "gimpcanvaspassepartout.h"
|
||||
#include "gimpdisplayshell.h"
|
||||
#include "gimpdisplayshell-draw.h"
|
||||
#include "gimpdisplayshell-scale.h"
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
@ -68,7 +68,7 @@ gimp_canvas_passe_partout_draw (GimpCanvasItem *item,
|
|||
GimpDisplayShell *shell = gimp_canvas_item_get_shell (item);
|
||||
gint w, h;
|
||||
|
||||
gimp_display_shell_draw_get_scaled_image_size (shell, &w, &h);
|
||||
gimp_display_shell_scale_get_image_size (shell, &w, &h);
|
||||
cairo_rectangle (cr, - shell->offset_x, - shell->offset_y, w, h);
|
||||
|
||||
GIMP_CANVAS_ITEM_CLASS (parent_class)->draw (item, cr);
|
||||
|
@ -84,9 +84,9 @@ gimp_canvas_passe_partout_get_extents (GimpCanvasItem *item)
|
|||
|
||||
rectangle.x = - shell->offset_x;
|
||||
rectangle.y = - shell->offset_y;
|
||||
gimp_display_shell_draw_get_scaled_image_size (shell,
|
||||
&rectangle.width,
|
||||
&rectangle.height);
|
||||
gimp_display_shell_scale_get_image_size (shell,
|
||||
&rectangle.width,
|
||||
&rectangle.height);
|
||||
|
||||
outer = cairo_region_create_rectangle (&rectangle);
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "gimpdisplayshell-appearance.h"
|
||||
#include "gimpdisplayshell-callbacks.h"
|
||||
#include "gimpdisplayshell-draw.h"
|
||||
#include "gimpdisplayshell-scale.h"
|
||||
#include "gimpdisplayshell-scroll.h"
|
||||
#include "gimpdisplayshell-selection.h"
|
||||
#include "gimpdisplayshell-title.h"
|
||||
|
@ -170,7 +171,7 @@ gimp_display_shell_canvas_size_allocate (GtkWidget *widget,
|
|||
gint sw;
|
||||
gint sh;
|
||||
|
||||
gimp_display_shell_draw_get_scaled_image_size (shell, &sw, &sh);
|
||||
gimp_display_shell_scale_get_image_size (shell, &sw, &sh);
|
||||
|
||||
center_horizontally = sw <= shell->disp_width;
|
||||
center_vertically = sh <= shell->disp_height;
|
||||
|
@ -487,9 +488,9 @@ gimp_display_shell_canvas_draw_image (GimpDisplayShell *shell,
|
|||
|
||||
image_rect.x = - shell->offset_x;
|
||||
image_rect.y = - shell->offset_y;
|
||||
gimp_display_shell_draw_get_scaled_image_size (shell,
|
||||
&image_rect.width,
|
||||
&image_rect.height);
|
||||
gimp_display_shell_scale_get_image_size (shell,
|
||||
&image_rect.width,
|
||||
&image_rect.height);
|
||||
image_region = cairo_region_create_rectangle (&image_rect);
|
||||
|
||||
cairo_region_subtract (clear_region, image_region);
|
||||
|
|
|
@ -28,8 +28,6 @@
|
|||
#include "display-types.h"
|
||||
|
||||
#include "core/gimp-cairo.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "gimpcanvas.h"
|
||||
#include "gimpcanvas-style.h"
|
||||
|
@ -38,66 +36,11 @@
|
|||
#include "gimpdisplayshell.h"
|
||||
#include "gimpdisplayshell-draw.h"
|
||||
#include "gimpdisplayshell-render.h"
|
||||
#include "gimpdisplayshell-scale.h"
|
||||
#include "gimpdisplayshell-scroll.h"
|
||||
#include "gimpdisplayshell-transform.h"
|
||||
#include "gimpdisplayxfer.h"
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
/**
|
||||
* gimp_display_shell_get_scaled_image_size:
|
||||
* @shell:
|
||||
* @w:
|
||||
* @h:
|
||||
*
|
||||
* Gets the size of the rendered image after it has been scaled.
|
||||
*
|
||||
**/
|
||||
void
|
||||
gimp_display_shell_draw_get_scaled_image_size (GimpDisplayShell *shell,
|
||||
gint *w,
|
||||
gint *h)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
|
||||
gimp_display_shell_draw_get_scaled_image_size_for_scale (shell,
|
||||
gimp_zoom_model_get_factor (shell->zoom),
|
||||
w,
|
||||
h);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_display_shell_draw_get_scaled_image_size_for_scale:
|
||||
* @shell:
|
||||
* @scale:
|
||||
* @w:
|
||||
* @h:
|
||||
*
|
||||
**/
|
||||
void
|
||||
gimp_display_shell_draw_get_scaled_image_size_for_scale (GimpDisplayShell *shell,
|
||||
gdouble scale,
|
||||
gint *w,
|
||||
gint *h)
|
||||
{
|
||||
GimpImage *image;
|
||||
gdouble scale_x;
|
||||
gdouble scale_y;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
|
||||
image = gimp_display_get_image (shell->display);
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
|
||||
gimp_display_shell_calculate_scale_x_and_y (shell, scale, &scale_x, &scale_y);
|
||||
|
||||
if (w) *w = scale_x * gimp_image_get_width (image);
|
||||
if (h) *h = scale_y * gimp_image_get_height (image);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_display_shell_draw_selection_out (GimpDisplayShell *shell,
|
||||
cairo_t *cr,
|
||||
|
|
|
@ -19,38 +19,28 @@
|
|||
#define __GIMP_DISPLAY_SHELL_DRAW_H__
|
||||
|
||||
|
||||
void gimp_display_shell_draw_get_scaled_image_size (GimpDisplayShell *shell,
|
||||
gint *w,
|
||||
gint *h);
|
||||
void gimp_display_shell_draw_get_scaled_image_size_for_scale
|
||||
(GimpDisplayShell *shell,
|
||||
gdouble scale,
|
||||
gint *w,
|
||||
gint *h);
|
||||
|
||||
void gimp_display_shell_draw_selection_out (GimpDisplayShell *shell,
|
||||
cairo_t *cr,
|
||||
GimpSegment *segs,
|
||||
gint n_segs);
|
||||
void gimp_display_shell_draw_selection_in (GimpDisplayShell *shell,
|
||||
cairo_t *cr,
|
||||
cairo_pattern_t *mask,
|
||||
gint index);
|
||||
|
||||
void gimp_display_shell_draw_background (GimpDisplayShell *shell,
|
||||
cairo_t *cr);
|
||||
void gimp_display_shell_draw_image (GimpDisplayShell *shell,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
void gimp_display_shell_draw_checkerboard (GimpDisplayShell *shell,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
void gimp_display_shell_draw_selection_out (GimpDisplayShell *shell,
|
||||
cairo_t *cr,
|
||||
GimpSegment *segs,
|
||||
gint n_segs);
|
||||
void gimp_display_shell_draw_selection_in (GimpDisplayShell *shell,
|
||||
cairo_t *cr,
|
||||
cairo_pattern_t *mask,
|
||||
gint index);
|
||||
void gimp_display_shell_draw_background (GimpDisplayShell *shell,
|
||||
cairo_t *cr);
|
||||
void gimp_display_shell_draw_image (GimpDisplayShell *shell,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
void gimp_display_shell_draw_checkerboard (GimpDisplayShell *shell,
|
||||
cairo_t *cr,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
|
||||
|
||||
#endif /* __GIMP_DISPLAY_SHELL_DRAW_H__ */
|
||||
|
|
|
@ -33,11 +33,9 @@
|
|||
|
||||
#include "gimpdisplay.h"
|
||||
#include "gimpdisplayshell.h"
|
||||
#include "gimpdisplayshell-draw.h"
|
||||
#include "gimpdisplayshell-expose.h"
|
||||
#include "gimpdisplayshell-scale.h"
|
||||
#include "gimpdisplayshell-scroll.h"
|
||||
#include "gimpdisplayshell-title.h"
|
||||
#include "gimpdisplayshell-transform.h"
|
||||
#include "gimpimagewindow.h"
|
||||
|
||||
|
@ -347,6 +345,57 @@ gimp_display_shell_get_screen_resolution (GimpDisplayShell *shell,
|
|||
if (yres) *yres = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_display_shell_scale_get_image_size:
|
||||
* @shell:
|
||||
* @w:
|
||||
* @h:
|
||||
*
|
||||
* Gets the size of the rendered image after it has been scaled.
|
||||
*
|
||||
**/
|
||||
void
|
||||
gimp_display_shell_scale_get_image_size (GimpDisplayShell *shell,
|
||||
gint *w,
|
||||
gint *h)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
|
||||
gimp_display_shell_scale_get_image_size_for_scale (shell,
|
||||
gimp_zoom_model_get_factor (shell->zoom),
|
||||
w, h);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_display_shell_scale_get_image_size_for_scale:
|
||||
* @shell:
|
||||
* @scale:
|
||||
* @w:
|
||||
* @h:
|
||||
*
|
||||
**/
|
||||
void
|
||||
gimp_display_shell_scale_get_image_size_for_scale (GimpDisplayShell *shell,
|
||||
gdouble scale,
|
||||
gint *w,
|
||||
gint *h)
|
||||
{
|
||||
GimpImage *image;
|
||||
gdouble scale_x;
|
||||
gdouble scale_y;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
|
||||
image = gimp_display_get_image (shell->display);
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
|
||||
gimp_display_shell_calculate_scale_x_and_y (shell, scale, &scale_x, &scale_y);
|
||||
|
||||
if (w) *w = scale_x * gimp_image_get_width (image);
|
||||
if (h) *h = scale_y * gimp_image_get_height (image);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_display_shell_scale:
|
||||
* @shell: the #GimpDisplayShell
|
||||
|
@ -442,7 +491,7 @@ gimp_display_shell_scale (GimpDisplayShell *shell,
|
|||
image_center_y,
|
||||
&image_center_almost_centered_horiz,
|
||||
&image_center_almost_centered_vert);
|
||||
|
||||
|
||||
gimp_display_shell_scroll_center_image (shell,
|
||||
starts_fitting_horiz ||
|
||||
(zoom_focus_almost_centered_horiz &&
|
||||
|
@ -517,7 +566,7 @@ gimp_display_shell_scale_image_is_within_viewport (GimpDisplayShell *shell,
|
|||
if (! horizontally) horizontally = &horizontally_dummy;
|
||||
if (! vertically) vertically = &vertically_dummy;
|
||||
|
||||
gimp_display_shell_draw_get_scaled_image_size (shell, &sw, &sh);
|
||||
gimp_display_shell_scale_get_image_size (shell, &sw, &sh);
|
||||
|
||||
*horizontally = sw <= shell->disp_width &&
|
||||
shell->offset_x <= 0 &&
|
||||
|
@ -906,15 +955,15 @@ gimp_display_shell_scale_image_starts_to_fit (GimpDisplayShell *shell,
|
|||
gint new_scale_width;
|
||||
gint new_scale_height;
|
||||
|
||||
gimp_display_shell_draw_get_scaled_image_size_for_scale (shell,
|
||||
current_scale,
|
||||
¤t_scale_width,
|
||||
¤t_scale_height);
|
||||
gimp_display_shell_scale_get_image_size_for_scale (shell,
|
||||
current_scale,
|
||||
¤t_scale_width,
|
||||
¤t_scale_height);
|
||||
|
||||
gimp_display_shell_draw_get_scaled_image_size_for_scale (shell,
|
||||
new_scale,
|
||||
&new_scale_width,
|
||||
&new_scale_height);
|
||||
gimp_display_shell_scale_get_image_size_for_scale (shell,
|
||||
new_scale,
|
||||
&new_scale_width,
|
||||
&new_scale_height);
|
||||
|
||||
*vertically = (current_scale_width > shell->disp_width &&
|
||||
new_scale_width <= shell->disp_width);
|
||||
|
@ -979,9 +1028,7 @@ gimp_display_shell_scale_get_image_center_viewport (GimpDisplayShell *shell,
|
|||
{
|
||||
gint sw, sh;
|
||||
|
||||
gimp_display_shell_draw_get_scaled_image_size (shell,
|
||||
&sw,
|
||||
&sh);
|
||||
gimp_display_shell_scale_get_image_size (shell, &sw, &sh);
|
||||
|
||||
if (image_center_x) *image_center_x = -shell->offset_x + sw / 2;
|
||||
if (image_center_y) *image_center_y = -shell->offset_y + sh / 2;
|
||||
|
|
|
@ -31,6 +31,13 @@ void gimp_display_shell_scale_set_dot_for_dot (GimpDisplayShell *sh
|
|||
void gimp_display_shell_get_screen_resolution (GimpDisplayShell *shell,
|
||||
gdouble *xres,
|
||||
gdouble *yres);
|
||||
void gimp_display_shell_scale_get_image_size (GimpDisplayShell *shell,
|
||||
gint *w,
|
||||
gint *h);
|
||||
void gimp_display_shell_scale_get_image_size_for_scale (GimpDisplayShell *shell,
|
||||
gdouble scale,
|
||||
gint *w,
|
||||
gint *h);
|
||||
|
||||
void gimp_display_shell_scale (GimpDisplayShell *shell,
|
||||
GimpZoomType zoom_type,
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "gimpdisplay.h"
|
||||
#include "gimpdisplay-foreach.h"
|
||||
#include "gimpdisplayshell.h"
|
||||
#include "gimpdisplayshell-draw.h"
|
||||
#include "gimpdisplayshell-expose.h"
|
||||
#include "gimpdisplayshell-scale.h"
|
||||
#include "gimpdisplayshell-scroll.h"
|
||||
|
@ -295,7 +294,7 @@ gimp_display_shell_scroll_unoverscrollify (GimpDisplayShell *shell,
|
|||
*out_offset_x = in_offset_x;
|
||||
*out_offset_y = in_offset_y;
|
||||
|
||||
gimp_display_shell_draw_get_scaled_image_size (shell, &sw, &sh);
|
||||
gimp_display_shell_scale_get_image_size (shell, &sw, &sh);
|
||||
|
||||
if (in_offset_x < 0)
|
||||
{
|
||||
|
@ -351,7 +350,7 @@ gimp_display_shell_scroll_center_image (GimpDisplayShell *shell,
|
|||
target_offset_x = shell->offset_x;
|
||||
target_offset_y = shell->offset_y;
|
||||
|
||||
gimp_display_shell_draw_get_scaled_image_size (shell, &sw, &sh);
|
||||
gimp_display_shell_scale_get_image_size (shell, &sw, &sh);
|
||||
|
||||
if (horizontally)
|
||||
{
|
||||
|
@ -495,7 +494,7 @@ gimp_display_shell_scroll_setup_hscrollbar (GimpDisplayShell *shell,
|
|||
! gimp_display_get_image (shell->display))
|
||||
return;
|
||||
|
||||
gimp_display_shell_draw_get_scaled_image_size (shell, &sw, NULL);
|
||||
gimp_display_shell_scale_get_image_size (shell, &sw, NULL);
|
||||
|
||||
if (shell->disp_width < sw)
|
||||
{
|
||||
|
@ -539,7 +538,7 @@ gimp_display_shell_scroll_setup_vscrollbar (GimpDisplayShell *shell,
|
|||
! gimp_display_get_image (shell->display))
|
||||
return;
|
||||
|
||||
gimp_display_shell_draw_get_scaled_image_size (shell, NULL, &sh);
|
||||
gimp_display_shell_scale_get_image_size (shell, NULL, &sh);
|
||||
|
||||
if (shell->disp_height < sh)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue