/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Contributor(s): Blender Foundation (2008) * * ***** END GPL LICENSE BLOCK ***** */ /** \file blender/makesrna/intern/rna_space.c * \ingroup RNA */ #include #include "MEM_guardedalloc.h" #include "RNA_access.h" #include "RNA_define.h" #include "rna_internal.h" #include "BKE_key.h" #include "DNA_action_types.h" #include "DNA_key_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_space_types.h" #include "DNA_view3d_types.h" #include "WM_api.h" #include "WM_types.h" EnumPropertyItem space_type_items[] = { {SPACE_EMPTY, "EMPTY", 0, "Empty", ""}, {SPACE_VIEW3D, "VIEW_3D", 0, "3D View", ""}, {SPACE_IPO, "GRAPH_EDITOR", 0, "Graph Editor", ""}, {SPACE_OUTLINER, "OUTLINER", 0, "Outliner", ""}, {SPACE_BUTS, "PROPERTIES", 0, "Properties", ""}, {SPACE_FILE, "FILE_BROWSER", 0, "File Browser", ""}, {SPACE_IMAGE, "IMAGE_EDITOR", 0, "Image Editor", ""}, {SPACE_INFO, "INFO", 0, "Info", ""}, {SPACE_SEQ, "SEQUENCE_EDITOR", 0, "Sequence Editor", ""}, {SPACE_TEXT, "TEXT_EDITOR", 0, "Text Editor", ""}, //{SPACE_IMASEL, "IMAGE_BROWSER", 0, "Image Browser", ""}, {SPACE_SOUND, "AUDIO_WINDOW", 0, "Audio Window", ""}, {SPACE_ACTION, "DOPESHEET_EDITOR", 0, "DopeSheet Editor", ""}, {SPACE_NLA, "NLA_EDITOR", 0, "NLA Editor", ""}, {SPACE_SCRIPT, "SCRIPTS_WINDOW", 0, "Scripts Window", ""}, {SPACE_TIME, "TIMELINE", 0, "Timeline", ""}, {SPACE_NODE, "NODE_EDITOR", 0, "Node Editor", ""}, {SPACE_LOGIC, "LOGIC_EDITOR", 0, "Logic Editor", ""}, {SPACE_CONSOLE, "CONSOLE", 0, "Python Console", ""}, {SPACE_USERPREF, "USER_PREFERENCES", 0, "User Preferences", ""}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem draw_channels_items[] = { {0, "COLOR", ICON_IMAGE_RGB, "Color", "Draw image with RGB colors"}, {SI_USE_ALPHA, "COLOR_ALPHA", ICON_IMAGE_RGB_ALPHA, "Color and Alpha", "Draw image with RGB colors and alpha transparency"}, {SI_SHOW_ALPHA, "ALPHA", ICON_IMAGE_ALPHA, "Alpha", "Draw alpha transparency channel"}, {SI_SHOW_ZBUF, "Z_BUFFER", ICON_IMAGE_ZDEPTH, "Z-Buffer", "Draw Z-buffer associated with image (mapped from camera clip start to end)"}, #ifdef WITH_LCMS {SI_COLOR_CORRECTION, "COLOR_CORRECTED", ICON_IMAGE_ALPHA, "Color Corrected", "Display color corrected image"}, #endif {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem transform_orientation_items[] = { {V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", "Align the transformation axes to world space"}, {V3D_MANIP_LOCAL, "LOCAL", 0, "Local", "Align the transformation axes to the selected objects' local space"}, {V3D_MANIP_GIMBAL, "GIMBAL", 0, "Gimbal", "Align each axis to the Euler rotation axis as used for input"}, {V3D_MANIP_NORMAL, "NORMAL", 0, "Normal", "Align the transformation axes to average normal of selected elements (bone Y axis for pose mode)"}, {V3D_MANIP_VIEW, "VIEW", 0, "View", "Align the transformation axes to the window"}, {V3D_MANIP_CUSTOM, "CUSTOM", 0, "Custom", "Use a custom transform orientation"}, {0, NULL, 0, NULL, NULL}}; EnumPropertyItem autosnap_items[] = { {SACTSNAP_OFF, "NONE", 0, "No Auto-Snap", ""}, {SACTSNAP_STEP, "STEP", 0, "Time Step", "Snap to 1.0 frame/second intervals"}, {SACTSNAP_FRAME, "FRAME", 0, "Nearest Frame", "Snap to actual frames/seconds (nla-action time)"}, {SACTSNAP_MARKER, "MARKER", 0, "Nearest Marker", "Snap to nearest marker"}, {0, NULL, 0, NULL, NULL}}; EnumPropertyItem viewport_shade_items[] = { {OB_BOUNDBOX, "BOUNDBOX", ICON_BBOX, "Bounding Box", "Display the object's local bounding boxes only"}, {OB_WIRE, "WIREFRAME", ICON_WIRE, "Wireframe", "Display the object as wire edges"}, {OB_SOLID, "SOLID", ICON_SOLID, "Solid", "Display the object solid, lit with default OpenGL lights"}, //{OB_SHADED, "SHADED", ICON_SMOOTH, "Shaded", "Display the object solid, with preview shading interpolated at vertices"}, {OB_TEXTURE, "TEXTURED", ICON_POTATO, "Textured", "Display the object solid, with face-assigned textures"}, {0, NULL, 0, NULL, NULL}}; #ifdef RNA_RUNTIME #include "DNA_anim_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "BLI_math.h" #include "BKE_animsys.h" #include "BKE_brush.h" #include "BKE_colortools.h" #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_paint.h" #include "ED_image.h" #include "ED_screen.h" #include "ED_view3d.h" #include "ED_sequencer.h" #include "IMB_imbuf_types.h" static StructRNA* rna_Space_refine(struct PointerRNA *ptr) { SpaceLink *space= (SpaceLink*)ptr->data; switch(space->spacetype) { case SPACE_VIEW3D: return &RNA_SpaceView3D; case SPACE_IPO: return &RNA_SpaceGraphEditor; case SPACE_OUTLINER: return &RNA_SpaceOutliner; case SPACE_BUTS: return &RNA_SpaceProperties; case SPACE_FILE: return &RNA_SpaceFileBrowser; case SPACE_IMAGE: return &RNA_SpaceImageEditor; case SPACE_INFO: return &RNA_SpaceInfo; case SPACE_SEQ: return &RNA_SpaceSequenceEditor; case SPACE_TEXT: return &RNA_SpaceTextEditor; //case SPACE_IMASEL: // return &RNA_SpaceImageBrowser; /*case SPACE_SOUND: return &RNA_SpaceAudioWindow;*/ case SPACE_ACTION: return &RNA_SpaceDopeSheetEditor; case SPACE_NLA: return &RNA_SpaceNLA; /*case SPACE_SCRIPT: return &RNA_SpaceScriptsWindow;*/ case SPACE_TIME: return &RNA_SpaceTimeline; case SPACE_NODE: return &RNA_SpaceNodeEditor; case SPACE_LOGIC: return &RNA_SpaceLogicEditor; case SPACE_CONSOLE: return &RNA_SpaceConsole; case SPACE_USERPREF: return &RNA_SpaceUserPreferences; default: return &RNA_Space; } } static ScrArea *rna_area_from_space(PointerRNA *ptr) { bScreen *sc = (bScreen*)ptr->id.data; SpaceLink *link= (SpaceLink*)ptr->data; ScrArea *sa; for(sa=sc->areabase.first; sa; sa=sa->next) if(BLI_findindex(&sa->spacedata, link) != -1) return sa; return NULL; } static void rna_area_region_from_regiondata(PointerRNA *ptr, ScrArea **sa_r, ARegion **ar_r) { bScreen *sc = (bScreen*)ptr->id.data; ScrArea *sa; ARegion *ar; void *regiondata= ptr->data; *sa_r= NULL; *ar_r= NULL; for(sa=sc->areabase.first; sa; sa=sa->next) { for(ar=sa->regionbase.first; ar; ar=ar->next) { if(ar->regiondata == regiondata) { *sa_r= sa; *ar_r= ar; return; } } } } static PointerRNA rna_CurrentOrientation_get(PointerRNA *ptr) { Scene *scene = ((bScreen*)ptr->id.data)->scene; View3D *v3d= (View3D*)ptr->data; if (v3d->twmode < V3D_MANIP_CUSTOM) return rna_pointer_inherit_refine(ptr, &RNA_TransformOrientation, NULL); else return rna_pointer_inherit_refine(ptr, &RNA_TransformOrientation, BLI_findlink(&scene->transform_spaces, v3d->twmode - V3D_MANIP_CUSTOM)); } EnumPropertyItem *rna_TransformOrientation_itemf(bContext *C, PointerRNA *ptr, int *free) { Scene *scene = NULL; ListBase *transform_spaces; TransformOrientation *ts= NULL; EnumPropertyItem tmp = {0, "", 0, "", ""}; EnumPropertyItem *item= NULL; int i = V3D_MANIP_CUSTOM, totitem= 0; RNA_enum_items_add_value(&item, &totitem, transform_orientation_items, V3D_MANIP_GLOBAL); RNA_enum_items_add_value(&item, &totitem, transform_orientation_items, V3D_MANIP_NORMAL); RNA_enum_items_add_value(&item, &totitem, transform_orientation_items, V3D_MANIP_GIMBAL); RNA_enum_items_add_value(&item, &totitem, transform_orientation_items, V3D_MANIP_LOCAL); RNA_enum_items_add_value(&item, &totitem, transform_orientation_items, V3D_MANIP_VIEW); if (ptr->type == &RNA_SpaceView3D) scene = ((bScreen*)ptr->id.data)->scene; else scene = CTX_data_scene(C); /* can't use scene from ptr->id.data because that enum is also used by operators */ if(scene) { transform_spaces = &scene->transform_spaces; ts = transform_spaces->first; } if(ts) { RNA_enum_item_add_separator(&item, &totitem); for(; ts; ts = ts->next) { tmp.identifier = ts->name; tmp.name= ts->name; tmp.value = i++; RNA_enum_item_add(&item, &totitem, &tmp); } } RNA_enum_item_end(&item, &totitem); *free= 1; return item; } /* Space 3D View */ static void rna_SpaceView3D_lock_camera_and_layers_set(PointerRNA *ptr, int value) { View3D *v3d= (View3D*)(ptr->data); bScreen *sc= (bScreen*)ptr->id.data; v3d->scenelock = value; if(value) { int bit; v3d->lay= sc->scene->lay; /* seek for layact */ bit= 0; while(bit<32) { if(v3d->lay & (1<layact= 1<camera= sc->scene->camera; } } static void rna_View3D_CursorLocation_get(PointerRNA *ptr, float *values) { View3D *v3d= (View3D*)(ptr->data); bScreen *sc= (bScreen*)ptr->id.data; Scene *scene= (Scene *)sc->scene; float *loc = give_cursor(scene, v3d); copy_v3_v3(values, loc); } static void rna_View3D_CursorLocation_set(PointerRNA *ptr, const float *values) { View3D *v3d= (View3D*)(ptr->data); bScreen *sc= (bScreen*)ptr->id.data; Scene *scene= (Scene *)sc->scene; float *cursor = give_cursor(scene, v3d); copy_v3_v3(cursor, values); } static void rna_SpaceView3D_layer_set(PointerRNA *ptr, const int *values) { View3D *v3d= (View3D*)(ptr->data); v3d->lay= ED_view3d_scene_layer_set(v3d->lay, values, &v3d->layact); } static void rna_SpaceView3D_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) { DAG_on_visible_update(bmain, FALSE); } static PointerRNA rna_SpaceView3D_region_3d_get(PointerRNA *ptr) { View3D *v3d= (View3D*)(ptr->data); ScrArea *sa= rna_area_from_space(ptr); void *regiondata= NULL; if(sa) { ListBase *regionbase= (sa->spacedata.first == v3d)? &sa->regionbase: &v3d->regionbase; ARegion *ar= regionbase->last; /* always last in list, weak .. */ regiondata= ar->regiondata; } return rna_pointer_inherit_refine(ptr, &RNA_RegionView3D, regiondata); } static PointerRNA rna_SpaceView3D_region_quadview_get(PointerRNA *ptr) { View3D *v3d= (View3D*)(ptr->data); ScrArea *sa= rna_area_from_space(ptr); void *regiondata= NULL; if(sa) { ListBase *regionbase= (sa->spacedata.first == v3d)? &sa->regionbase: &v3d->regionbase; ARegion *ar= regionbase->last; /* always before last in list, weak .. */ ar= (ar->alignment == RGN_ALIGN_QSPLIT)? ar->prev: NULL; if(ar) { regiondata= ar->regiondata; } } return rna_pointer_inherit_refine(ptr, &RNA_RegionView3D, regiondata); } static void rna_RegionView3D_quadview_update(Main *main, Scene *scene, PointerRNA *ptr) { ScrArea *sa; ARegion *ar; rna_area_region_from_regiondata(ptr, &sa, &ar); if(sa && ar && ar->alignment==RGN_ALIGN_QSPLIT) ED_view3d_quadview_update(sa, ar, FALSE); } /* same as above but call clip==TRUE */ static void rna_RegionView3D_quadview_clip_update(Main *main, Scene *scene, PointerRNA *ptr) { ScrArea *sa; ARegion *ar; rna_area_region_from_regiondata(ptr, &sa, &ar); if(sa && ar && ar->alignment==RGN_ALIGN_QSPLIT) ED_view3d_quadview_update(sa, ar, TRUE); } static void rna_RegionView3D_view_location_get(PointerRNA *ptr, float *values) { RegionView3D *rv3d= (RegionView3D *)(ptr->data); negate_v3_v3(values, rv3d->ofs); } static void rna_RegionView3D_view_location_set(PointerRNA *ptr, const float *values) { RegionView3D *rv3d= (RegionView3D *)(ptr->data); negate_v3_v3(rv3d->ofs, values); } /* Space Image Editor */ static PointerRNA rna_SpaceImageEditor_uvedit_get(PointerRNA *ptr) { return rna_pointer_inherit_refine(ptr, &RNA_SpaceUVEditor, ptr->data); } static void rna_SpaceImageEditor_paint_update(Main *bmain, Scene *scene, PointerRNA *ptr) { paint_init(&scene->toolsettings->imapaint.paint, PAINT_CURSOR_TEXTURE_PAINT); ED_space_image_paint_update(bmain->wm.first, scene->toolsettings); } static int rna_SpaceImageEditor_show_render_get(PointerRNA *ptr) { SpaceImage *sima= (SpaceImage*)(ptr->data); return ED_space_image_show_render(sima); } static int rna_SpaceImageEditor_show_paint_get(PointerRNA *ptr) { SpaceImage *sima= (SpaceImage*)(ptr->data); return ED_space_image_show_paint(sima); } static int rna_SpaceImageEditor_show_uvedit_get(PointerRNA *ptr) { SpaceImage *sima= (SpaceImage*)(ptr->data); bScreen *sc= (bScreen*)ptr->id.data; return ED_space_image_show_uvedit(sima, sc->scene->obedit); } static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value) { SpaceImage *sima= (SpaceImage*)(ptr->data); bScreen *sc= (bScreen*)ptr->id.data; ED_space_image_set(NULL, sima, sc->scene, sc->scene->obedit, (Image*)value.data); } static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *C, PointerRNA *ptr, int *free) { SpaceImage *sima= (SpaceImage*)ptr->data; EnumPropertyItem *item= NULL; ImBuf *ibuf; void *lock; int zbuf, alpha, totitem= 0; ibuf= ED_space_image_acquire_buffer(sima, &lock); alpha= ibuf && (ibuf->channels == 4); zbuf= ibuf && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels==1)); ED_space_image_release_buffer(sima, lock); if(alpha && zbuf) return draw_channels_items; RNA_enum_items_add_value(&item, &totitem, draw_channels_items, 0); if(alpha) { RNA_enum_items_add_value(&item, &totitem, draw_channels_items, SI_USE_ALPHA); RNA_enum_items_add_value(&item, &totitem, draw_channels_items, SI_SHOW_ALPHA); } else if(zbuf) { RNA_enum_items_add_value(&item, &totitem, draw_channels_items, SI_SHOW_ZBUF); } #ifdef WITH_LCMS RNA_enum_items_add_value(&item, &totitem, draw_channels_items, SI_COLOR_CORRECTION); #endif RNA_enum_item_end(&item, &totitem); *free= 1; return item; } static void rna_SpaceImageEditor_cursor_location_get(PointerRNA *ptr, float *values) { SpaceImage *sima= (SpaceImage*)ptr->data; if (sima->flag & SI_COORDFLOATS) { copy_v2_v2(values, sima->cursor); } else { int w, h; ED_space_image_size(sima, &w, &h); values[0] = sima->cursor[0] * w; values[1] = sima->cursor[1] * h; } } static void rna_SpaceImageEditor_cursor_location_set(PointerRNA *ptr, const float *values) { SpaceImage *sima= (SpaceImage*)ptr->data; if (sima->flag & SI_COORDFLOATS) { copy_v2_v2(sima->cursor, values); } else { int w, h; ED_space_image_size(sima, &w, &h); sima->cursor[0] = values[0] / w; sima->cursor[1] = values[1] / h; } } static void rna_SpaceImageEditor_curves_update(Main *bmain, Scene *scene, PointerRNA *ptr) { SpaceImage *sima= (SpaceImage*)ptr->data; ImBuf *ibuf; void *lock; ibuf= ED_space_image_acquire_buffer(sima, &lock); if(ibuf->rect_float) curvemapping_do_ibuf(sima->cumap, ibuf); ED_space_image_release_buffer(sima, lock); WM_main_add_notifier(NC_IMAGE, sima->image); } static void rna_SpaceImageEditor_scopes_update(Main *bmain, Scene *scene, PointerRNA *ptr) { SpaceImage *sima= (SpaceImage*)ptr->data; ImBuf *ibuf; void *lock; ibuf= ED_space_image_acquire_buffer(sima, &lock); if(ibuf) { scopes_update(&sima->scopes, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT); WM_main_add_notifier(NC_IMAGE, sima->image); } ED_space_image_release_buffer(sima, lock); } /* Space Text Editor */ static void rna_SpaceTextEditor_word_wrap_set(PointerRNA *ptr, int value) { SpaceText *st= (SpaceText*)(ptr->data); st->wordwrap= value; st->left= 0; } static void rna_SpaceTextEditor_text_set(PointerRNA *ptr, PointerRNA value) { SpaceText *st= (SpaceText*)(ptr->data); st->text= value.data; st->top= 0; } /* Space Properties */ /* note: this function exists only to avoid id refcounting */ static void rna_SpaceProperties_pin_id_set(PointerRNA *ptr, PointerRNA value) { SpaceButs *sbuts= (SpaceButs*)(ptr->data); sbuts->pinid= value.data; } static StructRNA *rna_SpaceProperties_pin_id_typef(PointerRNA *ptr) { SpaceButs *sbuts= (SpaceButs*)(ptr->data); if(sbuts->pinid) return ID_code_to_RNA_type(GS(sbuts->pinid->name)); return &RNA_ID; } static void rna_SpaceProperties_pin_id_update(Main *bmain, Scene *scene, PointerRNA *ptr) { SpaceButs *sbuts= (SpaceButs*)(ptr->data); ID *id = sbuts->pinid; if (id == NULL) { sbuts->flag &= ~SB_PIN_CONTEXT; return; } switch (GS(id->name)) { case ID_MA: WM_main_add_notifier(NC_MATERIAL|ND_SHADING, NULL); break; case ID_TE: WM_main_add_notifier(NC_TEXTURE, NULL); break; case ID_WO: WM_main_add_notifier(NC_WORLD, NULL); break; case ID_LA: WM_main_add_notifier(NC_LAMP, NULL); break; } } static void rna_SpaceProperties_context_set(PointerRNA *ptr, int value) { SpaceButs *sbuts= (SpaceButs*)(ptr->data); sbuts->mainb= value; sbuts->mainbuser = value; } static void rna_SpaceProperties_align_set(PointerRNA *ptr, int value) { SpaceButs *sbuts= (SpaceButs*)(ptr->data); sbuts->align= value; sbuts->re_align= 1; } /* Space Console */ static void rna_ConsoleLine_body_get(PointerRNA *ptr, char *value) { ConsoleLine *ci= (ConsoleLine*)ptr->data; strcpy(value, ci->line); } static int rna_ConsoleLine_body_length(PointerRNA *ptr) { ConsoleLine *ci= (ConsoleLine*)ptr->data; return ci->len; } static void rna_ConsoleLine_body_set(PointerRNA *ptr, const char *value) { ConsoleLine *ci= (ConsoleLine*)ptr->data; int len= strlen(value); if((len >= ci->len_alloc) || (len * 2 < ci->len_alloc) ) { /* allocate a new string */ MEM_freeN(ci->line); ci->line= MEM_mallocN((len + 1) * sizeof(char), "rna_consoleline"); ci->len_alloc= len + 1; } memcpy(ci->line, value, len + 1); ci->len= len; if(ci->cursor > len) /* clamp the cursor */ ci->cursor= len; } static void rna_ConsoleLine_cursor_index_range(PointerRNA *ptr, int *min, int *max) { ConsoleLine *ci= (ConsoleLine*)ptr->data; *min= 0; *max= ci->len; } /* Space Dopesheet */ static void rna_SpaceDopeSheetEditor_action_set(PointerRNA *ptr, PointerRNA value) { SpaceAction *saction= (SpaceAction*)(ptr->data); bAction *act = (bAction*)value.data; if ((act == NULL) || (act->idroot == 0)) { /* just set if we're clearing the action or if the action is "amorphous" still */ saction->action= act; } else { /* action to set must strictly meet the mode criteria... */ if (saction->mode == SACTCONT_ACTION) { /* currently, this is "object-level" only, until we have some way of specifying this */ if (act->idroot == ID_OB) saction->action = act; else printf("ERROR: cannot assign Action '%s' to Action Editor, as action is not object-level animation\n", act->id.name+2); } else if (saction->mode == SACTCONT_SHAPEKEY) { /* as the name says, "shapekey-level" only... */ if (act->idroot == ID_KE) saction->action = act; else printf("ERROR: cannot assign Action '%s' to Shape Key Editor, as action doesn't animate Shape Keys\n", act->id.name+2); } else { printf("ACK: who's trying to set an action while not in a mode displaying a single Action only?\n"); } } } static void rna_SpaceDopeSheetEditor_action_update(Main *bmain, Scene *scene, PointerRNA *ptr) { SpaceAction *saction= (SpaceAction*)(ptr->data); Object *obact= (scene->basact)? scene->basact->object: NULL; /* we must set this action to be the one used by active object (if not pinned) */ if (obact/* && saction->pin == 0*/) { AnimData *adt = NULL; if (saction->mode == SACTCONT_ACTION) { // TODO: context selector could help decide this with more control? adt= BKE_id_add_animdata(&obact->id); /* this only adds if non-existant */ } else if (saction->mode == SACTCONT_SHAPEKEY) { Key *key = ob_get_key(obact); if (key) adt= BKE_id_add_animdata(&key->id); /* this only adds if non-existant */ } /* set action */ if (adt) { /* fix id-count of action we're replacing */ id_us_min(&adt->action->id); /* show new id-count of action we're replacing */ adt->action= saction->action; id_us_plus(&adt->action->id); } /* force depsgraph flush too */ DAG_id_tag_update(&obact->id, OB_RECALC_OB|OB_RECALC_DATA); } } static void rna_SpaceDopeSheetEditor_mode_update(Main *bmain, Scene *scene, PointerRNA *ptr) { SpaceAction *saction= (SpaceAction*)(ptr->data); Object *obact= (scene->basact)? scene->basact->object: NULL; /* special exceptions for ShapeKey Editor mode */ if (saction->mode == SACTCONT_SHAPEKEY) { Key *key = ob_get_key(obact); /* 1) update the action stored for the editor */ if (key) saction->action = (key->adt)? key->adt->action : NULL; else saction->action = NULL; /* 2) enable 'show sliders' by default, since one of the main * points of the ShapeKey Editor is to provide a one-stop shop * for controlling the shapekeys, whose main control is the value */ saction->flag |= SACTION_SLIDERS; } /* make sure action stored is valid */ else if (saction->mode == SACTCONT_ACTION) { /* 1) update the action stored for the editor */ // TODO: context selector could help decide this with more control? if (obact) saction->action = (obact->adt)? obact->adt->action : NULL; else saction->action = NULL; } } /* Space Graph Editor */ static void rna_SpaceGraphEditor_display_mode_update(bContext *C, PointerRNA *ptr) { //SpaceIpo *sipo= (SpaceIpo*)(ptr->data); ScrArea *sa= CTX_wm_area(C); /* after changing view mode, must force recalculation of F-Curve colors * which can only be achieved using refresh as opposed to redraw */ ED_area_tag_refresh(sa); } static int rna_SpaceGraphEditor_has_ghost_curves_get(PointerRNA *ptr) { SpaceIpo *sipo= (SpaceIpo*)(ptr->data); return (sipo->ghostCurves.first != NULL); } static void rna_Sequencer_display_mode_update(bContext *C, PointerRNA *ptr) { int view = RNA_enum_get(ptr, "view_type"); ED_sequencer_update_view(C, view); } static float rna_BackgroundImage_opacity_get(PointerRNA *ptr) { BGpic *bgpic= (BGpic *)ptr->data; return 1.0f-bgpic->blend; } static void rna_BackgroundImage_opacity_set(PointerRNA *ptr, float value) { BGpic *bgpic= (BGpic *)ptr->data; bgpic->blend = 1.0f - value; } static EnumPropertyItem *rna_SpaceProperties_texture_context_itemf(bContext *C, PointerRNA *ptr, int *free) { Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); EnumPropertyItem *item= NULL; EnumPropertyItem tmp= {0, "", 0, "", ""}; int totitem= 0; if(ob) { if(ob->type == OB_LAMP) { tmp.value = SB_TEXC_MAT_OR_LAMP; tmp.description = "Show Lamp Textures"; tmp.identifier = "LAMP"; tmp.icon = ICON_LAMP_POINT; RNA_enum_item_add(&item, &totitem, &tmp); } else if(ob->totcol) { tmp.value = SB_TEXC_MAT_OR_LAMP; tmp.description = "Show Material Textures"; tmp.identifier = "MATERIAL"; tmp.icon = ICON_MATERIAL; RNA_enum_item_add(&item, &totitem, &tmp); } if(ob->particlesystem.first) { tmp.value = SB_TEXC_PARTICLES; tmp.description = "Show Particle Textures"; tmp.identifier = "PARTICLE"; tmp.icon = ICON_PARTICLES; RNA_enum_item_add(&item, &totitem, &tmp); } } if(scene && scene->world) { tmp.value = SB_TEXC_WORLD; tmp.description = "Show World Textures"; tmp.identifier = "WORLD"; tmp.icon = ICON_WORLD; RNA_enum_item_add(&item, &totitem, &tmp); } tmp.value = SB_TEXC_BRUSH; tmp.description = "Show Brush Textures"; tmp.identifier = "BRUSH"; tmp.icon = ICON_BRUSH_DATA; RNA_enum_item_add(&item, &totitem, &tmp); RNA_enum_item_end(&item, &totitem); *free = 1; return item; } #else static void rna_def_space(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; srna= RNA_def_struct(brna, "Space", NULL); RNA_def_struct_sdna(srna, "SpaceLink"); RNA_def_struct_ui_text(srna, "Space", "Space data for a screen area"); RNA_def_struct_refine_func(srna, "rna_Space_refine"); prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "spacetype"); RNA_def_property_enum_items(prop, space_type_items); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Type", "Space data type"); } static void rna_def_space_image_uv(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem sticky_mode_items[] = { {SI_STICKY_DISABLE, "DISABLED", ICON_STICKY_UVS_DISABLE, "Disabled", "Sticky vertex selection disabled"}, {SI_STICKY_LOC, "SHARED_LOCATION", ICON_STICKY_UVS_LOC, "Shared Location", "Select UVs that are at the same location and share a mesh vertex"}, {SI_STICKY_VERTEX, "SHARED_VERTEX", ICON_STICKY_UVS_VERT, "Shared Vertex", "Select UVs that share mesh vertex, irrespective if they are in the same location"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem dt_uv_items[] = { {SI_UVDT_OUTLINE, "OUTLINE", 0, "Outline", "Draw white edges with black outline"}, {SI_UVDT_DASH, "DASH", 0, "Dash", "Draw dashed black-white edges"}, {SI_UVDT_BLACK, "BLACK", 0, "Black", "Draw black edges"}, {SI_UVDT_WHITE, "WHITE", 0, "White", "Draw white edges"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem dt_uvstretch_items[] = { {SI_UVDT_STRETCH_ANGLE, "ANGLE", 0, "Angle", "Angular distortion between UV and 3D angles"}, {SI_UVDT_STRETCH_AREA, "AREA", 0, "Area", "Area distortion between UV and 3D faces"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem pivot_items[] = { {V3D_CENTER, "CENTER", ICON_ROTATE, "Bounding Box Center", ""}, {V3D_CENTROID, "MEDIAN", ICON_ROTATECENTER, "Median Point", ""}, {V3D_CURSOR, "CURSOR", ICON_CURSOR, "2D Cursor", ""}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "SpaceUVEditor", NULL); RNA_def_struct_sdna(srna, "SpaceImage"); RNA_def_struct_nested(brna, srna, "SpaceImageEditor"); RNA_def_struct_ui_text(srna, "Space UV Editor", "UV editor data for the image editor space"); /* selection */ prop= RNA_def_property(srna, "sticky_select_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "sticky"); RNA_def_property_enum_items(prop, sticky_mode_items); RNA_def_property_ui_text(prop, "Sticky Selection Mode", "Automatically select also UVs sharing the same vertex as the ones being selected"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); /* drawing */ prop= RNA_def_property(srna, "edge_draw_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "dt_uv"); RNA_def_property_enum_items(prop, dt_uv_items); RNA_def_property_ui_text(prop, "Edge Draw Type", "Draw type for drawing UV edges"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); prop= RNA_def_property(srna, "show_smooth_edges", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_SMOOTH_UV); RNA_def_property_ui_text(prop, "Draw Smooth Edges", "Draw UV edges anti-aliased"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); prop= RNA_def_property(srna, "show_stretch", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_STRETCH); 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)"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); prop= RNA_def_property(srna, "draw_stretch_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "dt_uvstretch"); RNA_def_property_enum_items(prop, dt_uvstretch_items); RNA_def_property_ui_text(prop, "Draw Stretch Type", "Type of stretch to draw"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); prop= RNA_def_property(srna, "show_modified_edges", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAWSHADOW); RNA_def_property_ui_text(prop, "Draw Modified Edges", "Draw edges after modifiers are applied"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); prop= RNA_def_property(srna, "show_other_objects", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_OTHER); RNA_def_property_ui_text(prop, "Draw Other Objects", "Draw other selected objects that share the same image"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); prop= RNA_def_property(srna, "show_normalized_coords", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_COORDFLOATS); RNA_def_property_ui_text(prop, "Normalized Coordinates", "Display UV coordinates from 0.0 to 1.0 rather than in pixels"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); prop= RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_XYZ); RNA_def_property_array(prop, 2); RNA_def_property_float_funcs(prop, "rna_SpaceImageEditor_cursor_location_get", "rna_SpaceImageEditor_cursor_location_set", NULL); RNA_def_property_ui_text(prop, "2D Cursor Location", "2D cursor location for this view"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); /* todo: move edge and face drawing options here from G.f */ prop= RNA_def_property(srna, "use_snap_to_pixels", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_PIXELSNAP); RNA_def_property_ui_text(prop, "Snap to Pixels", "Snap UVs to pixel locations while editing"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); prop= RNA_def_property(srna, "lock_bounds", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_CLIP_UV); RNA_def_property_ui_text(prop, "Constrain to Image Bounds", "Constraint to stay within the image bounds while editing"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); prop= RNA_def_property(srna, "use_live_unwrap", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_LIVE_UNWRAP); RNA_def_property_ui_text(prop, "Live Unwrap", "Continuously unwrap the selected UV island while transforming pinned vertices"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); prop= RNA_def_property(srna, "pivot_point", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "around"); RNA_def_property_enum_items(prop, pivot_items); RNA_def_property_ui_text(prop, "Pivot", "Rotation/Scaling Pivot"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); } static void rna_def_space_outliner(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem display_mode_items[] = { {SO_ALL_SCENES, "ALL_SCENES", 0, "All Scenes", ""}, {SO_CUR_SCENE, "CURRENT_SCENE", 0, "Current Scene", ""}, {SO_VISIBLE, "VISIBLE_LAYERS", 0, "Visible Layers", ""}, {SO_SELECTED, "SELECTED", 0, "Selected", ""}, {SO_ACTIVE, "ACTIVE", 0, "Active", ""}, {SO_SAME_TYPE, "SAME_TYPES", 0, "Same Types", ""}, {SO_GROUPS, "GROUPS", 0, "Groups", ""}, {SO_LIBRARIES, "LIBRARIES", 0, "Libraries", ""}, {SO_SEQUENCE, "SEQUENCE", 0, "Sequence", ""}, {SO_DATABLOCKS, "DATABLOCKS", 0, "Datablocks", ""}, {SO_USERDEF, "USER_PREFERENCES", 0, "User Preferences", ""}, {SO_KEYMAP, "KEYMAPS", 0, "Key Maps", ""}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "SpaceOutliner", "Space"); RNA_def_struct_sdna(srna, "SpaceOops"); RNA_def_struct_ui_text(srna, "Space Outliner", "Outliner space data"); prop= RNA_def_property(srna, "display_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "outlinevis"); RNA_def_property_enum_items(prop, display_mode_items); RNA_def_property_ui_text(prop, "Display Mode", "Type of information to display"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_OUTLINER, NULL); prop= RNA_def_property(srna, "filter_text", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "search_string"); RNA_def_property_ui_text(prop, "Display Filter", "Live search filtering string"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_OUTLINER, NULL); prop= RNA_def_property(srna, "use_filter_case_sensitive", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "search_flags", SO_FIND_CASE_SENSITIVE); RNA_def_property_ui_text(prop, "Case Sensitive Matches Only", "Only use case sensitive matches of search string"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_OUTLINER, NULL); prop= RNA_def_property(srna, "use_filter_complete", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "search_flags", SO_FIND_COMPLETE); RNA_def_property_ui_text(prop, "Complete Matches Only", "Only use complete matches of search string"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_OUTLINER, NULL); prop= RNA_def_property(srna, "show_restrict_columns", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SO_HIDE_RESTRICTCOLS); RNA_def_property_ui_text(prop, "Show Restriction Columns", "Show column"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_OUTLINER, NULL); } static void rna_def_background_image(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; /* note: combinations work but dont flip so arnt that useful */ static EnumPropertyItem bgpic_axis_items[] = { {0, "", 0, "X Axis", ""}, {(1<