예제 #1
0
static void
gimp_guide_undo_pop (GimpUndo              *undo,
                     GimpUndoMode           undo_mode,
                     GimpUndoAccumulator   *accum)
{
  GimpGuideUndo       *guide_undo = GIMP_GUIDE_UNDO (undo);
  GimpOrientationType  orientation;
  gint                 position;

  GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);

  orientation = gimp_guide_get_orientation (guide_undo->guide);
  position    = gimp_guide_get_position (guide_undo->guide);

  /*  add and move guides manually (nor using the gimp_image_guide
   *  API), because we might be in the middle of an image resizing
   *  undo group and the guide's position might be temporarily out of
   *  image.
   */

  if (position == -1)
    {
      undo->image->guides = g_list_prepend (undo->image->guides,
                                            guide_undo->guide);
      gimp_guide_set_position (guide_undo->guide, guide_undo->position);
      g_object_ref (guide_undo->guide);
      gimp_image_update_guide (undo->image, guide_undo->guide);
    }
  else if (guide_undo->position == -1)
    {
      gimp_image_remove_guide (undo->image, guide_undo->guide, FALSE);
    }
  else
    {
      gimp_image_update_guide (undo->image, guide_undo->guide);
      gimp_guide_set_position (guide_undo->guide, guide_undo->position);
      gimp_image_update_guide (undo->image, guide_undo->guide);
    }

  gimp_guide_set_orientation (guide_undo->guide, guide_undo->orientation);

  guide_undo->position    = position;
  guide_undo->orientation = orientation;
}
예제 #2
0
static void
gimp_image_rotate_guides (GimpImage        *image,
                          GimpRotationType  rotate_type)
{
  GList *list;

  /*  Rotate all Guides  */
  for (list = gimp_image_get_guides (image);
       list;
       list = g_list_next (list))
    {
      GimpGuide           *guide       = list->data;
      GimpOrientationType  orientation = gimp_guide_get_orientation (guide);
      gint                 position    = gimp_guide_get_position (guide);

      switch (rotate_type)
        {
        case GIMP_ROTATE_90:
          switch (orientation)
            {
            case GIMP_ORIENTATION_HORIZONTAL:
              gimp_image_undo_push_guide (image, NULL, guide);
              gimp_guide_set_orientation (guide, GIMP_ORIENTATION_VERTICAL);
              gimp_guide_set_position (guide,
                                       gimp_image_get_height (image) - position);
              break;

            case GIMP_ORIENTATION_VERTICAL:
              gimp_image_undo_push_guide (image, NULL, guide);
              gimp_guide_set_orientation (guide, GIMP_ORIENTATION_HORIZONTAL);
              break;

            default:
              break;
            }
          break;

        case GIMP_ROTATE_180:
          switch (orientation)
            {
            case GIMP_ORIENTATION_HORIZONTAL:
              gimp_image_move_guide (image, guide,
                                     gimp_image_get_height (image) - position,
                                     TRUE);
              break;

            case GIMP_ORIENTATION_VERTICAL:
              gimp_image_move_guide (image, guide,
                                     gimp_image_get_width (image) - position,
                                     TRUE);
              break;

            default:
              break;
            }
          break;

        case GIMP_ROTATE_270:
          switch (orientation)
            {
            case GIMP_ORIENTATION_HORIZONTAL:
              gimp_image_undo_push_guide (image, NULL, guide);
              gimp_guide_set_orientation (guide, GIMP_ORIENTATION_VERTICAL);
              break;

            case GIMP_ORIENTATION_VERTICAL:
              gimp_image_undo_push_guide (image, NULL, guide);
              gimp_guide_set_orientation (guide, GIMP_ORIENTATION_HORIZONTAL);
              gimp_guide_set_position (guide,
                                       gimp_image_get_width (image) - position);
              break;

            default:
              break;
            }
          break;
        }
    }
}