doxygen: add newline after \file
[blender.git] / source / blender / editors / include / ED_gizmo_library.h
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16
17 /** \file
18  * \ingroup wm
19  *
20  * \name Generic Gizmos.
21  *
22  * This is exposes pre-defined gizmos for re-use.
23  */
24
25
26 #ifndef __ED_GIZMO_LIBRARY_H__
27 #define __ED_GIZMO_LIBRARY_H__
28
29 /* initialize gizmos */
30 void ED_gizmotypes_arrow_2d(void);
31 void ED_gizmotypes_arrow_3d(void);
32 void ED_gizmotypes_button_2d(void);
33 void ED_gizmotypes_cage_2d(void);
34 void ED_gizmotypes_cage_3d(void);
35 void ED_gizmotypes_dial_3d(void);
36 void ED_gizmotypes_move_3d(void);
37 void ED_gizmotypes_facemap_3d(void);
38 void ED_gizmotypes_preselect_3d(void);
39 void ED_gizmotypes_primitive_3d(void);
40 void ED_gizmotypes_blank_3d(void);
41 void ED_gizmotypes_value_2d(void);
42
43 /* gizmo group types */
44 void ED_gizmogrouptypes_value_2d(void);
45
46 struct Object;
47 struct Scene;
48 struct bContext;
49 struct wmGizmo;
50 struct wmGizmoGroup;
51
52
53 /* -------------------------------------------------------------------- */
54 /* Shape Presets
55  *
56  * Intended to be called by custom draw functions.
57  */
58
59 /* gizmo_library_presets.c */
60 void ED_gizmo_draw_preset_box(
61         const struct wmGizmo *gz, float mat[4][4], int select_id);
62 void ED_gizmo_draw_preset_arrow(
63         const struct wmGizmo *gz, float mat[4][4], int axis, int select_id);
64 void ED_gizmo_draw_preset_circle(
65         const struct wmGizmo *gz, float mat[4][4], int axis, int select_id);
66 void ED_gizmo_draw_preset_facemap(
67         const struct bContext *C, const struct wmGizmo *gz,
68         struct Object *ob,  const int facemap, int select_id);
69
70
71 /* -------------------------------------------------------------------- */
72 /* 3D Arrow Gizmo */
73
74 enum {
75         ED_GIZMO_ARROW_STYLE_NORMAL        = 0,
76         ED_GIZMO_ARROW_STYLE_CROSS         = 1,
77         ED_GIZMO_ARROW_STYLE_BOX           = 2,
78         ED_GIZMO_ARROW_STYLE_CONE          = 3,
79 };
80
81 /* transform */
82 enum {
83         /* inverted offset during interaction - if set it also sets constrained below */
84         ED_GIZMO_ARROW_XFORM_FLAG_INVERTED      = (1 << 3),
85         /* clamp arrow interaction to property width */
86         ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED   = (1 << 4),
87 };
88
89 /* draw_options */
90 enum {
91         /* Show arrow stem. */
92         ED_GIZMO_ARROW_DRAW_FLAG_STEM      = (1 << 0),
93 };
94
95 void ED_gizmo_arrow3d_set_ui_range(struct wmGizmo *gz, const float min, const float max);
96 void ED_gizmo_arrow3d_set_range_fac(struct wmGizmo *gz, const float range_fac);
97
98 /* -------------------------------------------------------------------- */
99 /* 2D Arrow Gizmo */
100
101 /* none */
102
103 /* -------------------------------------------------------------------- */
104 /* Cage Gizmo */
105
106 enum {
107         ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE        = (1 << 0), /* Translates */
108         ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE           = (1 << 1), /* Rotates */
109         ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE            = (1 << 2), /* Scales */
110         ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM    = (1 << 3), /* Scales uniformly */
111         ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_SIGNED     = (1 << 4), /* Negative scale allowed */
112 };
113
114 /* draw_style */
115 enum {
116         ED_GIZMO_CAGE2D_STYLE_BOX = 0,
117         ED_GIZMO_CAGE2D_STYLE_CIRCLE = 1,
118 };
119
120 /* draw_options */
121 enum {
122         /** Draw a central handle (instead of having the entire area selectable)
123          * Needed for large rectangles that we don't want to swallow all events. */
124         ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE = (1 << 0),
125 };
126
127 /** #wmGizmo.highlight_part */
128 enum {
129         ED_GIZMO_CAGE2D_PART_TRANSLATE     = 0,
130         ED_GIZMO_CAGE2D_PART_SCALE_MIN_X   = 1,
131         ED_GIZMO_CAGE2D_PART_SCALE_MAX_X   = 2,
132         ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y   = 3,
133         ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y   = 4,
134         /* Corners */
135         ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y = 5,
136         ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y = 6,
137         ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y = 7,
138         ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y = 8,
139
140         ED_GIZMO_CAGE2D_PART_ROTATE = 9,
141 };
142
143 /** #wmGizmo.highlight_part */
144 enum {
145         /* ordered min/mid/max so we can loop over values (MIN/MID/MAX) on each axis. */
146         ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z = 0,
147         ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MID_Z,
148         ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MAX_Z,
149         ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MID_Y_MIN_Z,
150         ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MID_Y_MID_Z,
151         ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MID_Y_MAX_Z,
152         ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MIN_Z,
153         ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MID_Z,
154         ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MAX_Y_MAX_Z,
155         ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MIN_Y_MIN_Z,
156         ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MIN_Y_MID_Z,
157         ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MIN_Y_MAX_Z,
158         ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MID_Y_MIN_Z,
159         ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MID_Y_MID_Z,
160         ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MID_Y_MAX_Z,
161         ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MAX_Y_MIN_Z,
162         ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MAX_Y_MID_Z,
163         ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MAX_Y_MAX_Z,
164         ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MIN_Z,
165         ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MID_Z,
166         ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MIN_Y_MAX_Z,
167         ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MID_Y_MIN_Z,
168         ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MID_Y_MID_Z,
169         ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MID_Y_MAX_Z,
170         ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MIN_Z,
171         ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MID_Z,
172         ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z,
173
174         ED_GIZMO_CAGE3D_PART_TRANSLATE,
175
176         ED_GIZMO_CAGE3D_PART_ROTATE,
177 };
178
179 /* -------------------------------------------------------------------- */
180 /* Dial Gizmo */
181
182 /* draw_options */
183 enum {
184         ED_GIZMO_DIAL_DRAW_FLAG_NOP               = 0,
185         ED_GIZMO_DIAL_DRAW_FLAG_CLIP              = (1 << 0),
186         ED_GIZMO_DIAL_DRAW_FLAG_FILL              = (1 << 1),
187         ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR      = (1 << 2),
188         ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y     = (1 << 3),
189         /* Always show the angle value as an arc in the dial. */
190         ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE       = (1 << 4),
191 };
192
193 /* -------------------------------------------------------------------- */
194 /* Move Gizmo */
195
196 /* draw_options */
197 enum {
198         ED_GIZMO_MOVE_DRAW_FLAG_NOP               = 0,
199         /* only for solid shapes */
200         ED_GIZMO_MOVE_DRAW_FLAG_FILL              = (1 << 0),
201         ED_GIZMO_MOVE_DRAW_FLAG_ALIGN_VIEW        = (1 << 1),
202 };
203
204 enum {
205         ED_GIZMO_MOVE_STYLE_RING_2D = 0,
206         ED_GIZMO_MOVE_STYLE_CROSS_2D = 1,
207 };
208
209 /* -------------------------------------------------------------------- */
210 /* Button Gizmo */
211
212 enum {
213         ED_GIZMO_BUTTON_SHOW_OUTLINE = (1 << 0),
214         ED_GIZMO_BUTTON_SHOW_BACKDROP = (1 << 1),
215         /**
216          * Draw a line from the origin to the offset (similar to an arrow)
217          * sometimes needed to show what the button edits.
218          */
219         ED_GIZMO_BUTTON_SHOW_HELPLINE = (1 << 2),
220 };
221
222
223 /* -------------------------------------------------------------------- */
224 /* Primitive Gizmo */
225
226 enum {
227         ED_GIZMO_PRIMITIVE_STYLE_PLANE = 0,
228 };
229
230
231 /* -------------------------------------------------------------------- */
232 /* Gizmo Drawing Functions */
233
234 struct Dial3dParams {
235         int draw_options;
236         float angle_ofs;
237         float angle_delta;
238         float angle_increment;
239         float arc_partial_angle;
240         float arc_inner_factor;
241         float *clip_plane;
242 };
243 void ED_gizmotypes_dial_3d_draw_util(
244         const float matrix_basis[4][4],
245         const float matrix_final[4][4],
246         const float line_width,
247         const float color[4],
248         struct Dial3dParams *params);
249
250 #endif  /* __ED_GIZMO_LIBRARY_H__ */