gimp r26143 - in trunk: . app/display
- From: martinn svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26143 - in trunk: . app/display
- Date: Fri, 11 Jul 2008 21:08:34 +0000 (UTC)
Author: martinn
Date: Fri Jul 11 21:08:34 2008
New Revision: 26143
URL: http://svn.gnome.org/viewvc/gimp?rev=26143&view=rev
Log:
2008-07-11 Martin Nordholts <martinn svn gnome org>
* app/display/gimpdisplayshell-scale.c
(gimp_display_shell_scale_setup): Restructure the way the rulers
are setup, partly by making use of the new nifty
gimp_display_shell_get_scaled_image_viewport_offset().
Modified:
trunk/ChangeLog
trunk/app/display/gimpdisplayshell-scale.c
Modified: trunk/app/display/gimpdisplayshell-scale.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-scale.c (original)
+++ trunk/app/display/gimpdisplayshell-scale.c Fri Jul 11 21:08:34 2008
@@ -89,9 +89,6 @@
gimp_display_shell_scale_setup (GimpDisplayShell *shell)
{
GimpImage *image;
- gdouble lower;
- gdouble upper;
- gdouble max_size;
gfloat sx, sy;
gint image_width;
gint image_height;
@@ -135,87 +132,99 @@
gtk_adjustment_changed (shell->hsbdata);
gtk_adjustment_changed (shell->vsbdata);
- /* horizontal ruler */
-
- lower = 0;
-
- if (image)
- {
- upper = img2real (shell, TRUE, FUNSCALEX (shell, shell->disp_width));
- max_size = img2real (shell, TRUE, MAX (image_width, image_height));
- }
- else
- {
- upper = image_width;
- max_size = MAX (image_width, image_height);
- }
-
- if (image && sx < shell->disp_width)
- {
- shell->disp_xoffset = (shell->disp_width - sx) / 2;
-
- lower -= img2real (shell, TRUE,
- FUNSCALEX (shell, (gdouble) shell->disp_xoffset));
- upper -= img2real (shell, TRUE,
- FUNSCALEX (shell, (gdouble) shell->disp_xoffset));
- }
- else if (image)
- {
- shell->disp_xoffset = 0;
-
- lower += img2real (shell, TRUE,
- FUNSCALEX (shell, (gdouble) shell->offset_x));
- upper += img2real (shell, TRUE,
- FUNSCALEX (shell, (gdouble) shell->offset_x));
- }
- else
- {
- shell->disp_xoffset = 0;
- }
-
- gimp_ruler_set_range (GIMP_RULER (shell->hrule), lower, upper, max_size);
- gimp_ruler_set_unit (GIMP_RULER (shell->hrule), shell->unit);
-
- /* vertical ruler */
-
- lower = 0;
-
- if (image)
- {
- upper = img2real (shell, FALSE, FUNSCALEY (shell, shell->disp_height));
- max_size = img2real (shell, FALSE, MAX (image_width, image_height));
- }
- else
- {
- upper = image_height;
- max_size = MAX (image_width, image_height);
- }
-
- if (image && sy < shell->disp_height)
- {
- shell->disp_yoffset = (shell->disp_height - sy) / 2;
-
- lower -= img2real (shell, FALSE,
- FUNSCALEY (shell, (gdouble) shell->disp_yoffset));
- upper -= img2real (shell, FALSE,
- FUNSCALEY (shell, (gdouble) shell->disp_yoffset));
- }
- else if (image)
- {
- shell->disp_yoffset = 0;
-
- lower += img2real (shell, FALSE,
- FUNSCALEY (shell, (gdouble) shell->offset_y));
- upper += img2real (shell, FALSE,
- FUNSCALEY (shell, (gdouble) shell->offset_y));
- }
- else
- {
- shell->disp_yoffset = 0;
- }
-
- gimp_ruler_set_range (GIMP_RULER (shell->vrule), lower, upper, max_size);
- gimp_ruler_set_unit (GIMP_RULER (shell->vrule), shell->unit);
+ /* Setup rulers */
+ {
+ gdouble horizontal_lower;
+ gdouble horizontal_upper;
+ gdouble horizontal_max_size;
+ gdouble vertical_lower;
+ gdouble vertical_upper;
+ gdouble vertical_max_size;
+ gint scaled_image_viewport_offset_x;
+ gint scaled_image_viewport_offset_y;
+
+
+ /* Initialize values */
+
+ horizontal_lower = 0;
+ vertical_lower = 0;
+
+ if (image)
+ {
+ horizontal_upper = img2real (shell, TRUE, FUNSCALEX (shell, shell->disp_width));
+ horizontal_max_size = img2real (shell, TRUE, MAX (image_width, image_height));
+
+ vertical_upper = img2real (shell, FALSE, FUNSCALEY (shell, shell->disp_height));
+ vertical_max_size = img2real (shell, FALSE, MAX (image_width, image_height));
+ }
+ else
+ {
+ horizontal_upper = image_width;
+ horizontal_max_size = MAX (image_width, image_height);
+
+ vertical_upper = image_height;
+ vertical_max_size = MAX (image_width, image_height);
+ }
+
+
+ /* Center the image if its scaled width/height fits within the
+ * viewport
+ */
+
+ if (image && sx < shell->disp_width)
+ {
+ shell->disp_xoffset = (shell->disp_width - sx) / 2;
+ }
+ else
+ {
+ shell->disp_xoffset = 0;
+ }
+
+ if (image && sy < shell->disp_height)
+ {
+ shell->disp_yoffset = (shell->disp_height - sy) / 2;
+ }
+ else
+ {
+ shell->disp_yoffset = 0;
+ }
+
+
+ /* Adjust due to scrolling */
+
+ gimp_display_shell_get_scaled_image_viewport_offset (shell,
+ &scaled_image_viewport_offset_x,
+ &scaled_image_viewport_offset_y);
+
+ horizontal_lower -= img2real (shell, TRUE,
+ FUNSCALEX (shell, (gdouble) scaled_image_viewport_offset_x));
+ horizontal_upper -= img2real (shell, TRUE,
+ FUNSCALEX (shell, (gdouble) scaled_image_viewport_offset_x));
+
+ vertical_lower -= img2real (shell, FALSE,
+ FUNSCALEY (shell, (gdouble) scaled_image_viewport_offset_y));
+ vertical_upper -= img2real (shell, FALSE,
+ FUNSCALEY (shell, (gdouble) scaled_image_viewport_offset_y));
+
+
+ /* Finally setup the actual rulers */
+
+ gimp_ruler_set_range (GIMP_RULER (shell->hrule),
+ horizontal_lower,
+ horizontal_upper,
+ horizontal_max_size);
+
+ gimp_ruler_set_unit (GIMP_RULER (shell->hrule),
+ shell->unit);
+
+ gimp_ruler_set_range (GIMP_RULER (shell->vrule),
+ vertical_lower,
+ vertical_upper,
+ vertical_max_size);
+
+ gimp_ruler_set_unit (GIMP_RULER (shell->vrule),
+ shell->unit);
+ }
#if 0
g_printerr ("offset_x: %d\n"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]