/** * gimp_display_shell_scroll_center_image_xy: * @shell: * @image_x: * @image_y: * * Center the viewport around the passed image coordinate **/ void gimp_display_shell_scroll_center_image_xy (GimpDisplayShell *shell, gdouble image_x, gdouble image_y) { gint viewport_x; gint viewport_y; gimp_display_shell_transform_xy (shell, image_x, image_y, &viewport_x, &viewport_y); gimp_display_shell_scroll (shell, viewport_x - shell->disp_width / 2, viewport_y - shell->disp_height / 2); }
static void gimp_color_tool_motion (GimpTool *tool, const GimpCoords *coords, guint32 time, GdkModifierType state, GimpDisplay *display) { GimpColorTool *color_tool = GIMP_COLOR_TOOL (tool); GimpDisplayShell *shell = gimp_display_get_shell (display); if (! color_tool->enabled) return; if (color_tool->moving_sample_point) { gint tx, ty; gboolean delete_point = FALSE; gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); gimp_display_shell_transform_xy (shell, coords->x, coords->y, &tx, &ty); if (tx < 0 || tx > shell->disp_width || ty < 0 || ty > shell->disp_height) { color_tool->sample_point_x = SAMPLE_POINT_POSITION_INVALID; color_tool->sample_point_y = SAMPLE_POINT_POSITION_INVALID; delete_point = TRUE; } else { GimpImage *image = gimp_display_get_image (display); gint width = gimp_image_get_width (image); gint height = gimp_image_get_height (image); color_tool->sample_point_x = floor (coords->x); color_tool->sample_point_y = floor (coords->y); if (color_tool->sample_point_x < 0 || color_tool->sample_point_x >= width || color_tool->sample_point_y < 0 || color_tool->sample_point_y >= height) { delete_point = TRUE; } } gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); gimp_tool_pop_status (tool, display); if (delete_point) { gimp_tool_push_status (tool, display, color_tool->sample_point ? _("Remove Sample Point") : _("Cancel Sample Point")); } else { gimp_tool_push_status_coords (tool, display, gimp_tool_control_get_precision (tool->control), color_tool->sample_point ? _("Move Sample Point: ") : _("Add Sample Point: "), color_tool->sample_point_x, ", ", color_tool->sample_point_y, NULL); } } else { gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); color_tool->center_x = coords->x; color_tool->center_y = coords->y; gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); gimp_color_tool_pick (color_tool, GIMP_COLOR_PICK_STATE_UPDATE, coords->x, coords->y); } }
static void gimp_move_tool_motion (GimpTool *tool, const GimpCoords *coords, guint32 time, GdkModifierType state, GimpDisplay *display) { GimpMoveTool *move = GIMP_MOVE_TOOL (tool); GimpDisplayShell *shell = gimp_display_get_shell (display); if (move->moving_guide) { gint tx, ty; gboolean delete_guide = FALSE; gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); gimp_display_shell_transform_xy (shell, coords->x, coords->y, &tx, &ty); if (tx < 0 || tx >= shell->disp_width || ty < 0 || ty >= shell->disp_height) { move->guide_position = GUIDE_POSITION_INVALID; delete_guide = TRUE; } else { gint x, y, width, height; if (move->guide_orientation == GIMP_ORIENTATION_HORIZONTAL) move->guide_position = RINT (coords->y); else move->guide_position = RINT (coords->x); gimp_display_shell_untransform_viewport (shell, &x, &y, &width, &height); switch (move->guide_orientation) { case GIMP_ORIENTATION_HORIZONTAL: if ((move->guide_position < y) || (move->guide_position > (y + height))) delete_guide = TRUE; break; case GIMP_ORIENTATION_VERTICAL: if ((move->guide_position < x) || (move->guide_position > (x + width))) delete_guide = TRUE; break; default: break; } } gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); gimp_tool_pop_status (tool, display); if (delete_guide) { gimp_tool_push_status (tool, display, move->guide ? _("Remove Guide") : _("Cancel Guide")); } else { gimp_tool_push_status_length (tool, display, move->guide ? _("Move Guide: ") : _("Add Guide: "), SWAP_ORIENT (move->guide_orientation), move->guide_position, NULL); } } }
static void gimp_guide_tool_motion (GimpTool *tool, const GimpCoords *coords, guint32 time, GdkModifierType state, GimpDisplay *display) { GimpGuideTool *guide_tool = GIMP_GUIDE_TOOL (tool); GimpDisplayShell *shell = gimp_display_get_shell (display); GimpImage *image = gimp_display_get_image (display); gboolean delete_guide = FALSE; gint max_position; gint tx, ty; gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); gimp_display_shell_transform_xy (shell, coords->x, coords->y, &tx, &ty); if (guide_tool->guide_orientation == GIMP_ORIENTATION_HORIZONTAL) max_position = gimp_image_get_height (image); else max_position = gimp_image_get_width (image); if (tx < 0 || tx >= shell->disp_width || ty < 0 || ty >= shell->disp_height) { guide_tool->guide_position = GIMP_GUIDE_POSITION_UNDEFINED; delete_guide = TRUE; } else { if (guide_tool->guide_orientation == GIMP_ORIENTATION_HORIZONTAL) guide_tool->guide_position = RINT (coords->y); else guide_tool->guide_position = RINT (coords->x); if (guide_tool->guide_position < 0 || guide_tool->guide_position > max_position) { delete_guide = TRUE; } } gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); gimp_tool_pop_status (tool, display); /* custom guides are moved live */ if (guide_tool->guide_custom && guide_tool->guide_position != GIMP_GUIDE_POSITION_UNDEFINED) { gimp_image_move_guide (image, guide_tool->guide, CLAMP (guide_tool->guide_position, 0, max_position), TRUE); } if (delete_guide) { gimp_tool_push_status (tool, display, guide_tool->guide ? _("Remove Guide") : _("Cancel Guide")); } else if (guide_tool->guide) { gimp_tool_push_status_length (tool, display, _("Move Guide: "), SWAP_ORIENT (guide_tool->guide_orientation), guide_tool->guide_position - guide_tool->guide_old_position, NULL); } else { gimp_tool_push_status_length (tool, display, _("Add Guide: "), SWAP_ORIENT (guide_tool->guide_orientation), guide_tool->guide_position, NULL); } }
static void gimp_color_tool_motion (GimpTool *tool, GimpCoords *coords, guint32 time, GdkModifierType state, GimpDisplay *display) { GimpColorTool *color_tool = GIMP_COLOR_TOOL (tool); GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell); if (! color_tool->enabled) return; if (color_tool->moving_sample_point) { gint tx, ty; gboolean delete_point = FALSE; gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); gimp_display_shell_transform_xy (shell, coords->x, coords->y, &tx, &ty, FALSE); if (tx < 0 || tx > shell->disp_width || ty < 0 || ty > shell->disp_height) { color_tool->sample_point_x = -1; color_tool->sample_point_y = -1; delete_point = TRUE; } else { gint x, y, width, height; color_tool->sample_point_x = floor (coords->x); color_tool->sample_point_y = floor (coords->y); gimp_display_shell_untransform_viewport (shell, &x, &y, &width, &height); if ((color_tool->sample_point_x < x || color_tool->sample_point_x > (x + width - 1) || color_tool->sample_point_y < y || color_tool->sample_point_y > (y + height - 1))) { delete_point = TRUE; } } gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); gimp_tool_pop_status (tool, display); if (delete_point) { gimp_tool_push_status (tool, display, color_tool->sample_point ? _("Remove Sample Point") : _("Cancel Sample Point")); } else { gimp_tool_push_status_coords (tool, display, color_tool->sample_point ? _("Move Sample Point: ") : _("Add Sample Point: "), color_tool->sample_point_x, ", ", color_tool->sample_point_y, NULL); } } else { gint off_x, off_y; gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); gimp_item_offsets (GIMP_ITEM (tool->drawable), &off_x, &off_y); color_tool->center_x = coords->x - off_x; color_tool->center_y = coords->y - off_y; gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); gimp_color_tool_pick (color_tool, GIMP_COLOR_PICK_STATE_UPDATE, coords->x, coords->y); } }
static void gimp_sample_point_tool_motion (GimpTool *tool, const GimpCoords *coords, guint32 time, GdkModifierType state, GimpDisplay *display) { GimpSamplePointTool *sp_tool = GIMP_SAMPLE_POINT_TOOL (tool); GimpDisplayShell *shell = gimp_display_get_shell (display); gboolean delete_point = FALSE; gint tx, ty; gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); gimp_display_shell_transform_xy (shell, coords->x, coords->y, &tx, &ty); if (tx < 0 || tx >= shell->disp_width || ty < 0 || ty >= shell->disp_height) { sp_tool->sample_point_x = GIMP_SAMPLE_POINT_POSITION_UNDEFINED; sp_tool->sample_point_y = GIMP_SAMPLE_POINT_POSITION_UNDEFINED; delete_point = TRUE; } else { GimpImage *image = gimp_display_get_image (display); gint width = gimp_image_get_width (image); gint height = gimp_image_get_height (image); sp_tool->sample_point_x = floor (coords->x); sp_tool->sample_point_y = floor (coords->y); if (sp_tool->sample_point_x < 0 || sp_tool->sample_point_x >= height || sp_tool->sample_point_y < 0 || sp_tool->sample_point_y >= width) { delete_point = TRUE; } } gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); gimp_tool_pop_status (tool, display); if (delete_point) { gimp_tool_push_status (tool, display, sp_tool->sample_point ? _("Remove Sample Point") : _("Cancel Sample Point")); } else if (sp_tool->sample_point) { gimp_tool_push_status_coords (tool, display, gimp_tool_control_get_precision (tool->control), _("Move Sample Point: "), sp_tool->sample_point_x - sp_tool->sample_point_old_x, ", ", sp_tool->sample_point_y - sp_tool->sample_point_old_y, NULL); } else { gimp_tool_push_status_coords (tool, display, gimp_tool_control_get_precision (tool->control), _("Add Sample Point: "), sp_tool->sample_point_x, ", ", sp_tool->sample_point_y, NULL); } }