code cleanup: function naming, use BKE_*type* prefix.
[blender.git] / source / blender / editors / space_logic / space_logic.c
index ed3d956ce0142eb92e739f13b53ebf8773d295fe..1caf1075ae66d46dfd6db1c2bb88505b7c8e040a 100644 (file)
@@ -1,6 +1,4 @@
-/**
- * $Id$
- *
+/*
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
  * ***** END GPL LICENSE BLOCK *****
  */
 
+/** \file blender/editors/space_logic/space_logic.c
+ *  \ingroup splogic
+ */
+
+
 #include <string.h>
 #include <stdio.h>
 
 
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
+#include "BLI_utildefines.h"
 
 #include "BKE_context.h"
 #include "BKE_screen.h"
-#include "BKE_utildefines.h"
 
+#include "ED_space_api.h"
 #include "ED_screen.h"
 
 #include "BIF_gl.h"
-#include "BIF_glutil.h"
 
 
 #include "WM_api.h"
 ARegion *logic_has_buttons_region(ScrArea *sa)
 {
        ARegion *ar, *arnew;
-       
-       for(ar= sa->regionbase.first; ar; ar= ar->next)
-               if(ar->regiontype==RGN_TYPE_UI)
-                       return ar;
+
+       ar= BKE_area_find_region_type(sa, RGN_TYPE_UI);
+       if (ar) return ar;
        
        /* add subdiv level; after header */
-       for(ar= sa->regionbase.first; ar; ar= ar->next)
-               if(ar->regiontype==RGN_TYPE_HEADER)
-                       break;
-       
+       ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
+
        /* is error! */
-       if(ar==NULL) return NULL;
+       if (ar==NULL) return NULL;
        
        arnew= MEM_callocN(sizeof(ARegion), "buttons for image");
        
@@ -84,7 +84,7 @@ ARegion *logic_has_buttons_region(ScrArea *sa)
 
 /* ******************** default callbacks for image space ***************** */
 
-static SpaceLink *logic_new(const bContext *C)
+static SpaceLink *logic_new(const bContext *UNUSED(C))
 {
        ARegion *ar;
        SpaceLogic *slogic;
@@ -119,15 +119,15 @@ static SpaceLink *logic_new(const bContext *C)
        BLI_addtail(&slogic->regionbase, ar);
        ar->regiontype= RGN_TYPE_WINDOW;
 
-       ar->v2d.tot.xmin=  0.0f;
-       ar->v2d.tot.ymin=  0.0f;
-       ar->v2d.tot.xmax= 1280;
-       ar->v2d.tot.ymax= 240.0f;
+       ar->v2d.tot.xmin =  0.0f;
+       ar->v2d.tot.ymin =  0.0f;
+       ar->v2d.tot.xmax = 1280;
+       ar->v2d.tot.ymax = 240.0f;
        
-       ar->v2d.cur.xmin=  0.0f;
-       ar->v2d.cur.ymin=  0.0f;
-       ar->v2d.cur.xmax= 1280.0f;
-       ar->v2d.cur.ymax= 240.0f;
+       ar->v2d.cur.xmin =  0.0f;
+       ar->v2d.cur.ymin =  0.0f;
+       ar->v2d.cur.xmax = 1280.0f;
+       ar->v2d.cur.ymax = 240.0f;
        
        ar->v2d.min[0]= 1.0f;
        ar->v2d.min[1]= 1.0f;
@@ -147,18 +147,18 @@ static SpaceLink *logic_new(const bContext *C)
 }
 
 /* not spacelink itself */
-static void logic_free(SpaceLink *sl)
+static void logic_free(SpaceLink *UNUSED(sl))
 {      
 //     Spacelogic *slogic= (SpaceLogic*) sl;
        
-//     if(slogic->gpd)
-// XXX         free_gpencil_data(slogic->gpd);
+//     if (slogic->gpd)
+// XXX         BKE_gpencil_free(slogic->gpd);
        
 }
 
 
 /* spacetype; init callback */
-static void logic_init(struct wmWindowManager *wm, ScrArea *sa)
+static void logic_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
 {
 
 }
@@ -170,22 +170,22 @@ static SpaceLink *logic_duplicate(SpaceLink *sl)
        return (SpaceLink *)slogicn;
 }
 
-void logic_operatortypes(void)
+static void logic_operatortypes(void)
 {
        WM_operatortype_append(LOGIC_OT_properties);
        WM_operatortype_append(LOGIC_OT_links_cut);
 }
 
