mirror of https://github.com/GNOME/gimp.git
New function.
2008-08-13 Martin Nordholts <martinn@svn.gnome.org> * app/display/gimpdisplayshell-scale.c (gimp_display_shell_scale_image_is_within_viewport): New function. * app/display/gimpdisplayshell.c (gimp_display_shell_new): When the zoom button is toggled, implicitly do a View -> Fit Image in Window if the (scaled) image is within the viewport. svn path=/trunk/; revision=26529
This commit is contained in:
parent
a9bb68a248
commit
47b34e973d
|
@ -1,3 +1,12 @@
|
||||||
|
2008-08-13 Martin Nordholts <martinn@svn.gnome.org>
|
||||||
|
|
||||||
|
* app/display/gimpdisplayshell-scale.c
|
||||||
|
(gimp_display_shell_scale_image_is_within_viewport): New function.
|
||||||
|
|
||||||
|
* app/display/gimpdisplayshell.c (gimp_display_shell_new): When
|
||||||
|
the zoom button is toggled, implicitly do a View -> Fit Image in
|
||||||
|
Window if the (scaled) image is within the viewport.
|
||||||
|
|
||||||
2008-08-13 Martin Nordholts <martinn@svn.gnome.org>
|
2008-08-13 Martin Nordholts <martinn@svn.gnome.org>
|
||||||
|
|
||||||
* app/paint/gimppaintcore.c: Include gimpprojection.h for
|
* app/paint/gimppaintcore.c: Include gimpprojection.h for
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
|
|
||||||
#include "gimpdisplay.h"
|
#include "gimpdisplay.h"
|
||||||
#include "gimpdisplayshell.h"
|
#include "gimpdisplayshell.h"
|
||||||
|
#include "gimpdisplayshell-draw.h"
|
||||||
#include "gimpdisplayshell-scale.h"
|
#include "gimpdisplayshell-scale.h"
|
||||||
#include "gimpdisplayshell-scroll.h"
|
#include "gimpdisplayshell-scroll.h"
|
||||||
#include "gimpdisplayshell-title.h"
|
#include "gimpdisplayshell-title.h"
|
||||||
|
@ -445,6 +446,30 @@ gimp_display_shell_scale_fit_in (GimpDisplayShell *shell)
|
||||||
gimp_display_shell_scroll_center_image (shell, TRUE, TRUE);
|
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)
|
||||||
|
{
|
||||||
|
gint sw, sh;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
|
||||||
|
|
||||||
|
gimp_display_shell_draw_get_scaled_image_size (shell, &sw, &sh);
|
||||||
|
|
||||||
|
return sw < shell->disp_width &&
|
||||||
|
sh < shell->disp_height &&
|
||||||
|
shell->offset_x < 0 &&
|
||||||
|
shell->offset_y < 0 &&
|
||||||
|
shell->offset_x > sw - shell->disp_width &&
|
||||||
|
shell->offset_y > sh - shell->disp_height;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_display_shell_scale_fill:
|
* gimp_display_shell_scale_fill:
|
||||||
* @shell: the #GimpDisplayShell
|
* @shell: the #GimpDisplayShell
|
||||||
|
|
|
@ -20,42 +20,43 @@
|
||||||
#define __GIMP_DISPLAY_SHELL_SCALE_H__
|
#define __GIMP_DISPLAY_SHELL_SCALE_H__
|
||||||
|
|
||||||
|
|
||||||
void gimp_display_shell_update_scrollbars_and_rulers (GimpDisplayShell *shell);
|
void gimp_display_shell_update_scrollbars_and_rulers (GimpDisplayShell *shell);
|
||||||
|
|
||||||
gboolean gimp_display_shell_scale_revert (GimpDisplayShell *shell);
|
gboolean gimp_display_shell_scale_revert (GimpDisplayShell *shell);
|
||||||
gboolean gimp_display_shell_scale_can_revert (GimpDisplayShell *shell);
|
gboolean gimp_display_shell_scale_can_revert (GimpDisplayShell *shell);
|
||||||
|
|
||||||
void gimp_display_shell_scale_set_dot_for_dot (GimpDisplayShell *shell,
|
void gimp_display_shell_scale_set_dot_for_dot (GimpDisplayShell *shell,
|
||||||
gboolean dot_for_dot);
|
gboolean dot_for_dot);
|
||||||
|
|
||||||
void gimp_display_shell_scale (GimpDisplayShell *shell,
|
void gimp_display_shell_scale (GimpDisplayShell *shell,
|
||||||
GimpZoomType zoom_type,
|
GimpZoomType zoom_type,
|
||||||
gdouble scale);
|
gdouble scale);
|
||||||
void gimp_display_shell_scale_to (GimpDisplayShell *shell,
|
void gimp_display_shell_scale_to (GimpDisplayShell *shell,
|
||||||
GimpZoomType zoom_type,
|
GimpZoomType zoom_type,
|
||||||
gdouble scale,
|
gdouble scale,
|
||||||
gdouble x,
|
gdouble x,
|
||||||
gdouble y);
|
gdouble y);
|
||||||
void gimp_display_shell_scale_fit_in (GimpDisplayShell *shell);
|
void gimp_display_shell_scale_fit_in (GimpDisplayShell *shell);
|
||||||
void gimp_display_shell_scale_fill (GimpDisplayShell *shell);
|
gboolean gimp_display_shell_scale_image_is_within_viewport (GimpDisplayShell *shell);
|
||||||
void gimp_display_shell_scale_handle_zoom_revert (GimpDisplayShell *shell);
|
void gimp_display_shell_scale_fill (GimpDisplayShell *shell);
|
||||||
void gimp_display_shell_scale_by_values (GimpDisplayShell *shell,
|
void gimp_display_shell_scale_handle_zoom_revert (GimpDisplayShell *shell);
|
||||||
gdouble scale,
|
void gimp_display_shell_scale_by_values (GimpDisplayShell *shell,
|
||||||
gint offset_x,
|
gdouble scale,
|
||||||
gint offset_y,
|
gint offset_x,
|
||||||
gboolean resize_window);
|
gint offset_y,
|
||||||
void gimp_display_shell_scale_shrink_wrap (GimpDisplayShell *shell,
|
gboolean resize_window);
|
||||||
gboolean grow_only);
|
void gimp_display_shell_scale_shrink_wrap (GimpDisplayShell *shell,
|
||||||
|
gboolean grow_only);
|
||||||
|
|
||||||
void gimp_display_shell_scale_resize (GimpDisplayShell *shell,
|
void gimp_display_shell_scale_resize (GimpDisplayShell *shell,
|
||||||
gboolean resize_window,
|
gboolean resize_window,
|
||||||
gboolean grow_only);
|
gboolean grow_only);
|
||||||
void gimp_display_shell_set_initial_scale (GimpDisplayShell *shell,
|
void gimp_display_shell_set_initial_scale (GimpDisplayShell *shell,
|
||||||
gdouble scale,
|
gdouble scale,
|
||||||
gint *display_width,
|
gint *display_width,
|
||||||
gint *display_height);
|
gint *display_height);
|
||||||
|
|
||||||
void gimp_display_shell_scale_dialog (GimpDisplayShell *shell);
|
void gimp_display_shell_scale_dialog (GimpDisplayShell *shell);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_DISPLAY_SHELL_SCALE_H__ */
|
#endif /* __GIMP_DISPLAY_SHELL_SCALE_H__ */
|
||||||
|
|
|
@ -718,6 +718,21 @@ gimp_display_shell_get_icc_profile (GimpColorManaged *managed,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_display_shell_zoom_button_callback (GimpDisplayShell *shell,
|
||||||
|
GtkWidget *zoom_button)
|
||||||
|
{
|
||||||
|
shell->zoom_on_resize =
|
||||||
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (zoom_button));
|
||||||
|
|
||||||
|
if (shell->zoom_on_resize &&
|
||||||
|
gimp_display_shell_scale_image_is_within_viewport (shell))
|
||||||
|
{
|
||||||
|
/* Implicitly make a View -> Fit Image in Window */
|
||||||
|
gimp_display_shell_scale_fit_in (shell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* public functions */
|
/* public functions */
|
||||||
|
|
||||||
|
@ -1079,9 +1094,9 @@ gimp_display_shell_new (GimpDisplay *display,
|
||||||
_("Zoom image when window size changes"),
|
_("Zoom image when window size changes"),
|
||||||
GIMP_HELP_IMAGE_WINDOW_ZOOM_FOLLOW_BUTTON);
|
GIMP_HELP_IMAGE_WINDOW_ZOOM_FOLLOW_BUTTON);
|
||||||
|
|
||||||
g_signal_connect (shell->zoom_button, "toggled",
|
g_signal_connect_swapped (shell->zoom_button, "toggled",
|
||||||
G_CALLBACK (gimp_toggle_button_update),
|
G_CALLBACK (gimp_display_shell_zoom_button_callback),
|
||||||
&shell->zoom_on_resize);
|
shell);
|
||||||
|
|
||||||
/* create the contents of the lower_hbox *********************************/
|
/* create the contents of the lower_hbox *********************************/
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue