app: add GimpTransformGridTool::apply_info() vfunc

... which copies a TransInfo array to the current info array,
possibly with modifications.  While the default implementation
simply copies the array as-is, the following commit will override
the function for the Unified Transform tool, to avoid copying the
pivot position when the pivot is locked.

Use the function in GimpTransformGridTool, instead of copying the
array directly, as necessary.
This commit is contained in:
Ell 2020-04-27 16:44:40 +03:00
parent 9f6af7dbd3
commit aa1a1f0a0c
2 changed files with 14 additions and 3 deletions

View File

@ -170,6 +170,8 @@ static GeglBuffer * gimp_transform_grid_tool_transform (GimpTransformTool
gint *new_offset_x,
gint *new_offset_y);
static void gimp_transform_grid_tool_real_apply_info (GimpTransformGridTool *tg_tool,
const TransInfo info);
static gchar * gimp_transform_grid_tool_real_get_undo_desc (GimpTransformGridTool *tg_tool);
static void gimp_transform_grid_tool_real_update_widget (GimpTransformGridTool *tg_tool);
static void gimp_transform_grid_tool_real_widget_changed (GimpTransformGridTool *tg_tool);
@ -278,6 +280,7 @@ gimp_transform_grid_tool_class_init (GimpTransformGridToolClass *klass)
klass->info_to_matrix = NULL;
klass->matrix_to_info = NULL;
klass->apply_info = gimp_transform_grid_tool_real_apply_info;
klass->get_undo_desc = gimp_transform_grid_tool_real_get_undo_desc;
klass->dialog = NULL;
klass->dialog_update = NULL;
@ -1038,6 +1041,13 @@ gimp_transform_grid_tool_transform (GimpTransformTool *tr_tool,
return new_buffer;
}
static void
gimp_transform_grid_tool_real_apply_info (GimpTransformGridTool *tg_tool,
const TransInfo info)
{
memcpy (tg_tool->trans_info, info, sizeof (TransInfo));
}
static gchar *
gimp_transform_grid_tool_real_get_undo_desc (GimpTransformGridTool *tg_tool)
{
@ -1467,9 +1477,8 @@ gimp_transform_grid_tool_response (GimpToolGui *gui,
if (tr_options->direction == GIMP_TRANSFORM_BACKWARD)
gimp_matrix3_invert (&transform);
memcpy (tg_tool->trans_info, tg_tool->init_trans_info,
sizeof (TransInfo));
GIMP_TRANSFORM_GRID_TOOL_GET_CLASS (tg_tool)->apply_info (
tg_tool, tg_tool->init_trans_info);
GIMP_TRANSFORM_GRID_TOOL_GET_CLASS (tg_tool)->matrix_to_info (
tg_tool, &transform);

View File

@ -81,6 +81,8 @@ struct _GimpTransformGridToolClass
GimpMatrix3 *transform);
void (* matrix_to_info) (GimpTransformGridTool *tg_tool,
const GimpMatrix3 *transform);
void (* apply_info) (GimpTransformGridTool *tg_tool,
const TransInfo info);
gchar * (* get_undo_desc) (GimpTransformGridTool *tg_tool);
void (* dialog) (GimpTransformGridTool *tg_tool);
void (* dialog_update) (GimpTransformGridTool *tg_tool);