From 713e4071b2e92b14d330342e76aab97f9c20424c Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sat, 1 Oct 2016 22:45:51 +0200 Subject: [PATCH] Bug 770911 - Move tool should display relative coordinates in statusbar... ...when moving guides Show relative coordinates when moving guides and sample points, the cursor display in the statusbar already shows absolute coordinates. --- app/tools/gimpguidetool.c | 40 ++++++++++++++++----- app/tools/gimpguidetool.h | 4 +-- app/tools/gimpsamplepointtool.c | 62 ++++++++++++++++++++++++--------- app/tools/gimpsamplepointtool.h | 2 ++ 4 files changed, 79 insertions(+), 29 deletions(-) diff --git a/app/tools/gimpguidetool.c b/app/tools/gimpguidetool.c index a293e6cdfc..215558a070 100644 --- a/app/tools/gimpguidetool.c +++ b/app/tools/gimpguidetool.c @@ -123,6 +123,7 @@ gimp_guide_tool_button_release (GimpTool *tool, if (release_type == GIMP_BUTTON_RELEASE_CANCEL) { + /* custom guides are moved live */ if (guide_tool->guide_custom) gimp_image_move_guide (image, guide_tool->guide, guide_tool->guide_old_position, TRUE); @@ -272,11 +273,19 @@ gimp_guide_tool_motion (GimpTool *tool, 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, - guide_tool->guide ? - _("Move Guide: ") : _("Add Guide: "), + _("Add Guide: "), SWAP_ORIENT (guide_tool->guide_orientation), guide_tool->guide_position, NULL); @@ -290,6 +299,7 @@ gimp_guide_tool_draw (GimpDrawTool *draw_tool) if (guide_tool->guide_position != GIMP_GUIDE_POSITION_UNDEFINED) { + /* custom guides are moved live */ if (! guide_tool->guide_custom) gimp_draw_tool_add_guide (draw_tool, guide_tool->guide_orientation, @@ -318,18 +328,18 @@ gimp_guide_tool_start (GimpTool *parent_tool, if (guide) { guide_tool->guide = guide; + guide_tool->guide_old_position = gimp_guide_get_position (guide); guide_tool->guide_position = gimp_guide_get_position (guide); guide_tool->guide_orientation = gimp_guide_get_orientation (guide); guide_tool->guide_custom = gimp_guide_is_custom (guide); - guide_tool->guide_old_position = gimp_guide_get_position (guide); } else { guide_tool->guide = NULL; + guide_tool->guide_old_position = 0; guide_tool->guide_position = GIMP_GUIDE_POSITION_UNDEFINED; guide_tool->guide_orientation = orientation; guide_tool->guide_custom = FALSE; - guide_tool->guide_old_position = GIMP_GUIDE_POSITION_UNDEFINED; } gimp_tool_set_cursor (tool, display, @@ -344,11 +354,23 @@ gimp_guide_tool_start (GimpTool *parent_tool, gimp_draw_tool_start (GIMP_DRAW_TOOL (guide_tool), display); - gimp_tool_push_status_length (tool, display, - _("Add Guide: "), - SWAP_ORIENT (guide_tool->guide_orientation), - guide_tool->guide_position, - NULL); + 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); + } } diff --git a/app/tools/gimpguidetool.h b/app/tools/gimpguidetool.h index d9b2a4f189..ae06e86cea 100644 --- a/app/tools/gimpguidetool.h +++ b/app/tools/gimpguidetool.h @@ -38,12 +38,10 @@ struct _GimpGuideTool GimpDrawTool parent_instance; GimpGuide *guide; + gint guide_old_position; gint guide_position; GimpOrientationType guide_orientation; - - /* for live-moving custom guides */ gboolean guide_custom; - gint guide_old_position; }; struct _GimpGuideToolClass diff --git a/app/tools/gimpsamplepointtool.c b/app/tools/gimpsamplepointtool.c index d400650080..1175c439fd 100644 --- a/app/tools/gimpsamplepointtool.c +++ b/app/tools/gimpsamplepointtool.c @@ -240,16 +240,26 @@ gimp_sample_point_tool_motion (GimpTool *tool, _("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), - sp_tool->sample_point ? - _("Move Sample Point: ") : _("Add Sample Point: "), sp_tool->sample_point_x, ", ", - sp_tool->sample_point_x, + sp_tool->sample_point_y, NULL); } } @@ -289,14 +299,19 @@ gimp_sample_point_tool_start (GimpTool *parent_tool, sp_tool->sample_point = sample_point; gimp_sample_point_get_position (sample_point, - &sp_tool->sample_point_x, - &sp_tool->sample_point_y); + &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_x = GIMP_SAMPLE_POINT_POSITION_UNDEFINED; - sp_tool->sample_point_y = GIMP_SAMPLE_POINT_POSITION_UNDEFINED; + 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, @@ -311,15 +326,28 @@ gimp_sample_point_tool_start (GimpTool *parent_tool, gimp_draw_tool_start (GIMP_DRAW_TOOL (sp_tool), display); - gimp_tool_push_status_coords (tool, display, - gimp_tool_control_get_precision (tool->control), - sample_point ? - _("Move Sample Point: ") : - _("Add Sample Point: "), - sp_tool->sample_point_x, - ", ", - sp_tool->sample_point_y, - NULL); + 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); + } } diff --git a/app/tools/gimpsamplepointtool.h b/app/tools/gimpsamplepointtool.h index 4e3a3d9502..5fb361b636 100644 --- a/app/tools/gimpsamplepointtool.h +++ b/app/tools/gimpsamplepointtool.h @@ -38,6 +38,8 @@ struct _GimpSamplePointTool GimpDrawTool parent_instance; GimpSamplePoint *sample_point; + gint sample_point_old_x; + gint sample_point_old_y; gint sample_point_x; gint sample_point_y; };