static void
gimp_display_shell_resolution_changed_handler (GimpImage        *image,
                                               GimpDisplayShell *shell)
{
  gimp_display_shell_scale_update (shell);

  if (shell->dot_for_dot)
    {
      if (shell->unit != GIMP_UNIT_PIXEL)
        {
          gimp_display_shell_rulers_update (shell);
        }

      gimp_display_shell_scaled (shell);
    }
  else
    {
      /* A resolution change has the same effect as a size change from
       * a display shell point of view. Force a redraw of the display
       * so that we don't get any display garbage.
       */

      GimpDisplayConfig *config = shell->display->config;
      gboolean           resize_window;

      /* Resize windows only in multi-window mode */
      resize_window = (config->resize_windows_on_resize &&
                       ! GIMP_GUI_CONFIG (config)->single_window_mode);

      gimp_display_shell_scale_resize (shell, resize_window, FALSE);
    }
}
Пример #2
0
/**
 * gimp_display_shell_scroll_clamp_and_update:
 * @shell:
 *
 * Helper function for calling two functions that are commonly called
 * in pairs.
 **/
void
gimp_display_shell_scroll_clamp_and_update (GimpDisplayShell *shell)
{
  GimpImage *image;

  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));

  image = gimp_display_get_image (shell->display);

  if (image)
    {
      gint bounds_x;
      gint bounds_y;
      gint bounds_width;
      gint bounds_height;
      gint min_offset_x;
      gint max_offset_x;
      gint min_offset_y;
      gint max_offset_y;
      gint offset_x;
      gint offset_y;

      gimp_display_shell_rotate_update_transform (shell);

      gimp_display_shell_scale_get_image_bounds (shell,
                                                 &bounds_x, &bounds_y,
                                                 &bounds_width, &bounds_height);

      if (shell->disp_width < bounds_width)
        {
          min_offset_x = bounds_x -
                         shell->disp_width * OVERPAN_FACTOR;
          max_offset_x = bounds_x + bounds_width -
                         shell->disp_width * (1.0 - OVERPAN_FACTOR);
        }
      else
        {
          gint overpan_amount;

          overpan_amount = shell->disp_width -
                           bounds_width * (1.0 - OVERPAN_FACTOR);

          min_offset_x = bounds_x -
                         overpan_amount;
          max_offset_x = bounds_x + bounds_width - shell->disp_width +
                         overpan_amount;
        }

      if (shell->disp_height < bounds_height)
        {
          min_offset_y = bounds_y -
                         shell->disp_height * OVERPAN_FACTOR;
          max_offset_y = bounds_y + bounds_height -
                         shell->disp_height * (1.0 - OVERPAN_FACTOR);
        }
      else
        {
          gint overpan_amount;

          overpan_amount = shell->disp_height -
                           bounds_height * (1.0 - OVERPAN_FACTOR);

          min_offset_y = bounds_y -
                         overpan_amount;
          max_offset_y = bounds_y + bounds_height +
                         overpan_amount - shell->disp_height;
        }

      /* Clamp */

      offset_x = CLAMP (shell->offset_x, min_offset_x, max_offset_x);
      offset_y = CLAMP (shell->offset_y, min_offset_y, max_offset_y);

      if (offset_x != shell->offset_x || offset_y != shell->offset_y)
        {
          shell->offset_x = offset_x;
          shell->offset_y = offset_y;

          gimp_display_shell_rotate_update_transform (shell);
        }

      /* Set scrollbar stepper sensitiity */

      gimp_display_shell_scrollbars_update_steppers (shell,
                                                     min_offset_x,
                                                     max_offset_x,
                                                     min_offset_y,
                                                     max_offset_y);
    }
  else
    {
      shell->offset_x = 0;
      shell->offset_y = 0;
    }

  gimp_display_shell_scrollbars_update (shell);
  gimp_display_shell_rulers_update (shell);
}