~ubuntu-branches/ubuntu/karmic/gimp/karmic

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Pedro Fragoso
  • Date: 2008-11-24 14:16:39 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: james.westby@ubuntu.com-20081124141639-12b1g29vvadd5pzp
Tags: 2.6.3-1ubuntu1
* Sync with Debian experimental (LP: #301724)
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch:
  - updated some strings for ubuntu
* debian/rules:
  - updated translation templates
* debian/control:
  - Drop webkit build dependency. gimp is the only thing pulling
    in webkit for the desktop CDs, and makes them explode
    Without the webkit help browser
    plugin, help will just be displayed in the default browser.

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
                                                          gdouble           current_scale,
60
60
                                                          gboolean         *vertically,
61
61
                                                          gboolean         *horizontally);
62
 
static void      gimp_display_shell_scale_viewport_coord_almost_centered
 
62
static gboolean  gimp_display_shell_scale_viewport_coord_almost_centered
63
63
                                                         (GimpDisplayShell *shell,
64
64
                                                          gint              x,
65
65
                                                          gint              y,
66
66
                                                          gboolean         *horizontally,
67
67
                                                          gboolean         *vertically);
68
68
 
 
69
static void      gimp_display_shell_scale_get_image_center_viewport
 
70
                                                         (GimpDisplayShell *shell,
 
71
                                                          gint             *image_center_x,
 
72
                                                          gint             *image_center_y);
 
73
 
 
74
 
69
75
static void      gimp_display_shell_scale_get_zoom_focus (GimpDisplayShell *shell,
70
76
                                                          gdouble           new_scale,
71
77
                                                          gdouble           current_scale,
162
168
  gdouble    vertical_lower;
163
169
  gdouble    vertical_upper;
164
170
  gdouble    vertical_max_size;
165
 
  gint       scaled_viewport_offset_x;
166
 
  gint       scaled_viewport_offset_y;
167
171
 
168
172
  if (! shell->display)
169
173
    return;
211
215
 
212
216
  /* Adjust due to scrolling */
213
217
 
214
 
  gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
215
 
                                                        &scaled_viewport_offset_x,
216
 
                                                        &scaled_viewport_offset_y);
217
 
 
218
 
  horizontal_lower -= img2real (shell, TRUE,
219
 
                                FUNSCALEX (shell,
220
 
                                           (gdouble) scaled_viewport_offset_x));
221
 
  horizontal_upper -= img2real (shell, TRUE,
222
 
                                FUNSCALEX (shell,
223
 
                                           (gdouble) scaled_viewport_offset_x));
224
 
 
225
 
  vertical_lower   -= img2real (shell, FALSE,
226
 
                                FUNSCALEY (shell,
227
 
                                           (gdouble) scaled_viewport_offset_y));
228
 
  vertical_upper   -= img2real (shell, FALSE,
229
 
                                FUNSCALEY (shell,
230
 
                                           (gdouble) scaled_viewport_offset_y));
231
 
 
 
218
  if (image)
 
219
    {
 
220
      horizontal_lower += img2real (shell, TRUE,
 
221
                                    FUNSCALEX (shell,
 
222
                                               (gdouble) shell->offset_x));
 
223
      horizontal_upper += img2real (shell, TRUE,
 
224
                                    FUNSCALEX (shell,
 
225
                                               (gdouble) shell->offset_x));
 
226
 
 
227
      vertical_lower   += img2real (shell, FALSE,
 
228
                                    FUNSCALEY (shell,
 
229
                                               (gdouble) shell->offset_y));
 
230
      vertical_upper   += img2real (shell, FALSE,
 
231
                                    FUNSCALEY (shell,
 
232
                                               (gdouble) shell->offset_y));
 
233
    }
232
234
 
233
235
  /* Finally setup the actual rulers */
234
236
 
367
369
           * get things rolling
368
370
           */
369
371
          gimp_zoom_model_zoom (shell->zoom, GIMP_ZOOM_TO, real_new_scale);
 
372
          gimp_display_shell_scaled (shell);
 
373
 
370
374
          gimp_display_shell_shrink_wrap (shell, FALSE);
371
375
        }
372
376
      else
373
377
        {
374
 
          gboolean starts_fitting_horizontally;
375
 
          gboolean starts_fitting_vertically;
376
 
          gboolean almost_centered_horizontally;
377
 
          gboolean almost_centered_vertically;
 
378
          gboolean starts_fitting_horiz;
 
379
          gboolean starts_fitting_vert;
 
380
          gboolean zoom_focus_almost_centered_horiz;
 
381
          gboolean zoom_focus_almost_centered_vert;
 
382
          gboolean image_center_almost_centered_horiz;
 
383
          gboolean image_center_almost_centered_vert;
 
384
          gint     image_center_x;
 
385
          gint     image_center_y;
378
386
 
379
387
          gimp_display_shell_scale_get_zoom_focus (shell,
380
388
                                                   real_new_scale,
382
390
                                                   &x,
383
391
                                                   &y,
384
392
                                                   zoom_focus);
 
393
          gimp_display_shell_scale_get_image_center_viewport (shell,
 
394
                                                              &image_center_x,
 
395
                                                              &image_center_y);
385
396
 
386
397
          gimp_display_shell_scale_to (shell, real_new_scale, x, y);
387
398
 
393
404
          gimp_display_shell_scale_image_starts_to_fit (shell,
394
405
                                                        real_new_scale,
395
406
                                                        current_scale,
396
 
                                                        &starts_fitting_horizontally,
397
 
                                                        &starts_fitting_vertically);
 
407
                                                        &starts_fitting_horiz,
 
408
                                                        &starts_fitting_vert);
 
409
 
398
410
          gimp_display_shell_scale_viewport_coord_almost_centered (shell,
399
411
                                                                   x,
400
412
                                                                   y,
401
 
                                                                   &almost_centered_horizontally,
402
 
                                                                   &almost_centered_vertically);
 
413
                                                                   &zoom_focus_almost_centered_horiz,
 
414
                                                                   &zoom_focus_almost_centered_vert);
 
415
          gimp_display_shell_scale_viewport_coord_almost_centered (shell,
 
416
                                                                   image_center_x,
 
417
                                                                   image_center_y,
 
418
                                                                   &image_center_almost_centered_horiz,
 
419
                                                                   &image_center_almost_centered_vert);
 
420
            
403
421
          gimp_display_shell_scroll_center_image (shell,
404
 
                                                  starts_fitting_horizontally ||
405
 
                                                  almost_centered_horizontally,
406
 
                                                  starts_fitting_vertically ||
407
 
                                                  almost_centered_vertically);
 
422
                                                  starts_fitting_horiz ||
 
423
                                                  (zoom_focus_almost_centered_horiz &&
 
424
                                                   image_center_almost_centered_horiz),
 
425
                                                  starts_fitting_vert ||
 
426
                                                  (zoom_focus_almost_centered_vert &&
 
427
                                                   image_center_almost_centered_vert));
408
428
        }
409
429
    }
410
430
}
448
468
                            GIMP_ZOOM_TO,
449
469
                            zoom_factor,
450
470
                            GIMP_ZOOM_FOCUS_BEST_GUESS);
451
 
  
 
471
 
452
472
  gimp_display_shell_scroll_center_image (shell, TRUE, TRUE);
453
473
}
454
474
 
865
885
 * @vertically:
866
886
 *
867
887
 **/
868
 
static void
 
888
static gboolean
869
889
gimp_display_shell_scale_viewport_coord_almost_centered (GimpDisplayShell *shell,
870
890
                                                         gint              x,
871
891
                                                         gint              y,
872
892
                                                         gboolean         *horizontally,
873
893
                                                         gboolean         *vertically)
