tools: Rectangle select. Incorrect center_xy after converting channel selection to rectangle
Was caused by widget tool fixed_center_x and fixed_center_y coordinates set to coordinates of mouse click instead of rectangle center after converting channel selection bbox to rectangle. Now rectangle fixed_center_x and fixed_center_y coordinates are always updated when tool widget x1, x2, y1, or y2 coordinates are updated. Closes #6487
This commit is contained in:
@ -431,6 +431,8 @@ static void gimp_tool_rectangle_adjust_coord (GimpToolRectangle *rect
|
||||
gdouble coord_y_input,
|
||||
gdouble *coord_x_output,
|
||||
gdouble *coord_y_output);
|
||||
static void gimp_tool_rectangle_recalculate_center_xy
|
||||
(GimpToolRectangle *rectangle);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GimpToolRectangle, gimp_tool_rectangle,
|
||||
@ -1058,6 +1060,8 @@ gimp_tool_rectangle_notify (GObject *object,
|
||||
{
|
||||
gimp_tool_rectangle_update_int_rect (rectangle);
|
||||
|
||||
gimp_tool_rectangle_recalculate_center_xy (rectangle);
|
||||
|
||||
gimp_tool_rectangle_update_options (rectangle);
|
||||
}
|
||||
else if (! strcmp (pspec->name, "x") &&
|
||||
@ -1546,8 +1550,7 @@ gimp_tool_rectangle_button_release (GimpToolWidget *widget,
|
||||
}
|
||||
|
||||
/* We must update this. */
|
||||
private->center_x_on_fixed_center = (private->x1 + private->x2) / 2;
|
||||
private->center_y_on_fixed_center = (private->y1 + private->y2) / 2;
|
||||
gimp_tool_rectangle_recalculate_center_xy (rectangle);
|
||||
|
||||
gimp_tool_rectangle_update_options (rectangle);
|
||||
|
||||
@ -1824,8 +1827,7 @@ gimp_tool_rectangle_key_press (GimpToolWidget *widget,
|
||||
|
||||
gimp_tool_rectangle_update_with_coord (rectangle, new_x, new_y);
|
||||
|
||||
private->center_x_on_fixed_center = (private->x1 + private->x2) / 2;
|
||||
private->center_y_on_fixed_center = (private->y1 + private->y2) / 2;
|
||||
gimp_tool_rectangle_recalculate_center_xy (rectangle);
|
||||
|
||||
gimp_tool_rectangle_update_options (rectangle);
|
||||
|
||||
@ -2189,8 +2191,7 @@ gimp_tool_rectangle_synthesize_motion (GimpToolRectangle *rectangle,
|
||||
gimp_tool_rectangle_update_with_coord (rectangle, new_x, new_y);
|
||||
|
||||
/* We must update this. */
|
||||
private->center_x_on_fixed_center = (private->x1 + private->x2) / 2;
|
||||
private->center_y_on_fixed_center = (private->y1 + private->y2) / 2;
|
||||
gimp_tool_rectangle_recalculate_center_xy (rectangle);
|
||||
|
||||
gimp_tool_rectangle_update_options (rectangle);
|
||||
|
||||
@ -3858,6 +3859,15 @@ gimp_tool_rectangle_adjust_coord (GimpToolRectangle *rectangle,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_tool_rectangle_recalculate_center_xy (GimpToolRectangle *rectangle)
|
||||
{
|
||||
GimpToolRectanglePrivate *private = rectangle->private;
|
||||
|
||||
private->center_x_on_fixed_center = (private->x1 + private->x2) / 2;
|
||||
private->center_y_on_fixed_center = (private->y1 + private->y2) / 2;
|
||||
}
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
|
Reference in New Issue
Block a user