Commit 9391cd39 authored by Michael Natterer's avatar Michael Natterer 😴
Browse files

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.
parent c80f0136
......@@ -141,6 +141,31 @@ gimp_display_shell_scale_can_revert (GimpDisplayShell *shell)
return (shell->last_scale > SCALE_EPSILON);
}
/**
* 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
......@@ -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)
......@@ -496,45 +554,12 @@ gimp_display_shell_scale_fit_in (GimpDisplayShell *shell)
gimp_display_shell_scroll_center_image (shell, TRUE, TRUE);
}
/**
* 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)
......@@ -572,31 +597,6 @@ gimp_display_shell_scale_fill (GimpDisplayShell *shell)
gimp_display_shell_scroll_center_image (shell, TRUE, TRUE);
}
/**
* 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
......@@ -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);
......
......@@ -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__ */
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment