1 /* GIMP - The GNU Image Manipulation Program
2 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18 #include "config.h"
19
20 #include <gegl.h>
21 #include <gtk/gtk.h>
22
23 #include "libgimpbase/gimpbase.h"
24 #include "libgimpconfig/gimpconfig.h"
25 #include "libgimpwidgets/gimpwidgets.h"
26
27 #include "tools-types.h"
28
29 #include "core/gimp.h"
30 #include "core/gimptoolinfo.h"
31
32 #include "widgets/gimppropwidgets.h"
33 #include "widgets/gimpwidgets-utils.h"
34
35 #include "gimptransform3doptions.h"
36
37 #include "gimp-intl.h"
38
39
40 enum
41 {
42 PROP_0,
43 PROP_MODE,
44 PROP_UNIFIED,
45 PROP_CONSTRAIN_AXIS,
46 PROP_Z_AXIS,
47 PROP_LOCAL_FRAME
48 };
49
50
51 static void gimp_transform_3d_options_set_property (GObject *object,
52 guint property_id,
53 const GValue *value,
54 GParamSpec *pspec);
55 static void gimp_transform_3d_options_get_property (GObject *object,
56 guint property_id,
57 GValue *value,
58 GParamSpec *pspec);
59
60
G_DEFINE_TYPE(GimpTransform3DOptions,gimp_transform_3d_options,GIMP_TYPE_TRANSFORM_GRID_OPTIONS)61 G_DEFINE_TYPE (GimpTransform3DOptions, gimp_transform_3d_options,
62 GIMP_TYPE_TRANSFORM_GRID_OPTIONS)
63
64 #define parent_class gimp_transform_3d_options_parent_class
65
66
67 static void
68 gimp_transform_3d_options_class_init (GimpTransform3DOptionsClass *klass)
69 {
70 GObjectClass *object_class = G_OBJECT_CLASS (klass);
71
72 object_class->set_property = gimp_transform_3d_options_set_property;
73 object_class->get_property = gimp_transform_3d_options_get_property;
74
75 GIMP_CONFIG_PROP_ENUM (object_class, PROP_MODE,
76 "mode",
77 _("Mode"),
78 _("Transform mode"),
79 GIMP_TYPE_TRANSFORM_3D_MODE,
80 GIMP_TRANSFORM_3D_MODE_ROTATE,
81 GIMP_PARAM_STATIC_STRINGS);
82
83 GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_UNIFIED,
84 "unified",
85 _("Unified interaction"),
86 _("Combine all interaction modes"),
87 FALSE,
88 GIMP_PARAM_STATIC_STRINGS);
89
90 GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_CONSTRAIN_AXIS,
91 "constrain-axis",
92 NULL,
93 _("Constrain transformation to a single axis"),
94 FALSE,
95 GIMP_PARAM_STATIC_STRINGS);
96
97 GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_Z_AXIS,
98 "z-axis",
99 NULL,
100 _("Transform along the Z axis"),
101 FALSE,
102 GIMP_PARAM_STATIC_STRINGS);
103
104 GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_LOCAL_FRAME,
105 "local-frame",
106 NULL,
107 _("Transform in the local frame of reference"),
108 FALSE,
109 GIMP_PARAM_STATIC_STRINGS);
110 }
111
112 static void
gimp_transform_3d_options_init(GimpTransform3DOptions * options)113 gimp_transform_3d_options_init (GimpTransform3DOptions *options)
114 {
115 }
116
117 static void
gimp_transform_3d_options_set_property(GObject * object,guint property_id,const GValue * value,GParamSpec * pspec)118 gimp_transform_3d_options_set_property (GObject *object,
119 guint property_id,
120 const GValue *value,
121 GParamSpec *pspec)
122 {
123 GimpTransform3DOptions *options = GIMP_TRANSFORM_3D_OPTIONS (object);
124
125 switch (property_id)
126 {
127 case PROP_MODE:
128 options->mode = g_value_get_enum (value);
129 break;
130 case PROP_UNIFIED:
131 options->unified = g_value_get_boolean (value);
132 break;
133
134 case PROP_CONSTRAIN_AXIS:
135 options->constrain_axis = g_value_get_boolean (value);
136 break;
137 case PROP_Z_AXIS:
138 options->z_axis = g_value_get_boolean (value);
139 break;
140 case PROP_LOCAL_FRAME:
141 options->local_frame = g_value_get_boolean (value);
142 break;
143
144 default:
145 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
146 break;
147 }
148 }
149
150 static void
gimp_transform_3d_options_get_property(GObject * object,guint property_id,GValue * value,GParamSpec * pspec)151 gimp_transform_3d_options_get_property (GObject *object,
152 guint property_id,
153 GValue *value,
154 GParamSpec *pspec)
155 {
156 GimpTransform3DOptions *options = GIMP_TRANSFORM_3D_OPTIONS (object);
157
158 switch (property_id)
159 {
160 case PROP_MODE:
161 g_value_set_enum (value, options->mode);
162 break;
163 case PROP_UNIFIED:
164 g_value_set_boolean (value, options->unified);
165 break;
166
167 case PROP_CONSTRAIN_AXIS:
168 g_value_set_boolean (value, options->constrain_axis);
169 break;
170 case PROP_Z_AXIS:
171 g_value_set_boolean (value, options->z_axis);
172 break;
173 case PROP_LOCAL_FRAME:
174 g_value_set_boolean (value, options->local_frame);
175 break;
176
177 default:
178 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
179 break;
180 }
181 }
182
183 GtkWidget *
gimp_transform_3d_options_gui(GimpToolOptions * tool_options)184 gimp_transform_3d_options_gui (GimpToolOptions *tool_options)
185 {
186 GObject *config = G_OBJECT (tool_options);
187 GtkWidget *vbox = gimp_transform_grid_options_gui (tool_options);
188 GtkWidget *button;
189 gchar *label;
190 GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
191 GdkModifierType constrain_mask = gimp_get_constrain_behavior_mask ();
192
193 button = gimp_prop_check_button_new (config, "unified", NULL);
194 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
195 gtk_widget_show (button);
196
197 label = g_strdup_printf (_("Constrain axis (%s)"),
198 gimp_get_mod_string (extend_mask));
199
200 button = gimp_prop_check_button_new (config, "constrain-axis", label);
201 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
202 gtk_widget_show (button);
203
204 g_free (label);
205
206 label = g_strdup_printf (_("Z axis (%s)"),
207 gimp_get_mod_string (constrain_mask));
208
209 button = gimp_prop_check_button_new (config, "z-axis", label);
210 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
211 gtk_widget_show (button);
212
213 g_free (label);
214
215 label = g_strdup_printf (_("Local frame (%s)"),
216 gimp_get_mod_string (GDK_MOD1_MASK));
217
218 button = gimp_prop_check_button_new (config, "local-frame", label);
219 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
220 gtk_widget_show (button);
221
222 g_free (label);
223
224 return vbox;
225 }
226