GimpGuide * gimp_image_add_hguide (GimpImage *image, gint position, gboolean push_undo) { GimpGuide *guide; g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL); g_return_val_if_fail (position >= 0 && position <= gimp_image_get_height (image), NULL); guide = gimp_guide_new (GIMP_ORIENTATION_HORIZONTAL, image->gimp->next_guide_ID++); if (push_undo) gimp_image_undo_push_guide (image, C_("undo-type", "Add Horizontal Guide"), guide); gimp_image_add_guide (image, guide, position); g_object_unref (G_OBJECT (guide)); return guide; }
GimpGuide * gimp_image_add_vguide (GimpImage *image, gint position, gboolean push_undo) { GimpGuide *guide; g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL); g_return_val_if_fail (position >= 0 && position <= gimp_image_get_width (image), NULL); guide = gimp_guide_new (GIMP_ORIENTATION_VERTICAL, image->gimp->next_guide_ID++); if (push_undo) gimp_image_undo_push_guide (image, C_("undo-type", "Add Vertical Guide"), guide); gimp_image_add_guide (image, guide, position); g_object_unref (guide); return guide; }
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; } } }