[gimp/gimp-2-10] app: add GimpTransformGridTool::apply_info() vfunc



commit 7746da33dee1c4f3d5abb7fa5e33b6fc1b9c955e
Author: Ell <ell_se yahoo com>
Date:   Mon Apr 27 16:44:40 2020 +0300

    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.
    
    (cherry picked from commit aa1a1f0a0c979fbc2d22c1fe6f4f8007b6227c32)

 app/tools/gimptransformgridtool.c | 15 ++++++++++++---
 app/tools/gimptransformgridtool.h |  2 ++
 2 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/app/tools/gimptransformgridtool.c b/app/tools/gimptransformgridtool.c
index cca9ba2390..e446bf5f52 100644
--- a/app/tools/gimptransformgridtool.c
+++ b/app/tools/gimptransformgridtool.c
@@ -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)
 {
@@ -1468,9 +1478,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);
 
diff --git a/app/tools/gimptransformgridtool.h b/app/tools/gimptransformgridtool.h
index cb90671db5..3a8341841b 100644
--- a/app/tools/gimptransformgridtool.h
+++ b/app/tools/gimptransformgridtool.h
@@ -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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]