~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/display/gimpdisplayshell-scale.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2008-10-10 00:13:42 UTC
  • mfrom: (1.1.16 upstream)
  • Revision ID: james.westby@ubuntu.com-20081010001342-uja9qine9uybggd9
Tags: 2.6.1-1ubuntu1
* Sync new bugfix version on debian (lp: #280345, #280848)
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch:
  - updated some strings for ubuntu
* debian/rules:
  - updated translation templates

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
                                                          gdouble           new_scale,
71
71
                                                          gdouble           current_scale,
72
72
                                                          gint             *x,
73
 
                                                          gint             *y);
 
73
                                                          gint             *y,
 
74
                                                          GimpZoomFocus     zoom_focus);
74
75
 
75
76
static gdouble   img2real                                (GimpDisplayShell *shell,
76
77
                                                          gboolean          xdir,
89
90
{
90
91
  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
91
92
 
92
 
  if (! shell->display)
93
 
    return;
94
 
 
95
93
  gimp_display_shell_scale_update_scrollbars (shell);
96
94
  gimp_display_shell_scale_update_rulers (shell);
97
95
}
108
106
  gint       image_width;
109
107
  gint       image_height;
110
108
 
 
109
  if (! shell->display)
 
110
    return;
 
111
 
111
112
  image = shell->display->image;
112
113
 
113
114
  if (image)
164
165
  gint       scaled_viewport_offset_x;
165
166
  gint       scaled_viewport_offset_y;
166
167
 
 
168
  if (! shell->display)
 
169
    return;
 
170
 
167
171
  image = shell->display->image;
168
172
 
169
173
  if (image)
334
338
void
335
339
gimp_display_shell_scale (GimpDisplayShell *shell,
336
340
                          GimpZoomType      zoom_type,
337
 
                          gdouble           new_scale)
 
341
                          gdouble           new_scale,
 
342
                          GimpZoomFocus     zoom_focus)
338
343
{
339
344
  gint    x, y;
340
345
  gdouble current_scale;
375
380
                                                   real_new_scale,
376
381
                                                   current_scale,
377
382
                                                   &x,
378
 
                                                   &y);
 
383
                                                   &y,
 
384
                                                   zoom_focus);
379
385
 
380
386
          gimp_display_shell_scale_to (shell, real_new_scale, x, y);
381
387
 
438
444
  zoom_factor = MIN ((gdouble) shell->disp_width  / (gdouble) image_width,
439
445
                     (gdouble) shell->disp_height / (gdouble) image_height);
440
446
 
441
 
  gimp_display_shell_scale (shell, GIMP_ZOOM_TO, zoom_factor);
 
447
  gimp_display_shell_scale (shell,
 
448
                            GIMP_ZOOM_TO,
 
449
                            zoom_factor,
 
450
                            GIMP_ZOOM_FOCUS_BEST_GUESS);
 
451
  
442
452
  gimp_display_shell_scroll_center_image (shell, TRUE, TRUE);
443
453
}
444
454
 
510
520
  zoom_factor = MAX ((gdouble) shell->disp_width  / (gdouble) image_width,
511
521
                     (gdouble) shell->disp_height / (gdouble) image_height);
512
522
 
513
 
  gimp_display_shell_scale (shell, GIMP_ZOOM_TO, zoom_factor);
 
523
  gimp_display_shell_scale (shell,
 
524
                            GIMP_ZOOM_TO,
 
525
                            zoom_factor,
 
526
                            GIMP_ZOOM_FOCUS_BEST_GUESS);
 
527
 
514
528
  gimp_display_shell_scroll_center_image (shell, TRUE, TRUE);
515
529
}
516
530
 
883
897
                                         gdouble           new_scale,
884
898
                                         gdouble           current_scale,
885
899
                                         gint             *x,
886
 
                                         gint             *y)
 
900
                                         gint             *y,
 
901
                                         GimpZoomFocus     zoom_focus)
887
902
{
888
903
  gint image_center_x, image_center_y;
889
904
  gint other_x, other_y;
949
964
  }
950
965
 
951
966
  /* Decide which one to use for each axis */
952
 
  {
953
 
    gboolean within_horizontally, within_vertically;
954
 
    gboolean stops_horizontally, stops_vertically;
955
 
 
956
 
    gimp_display_shell_scale_image_is_within_viewport (shell,
957
 
                                                       &within_horizontally,
958
 
                                                       &within_vertically);
959
 
 
960
 
    gimp_display_shell_scale_image_stops_to_fit (shell,
961
 
                                                 new_scale,
962
 
                                                 current_scale,
963
 
                                                 &stops_horizontally,
964
 
                                                 &stops_vertically);
965
 
 
966
 
    *x = within_horizontally && ! stops_horizontally ? image_center_x : other_x;
967
 
    *y = within_vertically   && ! stops_vertically   ? image_center_y : other_y;
968
 
  }
 
967
  switch (zoom_focus)
 
968
    {
 
969
    case GIMP_ZOOM_FOCUS_POINTER:
 
970
      *x = other_x;
 
971
      *y = other_y;
 
972
      break;
 
973
 
 
974
    case GIMP_ZOOM_FOCUS_IMAGE_CENTER:
 
975
      *x = image_center_x;
 
976
      *y = image_center_y;
 
977
      break;
 
978
 
 
979
    case GIMP_ZOOM_FOCUS_BEST_GUESS:
 
980
    default:
 
981
      {
 
982
        gboolean within_horizontally, within_vertically;
 
983
        gboolean stops_horizontally, stops_vertically;
 
984
 
 
985
        gimp_display_shell_scale_image_is_within_viewport (shell,
 
986
                                                           &within_horizontally,
 
987
                                                           &within_vertically);
 
988
 
 
989
        gimp_display_shell_scale_image_stops_to_fit (shell,
 
990
                                                     new_scale,
 
991
                                                     current_scale,
 
992
                                                     &stops_horizontally,
 
993
                                                     &stops_vertically);
 
994
 
 
995
        *x = within_horizontally && ! stops_horizontally ? image_center_x : other_x;
 
996
        *y = within_vertically   && ! stops_vertically   ? image_center_y : other_y;
 
997
      }
 
998
      break;
 
999
    }
969
1000
}
970
1001
 
971
1002
/* scale image coord to realworld units (cm, inches, pixels)