-void logic_keymap(struct wmKeyConfig *keyconf)
+static void logic_keymap(struct wmKeyConfig *keyconf)
 {
-       wmKeyMap *keymap= WM_keymap_find(keyconf, "Logic Editor", SPACE_LOGIC, 0);
+       wmKeyMap *keymap = WM_keymap_find(keyconf, "Logic Editor", SPACE_LOGIC, 0);
        
        WM_keymap_add_item(keymap, "LOGIC_OT_properties", NKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "LOGIC_OT_links_cut", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
        WM_keymap_add_menu(keymap, "LOGIC_MT_logicbricks_add", AKEY, KM_PRESS, KM_SHIFT, 0);
 }
 
-static void logic_refresh(const bContext *C, ScrArea *sa)
+static void logic_refresh(const bContext *UNUSED(C), ScrArea *UNUSED(sa))
 {
 //     SpaceLogic *slogic= CTX_wm_space_logic(C);
 //     Object *obedit= CTX_data_edit_object(C);
@@ -195,12 +195,12 @@ static void logic_refresh(const bContext *C, ScrArea *sa)
 static void logic_listener(ARegion *ar, wmNotifier *wmn)
 {
        /* context changes */
-       switch(wmn->category) {
+       switch (wmn->category) {
                case NC_LOGIC:
                        ED_region_tag_redraw(ar);
                        break;
                case NC_SCENE:
-                       switch(wmn->data) {
+                       switch (wmn->data) {
                                case ND_FRAME:
                                        ED_region_tag_redraw(ar);
                                        break;
@@ -213,17 +213,15 @@ static void logic_listener(ARegion *ar, wmNotifier *wmn)
                case NC_OBJECT:
                        break;
                case NC_ID:
-                       if(wmn->action == NA_RENAME)
+                       if (wmn->action == NA_RENAME)
                                ED_region_tag_redraw(ar);
                        break;
        }
 }
 
-static int logic_context(const bContext *C, const char *member, bContextDataResult *result)
+static int logic_context(const bContext *UNUSED(C), const char *UNUSED(member), bContextDataResult *UNUSED(result))
 {
 //     SpaceLogic *slogic= CTX_wm_space_logic(C);
-
-
        return 0;
 }
 
@@ -238,7 +236,7 @@ static void logic_main_area_init(wmWindowManager *wm, ARegion *ar)
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
 
        /* own keymaps */
-       keymap= WM_keymap_find(wm->defaultconf, "Logic Editor", SPACE_LOGIC, 0);
+       keymap = WM_keymap_find(wm->defaultconf, "Logic Editor", SPACE_LOGIC, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
@@ -253,7 +251,7 @@ static void logic_main_area_draw(const bContext *C, ARegion *ar)
        UI_ThemeClearColor(TH_BACK);
        glClear(GL_COLOR_BUFFER_BIT);
        
-       UI_view2d_view_ortho(C, v2d);
+       UI_view2d_view_ortho(v2d);
        
        logic_buttons((bContext *)C, ar);
        
@@ -277,7 +275,7 @@ static void logic_buttons_area_init(wmWindowManager *wm, ARegion *ar)
 
        ED_region_panels_init(wm, ar);
        
-       keymap= WM_keymap_find(wm->defaultconf, "Logic Editor", SPACE_LOGIC, 0);
+       keymap = WM_keymap_find(wm->defaultconf, "Logic Editor", SPACE_LOGIC, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
@@ -289,24 +287,14 @@ static void logic_buttons_area_draw(const bContext *C, ARegion *ar)
 /************************* header region **************************/
 
 /* add handlers, stuff you only do once or on area/region changes */
-static void logic_header_area_init(wmWindowManager *wm, ARegion *ar)
+static void logic_header_area_init(wmWindowManager *UNUSED(wm), ARegion *ar)
 {
        ED_region_header_init(ar);
 }
 
 static void logic_header_area_draw(const bContext *C, ARegion *ar)
 {
-       /* clear */
-       UI_ThemeClearColor(ED_screen_area_active(C)?TH_HEADER:TH_HEADERDESEL);
-       glClear(GL_COLOR_BUFFER_BIT);
-       
-       /* set view2d view matrix for scrolling (without scrollers) */
-       UI_view2d_view_ortho(C, &ar->v2d);
-       
-       logic_header_buttons(C, ar);
-       
-       /* restore view matrix? */
-       UI_view2d_view_restore(C);
+       ED_region_header(C, ar);
 }
 
 /**************************** spacetype *****************************/
@@ -349,8 +337,6 @@ void ED_spacetype_logic(void)
        art->draw= logic_buttons_area_draw;
        BLI_addhead(&st->regiontypes, art);
 
-       logic_buttons_register(art);
-
        /* regions: header */
        art= MEM_callocN(sizeof(ARegionType), "spacetype logic region");
        art->regionid = RGN_TYPE_HEADER;