WM: rename BKE_regiontype_from_id
This returns the first as a fallback, causing confusing usage. Renamed and added a version of the function that doesn't.
This commit is contained in:
parent
ec4ce908db
commit
760e79d809
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue