Blender V2.61 - r43446

rna_screen.c

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * Contributor(s): Blender Foundation (2008), Nathan Letwory
00019  *
00020  * ***** END GPL LICENSE BLOCK *****
00021  */
00022 
00028 #include <stdlib.h>
00029 #include <stddef.h>
00030 
00031 #include "RNA_define.h"
00032 #include "RNA_enum_types.h"
00033 
00034 #include "rna_internal.h"
00035 
00036 #include "DNA_screen_types.h"
00037 #include "DNA_scene_types.h"
00038 
00039 EnumPropertyItem region_type_items[] = {
00040     {RGN_TYPE_WINDOW, "WINDOW", 0, "Window", ""},
00041     {RGN_TYPE_HEADER, "HEADER", 0, "Header", ""},
00042     {RGN_TYPE_CHANNELS, "CHANNELS", 0, "Channels", ""},
00043     {RGN_TYPE_TEMPORARY, "TEMPORARY", 0, "Temporary", ""},
00044     {RGN_TYPE_UI, "UI", 0, "UI", ""},
00045     {RGN_TYPE_TOOLS, "TOOLS", 0, "Tools", ""},
00046     {RGN_TYPE_TOOL_PROPS, "TOOL_PROPS", 0, "Tool Properties", ""},
00047     {RGN_TYPE_PREVIEW, "PREVIEW", 0, "Preview", ""},
00048     {0, NULL, 0, NULL, NULL}};
00049 
00050 #include "ED_screen.h"
00051 
00052 #include "WM_api.h"
00053 #include "WM_types.h"
00054 
00055 #ifdef RNA_RUNTIME
00056 
00057 #include "BKE_global.h"
00058 
00059 static void rna_Screen_scene_set(PointerRNA *ptr, PointerRNA value)
00060 {
00061     bScreen *sc= (bScreen*)ptr->data;
00062 
00063     if(value.data == NULL)
00064         return;
00065 
00066     sc->newscene= value.data;
00067 }
00068 
00069 static void rna_Screen_scene_update(bContext *C, PointerRNA *ptr)
00070 {
00071     bScreen *sc= (bScreen*)ptr->data;
00072 
00073     /* exception: must use context so notifier gets to the right window  */
00074     if(sc->newscene) {
00075         ED_screen_set_scene(C, sc->newscene);
00076         WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, sc->newscene);
00077 
00078         if(G.f & G_DEBUG)
00079             printf("scene set %p\n", sc->newscene);
00080 
00081         sc->newscene= NULL;
00082     }
00083 }
00084 
00085 static void rna_Screen_redraw_update(Main *bmain, Scene *scene, PointerRNA *ptr)
00086 {
00087     bScreen *screen= (bScreen*)ptr->data;
00088 
00089     /* the settings for this are currently only available from a menu in the TimeLine, hence refresh=SPACE_TIME */
00090     ED_screen_animation_timer_update(screen, screen->redraws_flag, SPACE_TIME);
00091 }
00092 
00093 
00094 static int rna_Screen_is_animation_playing_get(PointerRNA *ptr)
00095 {
00096     bScreen *sc= (bScreen*)ptr->data;
00097     return (sc->animtimer != NULL);
00098 }
00099 
00100 static int rna_Screen_fullscreen_get(PointerRNA *ptr)
00101 {
00102     bScreen *sc= (bScreen*)ptr->data;
00103     return (sc->full != 0);
00104 }
00105 
00106 static void rna_Area_type_set(PointerRNA *ptr, int value)
00107 {
00108     ScrArea *sa= (ScrArea*)ptr->data;
00109     sa->butspacetype= value;
00110 }
00111 
00112 static void rna_Area_type_update(bContext *C, PointerRNA *ptr)
00113 {
00114     ScrArea *sa= (ScrArea*)ptr->data;
00115 
00116     ED_area_newspace(C, sa, sa->butspacetype); /* XXX - this uses the window */
00117     ED_area_tag_redraw(sa);
00118 }
00119 
00120 #else
00121 
00122 /* Area.spaces */
00123 static void rna_def_area_spaces(BlenderRNA *brna, PropertyRNA *cprop)
00124 {
00125     StructRNA *srna;
00126     PropertyRNA *prop;
00127 
00128     RNA_def_property_srna(cprop, "AreaSpaces");
00129     srna= RNA_def_struct(brna, "AreaSpaces", NULL);
00130     RNA_def_struct_sdna(srna, "ScrArea");
00131     RNA_def_struct_ui_text(srna, "Area Spaces", "Collection of spaces");
00132 
00133     prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
00134     RNA_def_property_pointer_sdna(prop, NULL, "spacedata.first");
00135     RNA_def_property_struct_type(prop, "Space");
00136     RNA_def_property_ui_text(prop, "Active Space", "Space currently being displayed in this area");
00137 }
00138 
00139 static void rna_def_area(BlenderRNA *brna)
00140 {
00141     StructRNA *srna;
00142     PropertyRNA *prop;
00143     FunctionRNA *func;
00144 
00145     srna= RNA_def_struct(brna, "Area", NULL);
00146     RNA_def_struct_ui_text(srna, "Area", "Area in a subdivided screen, containing an editor");
00147     RNA_def_struct_sdna(srna, "ScrArea");
00148 
00149     prop= RNA_def_property(srna, "spaces", PROP_COLLECTION, PROP_NONE);
00150     RNA_def_property_collection_sdna(prop, NULL, "spacedata", NULL);
00151     RNA_def_property_struct_type(prop, "Space");
00152     RNA_def_property_ui_text(prop, "Spaces",
00153                              "Spaces contained in this area, the first being the active space "
00154                              "(NOTE: Useful for example to restore a previously used 3D view space "
00155                              "in a certain area to get the old view orientation)");
00156     rna_def_area_spaces(brna, prop);
00157 
00158     prop= RNA_def_property(srna, "regions", PROP_COLLECTION, PROP_NONE);
00159     RNA_def_property_collection_sdna(prop, NULL, "regionbase", NULL);
00160     RNA_def_property_struct_type(prop, "Region");
00161     RNA_def_property_ui_text(prop, "Regions", "Regions this area is subdivided in");
00162 
00163     prop= RNA_def_property(srna, "show_menus", PROP_BOOLEAN, PROP_NONE);
00164     RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", HEADER_NO_PULLDOWN);
00165     RNA_def_property_ui_text(prop, "Show Menus", "Show menus in the header");
00166 
00167     prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
00168     RNA_def_property_enum_sdna(prop, NULL, "spacetype");
00169     RNA_def_property_enum_items(prop, space_type_items);
00170     RNA_def_property_enum_funcs(prop, NULL, "rna_Area_type_set", NULL);
00171     RNA_def_property_ui_text(prop, "Type", "Space type");
00172     RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
00173     RNA_def_property_update(prop, 0, "rna_Area_type_update");
00174 
00175     prop= RNA_def_property(srna, "width", PROP_INT, PROP_UNSIGNED);
00176     RNA_def_property_int_sdna(prop, NULL, "winx");
00177     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
00178     RNA_def_property_ui_text(prop, "Width", "Area width");
00179 
00180     prop= RNA_def_property(srna, "height", PROP_INT, PROP_UNSIGNED);
00181     RNA_def_property_int_sdna(prop, NULL, "winy");
00182     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
00183     RNA_def_property_ui_text(prop, "Height", "Area height");
00184 
00185     RNA_def_function(srna, "tag_redraw", "ED_area_tag_redraw");
00186 
00187     func= RNA_def_function(srna, "header_text_set", "ED_area_headerprint");
00188     RNA_def_function_ui_description(func, "Set the header text");
00189     RNA_def_string(func, "text", NULL, 0, "Text", "New string for the header, no argument clears the text");
00190 }
00191 
00192 static void rna_def_region(BlenderRNA *brna)
00193 {
00194     StructRNA *srna;
00195     PropertyRNA *prop;
00196 
00197     srna= RNA_def_struct(brna, "Region", NULL);
00198     RNA_def_struct_ui_text(srna, "Region", "Region in a subdivided screen area");
00199     RNA_def_struct_sdna(srna, "ARegion");
00200 
00201     prop= RNA_def_property(srna, "id", PROP_INT, PROP_NONE);
00202     RNA_def_property_int_sdna(prop, NULL, "swinid");
00203     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
00204     RNA_def_property_ui_text(prop, "Region ID", "Unique ID for this region");
00205 
00206     prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
00207     RNA_def_property_enum_sdna(prop, NULL, "regiontype");
00208     RNA_def_property_enum_items(prop, region_type_items);
00209     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
00210     RNA_def_property_ui_text(prop, "Region Type", "Type of this region");
00211 
00212     prop= RNA_def_property(srna, "width", PROP_INT, PROP_UNSIGNED);
00213     RNA_def_property_int_sdna(prop, NULL, "winx");
00214     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
00215     RNA_def_property_ui_text(prop, "Width", "Region width");
00216 
00217     prop= RNA_def_property(srna, "height", PROP_INT, PROP_UNSIGNED);
00218     RNA_def_property_int_sdna(prop, NULL, "winy");
00219     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
00220     RNA_def_property_ui_text(prop, "Height", "Region height");
00221 
00222     RNA_def_function(srna, "tag_redraw", "ED_region_tag_redraw");
00223 }
00224 
00225 static void rna_def_screen(BlenderRNA *brna)
00226 {
00227     StructRNA *srna;
00228     PropertyRNA *prop;
00229 
00230     srna= RNA_def_struct(brna, "Screen", "ID");
00231     RNA_def_struct_sdna(srna, "Screen"); /* it is actually bScreen but for 2.5 the dna is patched! */
00232     RNA_def_struct_ui_text(srna, "Screen", "Screen datablock, defining the layout of areas in a window");
00233     RNA_def_struct_ui_icon(srna, ICON_SPLITSCREEN);
00234 
00235     /* pointers */
00236     prop= RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE);
00237     RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_NULL);
00238     RNA_def_property_pointer_funcs(prop, NULL, "rna_Screen_scene_set", NULL, NULL);
00239     RNA_def_property_ui_text(prop, "Scene", "Active scene to be edited in the screen");
00240     RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
00241     RNA_def_property_update(prop, 0, "rna_Screen_scene_update");
00242 
00243     /* collections */
00244     prop= RNA_def_property(srna, "areas", PROP_COLLECTION, PROP_NONE);
00245     RNA_def_property_collection_sdna(prop, NULL, "areabase", NULL);
00246     RNA_def_property_struct_type(prop, "Area");
00247     RNA_def_property_ui_text(prop, "Areas", "Areas the screen is subdivided into");
00248 
00249     /* readonly status indicators */
00250     prop= RNA_def_property(srna, "is_animation_playing", PROP_BOOLEAN, PROP_NONE);
00251     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
00252     RNA_def_property_boolean_funcs(prop, "rna_Screen_is_animation_playing_get", NULL);
00253     RNA_def_property_ui_text(prop, "Animation Playing", "Animation playback is active");
00254 
00255     prop= RNA_def_property(srna, "show_fullscreen", PROP_BOOLEAN, PROP_NONE);
00256     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
00257     RNA_def_property_boolean_funcs(prop, "rna_Screen_fullscreen_get", NULL);
00258     RNA_def_property_ui_text(prop, "Fullscreen", "An area is maximised, filling this screen");
00259 
00260     /* Define Anim Playback Areas */
00261     prop= RNA_def_property(srna, "use_play_top_left_3d_editor", PROP_BOOLEAN, PROP_NONE);
00262     RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_REGION);
00263     RNA_def_property_ui_text(prop, "Top-Left 3D Editor", "");
00264     RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
00265 
00266     prop= RNA_def_property(srna, "use_play_3d_editors", PROP_BOOLEAN, PROP_NONE);
00267     RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_ALL_3D_WIN);
00268     RNA_def_property_ui_text(prop, "All 3D View Editors", "");
00269     RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
00270 
00271     prop= RNA_def_property(srna, "use_play_animation_editors", PROP_BOOLEAN, PROP_NONE);
00272     RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_ALL_ANIM_WIN);
00273     RNA_def_property_ui_text(prop, "Animation Editors", "");
00274     RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
00275 
00276     prop= RNA_def_property(srna, "use_play_properties_editors", PROP_BOOLEAN, PROP_NONE);
00277     RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_ALL_BUTS_WIN);
00278     RNA_def_property_ui_text(prop, "Property Editors", "");
00279     RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
00280 
00281     prop= RNA_def_property(srna, "use_play_image_editors", PROP_BOOLEAN, PROP_NONE);
00282     RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_ALL_IMAGE_WIN);
00283     RNA_def_property_ui_text(prop, "Image Editors", "");
00284     RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
00285 
00286     prop= RNA_def_property(srna, "use_play_sequence_editors", PROP_BOOLEAN, PROP_NONE);
00287     RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_SEQ);
00288     RNA_def_property_ui_text(prop, "Sequencer Editors", "");
00289     RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
00290 
00291     prop= RNA_def_property(srna, "use_play_node_editors", PROP_BOOLEAN, PROP_NONE);
00292     RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_NODES);
00293     RNA_def_property_ui_text(prop, "Node Editors", "");
00294     RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
00295 
00296     prop= RNA_def_property(srna, "use_play_clip_editors", PROP_BOOLEAN, PROP_NONE);
00297     RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_CLIPS);
00298     RNA_def_property_ui_text(prop, "Clip Editors", "");
00299     RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
00300 }
00301 
00302 void RNA_def_screen(BlenderRNA *brna)
00303 {
00304     rna_def_screen(brna);
00305     rna_def_area(brna);
00306     rna_def_region(brna);
00307 }
00308 
00309 #endif
00310