WM: rename BKE_regiontype_from_id
authorCampbell Barton <ideasman42@gmail.com>
Tue, 12 Jun 2018 15:26:38 +0000 (17:26 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 12 Jun 2018 15:26:38 +0000 (17:26 +0200)
This returns the first as a fallback, causing confusing usage.
Renamed and added a version of the function that doesn't.

source/blender/blenkernel/BKE_screen.h
source/blender/blenkernel/intern/screen.c
source/blender/editors/interface/interface_eyedropper_datablock.c
source/blender/editors/interface/interface_eyedropper_depth.c
source/blender/editors/screen/area.c
source/blender/editors/screen/screen_edit.c
source/blender/python/intern/bpy_rna_callback.c

index 44f5d9a393e5c4b953ae77fa592796781c806e0d..09390ab8776064e2fc5d9996570a16748bc67f37 100644 (file)
@@ -271,6 +271,7 @@ typedef struct Menu {
 
 /* spacetypes */
 struct SpaceType *BKE_spacetype_from_id(int spaceid);
+struct ARegionType *BKE_regiontype_from_id_or_first(struct SpaceType *st, int regionid);
 struct ARegionType *BKE_regiontype_from_id(struct SpaceType *st, int regionid);
 const struct ListBase *BKE_spacetypes_list(void);
 void BKE_spacetype_register(struct SpaceType *st);
index 2b1cf0a01df054eb88f45f2e0e71c64394b8187c..6723e826cdbf19fa1e5d3b198620deb4b8bfb3a7 100644 (file)
@@ -107,7 +107,7 @@ SpaceType *BKE_spacetype_from_id(int spaceid)
        return NULL;
 }
 
-ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid)
+ARegionType *BKE_regiontype_from_id_or_first(SpaceType *st, int regionid)
 {
        ARegionType *art;
        
@@ -119,6 +119,18 @@ ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid)
        return st->regiontypes.first;
 }
 
+ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid)
+{
+       ARegionType *art;
+       
+       for (art = st->regiontypes.first; art; art = art->next) {
+               if (art->regionid == regionid) {
+                       return art;
+               }
+       }
+       return NULL;
+}
+
 
 const ListBase *BKE_spacetypes_list(void)
 {
@@ -185,7 +197,7 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
        
        /* use optional regiondata callback */
        if (ar->regiondata) {
-               ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype);
+               ARegionType *art = BKE_regiontype_from_id_or_first(st, ar->regiontype);
 
                if (art && art->duplicate)
                        newar->regiondata = art->duplicate(ar->regiondata);
@@ -295,7 +307,7 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar)
        uiList *uilst;
 
        if (st) {
-               ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype);
+               ARegionType *art = BKE_regiontype_from_id_or_first(st, ar->regiontype);
                
                if (art && art->free)
                        art->free(ar);
index 416022a9dd06ab25fcf6b8e86729cce09c4c96bc..5e449ae34e3b40cf2c503f40ca1095abdbe67bff 100644 (file)
@@ -94,7 +94,7 @@ static int datadropper_init(bContext *C, wmOperator *op)
        ARegionType *art;
 
        st = BKE_spacetype_from_id(SPACE_VIEW3D);
-       art = BKE_regiontype_from_id(st, RGN_TYPE_WINDOW);
+       art = BKE_regiontype_from_id_or_first(st, RGN_TYPE_WINDOW);
 
        op->customdata = ddr = MEM_callocN(sizeof(DataDropper), "DataDropper");
 
index 8e2ca2e2b3ab510dd36f5e92724f51e4d2e80a0e..8b37ec1d2b46ca284aa45cbc65c0b6adb87bfb50 100644 (file)
@@ -94,7 +94,7 @@ static int depthdropper_init(bContext *C, wmOperator *op)
        ARegionType *art;
 
        st = BKE_spacetype_from_id(SPACE_VIEW3D);
-       art = BKE_regiontype_from_id(st, RGN_TYPE_WINDOW);
+       art = BKE_regiontype_from_id_or_first(st, RGN_TYPE_WINDOW);
 
        op->customdata = ddr = MEM_callocN(sizeof(DepthDropper), "DepthDropper");
 
index 3f365fc15009c74cba5e2347991dbdc459b1745a..6e4cbf27e287d42922f50c0f6e9c34d28439857f 100644 (file)
@@ -1452,7 +1452,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
        }
 
        for (ar = sa->regionbase.first; ar; ar = ar->next)
-               ar->type = BKE_regiontype_from_id(sa->type, ar->regiontype);
+               ar->type = BKE_regiontype_from_id_or_first(sa->type, ar->regiontype);
 
        /* area sizes */
        area_calc_totrct(sa, WM_window_pixels_x(win), WM_window_pixels_y(win));
index 0e32ec3c34f9cc8301a8bd039bdd51f1b1c1e4f5..d1b14c7bd316219cab91c667713f00143b9a1183 100644 (file)
@@ -897,7 +897,7 @@ static void screen_refresh_headersizes(void)
        SpaceType *st;
 
        for (st = lb->first; st; st = st->next) {
-               ARegionType *art = BKE_regiontype_from_id(st, RGN_TYPE_HEADER);
+               ARegionType *art = BKE_regiontype_from_id_or_first(st, RGN_TYPE_HEADER);
                if (art) art->prefsizey = ED_area_headersize();
        }
 }
index b1ac6bee608f2545616d5fad91c82f351962c057..0a7e9c3b4c9a57aaeb1b6d901648a9b11ee26719 100644 (file)
@@ -226,7 +226,7 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args)
                        }
                        else {
                                SpaceType *st = BKE_spacetype_from_id(spaceid);
-                               ARegionType *art = BKE_regiontype_from_id(st, cb_regiontype);
+                               ARegionType *art = BKE_regiontype_from_id_or_first(st, cb_regiontype);
 
                                handle = ED_region_draw_cb_activate(art, cb_region_draw, (void *)args, cb_event);
                                Py_INCREF(args);
@@ -289,7 +289,7 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
                        }
                        else {
                                SpaceType *st = BKE_spacetype_from_id(spaceid);
-                               ARegionType *art = BKE_regiontype_from_id(st, cb_regiontype);
+                               ARegionType *art = BKE_regiontype_from_id_or_first(st, cb_regiontype);
 
                                ED_region_draw_cb_exit(art, handle);
                        }