[gimp] app: reorder an rename stuff in gimpdisplayshell-scale.[ch]
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: reorder an rename stuff in gimpdisplayshell-scale.[ch]
- Date: Tue, 5 Jan 2016 18:21:44 +0000 (UTC)
commit 9391cd390fe89ea6168b1be936666f2a706d2212
Author: Michael Natterer <mitch gimp org>
Date: Tue Jan 5 19:18:40 2016 +0100
app: reorder an rename stuff in gimpdisplayshell-scale.[ch]
Rename gimp_display_shell_scale_handle_zoom_revert() to
gimp_display_shell_scale_save_revert_values() because the old name was
completely unclear.
app/display/gimpdisplayshell-scale.c | 126 ++++++++++++++++----------------
app/display/gimpdisplayshell-scale.h | 89 ++++++++++++-----------
app/display/gimpdisplayshell-scroll.c | 2 +-
3 files changed, 111 insertions(+), 106 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-scale.c b/app/display/gimpdisplayshell-scale.c
index 85a4fcc..48072ed 100644
--- a/app/display/gimpdisplayshell-scale.c
+++ b/app/display/gimpdisplayshell-scale.c
@@ -142,6 +142,31 @@ gimp_display_shell_scale_can_revert (GimpDisplayShell *shell)
}
/**
+ * gimp_display_shell_scale_save_revert_values:
+ * @shell:
+ *
+ * Handle the updating of the Revert Zoom variables.
+ **/
+void
+gimp_display_shell_scale_save_revert_values (GimpDisplayShell *shell)
+{
+ guint now;
+
+ g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+
+ now = time (NULL);
+
+ if (now - shell->last_scale_time >= SCALE_TIMEOUT)
+ {
+ shell->last_scale = gimp_zoom_model_get_factor (shell->zoom);
+ shell->last_offset_x = shell->offset_x;
+ shell->last_offset_y = shell->offset_y;
+ }
+
+ shell->last_scale_time = now;
+}
+
+/**
* gimp_display_shell_scale_set_dot_for_dot:
* @shell: the #GimpDisplayShell
* @dot_for_dot: whether "Dot for Dot" should be enabled
@@ -195,6 +220,39 @@ gimp_display_shell_scale_get_image_size (GimpDisplayShell *shell,
w, h);
}
+/**
+ * gimp_display_shell_scale_image_is_within_viewport:
+ * @shell:
+ *
+ * Returns: %TRUE if the (scaled) image is smaller than and within the
+ * viewport.
+ **/
+gboolean
+gimp_display_shell_scale_image_is_within_viewport (GimpDisplayShell *shell,
+ gboolean *horizontally,
+ gboolean *vertically)
+{
+ gint sw, sh;
+ gboolean horizontally_dummy, vertically_dummy;
+
+ g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
+
+ if (! horizontally) horizontally = &horizontally_dummy;
+ if (! vertically) vertically = &vertically_dummy;
+
+ gimp_display_shell_scale_get_image_size (shell, &sw, &sh);
+
+ *horizontally = sw <= shell->disp_width &&
+ shell->offset_x <= 0 &&
+ shell->offset_x >= sw - shell->disp_width;
+
+ *vertically = sh <= shell->disp_height &&
+ shell->offset_y <= 0 &&
+ shell->offset_y >= sh - shell->disp_height;
+
+ return *vertically && *horizontally;
+}
+
/* 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
@@ -457,8 +515,8 @@ gimp_display_shell_scale_to_rectangle (GimpDisplayShell *shell,
* gimp_display_shell_scale_fit_in:
* @shell: the #GimpDisplayShell
*
- * Sets the scale such that the entire image precisely fits in the display
- * area.
+ * Sets the scale such that the entire image precisely fits in the
+ * display area.
**/
void
gimp_display_shell_scale_fit_in (GimpDisplayShell *shell)
@@ -497,44 +555,11 @@ gimp_display_shell_scale_fit_in (GimpDisplayShell *shell)
}
/**
- * gimp_display_shell_scale_image_is_within_viewport:
- * @shell:
- *
- * Returns: %TRUE if the (scaled) image is smaller than and within the
- * viewport.
- **/
-gboolean
-gimp_display_shell_scale_image_is_within_viewport (GimpDisplayShell *shell,
- gboolean *horizontally,
- gboolean *vertically)
-{
- gint sw, sh;
- gboolean horizontally_dummy, vertically_dummy;
-
- g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
-
- if (! horizontally) horizontally = &horizontally_dummy;
- if (! vertically) vertically = &vertically_dummy;
-
- gimp_display_shell_scale_get_image_size (shell, &sw, &sh);
-
- *horizontally = sw <= shell->disp_width &&
- shell->offset_x <= 0 &&
- shell->offset_x >= sw - shell->disp_width;
-
- *vertically = sh <= shell->disp_height &&
- shell->offset_y <= 0 &&
- shell->offset_y >= sh - shell->disp_height;
-
- return *vertically && *horizontally;
-}
-
-/**
* gimp_display_shell_scale_fill:
* @shell: the #GimpDisplayShell
*
- * Sets the scale such that the entire display area is precisely filled by the
- * image.
+ * Sets the scale such that the entire display area is precisely
+ * filled by the image.
**/
void
gimp_display_shell_scale_fill (GimpDisplayShell *shell)
@@ -573,31 +598,6 @@ gimp_display_shell_scale_fill (GimpDisplayShell *shell)
}
/**
- * gimp_display_shell_scale_handle_zoom_revert:
- * @shell:
- *
- * Handle the updating of the Revert Zoom variables.
- **/
-void
-gimp_display_shell_scale_handle_zoom_revert (GimpDisplayShell *shell)
-{
- guint now;
-
- g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
-
- now = time (NULL);
-
- if (now - shell->last_scale_time >= SCALE_TIMEOUT)
- {
- shell->last_scale = gimp_zoom_model_get_factor (shell->zoom);
- shell->last_offset_x = shell->offset_x;
- shell->last_offset_y = shell->offset_y;
- }
-
- shell->last_scale_time = now;
-}
-
-/**
* gimp_display_shell_scale_by_values:
* @shell: the #GimpDisplayShell
* @scale: the new scale
@@ -626,7 +626,7 @@ gimp_display_shell_scale_by_values (GimpDisplayShell *shell,
shell->offset_y == offset_y)
return;
- gimp_display_shell_scale_handle_zoom_revert (shell);
+ gimp_display_shell_scale_save_revert_values (shell);
/* freeze the active tool */
gimp_display_shell_pause (shell);
diff --git a/app/display/gimpdisplayshell-scale.h b/app/display/gimpdisplayshell-scale.h
index ab5fac7..033a78d 100644
--- a/app/display/gimpdisplayshell-scale.h
+++ b/app/display/gimpdisplayshell-scale.h
@@ -19,53 +19,58 @@
#define __GIMP_DISPLAY_SHELL_SCALE_H__
-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_save_revert_values (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_get_image_size (GimpDisplayShell *shell,
- gint *w,
- gint *h);
+void gimp_display_shell_scale_get_image_size (GimpDisplayShell *shell,
+ gint *w,
+ gint *h);
+gboolean gimp_display_shell_scale_image_is_within_viewport
+ (GimpDisplayShell *shell,
+ gboolean *horizontally,
+ gboolean *vertically);
-void gimp_display_shell_scale_update (GimpDisplayShell *shell);
+void gimp_display_shell_scale_update (GimpDisplayShell *shell);
-void gimp_display_shell_scale (GimpDisplayShell *shell,
- GimpZoomType zoom_type,
- gdouble scale,
- GimpZoomFocus zoom_focus);
-void gimp_display_shell_scale_to_rectangle (GimpDisplayShell *shell,
- GimpZoomType zoom_type,
- gdouble x,
- gdouble y,
- gdouble width,
- gdouble height,
- gboolean resize_window);
-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 (GimpDisplayShell *shell,
+ GimpZoomType zoom_type,
+ gdouble scale,
+ GimpZoomFocus zoom_focus);
+void gimp_display_shell_scale_to_rectangle (GimpDisplayShell *shell,
+ GimpZoomType zoom_type,
+ gdouble x,
+ gdouble y,
+ gdouble width,
+ gdouble height,
+ gboolean resize_window);
+void gimp_display_shell_scale_fit_in (GimpDisplayShell *shell);
+void gimp_display_shell_scale_fill (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_resize (GimpDisplayShell *shell,
- gboolean resize_window,
- gboolean grow_only);
-void gimp_display_shell_set_initial_scale (GimpDisplayShell *shell,
- gdouble scale,
- gint *display_width,
- gint *display_height);
-void gimp_display_shell_push_zoom_focus_pointer_pos (GimpDisplayShell *shell,
- gint x,
- gint y);
+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_set_initial_scale (GimpDisplayShell *shell,
+ gdouble scale,
+ gint *display_width,
+ gint *display_height);
+
+
+/* debug API for testing */
+
+void gimp_display_shell_push_zoom_focus_pointer_pos (GimpDisplayShell *shell,
+ gint x,
+ gint y);
#endif /* __GIMP_DISPLAY_SHELL_SCALE_H__ */
diff --git a/app/display/gimpdisplayshell-scroll.c b/app/display/gimpdisplayshell-scroll.c
index ec1807f..d7f2e87 100644
--- a/app/display/gimpdisplayshell-scroll.c
+++ b/app/display/gimpdisplayshell-scroll.c
@@ -122,7 +122,7 @@ gimp_display_shell_scroll_set_offset (GimpDisplayShell *shell,
shell->offset_y == offset_y)
return;
- gimp_display_shell_scale_handle_zoom_revert (shell);
+ gimp_display_shell_scale_save_revert_values (shell);
/* freeze the active tool */
gimp_display_shell_pause (shell);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]