~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/text/gimptextlayer-transform.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * GimpTextLayer
25
25
 
26
26
#include "text-types.h"
27
27
 
 
28
#include "core/gimp-transform-utils.h"
28
29
#include "core/gimpimage-undo.h"
29
30
 
30
31
#include "gimptext.h"
32
33
#include "gimptextlayer-transform.h"
33
34
 
34
35
 
 
36
static GimpItemClass * gimp_text_layer_parent_class (void) G_GNUC_CONST;
35
37
 
36
 
static void  gimp_text_layer_get_trafo (GimpTextLayer *layer,
37
 
                                        GimpMatrix2   *trafo);
 
38
static gboolean  gimp_text_layer_get_transformation  (GimpTextLayer *layer,
 
39
                                                      GimpMatrix3   *matrix);
 
40
static gboolean  gimp_text_layer_set_transformation  (GimpTextLayer *layer,
 
41
                                                      GimpMatrix3   *matrix);
38
42
 
39
43
 
40
44
void
44
48
                       gint                    new_offset_x,
45
49
                       gint                    new_offset_y,
46
50
                       GimpInterpolationType   interpolation_type,
47
 
                       GimpProgressFunc        progress_callback,
48
 
                       gpointer                progress_data)
49
 
{
50
 
 
 
51
                       GimpProgress           *progress)
 
52
{
 
53
  /*  TODO  */
 
54
}
 
55
 
 
56
static gboolean
 
57
gimp_text_layer_transform_flip (GimpTextLayer       *layer,
 
58
                                GimpOrientationType  flip_type,
 
59
                                gdouble              axis)
 
60
{
 
61
  GimpMatrix3  matrix;
 
62
 
 
63
  if (! gimp_text_layer_get_transformation (layer, &matrix))
 
64
    return FALSE;
 
65
 
 
66
  gimp_transform_matrix_flip (&matrix, flip_type, axis);
 
67
 
 
68
  return gimp_text_layer_set_transformation (layer, &matrix);
51
69
}
52
70
 
53
71
void
57
75
                      gdouble              axis,
58
76
                      gboolean             clip_result)
59
77
{
60
 
  GimpLayer   *layer = GIMP_LAYER (item);
61
 
  GimpMatrix2  text_trafo;
62
 
  GimpMatrix2  trafo = { { { 1.0, 0.0 }, { 0.0, 1.0 } } };
63
 
 
64
 
  switch (flip_type)
65
 
    {
66
 
    case GIMP_ORIENTATION_HORIZONTAL:
67
 
      trafo.coeff[0][0] = - 1.0;
68
 
      break;
69
 
 
70
 
    case GIMP_ORIENTATION_VERTICAL:
71
 
      trafo.coeff[1][1] = - 1.0;
72
 
      break;
73
 
 
74
 
    case GIMP_ORIENTATION_UNKNOWN:
75
 
      break;
76
 
    }
77
 
 
78
 
  gimp_text_layer_get_trafo (GIMP_TEXT_LAYER (layer), &text_trafo);
79
 
  gimp_matrix2_mult (&trafo, &text_trafo);
80
 
 
81
 
  gimp_text_layer_set (GIMP_TEXT_LAYER (layer), NULL,
82
 
                       "transformation", &text_trafo,
83
 
                       NULL);
84
 
 
85
 
  if (layer->mask)
86
 
    gimp_item_flip (GIMP_ITEM (layer->mask), context,
87
 
                    flip_type, axis, clip_result);
 
78
  GimpTextLayer *layer = GIMP_TEXT_LAYER (item);
 
79
 
 
80
  if (gimp_text_layer_transform_flip (layer, flip_type, axis))
 
81
    {
 
82
      GimpLayerMask *mask = gimp_layer_get_mask (GIMP_LAYER (layer));
 
83
 
 
84
      if (mask)
 
85
        gimp_item_flip (GIMP_ITEM (mask), context,
 
86
                        flip_type, axis, clip_result);
 
87
    }
 
88
  else
 
89
    {
 
90
      gimp_text_layer_parent_class ()->flip (item, context,
 
91
                                             flip_type, axis, clip_result);
 
92
    }
 
93
}
 
94
 
 
95
static gboolean
 
96
gimp_text_layer_transform_rotate (GimpTextLayer    *layer,
 
97
                                  GimpRotationType  rotate_type,
 
98
                                  gdouble           center_x,
 
99
                                  gdouble           center_y)
 
