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"
38 #include "DNA_scene_types.h"
40 #include "BKE_brush.h"
41 #include "BKE_context.h"
43 static StructRNA* rna_Space_refine(struct PointerRNA *ptr)
45 SpaceLink *space= (SpaceLink*)ptr->data;
47 switch(space->spacetype) {
49 return &RNA_SpaceView3D;
51 return &RNA_SpaceGraphEditor;
53 return &RNA_SpaceOutliner;
55 return &RNA_SpaceButtonsWindow;
57 return &RNA_SpaceFileBrowser;*/
59 return &RNA_SpaceImageEditor;
61 return &RNA_SpaceUserPreferences;
63 return &RNA_SpaceSequenceEditor;*/
65 return &RNA_SpaceTextEditor;
67 // return &RNA_SpaceImageBrowser;
69 return &RNA_SpaceAudioWindow;
71 return &RNA_SpaceDopeSheetEditor;
73 return &RNA_SpaceNLAEditor;
75 return &RNA_SpaceScriptsWindow;
77 return &RNA_SpaceTimeline;
79 return &RNA_SpaceNodeEditor;*/
85 static PointerRNA rna_SpaceImage_uvedit_get(PointerRNA *ptr)
87 return rna_pointer_inherit_refine(ptr, &RNA_SpaceUVEditor, ptr->data);
90 static void rna_SpaceImage_paint_update(bContext *C, PointerRNA *ptr)
92 Scene *scene= CTX_data_scene(C);
95 brush_check_exists(&scene->toolsettings->imapaint.brush);
98 void rna_SpaceTextEditor_word_wrap_set(PointerRNA *ptr, int value)
100 SpaceText *st= (SpaceText*)(ptr->data);
108 static void rna_def_space(BlenderRNA *brna)
113 static EnumPropertyItem type_items[] = {
114 {SPACE_EMPTY, "EMPTY", "Empty", ""},
115 {SPACE_VIEW3D, "VIEW_3D", "3D View", ""},
116 {SPACE_IPO, "GRAPH_EDITOR", "Graph Editor", ""},
117 {SPACE_OOPS, "OUTLINER", "Outliner", ""},
118 {SPACE_BUTS, "BUTTONS_WINDOW", "Buttons Window", ""},
119 {SPACE_FILE, "FILE_BROWSER", "File Browser", ""},
120 {SPACE_IMAGE, "IMAGE_EDITOR", "Image Editor", ""},
121 {SPACE_INFO, "USER_PREFERENCES", "User Preferences", ""},
122 {SPACE_SEQ, "SEQUENCE_EDITOR", "Sequence Editor", ""},
123 {SPACE_TEXT, "TEXT_EDITOR", "Text Editor", ""},
124 //{SPACE_IMASEL, "IMAGE_BROWSER", "Image Browser", ""},
125 {SPACE_SOUND, "AUDIO_WINDOW", "Audio Window", ""},
126 {SPACE_ACTION, "DOPESHEET_EDITOR", "DopeSheet Editor", ""},
127 {SPACE_NLA, "NLA_EDITOR", "NLA Editor", ""},
128 {SPACE_SCRIPT, "SCRIPTS_WINDOW", "Scripts Window", ""},
129 {SPACE_TIME, "TIMELINE", "Timeline", ""},
130 {SPACE_NODE, "NODE_EDITOR", "Node Editor", ""},
131 {0, NULL, NULL, NULL}};
133 srna= RNA_def_struct(brna, "Space", NULL);
134 RNA_def_struct_sdna(srna, "SpaceLink");
135 RNA_def_struct_ui_text(srna, "Space", "Space data for a screen area.");
136 RNA_def_struct_refine_func(srna, "rna_Space_refine");
138 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
139 RNA_def_property_enum_sdna(prop, NULL, "spacetype");
140 RNA_def_property_enum_items(prop, type_items);
141 RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
142 RNA_def_property_ui_text(prop, "Type", "Space data type.");
145 static void rna_def_space_image_uv(BlenderRNA *brna)
151 static EnumPropertyItem select_mode_items[] = {
152 {SI_SELECT_VERTEX, "VERTEX", "Vertex", "Vertex selection mode."},
153 //{SI_SELECT_EDGE, "Edge", "Edge", "Edge selection mode."},
154 {SI_SELECT_FACE, "FACE", "Face", "Face selection mode."},
155 {SI_SELECT_ISLAND, "ISLAND", "Island", "Island selection mode."},
156 {0, NULL, NULL, NULL}};
159 static EnumPropertyItem sticky_mode_items[] = {
160 {SI_STICKY_DISABLE, "DISABLED", "Disabled", "Sticky vertex selection disabled."},
161 {SI_STICKY_LOC, "SHARED_LOCATION", "SHARED_LOCATION", "Select UVs that are at the same location and share a mesh vertex."},
162 {SI_STICKY_VERTEX, "SHARED_VERTEX", "SHARED_VERTEX", "Select UVs that share mesh vertex, irrespective if they are in the same location."},
163 {0, NULL, NULL, NULL}};
165 static EnumPropertyItem dt_uv_items[] = {
166 {SI_UVDT_OUTLINE, "OUTLINE", "Outline", "Draw white edges with black outline."},
167 {SI_UVDT_DASH, "DASH", "Dash", "Draw dashed black-white edges."},
168 {SI_UVDT_BLACK, "BLACK", "Black", "Draw black edges."},
169 {SI_UVDT_WHITE, "WHITE", "White", "Draw white edges."},
170 {0, NULL, NULL, NULL}};
172 static EnumPropertyItem dt_uvstretch_items[] = {
173 {SI_UVDT_STRETCH_ANGLE, "ANGLE", "Angle", "Angular distortion between UV and 3D angles."},
174 {SI_UVDT_STRETCH_AREA, "AREA", "Area", "Area distortion between UV and 3D faces."},
175 {0, NULL, NULL, NULL}};
177 srna= RNA_def_struct(brna, "SpaceUVEditor", NULL);
178 RNA_def_struct_sdna(srna, "SpaceImage");
179 RNA_def_struct_nested(brna, srna, "SpaceImageEditor");
180 RNA_def_struct_ui_text(srna, "Space UV Editor", "UV editor data for the image editor space.");
183 /*prop= RNA_def_property(srna, "selection_mode", PROP_ENUM, PROP_NONE);
184 RNA_def_property_enum_sdna(prop, NULL, "selectmode");
185 RNA_def_property_enum_items(prop, select_mode_items);
186 RNA_def_property_ui_text(prop, "Selection Mode", "UV selection and display mode.");*/
188 prop= RNA_def_property(srna, "sticky_selection_mode", PROP_ENUM, PROP_NONE);
189 RNA_def_property_enum_sdna(prop, NULL, "sticky");
190 RNA_def_property_enum_items(prop, sticky_mode_items);
191 RNA_def_property_ui_text(prop, "Sticky Selection Mode", "Automatically select also UVs sharing the same vertex as the ones being selected.");
194 prop= RNA_def_property(srna, "edge_draw_type", PROP_ENUM, PROP_NONE);
195 RNA_def_property_enum_sdna(prop, NULL, "dt_uv");
196 RNA_def_property_enum_items(prop, dt_uv_items);
197 RNA_def_property_ui_text(prop, "Edge Draw Type", "Draw type for drawing UV edges.");
199 prop= RNA_def_property(srna, "draw_smooth_edges", PROP_BOOLEAN, PROP_NONE);
200 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_SMOOTH_UV);
201 RNA_def_property_ui_text(prop, "Draw Smooth Edges", "Draw UV edges anti-aliased.");
203 prop= RNA_def_property(srna, "draw_stretch", PROP_BOOLEAN, PROP_NONE);
204 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_STRETCH);
205 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).");
207 prop= RNA_def_property(srna, "draw_stretch_type", PROP_ENUM, PROP_NONE);
208 RNA_def_property_enum_sdna(prop, NULL, "dt_uvstretch");
209 RNA_def_property_enum_items(prop, dt_uvstretch_items);
210 RNA_def_property_ui_text(prop, "Draw Stretch Type", "Type of stretch to draw.");
212 prop= RNA_def_property(srna, "draw_modified_edges", PROP_ENUM, PROP_NONE);
213 RNA_def_property_enum_sdna(prop, NULL, "dt_uvstretch");
214 RNA_def_property_enum_items(prop, dt_uvstretch_items);
215 RNA_def_property_ui_text(prop, "Draw Modified Edges", "Draw edges from the final mesh after object modifier evaluation.");
217 /*prop= RNA_def_property(srna, "local_view", PROP_BOOLEAN, PROP_NONE);
218 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_LOCAL_UV);
219 RNA_def_property_ui_text(prop, "Local View", "Draw only faces with the currently displayed image assigned.");*/
221 prop= RNA_def_property(srna, "normalized_coordinates", PROP_BOOLEAN, PROP_NONE);
222 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_COORDFLOATS);
223 RNA_def_property_ui_text(prop, "Normalized Coordinates", "Display UV coordinates from 0.0 to 1.0 rather than in pixels.");
225 /* todo: move edge and face drawing options here from G.f */
228 /*prop= RNA_def_property(srna, "sync_selection", PROP_BOOLEAN, PROP_NONE);
229 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_SYNC_UVSEL);
230 RNA_def_property_ui_text(prop, "Sync Selection", "Keep UV and edit mode mesh selection in sync.");*/
232 prop= RNA_def_property(srna, "snap_to_pixels", PROP_BOOLEAN, PROP_NONE);
233 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_PIXELSNAP);
234 RNA_def_property_ui_text(prop, "Snap to Pixels", "Snap UVs to pixel locations while editing.");
236 prop= RNA_def_property(srna, "constrain_to_image_bounds", PROP_BOOLEAN, PROP_NONE);
237 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_CLIP_UV);
238 RNA_def_property_ui_text(prop, "Constrain to Image Bounds", "Constraint to stay within the image bounds while editing.");
240 prop= RNA_def_property(srna, "live_unwrap", PROP_BOOLEAN, PROP_NONE);
241 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_LIVE_UNWRAP);
242 RNA_def_property_ui_text(prop, "Live Unwrap", "Continuously unwrap the selected UV island while transforming pinned vertices.");
245 static void rna_def_space_image(BlenderRNA *brna)
250 static EnumPropertyItem draw_channels_items[] = {
251 {0, "COLOR", "Color", "Draw image with RGB colors."},
252 {SI_USE_ALPHA, "COLOR_ALPHA", "Color and Alpha", "Draw image with RGB colors and alpha transparency."},
253 {SI_SHOW_ALPHA, "ALPHA", "Alpha", "Draw alpha transparency channel."},
254 {SI_SHOW_ZBUF, "Z_BUFFER", "Z-Buffer", "Draw Z-buffer associated with image (mapped from camera clip start to end)."},
255 {0, NULL, NULL, NULL}};
257 srna= RNA_def_struct(brna, "SpaceImageEditor", "Space");
258 RNA_def_struct_sdna(srna, "SpaceImage");
259 RNA_def_struct_ui_text(srna, "Space Image Editor", "Image and UV editor space data.");
262 prop= RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
263 RNA_def_property_ui_text(prop, "Image", "Image displayed and edited in this space.");
265 prop= RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NEVER_NULL);
266 RNA_def_property_pointer_sdna(prop, NULL, "iuser");
267 RNA_def_property_ui_text(prop, "Image User", "Parameters defining which layer, pass and frame of the image is displayed.");
269 prop= RNA_def_property(srna, "curves", PROP_POINTER, PROP_NONE);
270 RNA_def_property_pointer_sdna(prop, NULL, "cumap");
271 RNA_def_property_ui_text(prop, "Curves", "Color curve mapping to use for displaying the image.");
273 prop= RNA_def_property(srna, "image_pin", PROP_BOOLEAN, PROP_NONE);
274 RNA_def_property_boolean_sdna(prop, NULL, "pin", 0);
275 RNA_def_property_ui_text(prop, "Image Pin", "Display current image regardless of object selection.");
278 prop= RNA_def_property(srna, "draw_repeated", PROP_BOOLEAN, PROP_NONE);
279 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_TILE);
280 RNA_def_property_ui_text(prop, "Draw Repeated", "Draw the image repeated outside of the main view.");
282 prop= RNA_def_property(srna, "draw_channels", PROP_ENUM, PROP_NONE);
283 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
284 RNA_def_property_enum_items(prop, draw_channels_items);
285 RNA_def_property_ui_text(prop, "Draw Channels", "Channels of the image to draw.");
288 prop= RNA_def_property(srna, "uv_editor", PROP_POINTER, PROP_NEVER_NULL);
289 RNA_def_property_struct_type(prop, "SpaceUVEditor");
290 RNA_def_property_pointer_funcs(prop, "rna_SpaceImage_uvedit_get", NULL);
291 RNA_def_property_ui_text(prop, "UV Editor", "UV editor settings.");
294 prop= RNA_def_property(srna, "image_painting", PROP_BOOLEAN, PROP_NONE);
295 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAWTOOL);
296 RNA_def_property_ui_text(prop, "Image Painting", "Enable image painting mode.");
297 RNA_def_property_update(prop, 0, "rna_SpaceImage_paint_update");
300 prop= RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
301 RNA_def_property_pointer_sdna(prop, NULL, "gpd");
302 RNA_def_property_struct_type(prop, "UnknownType");
303 RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this space.");
305 prop= RNA_def_property(srna, "use_grease_pencil", PROP_BOOLEAN, PROP_NONE);
306 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DISPGP);
307 RNA_def_property_ui_text(prop, "Use Grease Pencil", "Display and edit the grease pencil freehand annotations overlay.");
310 prop= RNA_def_property(srna, "update_automatically", PROP_BOOLEAN, PROP_NONE);
311 RNA_def_property_boolean_sdna(prop, NULL, "lock", 0);
312 RNA_def_property_ui_text(prop, "Update Automatically", "Update other affected window spaces automatically to reflect changes during interactive operations such as transform.");
314 rna_def_space_image_uv(brna);
317 static void rna_def_space_text(BlenderRNA *brna)
322 static EnumPropertyItem font_size_items[] = {
323 {12, "SCREEN_12", "Screen 12", ""},
324 {15, "SCREEN_15", "Screen 15", ""},
325 {0, NULL, NULL, NULL}};
327 srna= RNA_def_struct(brna, "SpaceTextEditor", "Space");
328 RNA_def_struct_sdna(srna, "SpaceText");
329 RNA_def_struct_ui_text(srna, "Space Text Editor", "Text editor space data.");
332 prop= RNA_def_property(srna, "text", PROP_POINTER, PROP_NONE);
333 RNA_def_property_ui_text(prop, "Text", "Text displayed and edited in this space.");
336 prop= RNA_def_property(srna, "syntax_highlight", PROP_BOOLEAN, PROP_NONE);
337 RNA_def_property_boolean_sdna(prop, NULL, "showsyntax", 0);
338 RNA_def_property_ui_text(prop, "Syntax Highlight", "Syntax highlight for scripting.");
339 RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL);
341 prop= RNA_def_property(srna, "word_wrap", PROP_BOOLEAN, PROP_NONE);
342 RNA_def_property_boolean_sdna(prop, NULL, "wordwrap", 0);
343 RNA_def_property_boolean_funcs(prop, NULL, "rna_SpaceTextEditor_word_wrap_set");
344 RNA_def_property_ui_text(prop, "Word Wrap", "Wrap words if there is not enough horizontal space.");
345 RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL);
347 prop= RNA_def_property(srna, "line_numbers", PROP_BOOLEAN, PROP_NONE);
348 RNA_def_property_boolean_sdna(prop, NULL, "showlinenrs", 0);
349 RNA_def_property_ui_text(prop, "Line Numbers", "Show line numbers next to the text.");
350 RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL);
352 prop= RNA_def_property(srna, "overwrite", PROP_BOOLEAN, PROP_NONE);
353 RNA_def_property_ui_text(prop, "Overwrite", "Overwrite characters when typing rather than inserting them.");
354 RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL);
356 prop= RNA_def_property(srna, "tab_width", PROP_INT, PROP_NONE);
357 RNA_def_property_int_sdna(prop, NULL, "tabnumber");
358 RNA_def_property_range(prop, 2, 8);
359 RNA_def_property_ui_text(prop, "Tab Width", "Number of spaces to display tabs with.");
360 RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL);
362 prop= RNA_def_property(srna, "font_size", PROP_ENUM, PROP_NONE);
363 RNA_def_property_enum_sdna(prop, NULL, "lheight");
364 RNA_def_property_enum_items(prop, font_size_items);
365 RNA_def_property_ui_text(prop, "Font Size", "Font size to use for displaying the text.");
366 RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL);
369 prop= RNA_def_property(srna, "find_all", PROP_BOOLEAN, PROP_NONE);
370 RNA_def_property_boolean_sdna(prop, NULL, "flags", ST_FIND_ALL);
371 RNA_def_property_ui_text(prop, "Find All", "Search in all text datablocks, instead of only the active one.");
373 prop= RNA_def_property(srna, "find_wrap", PROP_BOOLEAN, PROP_NONE);
374 RNA_def_property_boolean_sdna(prop, NULL, "flags", ST_FIND_WRAP);
375 RNA_def_property_ui_text(prop, "Find Wrap", "Search again from the start of the file when reaching the end.");
377 prop= RNA_def_property(srna, "find_text", PROP_STRING, PROP_NONE);
378 RNA_def_property_string_sdna(prop, NULL, "findstr");
379 RNA_def_property_ui_text(prop, "Find Text", "Text to search for with the find tool.");
381 prop= RNA_def_property(srna, "replace_text", PROP_STRING, PROP_NONE);
382 RNA_def_property_string_sdna(prop, NULL, "replacestr");
383 RNA_def_property_ui_text(prop, "Replace Text", "Text to replace selected text with using the replace tool.");
386 void RNA_def_space(BlenderRNA *brna)
389 rna_def_space_image(brna);
390 rna_def_space_text(brna);