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);
106 void rna_SpaceTextEditor_text_set(PointerRNA *ptr, PointerRNA value)
108 SpaceText *st= (SpaceText*)(ptr->data);
110 st->text= value.data;
116 static void rna_def_space(BlenderRNA *brna)
121 static EnumPropertyItem type_items[] = {
122 {SPACE_EMPTY, "EMPTY", "Empty", ""},
123 {SPACE_VIEW3D, "VIEW_3D", "3D View", ""},
124 {SPACE_IPO, "GRAPH_EDITOR", "Graph Editor", ""},
125 {SPACE_OUTLINER, "OUTLINER", "Outliner", ""},
126 {SPACE_BUTS, "BUTTONS_WINDOW", "Buttons Window", ""},
127 {SPACE_FILE, "FILE_BROWSER", "File Browser", ""},
128 {SPACE_IMAGE, "IMAGE_EDITOR", "Image Editor", ""},
129 {SPACE_INFO, "USER_PREFERENCES", "User Preferences", ""},
130 {SPACE_SEQ, "SEQUENCE_EDITOR", "Sequence Editor", ""},
131 {SPACE_TEXT, "TEXT_EDITOR", "Text Editor", ""},
132 //{SPACE_IMASEL, "IMAGE_BROWSER", "Image Browser", ""},
133 {SPACE_SOUND, "AUDIO_WINDOW", "Audio Window", ""},
134 {SPACE_ACTION, "DOPESHEET_EDITOR", "DopeSheet Editor", ""},
135 {SPACE_NLA, "NLA_EDITOR", "NLA Editor", ""},
136 {SPACE_SCRIPT, "SCRIPTS_WINDOW", "Scripts Window", ""},
137 {SPACE_TIME, "TIMELINE", "Timeline", ""},
138 {SPACE_NODE, "NODE_EDITOR", "Node Editor", ""},
139 {0, NULL, NULL, NULL}};
141 srna= RNA_def_struct(brna, "Space", NULL);
142 RNA_def_struct_sdna(srna, "SpaceLink");
143 RNA_def_struct_ui_text(srna, "Space", "Space data for a screen area.");
144 RNA_def_struct_refine_func(srna, "rna_Space_refine");
146 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
147 RNA_def_property_enum_sdna(prop, NULL, "spacetype");
148 RNA_def_property_enum_items(prop, type_items);
149 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
150 RNA_def_property_ui_text(prop, "Type", "Space data type.");
153 static void rna_def_space_image_uv(BlenderRNA *brna)
159 static EnumPropertyItem select_mode_items[] = {
160 {SI_SELECT_VERTEX, "VERTEX", "Vertex", "Vertex selection mode."},
161 //{SI_SELECT_EDGE, "Edge", "Edge", "Edge selection mode."},
162 {SI_SELECT_FACE, "FACE", "Face", "Face selection mode."},
163 {SI_SELECT_ISLAND, "ISLAND", "Island", "Island selection mode."},
164 {0, NULL, NULL, NULL}};
167 static EnumPropertyItem sticky_mode_items[] = {
168 {SI_STICKY_DISABLE, "DISABLED", "Disabled", "Sticky vertex selection disabled."},
169 {SI_STICKY_LOC, "SHARED_LOCATION", "SHARED_LOCATION", "Select UVs that are at the same location and share a mesh vertex."},
170 {SI_STICKY_VERTEX, "SHARED_VERTEX", "SHARED_VERTEX", "Select UVs that share mesh vertex, irrespective if they are in the same location."},
171 {0, NULL, NULL, NULL}};
173 static EnumPropertyItem dt_uv_items[] = {
174 {SI_UVDT_OUTLINE, "OUTLINE", "Outline", "Draw white edges with black outline."},
175 {SI_UVDT_DASH, "DASH", "Dash", "Draw dashed black-white edges."},
176 {SI_UVDT_BLACK, "BLACK", "Black", "Draw black edges."},
177 {SI_UVDT_WHITE, "WHITE", "White", "Draw white edges."},
178 {0, NULL, NULL, NULL}};
180 static EnumPropertyItem dt_uvstretch_items[] = {
181 {SI_UVDT_STRETCH_ANGLE, "ANGLE", "Angle", "Angular distortion between UV and 3D angles."},
182 {SI_UVDT_STRETCH_AREA, "AREA", "Area", "Area distortion between UV and 3D faces."},
183 {0, NULL, NULL, NULL}};
185 srna= RNA_def_struct(brna, "SpaceUVEditor", NULL);
186 RNA_def_struct_sdna(srna, "SpaceImage");
187 RNA_def_struct_nested(brna, srna, "SpaceImageEditor");
188 RNA_def_struct_ui_text(srna, "Space UV Editor", "UV editor data for the image editor space.");
191 /*prop= RNA_def_property(srna, "selection_mode", PROP_ENUM, PROP_NONE);
192 RNA_def_property_enum_sdna(prop, NULL, "selectmode");
193 RNA_def_property_enum_items(prop, select_mode_items);
194 RNA_def_property_ui_text(prop, "Selection Mode", "UV selection and display mode.");*/
196 prop= RNA_def_property(srna, "sticky_selection_mode", PROP_ENUM, PROP_NONE);
197 RNA_def_property_enum_sdna(prop, NULL, "sticky");
198 RNA_def_property_enum_items(prop, sticky_mode_items);
199 RNA_def_property_ui_text(prop, "Sticky Selection Mode", "Automatically select also UVs sharing the same vertex as the ones being selected.");
202 prop= RNA_def_property(srna, "edge_draw_type", PROP_ENUM, PROP_NONE);
203 RNA_def_property_enum_sdna(prop, NULL, "dt_uv");
204 RNA_def_property_enum_items(prop, dt_uv_items);
205 RNA_def_property_ui_text(prop, "Edge Draw Type", "Draw type for drawing UV edges.");
207 prop= RNA_def_property(srna, "draw_smooth_edges", PROP_BOOLEAN, PROP_NONE);
208 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_SMOOTH_UV);
209 RNA_def_property_ui_text(prop, "Draw Smooth Edges", "Draw UV edges anti-aliased.");
211 prop= RNA_def_property(srna, "draw_stretch", PROP_BOOLEAN, PROP_NONE);
212 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_STRETCH);
213 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).");
215 prop= RNA_def_property(srna, "draw_stretch_type", PROP_ENUM, PROP_NONE);
216 RNA_def_property_enum_sdna(prop, NULL, "dt_uvstretch");
217 RNA_def_property_enum_items(prop, dt_uvstretch_items);
218 RNA_def_property_ui_text(prop, "Draw Stretch Type", "Type of stretch to draw.");
220 prop= RNA_def_property(srna, "draw_modified_edges", PROP_ENUM, PROP_NONE);
221 RNA_def_property_enum_sdna(prop, NULL, "dt_uvstretch");
222 RNA_def_property_enum_items(prop, dt_uvstretch_items);
223 RNA_def_property_ui_text(prop, "Draw Modified Edges", "Draw edges from the final mesh after object modifier evaluation.");
225 /*prop= RNA_def_property(srna, "local_view", PROP_BOOLEAN, PROP_NONE);
226 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_LOCAL_UV);
227 RNA_def_property_ui_text(prop, "Local View", "Draw only faces with the currently displayed image assigned.");*/
229 prop= RNA_def_property(srna, "normalized_coordinates", PROP_BOOLEAN, PROP_NONE);
230 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_COORDFLOATS);
231 RNA_def_property_ui_text(prop, "Normalized Coordinates", "Display UV coordinates from 0.0 to 1.0 rather than in pixels.");
233 /* todo: move edge and face drawing options here from G.f */
236 /*prop= RNA_def_property(srna, "sync_selection", PROP_BOOLEAN, PROP_NONE);
237 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_SYNC_UVSEL);
238 RNA_def_property_ui_text(prop, "Sync Selection", "Keep UV and edit mode mesh selection in sync.");*/
240 prop= RNA_def_property(srna, "snap_to_pixels", PROP_BOOLEAN, PROP_NONE);
241 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_PIXELSNAP);
242 RNA_def_property_ui_text(prop, "Snap to Pixels", "Snap UVs to pixel locations while editing.");
244 prop= RNA_def_property(srna, "constrain_to_image_bounds", PROP_BOOLEAN, PROP_NONE);
245 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_CLIP_UV);
246 RNA_def_property_ui_text(prop, "Constrain to Image Bounds", "Constraint to stay within the image bounds while editing.");
248 prop= RNA_def_property(srna, "live_unwrap", PROP_BOOLEAN, PROP_NONE);
249 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_LIVE_UNWRAP);
250 RNA_def_property_ui_text(prop, "Live Unwrap", "Continuously unwrap the selected UV island while transforming pinned vertices.");
253 static void rna_def_space_image(BlenderRNA *brna)
258 static EnumPropertyItem draw_channels_items[] = {
259 {0, "COLOR", "Color", "Draw image with RGB colors."},
260 {SI_USE_ALPHA, "COLOR_ALPHA", "Color and Alpha", "Draw image with RGB colors and alpha transparency."},
261 {SI_SHOW_ALPHA, "ALPHA", "Alpha", "Draw alpha transparency channel."},
262 {SI_SHOW_ZBUF, "Z_BUFFER", "Z-Buffer", "Draw Z-buffer associated with image (mapped from camera clip start to end)."},
263 {0, NULL, NULL, NULL}};
265 srna= RNA_def_struct(brna, "SpaceImageEditor", "Space");
266 RNA_def_struct_sdna(srna, "SpaceImage");
267 RNA_def_struct_ui_text(srna, "Space Image Editor", "Image and UV editor space data.");
270 prop= RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
271 RNA_def_property_ui_text(prop, "Image", "Image displayed and edited in this space.");
273 prop= RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NEVER_NULL);
274 RNA_def_property_pointer_sdna(prop, NULL, "iuser");
275 RNA_def_property_ui_text(prop, "Image User", "Parameters defining which layer, pass and frame of the image is displayed.");
277 prop= RNA_def_property(srna, "curves", PROP_POINTER, PROP_NONE);
278 RNA_def_property_pointer_sdna(prop, NULL, "cumap");
279 RNA_def_property_ui_text(prop, "Curves", "Color curve mapping to use for displaying the image.");
281 prop= RNA_def_property(srna, "image_pin", PROP_BOOLEAN, PROP_NONE);
282 RNA_def_property_boolean_sdna(prop, NULL, "pin", 0);
283 RNA_def_property_ui_text(prop, "Image Pin", "Display current image regardless of object selection.");
286 prop= RNA_def_property(srna, "draw_repeated", PROP_BOOLEAN, PROP_NONE);
287 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_TILE);
288 RNA_def_property_ui_text(prop, "Draw Repeated", "Draw the image repeated outside of the main view.");
290 prop= RNA_def_property(srna, "draw_channels", PROP_ENUM, PROP_NONE);
291 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
292 RNA_def_property_enum_items(prop, draw_channels_items);
293 RNA_def_property_ui_text(prop, "Draw Channels", "Channels of the image to draw.");
296 prop= RNA_def_property(srna, "uv_editor", PROP_POINTER, PROP_NEVER_NULL);
297 RNA_def_property_struct_type(prop, "SpaceUVEditor");
298 RNA_def_property_pointer_funcs(prop, "rna_SpaceImage_uvedit_get", NULL);
299 RNA_def_property_ui_text(prop, "UV Editor", "UV editor settings.");
302 prop= RNA_def_property(srna, "image_painting", PROP_BOOLEAN, PROP_NONE);
303 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAWTOOL);
304 RNA_def_property_ui_text(prop, "Image Painting", "Enable image painting mode.");
305 RNA_def_property_update(prop, 0, "rna_SpaceImage_paint_update");
308 prop= RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
309 RNA_def_property_pointer_sdna(prop, NULL, "gpd");
310 RNA_def_property_struct_type(prop, "UnknownType");
311 RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this space.");
313 prop= RNA_def_property(srna, "use_grease_pencil", PROP_BOOLEAN, PROP_NONE);
314 RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DISPGP);
315 RNA_def_property_ui_text(prop, "Use Grease Pencil", "Display and edit the grease pencil freehand annotations overlay.");
318 prop= RNA_def_property(srna, "update_automatically", PROP_BOOLEAN, PROP_NONE);
319 RNA_def_property_boolean_sdna(prop, NULL, "lock", 0);
320 RNA_def_property_ui_text(prop, "Update Automatically", "Update other affected window spaces automatically to reflect changes during interactive operations such as transform.");
322 rna_def_space_image_uv(brna);
325 static void rna_def_space_text(BlenderRNA *brna)
330 static EnumPropertyItem font_size_items[] = {
331 {12, "SCREEN_12", "Screen 12", ""},
332 {15, "SCREEN_15", "Screen 15", ""},
333 {0, NULL, NULL, NULL}};
335 srna= RNA_def_struct(brna, "SpaceTextEditor", "Space");
336 RNA_def_struct_sdna(srna, "SpaceText");
337 RNA_def_struct_ui_text(srna, "Space Text Editor", "Text editor space data.");
340 prop= RNA_def_property(srna, "text", PROP_POINTER, PROP_NONE);
341 RNA_def_property_flag(prop, PROP_EDITABLE);
342 RNA_def_property_ui_text(prop, "Text", "Text displayed and edited in this space.");
343 RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceTextEditor_text_set");
344 RNA_def_property_update(prop, NC_TEXT|ND_CURSOR, NULL);
347 prop= RNA_def_property(srna, "syntax_highlight", PROP_BOOLEAN, PROP_NONE);
348 RNA_def_property_boolean_sdna(prop, NULL, "showsyntax", 0);
349 RNA_def_property_ui_text(prop, "Syntax Highlight", "Syntax highlight for scripting.");
350 RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL);
352 prop= RNA_def_property(srna, "word_wrap", PROP_BOOLEAN, PROP_NONE);
353 RNA_def_property_boolean_sdna(prop, NULL, "wordwrap", 0);
354 RNA_def_property_boolean_funcs(prop, NULL, "rna_SpaceTextEditor_word_wrap_set");
355 RNA_def_property_ui_text(prop, "Word Wrap", "Wrap words if there is not enough horizontal space.");
356 RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL);
358 prop= RNA_def_property(srna, "line_numbers", PROP_BOOLEAN, PROP_NONE);
359 RNA_def_property_boolean_sdna(prop, NULL, "showlinenrs", 0);
360 RNA_def_property_ui_text(prop, "Line Numbers", "Show line numbers next to the text.");
361 RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL);
363 prop= RNA_def_property(srna, "overwrite", PROP_BOOLEAN, PROP_NONE);
364 RNA_def_property_ui_text(prop, "Overwrite", "Overwrite characters when typing rather than inserting them.");
365 RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL);
367 prop= RNA_def_property(srna, "tab_width", PROP_INT, PROP_NONE);
368 RNA_def_property_int_sdna(prop, NULL, "tabnumber");
369 RNA_def_property_range(prop, 2, 8);
370 RNA_def_property_ui_text(prop, "Tab Width", "Number of spaces to display tabs with.");
371 RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL);
373 prop= RNA_def_property(srna, "font_size", PROP_ENUM, PROP_NONE);
374 RNA_def_property_enum_sdna(prop, NULL, "lheight");
375 RNA_def_property_enum_items(prop, font_size_items);
376 RNA_def_property_ui_text(prop, "Font Size", "Font size to use for displaying the text.");
377 RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL);
380 prop= RNA_def_property(srna, "find_all", PROP_BOOLEAN, PROP_NONE);
381 RNA_def_property_boolean_sdna(prop, NULL, "flags", ST_FIND_ALL);
382 RNA_def_property_ui_text(prop, "Find All", "Search in all text datablocks, instead of only the active one.");
384 prop= RNA_def_property(srna, "find_wrap", PROP_BOOLEAN, PROP_NONE);
385 RNA_def_property_boolean_sdna(prop, NULL, "flags", ST_FIND_WRAP);
386 RNA_def_property_ui_text(prop, "Find Wrap", "Search again from the start of the file when reaching the end.");
388 prop= RNA_def_property(srna, "find_text", PROP_STRING, PROP_NONE);
389 RNA_def_property_string_sdna(prop, NULL, "findstr");
390 RNA_def_property_ui_text(prop, "Find Text", "Text to search for with the find tool.");
392 prop= RNA_def_property(srna, "replace_text", PROP_STRING, PROP_NONE);
393 RNA_def_property_string_sdna(prop, NULL, "replacestr");
394 RNA_def_property_ui_text(prop, "Replace Text", "Text to replace selected text with using the replace tool.");
397 void RNA_def_space(BlenderRNA *brna)
400 rna_def_space_image(brna);
401 rna_def_space_text(brna);