This returns the first as a fallback, causing confusing usage.
Renamed and added a version of the function that doesn't.
/* 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);
return NULL;
}
-ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid)
+ARegionType *BKE_regiontype_from_id_or_first(SpaceType *st, int regionid)
{
ARegionType *art;
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)
{
/* 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);
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);
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");
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");
}
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));
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();
}
}
}
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);
}
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);
}