874
894
{
875
 
  gint center_x = shell->disp_width  / 2;
876
 
  gint center_y = shell->disp_height / 2;
877
 
 
878
 
  *horizontally = x > center_x - ALMOST_CENTERED_THRESHOLD &&
879
 
                  x < center_x + ALMOST_CENTERED_THRESHOLD;
880
 
 
881
 
  *vertically   = y > center_y - ALMOST_CENTERED_THRESHOLD &&
882
 
                  y < center_y + ALMOST_CENTERED_THRESHOLD;
 
895
  gboolean local_horizontally;
 
896
  gboolean local_vertically;
 
897
  gint     center_x = shell->disp_width  / 2;
 
898
  gint     center_y = shell->disp_height / 2;
 
899
 
 
900
  local_horizontally = (x > center_x - ALMOST_CENTERED_THRESHOLD &&
 
901
                        x < center_x + ALMOST_CENTERED_THRESHOLD);
 
902
 
 
903
  local_vertically   = (y > center_y - ALMOST_CENTERED_THRESHOLD &&
 
904
                        y < center_y + ALMOST_CENTERED_THRESHOLD);
 
905
 
 
906
  if (horizontally) *horizontally = local_horizontally;
 
907
  if (vertically)   *vertically   = local_vertically;
 
908
 
 
909
  return local_horizontally && local_vertically;
 
910
}
 
911
 
 
912
static void
 
913
gimp_display_shell_scale_get_image_center_viewport (GimpDisplayShell *shell,
 
914
                                                    gint             *image_center_x,
 
915
                                                    gint             *image_center_y)
 
916
{
 
917
  gint sw, sh;
 
918
 
 
919
  gimp_display_shell_draw_get_scaled_image_size (shell,
 
920
                                                 &sw,
 
921
                                                 &sh);
 
922
 
 
923
  if (image_center_x) *image_center_x = -shell->offset_x + sw / 2;
 
924
  if (image_center_y) *image_center_y = -shell->offset_y + sh / 2;
883
925
}
884
926
 
885
927
/**
900
942
                                         gint             *y,
901
943
                                         GimpZoomFocus     zoom_focus)
902
944
{
903
 
  gint image_center_x, image_center_y;
904
 
  gint other_x, other_y;
 
945
  GimpZoomFocus real_zoom_focus = zoom_focus;
 
946
  gint          image_center_x, image_center_y;
 
947
  gint          other_x, other_y;
905
948
 
906
949
  /* Calculate stops-to-fit focus point */
907
 
  {
908
 
    gint sw, sh;
909
 
 
910
 
    gimp_display_shell_draw_get_scaled_image_size (shell,
911
 
                                                   &sw,
912
 
                                                   &sh);
913
 
    image_center_x = -shell->offset_x + sw / 2;
914
 
    image_center_y = -shell->offset_y + sh / 2;
915
 
  }
 
950
  gimp_display_shell_scale_get_image_center_viewport (shell,
 
951
                                                      &image_center_x,
 
952
                                                      &image_center_y);
916
953
 
917
954
  /* Calculate other focus point */
918
955
  {
964
1001
  }
965
1002
 
966
1003
  /* Decide which one to use for each axis */
967
 
  switch (zoom_focus)
 
1004
  if (zoom_focus == GIMP_ZOOM_FOCUS_RETAIN_CENTERING_ELSE_BEST_GUESS)
 
1005
    {
 
1006
      gboolean centered;
 
1007
 
 
1008
      centered = gimp_display_shell_scale_viewport_coord_almost_centered (shell,
 
1009
                                                                          image_center_x,
 
1010
                                                                          image_center_y,
 
1011
                                                                          NULL,
 
1012
                                                                          NULL);
 
1013
      real_zoom_focus = (centered ?
 
1014
                         GIMP_ZOOM_FOCUS_IMAGE_CENTER :
 
1015
                         GIMP_ZOOM_FOCUS_BEST_GUESS);
 
1016
    }
 
1017
  else
 
1018
    {
 
1019
      real_zoom_focus = zoom_focus;
 
1020
    }
 
1021
 
 
1022
  switch (real_zoom_focus)
968
1023
    {
969
1024
    case GIMP_ZOOM_FOCUS_POINTER:
970
1025
      *x = other_x;