32
33
#include "gimptextlayer-transform.h"
36
static GimpItemClass * gimp_text_layer_parent_class (void) G_GNUC_CONST;
36
static void gimp_text_layer_get_trafo (GimpTextLayer *layer,
38
static gboolean gimp_text_layer_get_transformation (GimpTextLayer *layer,
40
static gboolean gimp_text_layer_set_transformation (GimpTextLayer *layer,
46
50
GimpInterpolationType interpolation_type,
47
GimpProgressFunc progress_callback,
48
gpointer progress_data)
51
GimpProgress *progress)
57
gimp_text_layer_transform_flip (GimpTextLayer *layer,
58
GimpOrientationType flip_type,
63
if (! gimp_text_layer_get_transformation (layer, &matrix))
66
gimp_transform_matrix_flip (&matrix, flip_type, axis);
68
return gimp_text_layer_set_transformation (layer, &matrix);
58
76
gboolean clip_result)
60
GimpLayer *layer = GIMP_LAYER (item);
61
GimpMatrix2 text_trafo;
62
GimpMatrix2 trafo = { { { 1.0, 0.0 }, { 0.0, 1.0 } } };
66
case GIMP_ORIENTATION_HORIZONTAL:
67
trafo.coeff[0][0] = - 1.0;
70
case GIMP_ORIENTATION_VERTICAL:
71
trafo.coeff[1][1] = - 1.0;
74
case GIMP_ORIENTATION_UNKNOWN:
78
gimp_text_layer_get_trafo (GIMP_TEXT_LAYER (layer), &text_trafo);
79
gimp_matrix2_mult (&trafo, &text_trafo);
81
gimp_text_layer_set (GIMP_TEXT_LAYER (layer), NULL,
82
"transformation", &text_trafo,
86
gimp_item_flip (GIMP_ITEM (layer->mask), context,
87
flip_type, axis, clip_result);
78
GimpTextLayer *layer = GIMP_TEXT_LAYER (item);
80
if (gimp_text_layer_transform_flip (layer, flip_type, axis))
82
GimpLayerMask *mask = gimp_layer_get_mask (GIMP_LAYER (layer));
85
gimp_item_flip (GIMP_ITEM (mask), context,
86
flip_type, axis, clip_result);
90
gimp_text_layer_parent_class ()->flip (item, context,
91
flip_type, axis, clip_result);
96
gimp_text_layer_transform_rotate (GimpTextLayer *layer,
97
GimpRotationType rotate_type,
103
if (! gimp_text_layer_get_transformation (layer, &matrix))
106
gimp_transform_matrix_rotate (&matrix, rotate_type, center_x, center_y);
108
return gimp_text_layer_set_transformation (layer, &matrix);
96
117
gboolean clip_result)
98
GimpLayer *layer = GIMP_LAYER (item);
99
GimpMatrix2 text_trafo;
110
case GIMP_ROTATE_180:
114
case GIMP_ROTATE_270:
120
trafo.coeff[0][0] = cos;
121
trafo.coeff[0][1] = -sin;
122
trafo.coeff[1][0] = sin;
123
trafo.coeff[1][1] = cos;
125
gimp_text_layer_get_trafo (GIMP_TEXT_LAYER (layer), &text_trafo);
126
gimp_matrix2_mult (&trafo, &text_trafo);
128
gimp_text_layer_set (GIMP_TEXT_LAYER (layer), NULL,
129
"transformation", &text_trafo,
133
gimp_item_rotate (GIMP_ITEM (layer->mask), context,
134
rotate_type, center_x, center_y, clip_result);
119
GimpTextLayer *layer = GIMP_TEXT_LAYER (item);
121
if (! gimp_text_layer_transform_rotate (layer,
122
rotate_type, center_x, center_y))
124
GimpLayerMask *mask = gimp_layer_get_mask (GIMP_LAYER (layer));
127
gimp_item_rotate (GIMP_ITEM (mask), context,
128
rotate_type, center_x, center_y, clip_result);
132
gimp_text_layer_parent_class ()->rotate (item, context,
133
rotate_type, center_x, center_y,
142
143
GimpInterpolationType interpolation_type,
143
144
gboolean supersample,
144
145
gint recursion_level,
145
gboolean clip_result,
146
GimpProgressFunc progress_callback,
147
gpointer progress_data)
153
gimp_text_layer_get_trafo (GimpTextLayer *layer,
156
*trafo = layer->text->transformation;
146
GimpTransformResize clip_result,
147
GimpProgress *progress)
152
static GimpItemClass *
153
gimp_text_layer_parent_class (void)
155
static GimpItemClass *parent_class = NULL;
159
gpointer klass = g_type_class_peek (GIMP_TYPE_TEXT_LAYER);
161
parent_class = g_type_class_peek_parent (klass);
168
gimp_text_layer_get_transformation (GimpTextLayer *layer,
171
if (! layer->text || layer->modified)
174
gimp_text_get_transformation (layer->text, matrix);
180
gimp_text_layer_set_transformation (GimpTextLayer *layer,
185
if (! gimp_matrix3_is_affine (matrix))
188
trafo.coeff[0][0] = matrix->coeff[0][0];
189
trafo.coeff[0][1] = matrix->coeff[0][1];
190
trafo.coeff[1][0] = matrix->coeff[1][0];
191
trafo.coeff[1][1] = matrix->coeff[1][1];
193
gimp_text_layer_set (GIMP_TEXT_LAYER (layer), NULL,
194
"transformation", &trafo,
195
"offset-x", matrix->coeff[0][2],
196
"offset-y", matrix->coeff[1][2],