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; }
static void gimp_image_map_tool_move_guide (GimpImageMapTool *im_tool) { GimpImageMapOptions *options = GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (im_tool); GimpItem *item; GimpOrientationType orientation; gint position; if (! im_tool->percent_guide) return; item = GIMP_ITEM (im_tool->drawable); if (options->preview_alignment == GIMP_ALIGN_LEFT || options->preview_alignment == GIMP_ALIGN_RIGHT) { orientation = GIMP_ORIENTATION_VERTICAL; position = (gimp_item_get_offset_x (item) + gimp_item_get_width (item) * options->preview_position); } else { orientation = GIMP_ORIENTATION_HORIZONTAL; position = (gimp_item_get_offset_y (item) + gimp_item_get_height (item) * options->preview_position); } if (orientation != gimp_guide_get_orientation (im_tool->percent_guide) || position != gimp_guide_get_position (im_tool->percent_guide)) { gimp_guide_set_orientation (im_tool->percent_guide, orientation); gimp_image_move_guide (gimp_item_get_image (item), im_tool->percent_guide, position, FALSE); } }
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; } } }