From 095eea65327369c21f6cf24e607106fc36106fee Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Tue, 5 Jan 2016 18:48:22 +0100 Subject: [PATCH] app: move gimp_display_shell_scale_changed() to gimpdisplayshell-scale.[ch] and rename it to gimp_display_shell_scale_update(). --- app/display/gimpdisplayshell-handlers.c | 4 +-- app/display/gimpdisplayshell-scale.c | 30 ++++++++++++++++++++- app/display/gimpdisplayshell-scale.h | 2 ++ app/display/gimpdisplayshell.c | 36 +++---------------------- app/display/gimpdisplayshell.h | 2 -- app/display/gimpimagewindow.c | 3 ++- 6 files changed, 39 insertions(+), 38 deletions(-) diff --git a/app/display/gimpdisplayshell-handlers.c b/app/display/gimpdisplayshell-handlers.c index fa2d40588b..62be4d500d 100644 --- a/app/display/gimpdisplayshell-handlers.c +++ b/app/display/gimpdisplayshell-handlers.c @@ -563,7 +563,7 @@ static void gimp_display_shell_resolution_changed_handler (GimpImage *image, GimpDisplayShell *shell) { - gimp_display_shell_scale_changed (shell); + gimp_display_shell_scale_update (shell); if (shell->dot_for_dot) { @@ -990,7 +990,7 @@ gimp_display_shell_monitor_res_notify_handler (GObject *config, shell->monitor_yres = GIMP_DISPLAY_CONFIG (config)->monitor_yres; } - gimp_display_shell_scale_changed (shell); + gimp_display_shell_scale_update (shell); if (! shell->dot_for_dot) { diff --git a/app/display/gimpdisplayshell-scale.c b/app/display/gimpdisplayshell-scale.c index e9b07e1104..ef0459d19e 100644 --- a/app/display/gimpdisplayshell-scale.c +++ b/app/display/gimpdisplayshell-scale.c @@ -158,7 +158,7 @@ gimp_display_shell_scale_set_dot_for_dot (GimpDisplayShell *shell, shell->dot_for_dot = dot_for_dot; - gimp_display_shell_scale_changed (shell); + gimp_display_shell_scale_update (shell); gimp_display_shell_scale_resize (shell, shell->display->config->resize_windows_on_zoom, @@ -190,6 +190,34 @@ gimp_display_shell_scale_get_image_size (GimpDisplayShell *shell, w, h); } +/* We used to calculate the scale factor in the SCALEFACTOR_X() and + * SCALEFACTOR_Y() macros. But since these are rather frequently + * called and the values rarely change, we now store them in the + * shell and call this function whenever they need to be recalculated. + */ +void +gimp_display_shell_scale_update (GimpDisplayShell *shell) +{ + GimpImage *image; + + g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); + + image = gimp_display_get_image (shell->display); + + if (image) + { + gimp_display_shell_calculate_scale_x_and_y (shell, + gimp_zoom_model_get_factor (shell->zoom), + &shell->scale_x, + &shell->scale_y); + } + else + { + shell->scale_x = 1.0; + shell->scale_y = 1.0; + } +} + /** * gimp_display_shell_scale: * @shell: the #GimpDisplayShell diff --git a/app/display/gimpdisplayshell-scale.h b/app/display/gimpdisplayshell-scale.h index 03a42f7076..1940f5346c 100644 --- a/app/display/gimpdisplayshell-scale.h +++ b/app/display/gimpdisplayshell-scale.h @@ -29,6 +29,8 @@ void gimp_display_shell_scale_get_image_size (GimpDisplayShell *sh gint *w, gint *h); +void gimp_display_shell_scale_update (GimpDisplayShell *shell); + void gimp_display_shell_scale (GimpDisplayShell *shell, GimpZoomType zoom_type, gdouble scale, diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c index 3d2f9a014a..81a9398291 100644 --- a/app/display/gimpdisplayshell.c +++ b/app/display/gimpdisplayshell.c @@ -361,7 +361,7 @@ gimp_display_shell_init (GimpDisplayShell *shell) /* zoom model callback */ g_signal_connect_swapped (shell->zoom, "zoomed", - G_CALLBACK (gimp_display_shell_scale_changed), + G_CALLBACK (gimp_display_shell_scale_update), shell); /* active display callback */ @@ -778,7 +778,7 @@ gimp_display_shell_constructed (GObject *object) } /* make sure the information is up-to-date */ - gimp_display_shell_scale_changed (shell); + gimp_display_shell_scale_update (shell); } static void @@ -1521,7 +1521,7 @@ gimp_display_shell_fill (GimpDisplayShell *shell, gimp_display_shell_set_unit (shell, unit); gimp_display_shell_set_initial_scale (shell, scale, NULL, NULL); - gimp_display_shell_scale_changed (shell); + gimp_display_shell_scale_update (shell); gimp_display_shell_sync_config (shell, shell->display->config); @@ -1550,34 +1550,6 @@ gimp_display_shell_fill (GimpDisplayShell *shell, NULL); } -/* We used to calculate the scale factor in the SCALEFACTOR_X() and - * SCALEFACTOR_Y() macros. But since these are rather frequently - * called and the values rarely change, we now store them in the - * shell and call this function whenever they need to be recalculated. - */ -void -gimp_display_shell_scale_changed (GimpDisplayShell *shell) -{ - GimpImage *image; - - g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); - - image = gimp_display_get_image (shell->display); - - if (image) - { - gimp_display_shell_calculate_scale_x_and_y (shell, - gimp_zoom_model_get_factor (shell->zoom), - &shell->scale_x, - &shell->scale_y); - } - else - { - shell->scale_x = 1.0; - shell->scale_y = 1.0; - } -} - void gimp_display_shell_scaled (GimpDisplayShell *shell) { @@ -1847,7 +1819,7 @@ gimp_display_shell_flush (GimpDisplayShell *shell, gimp_display_shell_title_update (shell); /* make sure the information is up-to-date */ - gimp_display_shell_scale_changed (shell); + gimp_display_shell_scale_update (shell); gimp_canvas_layer_boundary_set_layer (GIMP_CANVAS_LAYER_BOUNDARY (shell->layer_boundary), gimp_image_get_active_layer (gimp_display_get_image (shell->display))); diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h index cf09fa741c..2358507cfe 100644 --- a/app/display/gimpdisplayshell.h +++ b/app/display/gimpdisplayshell.h @@ -261,8 +261,6 @@ void gimp_display_shell_fill (GimpDisplayShell *shell, GimpUnit unit, gdouble scale); -void gimp_display_shell_scale_changed (GimpDisplayShell *shell); - void gimp_display_shell_scaled (GimpDisplayShell *shell); void gimp_display_shell_scrolled (GimpDisplayShell *shell); void gimp_display_shell_rotated (GimpDisplayShell *shell); diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c index 98283b68bf..bae461c8be 100644 --- a/app/display/gimpimagewindow.c +++ b/app/display/gimpimagewindow.c @@ -56,6 +56,7 @@ #include "gimpdisplayshell.h" #include "gimpdisplayshell-appearance.h" #include "gimpdisplayshell-close.h" +#include "gimpdisplayshell-scale.h" #include "gimpdisplayshell-scroll.h" #include "gimpdisplayshell-tool-events.h" #include "gimpdisplayshell-transform.h" @@ -777,7 +778,7 @@ gimp_image_window_monitor_changed (GimpWindow *window, gtk_widget_get_screen (list->data)); /* make it fetch the new monitor's resolution */ - gimp_display_shell_scale_changed (GIMP_DISPLAY_SHELL (list->data)); + gimp_display_shell_scale_update (GIMP_DISPLAY_SHELL (list->data)); /* make it fetch the right monitor profile */ gimp_color_managed_profile_changed (GIMP_COLOR_MANAGED (list->data));