static void gimp_blend_tool_push_status (GimpBlendTool *blend_tool, GdkModifierType state, GimpDisplay *display) { GimpTool *tool = GIMP_TOOL (blend_tool); gchar *status_help; status_help = gimp_suggest_modifiers ("", (gimp_get_constrain_behavior_mask () | GDK_MOD1_MASK) & ~state, NULL, _("%s for constrained angles"), _("%s to move the whole line")); gimp_tool_push_status_coords (tool, display, gimp_tool_control_get_precision (tool->control), _("Blend: "), blend_tool->end_x - blend_tool->start_x, ", ", blend_tool->end_y - blend_tool->start_y, status_help); g_free (status_help); }
static void gimp_color_tool_button_press (GimpTool *tool, const GimpCoords *coords, guint32 time, GdkModifierType state, GimpButtonPressType press_type, GimpDisplay *display) { GimpColorTool *color_tool = GIMP_COLOR_TOOL (tool); GimpDisplayShell *shell = gimp_display_get_shell (display); /* Chain up to activate the tool */ GIMP_TOOL_CLASS (parent_class)->button_press (tool, coords, time, state, press_type, display); if (! color_tool->enabled) return; if (color_tool->sample_point) { color_tool->moving_sample_point = TRUE; gimp_sample_point_get_position (color_tool->sample_point, &color_tool->sample_point_x, &color_tool->sample_point_y); gimp_tool_control_set_scroll_lock (tool->control, TRUE); gimp_display_shell_selection_pause (shell); if (! gimp_draw_tool_is_active (GIMP_DRAW_TOOL (tool))) gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display); gimp_tool_push_status_coords (tool, display, gimp_tool_control_get_precision (tool->control), _("Move Sample Point: "), color_tool->sample_point_x, ", ", color_tool->sample_point_y, NULL); } else { color_tool->center_x = coords->x; color_tool->center_y = coords->y; gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display); gimp_color_tool_pick (color_tool, GIMP_COLOR_PICK_STATE_START, coords->x, coords->y); } }
static void gimp_color_tool_button_press (GimpTool *tool, GimpCoords *coords, guint32 time, GdkModifierType state, GimpDisplay *display) { GimpColorTool *color_tool = GIMP_COLOR_TOOL (tool); GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell); /* Chain up to activate the tool */ GIMP_TOOL_CLASS (parent_class)->button_press (tool, coords, time, state, display); if (! color_tool->enabled) return; if (color_tool->sample_point) { color_tool->moving_sample_point = TRUE; color_tool->sample_point_x = color_tool->sample_point->x; color_tool->sample_point_y = color_tool->sample_point->y; gimp_display_shell_selection_control (shell, GIMP_SELECTION_PAUSE); gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display); gimp_tool_push_status_coords (tool, display, _("Move Sample Point: "), color_tool->sample_point_x, ", ", color_tool->sample_point_y, NULL); } else { gint off_x, off_y; /* Keep the coordinates of the target */ 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_start (GIMP_DRAW_TOOL (tool), display); gimp_color_tool_pick (color_tool, GIMP_COLOR_PICK_STATE_NEW, coords->x, coords->y); } }
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_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_start (GimpTool *parent_tool, GimpDisplay *display, GimpSamplePoint *sample_point) { GimpSamplePointTool *sp_tool; GimpTool *tool; sp_tool = g_object_new (GIMP_TYPE_SAMPLE_POINT_TOOL, "tool-info", parent_tool->tool_info, NULL); tool = GIMP_TOOL (sp_tool); gimp_display_shell_selection_pause (gimp_display_get_shell (display)); if (sample_point) { sp_tool->sample_point = sample_point; gimp_sample_point_get_position (sample_point, &sp_tool->sample_point_old_x, &sp_tool->sample_point_old_y); sp_tool->sample_point_x = sp_tool->sample_point_old_x; sp_tool->sample_point_y = sp_tool->sample_point_old_y; } else { sp_tool->sample_point = NULL; sp_tool->sample_point_old_x = 0; sp_tool->sample_point_old_y = 0; sp_tool->sample_point_x = GIMP_SAMPLE_POINT_POSITION_UNDEFINED; sp_tool->sample_point_y = GIMP_SAMPLE_POINT_POSITION_UNDEFINED; } gimp_tool_set_cursor (tool, display, GIMP_CURSOR_MOUSE, GIMP_TOOL_CURSOR_COLOR_PICKER, GIMP_CURSOR_MODIFIER_MOVE); tool_manager_push_tool (display->gimp, tool); tool->display = display; gimp_tool_control_activate (tool->control); gimp_draw_tool_start (GIMP_DRAW_TOOL (sp_tool), display); 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); } }
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); } }