svn merge -r 21041:21301 https://svn.blender.org/svnroot/bf-blender/branches/blender2...
[blender.git] / source / blender / editors / space_api / spacetypes.c
index c8b414f56ac438d62a1e6af5a2f17d7d8af1776e..510103895f4103a338b56dfc8085446765d6ca3a 100644 (file)
 #include "MEM_guardedalloc.h"
 #include "BLI_blenlib.h"
 
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
 #include "DNA_windowmanager_types.h"
 
-#include "BKE_global.h"
+#include "BKE_context.h"
 #include "BKE_screen.h"
 
 #include "UI_interface.h"
 
 #include "BIF_gl.h"
 
+#include "ED_anim_api.h"
+#include "ED_armature.h"
+#include "ED_curve.h"
+#include "ED_mesh.h"
+#include "ED_markers.h"
+#include "ED_object.h"
+#include "ED_particle.h"
+#include "ED_sculpt.h"
 #include "ED_screen.h"
 #include "ED_space_api.h"
-
-
-ARegionType *ED_regiontype_from_id(SpaceType *st, int regionid)
-{
-       ARegionType *art;
-       
-       for(art= st->regiontypes.first; art; art= art->next)
-               if(art->regionid==regionid)
-                       return art;
-       
-       printf("Error, region type missing in %s\n", st->name);
-       return st->regiontypes.first;
-}
-
+#include "ED_uvedit.h"
+#include "ED_pointcache.h"
 
 /* only call once on startup, storage is global in BKE kernel listbase */
 void ED_spacetypes_init(void)
@@ -67,10 +65,33 @@ void ED_spacetypes_init(void)
        ED_spacetype_ipo();
        ED_spacetype_image();
        ED_spacetype_node();
+       ED_spacetype_buttons();
+       ED_spacetype_info();
+       ED_spacetype_file();
+       ED_spacetype_sound();
+       ED_spacetype_action();
+       ED_spacetype_nla();
+       ED_spacetype_script();
+       ED_spacetype_text();
+       ED_spacetype_sequencer();
+       ED_spacetype_logic();
 //     ...
        
        /* register operator types for screen and all spaces */
        ED_operatortypes_screen();
+       ED_operatortypes_anim();
+       ED_operatortypes_animchannels(); // XXX have this as part of anim() ones instead?
+       ED_operatortypes_object();
+       ED_operatortypes_mesh();
+       ED_operatortypes_sculpt();
+       ED_operatortypes_uvedit();
+       ED_operatortypes_paint();
+       ED_operatortypes_particle();
+       ED_operatortypes_curve();
+       ED_operatortypes_armature();
+       ED_marker_operatortypes();
+       ED_operatortypes_pointcache();
+       
        ui_view2d_operatortypes();
        
        spacetypes = BKE_spacetypes_list();
@@ -88,6 +109,16 @@ void ED_spacetypes_keymap(wmWindowManager *wm)
        ARegionType *atype;
 
        ED_keymap_screen(wm);
+       ED_keymap_anim(wm);
+       ED_keymap_animchannels(wm);
+       ED_keymap_object(wm);
+       ED_keymap_mesh(wm);
+       ED_keymap_uvedit(wm);
+       ED_keymap_curve(wm);
+       ED_keymap_armature(wm);
+       ED_keymap_particle(wm);
+       ED_marker_keymap(wm);
+
        UI_view2d_keymap(wm);
 
        spacetypes = BKE_spacetypes_list();
@@ -101,10 +132,65 @@ void ED_spacetypes_keymap(wmWindowManager *wm)
        }
 }
 
-/* ****************************** space template *********************** */
+/* ********************** custom drawcall api ***************** */
+
+/* type */
+#define REGION_DRAW_PRE                1
+#define REGION_DRAW_POST       0
+
+typedef struct RegionDrawCB {
+       struct RegionDrawCB *next, *prev;
+       
+       void (*draw)(const struct bContext *, struct ARegion *, void *);        
+       void *customdata;
+       
+       int type;
+       
+} RegionDrawCB;
+
+void *ED_region_draw_cb_activate(ARegionType *art, 
+                                                                void   (*draw)(const struct bContext *, struct ARegion *, void *),
+                                                                void *customdata, int type)
+{
+       RegionDrawCB *rdc= MEM_callocN(sizeof(RegionDrawCB), "RegionDrawCB");
+       
+       BLI_addtail(&art->drawcalls, rdc);
+       rdc->draw= draw;
+       rdc->customdata= customdata;
+       rdc->type= type;
+       
+       return rdc;
+}
+
+void ED_region_draw_cb_exit(ARegionType *art, void *handle)
+{
+       RegionDrawCB *rdc;
+       
+       for(rdc= art->drawcalls.first; rdc; rdc= rdc->next) {
+               if(rdc==(RegionDrawCB *)handle) {
+                       BLI_remlink(&art->drawcalls, rdc);
+                       MEM_freeN(rdc);
+                       return;
+               }
+       }
+}
+
+void ED_region_draw_cb_draw(const bContext *C, ARegion *ar, int type)
+{
+       RegionDrawCB *rdc;
+       
+       for(rdc= ar->type->drawcalls.first; rdc; rdc= rdc->next) {
+               if(rdc->type==type)
+                       rdc->draw(C, ar, rdc->customdata);
+       }               
+}
+
+
+
+/* ********************* space template *********************** */
 
 /* allocate and init some vars */
-static SpaceLink *xxx_new(void)
+static SpaceLink *xxx_new(const bContext *C)
 {
        return NULL;
 }