100
{
 
101
  GimpMatrix3  matrix;
 
102
 
 
103
  if (! gimp_text_layer_get_transformation (layer, &matrix))
 
104
    return FALSE;
 
105
 
 
106
  gimp_transform_matrix_rotate (&matrix, rotate_type, center_x, center_y);
 
107
 
 
108
  return gimp_text_layer_set_transformation (layer, &matrix);
88
109
}
89
110
 
90
111
void
95
116
                        gdouble           center_y,
96
117
                        gboolean          clip_result)
97
118
{
98
 
  GimpLayer   *layer = GIMP_LAYER (item);
99
 
  GimpMatrix2  text_trafo;
100
 
  GimpMatrix2  trafo;
101
 
  gdouble      cos   = 1.0;
102
 
  gdouble      sin   = 0.0;
103
 
 
104
 
  switch (rotate_type)
105
 
    {
106
 
    case GIMP_ROTATE_90:
107
 
      cos =   0.0;
108
 
      sin = - 1.0;
109
 
      break;
110
 
    case GIMP_ROTATE_180:
111
 
      cos = - 1.0;
112
 
      sin =   0.0;
113
 
      break;
114
 
    case GIMP_ROTATE_270:
115
 
      cos =   0.0;
116
 
      sin =   1.0;
117
 
      break;
118
 
    }
119
 
 
120
 
  trafo.coeff[0][0] = cos;
121
 
  trafo.coeff[0][1] = -sin;
122
 
  trafo.coeff[1][0] = sin;
123
 
  trafo.coeff[1][1] = cos;
124
 
 
125
 
  gimp_text_layer_get_trafo (GIMP_TEXT_LAYER (layer), &text_trafo);
126
 
  gimp_matrix2_mult (&trafo, &text_trafo);
127
 
 
128
 
  gimp_text_layer_set (GIMP_TEXT_LAYER (layer), NULL,
129
 
                       "transformation", &text_trafo,
130
 
                       NULL);
131
 
 
132
 
  if (layer->mask)
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);
 
120
 
 
121
  if (! gimp_text_layer_transform_rotate (layer,
 
122
                                          rotate_type, center_x, center_y))
 
123
    {
 
124
      GimpLayerMask *mask = gimp_layer_get_mask (GIMP_LAYER (layer));
 
125
 
 
126
      if (mask)
 
127
        gimp_item_rotate (GIMP_ITEM (mask), context,
 
128
                          rotate_type, center_x, center_y, clip_result);
 
129
    }
 
130
  else
 
131
    {
 
132
      gimp_text_layer_parent_class ()->rotate (item, context,
 
133
                                               rotate_type, center_x, center_y,
 
134
                                               clip_result);
 
135
    }
135
136
}
136
137
 
137
138
void
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)
148
 
{
149
 
 
150
 
}
151
 
 
152
 
static void
153
 
gimp_text_layer_get_trafo (GimpTextLayer *layer,
154
 
                           GimpMatrix2   *trafo)
155
 
{
156
 
  *trafo = layer->text->transformation;
 
146
                           GimpTransformResize     clip_result,
 
147
                           GimpProgress           *progress)
 
148
{
 
149
  /*  TODO  */
 
150
}
 
151
 
 
152
static GimpItemClass *
 
153
gimp_text_layer_parent_class (void)
 
154
{
 
155
  static GimpItemClass *parent_class = NULL;
 
156
 
 
157
  if (! parent_class)
 
158
    {
 
159
      gpointer klass = g_type_class_peek (GIMP_TYPE_TEXT_LAYER);
 
160
 
 
161
      parent_class = g_type_class_peek_parent (klass);
 
162
    }
 
163
 
 
164
  return parent_class;
 
165
}
 
166
 
 
167
static gboolean
 
168
gimp_text_layer_get_transformation (GimpTextLayer *layer,
 
169
                                    GimpMatrix3   *matrix)
 
170
{
 
171
  if (! layer->text || layer->modified)
 
172
    return FALSE;
 
173
 
 
174
  gimp_text_get_transformation (layer->text, matrix);
 
175
 
 
176
  return TRUE;
 
177
}
 
178
 
 
179
static gboolean
 
180
gimp_text_layer_set_transformation (GimpTextLayer *layer,
 
181
                                    GimpMatrix3   *matrix)
 
182
{
 
183
  GimpMatrix2  trafo;
 
184
 
 
185
  if (! gimp_matrix3_is_affine (matrix))
 
186
    return FALSE;
 
187
 
 
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];
 
192
 
 
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],
 
197
                       NULL);
 
198
 
 
199
  return TRUE;
157
200
}