4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * Contributor(s): Blender Foundation (2008)
22 * ***** END GPL LICENSE BLOCK *****
27 #include "RNA_define.h"
28 #include "RNA_types.h"
30 #include "rna_internal.h"
32 #include "DNA_space_types.h"
36 static StructRNA* rna_Space_refine(struct PointerRNA *ptr)
38 SpaceLink *space= (SpaceLink*)ptr->data;
40 switch(space->spacetype) {
42 return &RNA_SpaceView3D;
44 return &RNA_SpaceIpoEditor;
46 return &RNA_SpaceOutliner;
48 return &RNA_SpaceButtonsWindow;
50 return &RNA_SpaceFileBrowser;*/
52 return &RNA_SpaceImageEditor;
54 return &RNA_SpaceUserPreferences;
56 return &RNA_SpaceSequenceEditor;
58 return &RNA_SpaceTextEditor;
60 // return &RNA_SpaceImageBrowser;
62 return &RNA_SpaceAudioWindow;
64 return &RNA_SpaceActionEditor;
66 return &RNA_SpaceNLAEditor;
68 return &RNA_SpaceScriptsWindow;
70 return &RNA_SpaceTimeline;
72 return &RNA_SpaceNodeEditor;*/
78 static void *rna_SpaceImage_self_get(PointerRNA *ptr)
85 static void rna_def_space(BlenderRNA *brna)
90 static EnumPropertyItem type_items[] = {
91 {SPACE_EMPTY, "EMPTY", "Empty", ""},
92 {SPACE_VIEW3D, "VIEW_3D", "3D View", ""},
93 {SPACE_IPO, "IPO_EDITOR", "Ipo Editor", ""},
94 {SPACE_OOPS, "OUTLINER", "Outliner", ""},
95 {SPACE_BUTS, "BUTTONS_WINDOW", "Buttons Window", ""},
96 {SPACE_FILE, "FILE_BROWSER", "File Browser", ""},
97 {SPACE_IMAGE, "IMAGE_EDITOR", "Image Editor", ""},
98 {SPACE_INFO, "USER_PREFERENCES", "User Preferences", ""},
99 {SPACE_SEQ, "SEQUENCE_EDITOR", "Sequence Editor", ""},
100 {SPACE_TEXT, "TEXT_EDITOR", "Text Editor", ""},
101 //{SPACE_IMASEL, "IMAGE_BROWSER", "Image Browser", ""},
102 {SPACE_SOUND, "AUDIO_WINDOW", "Audio Window", ""},
103 {SPACE_ACTION, "ACTION_EDITOR", "Action Editor", ""},
104 {SPACE_NLA, "NLA_EDITOR", "NLA Editor", ""},
105 {SPACE_SCRIPT, "SCRIPTS_WINDOW", "Scripts Window", ""},
106 {SPACE_TIME, "TIMELINE", "Timeline", ""},
107 {SPACE_NODE, "NODE_EDITOR", "Node Editor", ""},
108 {0, NULL, NULL, NULL}};
110 srna= RNA_def_struct(brna, "Space", NULL);
111 RNA_def_struct_sdna(srna, "SpaceLink");
112 RNA_def_struct_ui_text(srna, "Space", "Space data for a screen area.");
113 RNA_def_struct_refine_func(srna, "rna_Space_refine");
115 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
116 RNA_def_property_enum_sdna(prop, NULL, "spacetype");
117 RNA_def_property_enum_items(prop, type_items);
118 RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
119 RNA_def_property_ui_text(prop, "Type", "Space data type.");
122 static void rna_def_space_image_uv(BlenderRNA *brna)
128 static EnumPropertyItem select_mode_items[] = {
129 {SI_SELECT_VERTEX, "VERTEX", "Vertex", "Vertex selection mode."},
130 //{SI_SELECT_EDGE, "Edge", "Edge", "Edge selection mode."},
131 {SI_SELECT_FACE, "FACE", "Face", "Face selection mode."},
132 {SI_SELECT_ISLAND, "ISLAND", "Island", "Island selection mode."},
133 {0, NULL, NULL, NULL}};
136 static EnumPropertyItem sticky_mode_items[] = {
137 {SI_STICKY_DISABLE, "DISABLED", "Disabled", "Sticky vertex selection disabled."},
138 {SI_STICKY_LOC, "SHARED_LOCATION", "SHARED_LOCATION", "Select UVs that are at the same location and share a mesh vertex."},
139 {SI_STICKY_VERTEX, "SHARED_VERTEX", "SHARED_VERTEX", "Select UVs that share mesh vertex, irrespective if they are in the same location."},
140 {0, NULL, NULL, NULL}};
142 static EnumPropertyItem dt_uv_items[] = {
143 {SI_UVDT_OUTLINE, "OUTLINE", "Outline", "Draw white edges with black outline."},
144 {SI_UVDT_DASH, "DASH", "Dash", "Draw dashed black-white edges."},
145 {SI_UVDT_BLACK, "BLACK", "Black", "Draw black edges."},
146 {SI_UVDT_WHITE, "WHITE", "White", "Draw white edges."},
147 {0, NULL, NULL, NULL}};
149 static EnumPropertyItem dt_uvstretch_items[] = {
150 {SI_UVDT_STRETCH_ANGLE, "ANGLE", "Angle", "Angular distortion between UV and 3D angles."},
151 {SI_UVDT_STRETCH_AREA, "AREA", "Area", "Area distortion between UV and 3D faces."},
152 {0, NULL, NULL, NULL}};
154 srna= RNA_def_struct(brna, "SpaceUVEditor", NULL);
155 RNA_def_struct_sdna(srna, "SpaceImage");
156 RNA_def_struct_nested(brna, srna, "SpaceImageEditor");
157 RNA_def_struct_ui_text(srna, "Space UV Editor", "UV editor data for the image editor space.");
160 /*prop= RNA_def_property(srna, "selection_mode", PROP_ENUM, PROP_NONE);
161 RNA_def_property_enum_sdna(prop, NULL, "selectmode");
162 RNA_def_property_enum_items(prop, select_mode_items);
163 RNA_def_property_ui_text(prop, "Selection Mode", "UV selection and display mode.");*/
165 prop= RNA_def_property(srna, "sticky_selection_mode", PROP_ENUM, PROP_NONE);
166 RNA_def_property_enum_sdna(prop, NULL, "sticky");
167 RNA_def_property_enum_items(prop, sticky_mode_items);
168 RNA_def_property_ui_text(prop, "Sticky Selection Mode", "Automatically select also UVs sharing the same vertex as the ones being selected.");
171 prop= RNA_def_property(srna, "edge_draw_type", PROP_ENUM, PROP_NONE);
172 RNA_def_property_enum_sdna(prop, NULL, "dt_uv");
173 RNA_def_property_enum_items(prop, dt_uv_items);
174 RNA_def_property_ui_text(prop, "Edge Draw Type", "Draw type for drawing UV edges.");
176 prop= RNA_def_property(srna, "draw_smooth_edges", PROP_BOOLEAN, PROP_NONE);
177 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_SMOOTH_UV);
178 RNA_def_property_ui_text(prop, "Draw Smooth Edges", "Draw UV edges anti-aliased.");
180 prop= RNA_def_property(srna, "draw_stretch", PROP_BOOLEAN, PROP_NONE);
181 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_STRETCH);
182 RNA_def_property_ui_text(prop, "Draw Stretch", "Draw faces colored according to the difference in shape between UVs and their 3D coordinates (blue for low distortion, red for high distortion).");
184 prop= RNA_def_property(srna, "draw_stretch_type", PROP_ENUM, PROP_NONE);
185 RNA_def_property_enum_sdna(prop, NULL, "dt_uvstretch");
186 RNA_def_property_enum_items(prop, dt_uvstretch_items);
187 RNA_def_property_ui_text(prop, "Draw Stretch Type", "Type of stretch to draw.");
189 prop= RNA_def_property(srna, "draw_modified_edges", PROP_ENUM, PROP_NONE);
190 RNA_def_property_enum_sdna(prop, NULL, "dt_uvstretch");
191 RNA_def_property_enum_items(prop, dt_uvstretch_items);
192 RNA_def_property_ui_text(prop, "Draw Modified Edges", "Draw edges from the final mesh after object modifier evaluation.");
194 /*prop= RNA_def_property(srna, "local_view", PROP_BOOLEAN, PROP_NONE);
195 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_LOCAL_UV);
196 RNA_def_property_ui_text(prop, "Local View", "Draw only faces with the currently displayed image assigned.");*/
198 prop= RNA_def_property(srna, "display_normalized_coordinates", PROP_BOOLEAN, PROP_NONE);
199 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_COORDFLOATS);
200 RNA_def_property_ui_text(prop, "Display Normalized Coordinates", "Display UV coordinates from 0.0 to 1.0 rather than in pixels.");
202 /* todo: move edge and face drawing options here from G.f */
205 /*prop= RNA_def_property(srna, "sync_selection", PROP_BOOLEAN, PROP_NONE);
206 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_SYNC_UVSEL);
207 RNA_def_property_ui_text(prop, "Sync Selection", "Keep UV and edit mode mesh selection in sync.");*/
209 prop= RNA_def_property(srna, "snap_to_pixels", PROP_BOOLEAN, PROP_NONE);
210 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_PIXELSNAP);
211 RNA_def_property_ui_text(prop, "Snap to Pixels", "Snap UVs to pixel locations while editing.");
213 prop= RNA_def_property(srna, "constrain_to_image_bounds", PROP_BOOLEAN, PROP_NONE);
214 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_CLIP_UV);
215 RNA_def_property_ui_text(prop, "Constrain to Image Bounds", "Constraint to stay within the image bounds while editing.");
217 prop= RNA_def_property(srna, "live_unwrap", PROP_BOOLEAN, PROP_NONE);
218 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_LIVE_UNWRAP);
219 RNA_def_property_ui_text(prop, "Live Unwrap", "Continuously unwrap the selected UV island while transforming pinned vertices.");
222 static void rna_def_space_image(BlenderRNA *brna)
227 static EnumPropertyItem draw_channels_items[] = {
228 {0, "COLOR", "Color", "Draw image with RGB colors."},
229 {SI_USE_ALPHA, "COLOR_ALPHA", "Color and Alpha", "Draw image with RGB colors and alpha transparency."},
230 {SI_SHOW_ALPHA, "ALPHA", "Alpha", "Draw alpha transparency channel."},
231 {SI_SHOW_ZBUF, "Z_BUFFER", "Z-Buffer", "Draw Z-buffer associated with image (mapped from camera clip start to end)."},
232 {0, NULL, NULL, NULL}};
234 srna= RNA_def_struct(brna, "SpaceImageEditor", "Space");
235 RNA_def_struct_sdna(srna, "SpaceImage");
236 RNA_def_struct_ui_text(srna, "Space Image Editor", "Image and UV editor space data.");
239 prop= RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
240 RNA_def_property_ui_text(prop, "Image", "Image displayed and edited in this space.");
242 prop= RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NEVER_NULL);
243 RNA_def_property_pointer_sdna(prop, NULL, "iuser");
244 RNA_def_property_ui_text(prop, "Image User", "Parameters defining which layer, pass and frame of the image is displayed.");
246 prop= RNA_def_property(srna, "curves", PROP_POINTER, PROP_NONE);
247 RNA_def_property_pointer_sdna(prop, NULL, "cumap");
248 RNA_def_property_ui_text(prop, "Curves", "Color curve mapping to use for displaying the image.");
250 prop= RNA_def_property(srna, "image_pin", PROP_BOOLEAN, PROP_NONE);
251 RNA_def_property_boolean_sdna(prop, NULL, "pin", 0);
252 RNA_def_property_ui_text(prop, "Image Pin", "Display current image regardless of object selection.");
255 prop= RNA_def_property(srna, "draw_repeated", PROP_BOOLEAN, PROP_NONE);
256 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_TILE);
257 RNA_def_property_ui_text(prop, "Draw Repeated", "Draw the image repeated outside of the main view.");
259 prop= RNA_def_property(srna, "draw_channels", PROP_ENUM, PROP_NONE);
260 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
261 RNA_def_property_enum_items(prop, draw_channels_items);
262 RNA_def_property_ui_text(prop, "Draw Channels", "Channels of the image to draw.");
265 prop= RNA_def_property(srna, "uv_editor", PROP_POINTER, PROP_NEVER_NULL);
266 RNA_def_property_struct_type(prop, "SpaceUVEditor");
267 RNA_def_property_pointer_funcs(prop, "rna_SpaceImage_self_get", NULL, NULL);
268 RNA_def_property_ui_text(prop, "UV Editor", "UV editor settings.");
271 prop= RNA_def_property(srna, "image_painting", PROP_BOOLEAN, PROP_NONE);
272 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAWTOOL);
273 RNA_def_property_flag(prop, PROP_NOT_EDITABLE); // brush check
274 RNA_def_property_ui_text(prop, "Image Painting", "Enable image painting mode.");
277 prop= RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
278 RNA_def_property_pointer_sdna(prop, NULL, "gpd");
279 RNA_def_property_struct_type(prop, "UnknownType");
280 RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this space.");
282 prop= RNA_def_property(srna, "use_grease_pencil", PROP_BOOLEAN, PROP_NONE);
283 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DISPGP);
284 RNA_def_property_ui_text(prop, "Use Grease Pencil", "Display and edit the grease pencil freehand annotations overlay.");
287 prop= RNA_def_property(srna, "update_automatically", PROP_BOOLEAN, PROP_NONE);
288 RNA_def_property_boolean_sdna(prop, NULL, "lock", 0);
289 RNA_def_property_ui_text(prop, "Update Automatically", "Update other affected window spaces automatically to reflect changes during interactive operations such as transform.");
291 rna_def_space_image_uv(brna);
294 void RNA_def_space(BlenderRNA *brna)
297 rna_def_space_image(brna);