Revert "Cleanup: Use LISTBASE_FOREACH in editors screen directory"

This reverts commit 52f40bcff2.

Apologies for the noise. I caught a problem with this that I hadn't before. I will
commit later after thorough testing.
This commit is contained in:
Hans Goudey 2020-08-20 09:34:09 -04:00
parent 52f40bcff2
commit f9697543e4
8 changed files with 127 additions and 76 deletions

View File

@ -302,6 +302,8 @@ static void area_azone_tag_update(ScrArea *area)
static void region_draw_azones(ScrArea *area, ARegion *region)
{
AZone *az;
if (!area) {
return;
}
@ -312,7 +314,7 @@ static void region_draw_azones(ScrArea *area, ARegion *region)
GPU_matrix_push();
GPU_matrix_translate_2f(-region->winrct.xmin, -region->winrct.ymin);
LISTBASE_FOREACH (AZone *, az, &area->actionzones) {
for (az = area->actionzones.first; az; az = az->next) {
/* test if action zone is over this region */
rcti azrct;
BLI_rcti_init(&azrct, az->x1, az->x2, az->y1, az->y2);
@ -703,8 +705,10 @@ void ED_region_tag_redraw_partial(ARegion *region, const rcti *rct, bool rebuild
void ED_area_tag_redraw(ScrArea *area)
{
ARegion *region;
if (area) {
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
for (region = area->regionbase.first; region; region = region->next) {
ED_region_tag_redraw(region);
}
}
@ -712,8 +716,10 @@ void ED_area_tag_redraw(ScrArea *area)
void ED_area_tag_redraw_no_rebuild(ScrArea *area)
{
ARegion *region;
if (area) {
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
for (region = area->regionbase.first; region; region = region->next) {
ED_region_tag_redraw_no_rebuild(region);
}
}
@ -721,8 +727,10 @@ void ED_area_tag_redraw_no_rebuild(ScrArea *area)
void ED_area_tag_redraw_regiontype(ScrArea *area, int regiontype)
{
ARegion *region;
if (area) {
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
for (region = area->regionbase.first; region; region = region->next) {
if (region->regiontype == regiontype) {
ED_region_tag_redraw(region);
}
@ -742,12 +750,14 @@ void ED_area_tag_refresh(ScrArea *area)
/* use NULL to disable it */
void ED_area_status_text(ScrArea *area, const char *str)
{
ARegion *region;
/* happens when running transform operators in background mode */
if (area == NULL) {
return;
}
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
for (region = area->regionbase.first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_HEADER) {
if (str) {
if (region->headerstr == NULL) {
@ -932,6 +942,7 @@ static void region_azone_edge(AZone *az, ARegion *region)
/* region already made zero sized, in shape of edge */
static void region_azone_tab_plus(ScrArea *area, AZone *az, ARegion *region)
{
AZone *azt;
int tot = 0, add;
/* Edge offset multiplied by the */
@ -939,7 +950,7 @@ static void region_azone_tab_plus(ScrArea *area, AZone *az, ARegion *region)
const float tab_size_x = 0.7f * U.widget_unit;
const float tab_size_y = 0.4f * U.widget_unit;
LISTBASE_FOREACH (AZone *, azt, &area->actionzones) {
for (azt = area->actionzones.first; azt; azt = azt->next) {
if (azt->edge == az->edge) {
tot++;
}
@ -1835,6 +1846,7 @@ void ED_area_init(wmWindowManager *wm, wmWindow *win, ScrArea *area)
WorkSpace *workspace = WM_window_get_active_workspace(win);
const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
ARegion *region;
rcti rect, overlap_rect;
rcti window_rect;
@ -1851,7 +1863,7 @@ void ED_area_init(wmWindowManager *wm, wmWindow *win, ScrArea *area)
area->type = BKE_spacetype_from_id(area->spacetype);
}
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
for (region = area->regionbase.first; region; region = region->next) {
region->type = BKE_regiontype_from_id_or_first(area->type, region->regiontype);
}
@ -1875,7 +1887,7 @@ void ED_area_init(wmWindowManager *wm, wmWindow *win, ScrArea *area)
area_azone_init(win, screen, area);
/* region windows, default and own handlers */
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
for (region = area->regionbase.first; region; region = region->next) {
region_subwindow(region);
if (region->visible) {
@ -1994,6 +2006,7 @@ void ED_region_toggle_hidden(bContext *C, ARegion *region)
void ED_area_data_copy(ScrArea *area_dst, ScrArea *area_src, const bool do_free)
{
SpaceType *st;
ARegion *region;
const char spacetype = area_dst->spacetype;
const short flag_copy = HEADER_NO_PULLDOWN;
@ -2013,13 +2026,13 @@ void ED_area_data_copy(ScrArea *area_dst, ScrArea *area_src, const bool do_free)
/* regions */
if (do_free) {
st = BKE_spacetype_from_id(spacetype);
LISTBASE_FOREACH (ARegion *, region, &area_dst->regionbase) {
for (region = area_dst->regionbase.first; region; region = region->next) {
BKE_area_region_free(st, region);
}
BLI_freelistN(&area_dst->regionbase);
}
st = BKE_spacetype_from_id(area_src->spacetype);
LISTBASE_FOREACH (ARegion *, region, &area_src->regionbase) {
for (region = area_src->regionbase.first; region; region = region->next) {
ARegion *newar = BKE_area_region_copy(st, region);
BLI_addtail(&area_dst->regionbase, newar);
}
@ -2307,6 +2320,7 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi
if (area->spacetype != type) {
SpaceType *st;
SpaceLink *slold = area->spacedata.first;
SpaceLink *sl;
/* store area->type->exit callback */
void *area_exit = area->type ? area->type->exit : NULL;
/* When the user switches between space-types from the type-selector,
@ -2350,10 +2364,8 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi
* (e.g. with properties editor) until space-data is properly created */
/* check previously stored space */
SpaceLink *sl = NULL;
LISTBASE_FOREACH (SpaceLink *, sl_iter, &area->spacedata) {
if (sl_iter->spacetype == type) {
sl = sl_iter;
for (sl = area->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == type) {
break;
}
}
@ -2702,7 +2714,7 @@ void ED_region_panels_layout_ex(const bContext *C,
/* collect panels to draw */
WorkSpace *workspace = CTX_wm_workspace(C);
LinkNode *panel_types_stack = NULL;
LISTBASE_FOREACH_BACKWARD (PanelType *, pt, paneltypes) {
for (PanelType *pt = paneltypes->last; pt; pt = pt->prev) {
/* Only draw top level panels. */
if (pt->parent) {
continue;
@ -2979,6 +2991,7 @@ void ED_region_header_layout(const bContext *C, ARegion *region)
const uiStyle *style = UI_style_get_dpi();
uiBlock *block;
uiLayout *layout;
HeaderType *ht;
Header header = {NULL};
bool region_layout_based = region->flag & RGN_FLAG_DYNAMIC_SIZE;
@ -3001,7 +3014,7 @@ void ED_region_header_layout(const bContext *C, ARegion *region)
UI_view2d_view_ortho(&region->v2d);
/* draw all headers types */
LISTBASE_FOREACH (HeaderType *, ht, &region->type->headertypes) {
for (ht = region->type->headertypes.first; ht; ht = ht->next) {
if (ht->poll && !ht->poll(C, ht)) {
continue;
}

View File

@ -204,7 +204,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
if (CTX_data_equals(member, "visible_bones") || CTX_data_equals(member, "editable_bones")) {
bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL;
EditBone *flipbone = NULL;
EditBone *ebone, *flipbone = NULL;
const bool editable_bones = CTX_data_equals(member, "editable_bones");
if (arm && arm->edbo) {
@ -216,7 +216,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
arm = ob->data;
/* Attention: X-Axis Mirroring is also handled here... */
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
/* first and foremost, bone must be visible and selected */
if (EBONE_VISIBLE(arm, ebone)) {
/* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled
@ -262,7 +262,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
if (CTX_data_equals(member, "selected_bones") ||
CTX_data_equals(member, "selected_editable_bones")) {
bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL;
EditBone *flipbone = NULL;
EditBone *ebone, *flipbone = NULL;
const bool selected_editable_bones = CTX_data_equals(member, "selected_editable_bones");
if (arm && arm->edbo) {
@ -274,7 +274,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
arm = ob->data;
/* Attention: X-Axis Mirroring is also handled here... */
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
/* first and foremost, bone must be visible and selected */
if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_SELECTED)) {
/* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled
@ -479,7 +479,8 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
if (CTX_data_equals(member, "sequences")) {
Editing *ed = BKE_sequencer_editing_get(scene, false);
if (ed) {
LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) {
Sequence *seq;
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq);
}
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
@ -490,7 +491,8 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
if (CTX_data_equals(member, "selected_sequences")) {
Editing *ed = BKE_sequencer_editing_get(scene, false);
if (ed) {
LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) {
Sequence *seq;
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->flag & SELECT) {
CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq);
}
@ -503,7 +505,8 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
if (CTX_data_equals(member, "selected_editable_sequences")) {
Editing *ed = BKE_sequencer_editing_get(scene, false);
if (ed) {
LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) {
Sequence *seq;
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->flag & SELECT && !(seq->flag & SEQ_LOCK)) {
CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq);
}
@ -517,14 +520,16 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
bAnimContext ac;
if (ANIM_animdata_get_context(C, &ac) != 0) {
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
ANIM_animdata_filter(&ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac.data, ac.datatype);
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
for (ale = anim_data.first; ale; ale = ale->next) {
if (ale->datatype != ALE_NLASTRIP) {
continue;
}
NlaTrack *nlt = (NlaTrack *)ale->data;
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
NlaStrip *strip;
for (strip = nlt->strips.first; strip; strip = strip->next) {
if (strip->flag & NLASTRIP_FLAG_SELECT) {
CTX_data_list_add(result, &scene->id, &RNA_NlaStrip, strip);
}
@ -632,7 +637,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact);
if (gpd) {
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
bGPDlayer *gpl;
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
if ((gpl->flag & GP_LAYER_HIDE) == 0) {
CTX_data_list_add(result, &gpd->id, &RNA_GPencilLayer, gpl);
}
@ -646,7 +653,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact);
if (gpd) {
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
bGPDlayer *gpl;
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
if (BKE_gpencil_layer_is_editable(gpl)) {
CTX_data_list_add(result, &gpd->id, &RNA_GPencilLayer, gpl);
}
@ -661,9 +670,12 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
if (gpd) {
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
bGPDlayer *gpl;
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe)) {
bGPDframe *gpf;
bGPDstroke *gps;
bGPDframe *init_gpf = gpl->actframe;
if (is_multiedit) {
init_gpf = gpl->frames.first;
@ -671,7 +683,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
for (gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
for (gps = gpf->strokes.first; gps; gps = gps->next) {
if (ED_gpencil_stroke_can_use_direct(area, gps)) {
/* check if the color is editable */
if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false) {

View File

@ -379,9 +379,11 @@ void ED_screen_draw_edges(wmWindow *win)
float col[4], corner_scale, edge_thickness;
int verts_per_corner = 0;
ScrArea *area;
rcti scissor_rect;
BLI_rcti_init_minmax(&scissor_rect);
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
for (area = screen->areabase.first; area; area = area->next) {
BLI_rcti_do_minmax_v(&scissor_rect, (int[2]){area->v1->vec.x, area->v1->vec.y});
BLI_rcti_do_minmax_v(&scissor_rect, (int[2]){area->v3->vec.x, area->v3->vec.y});
}
@ -416,7 +418,7 @@ void ED_screen_draw_edges(wmWindow *win)
GPU_batch_uniform_1f(batch, "scale", corner_scale);
GPU_batch_uniform_4fv(batch, "color", col);
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
for (area = screen->areabase.first; area; area = area->next) {
drawscredge_area(area, winsize_x, winsize_y, edge_thickness);
}

View File

@ -230,7 +230,8 @@ bScreen *screen_add(Main *bmain, const char *name, const rcti *rect)
void screen_data_copy(bScreen *to, bScreen *from)
{
ScrVert *s2;
ScrVert *s1, *s2;
ScrEdge *se;
ScrArea *area, *saf;
/* free contents of 'to', is from blenkernel screen.c */
@ -244,11 +245,11 @@ void screen_data_copy(bScreen *to, bScreen *from)
BLI_listbase_clear(&to->regionbase);
s2 = to->vertbase.first;
LISTBASE_FOREACH (ScrVert *, s1, &from->vertbase) {
for (s1 = from->vertbase.first; s1; s1 = s1->next, s2 = s2->next) {
s1->newv = s2;
}
LISTBASE_FOREACH (ScrEdge *, se, &to->edgebase) {
for (se = to->edgebase.first; se; se = se->next) {
se->v1 = se->v1->newv;
se->v2 = se->v2->newv;
BKE_screen_sort_scrvert(&(se->v1), &(se->v2));
@ -270,7 +271,7 @@ void screen_data_copy(bScreen *to, bScreen *from)
}
/* put at zero (needed?) */
LISTBASE_FOREACH (ScrVert *, s1, &from->vertbase) {
for (s1 = from->vertbase.first; s1; s1 = s1->next) {
s1->newv = NULL;
}
}
@ -537,7 +538,9 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
/* file read, set all screens, ... */
void ED_screens_init(Main *bmain, wmWindowManager *wm)
{
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
wmWindow *win;
for (win = wm->windows.first; win; win = win->next) {
if (BKE_workspace_active_get(win->workspace_hook) == NULL) {
BKE_workspace_active_set(win->workspace_hook, bmain->workspaces.first);
}
@ -549,7 +552,7 @@ void ED_screens_init(Main *bmain, wmWindowManager *wm)
}
if (U.uiflag & USER_HEADER_FROM_PREF) {
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
BKE_screen_header_alignment_reset(screen);
}
}
@ -611,6 +614,7 @@ void ED_area_exit(bContext *C, ScrArea *area)
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
ScrArea *prevsa = CTX_wm_area(C);
ARegion *region;
if (area->type && area->type->exit) {
area->type->exit(wm, area);
@ -618,7 +622,7 @@ void ED_area_exit(bContext *C, ScrArea *area)
CTX_wm_area_set(C, area);
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
for (region = area->regionbase.first; region; region = region->next) {
ED_region_exit(C, region);
}
@ -679,11 +683,10 @@ static void screen_cursor_set(wmWindow *win, const int xy[2])
{
const bScreen *screen = WM_window_get_active_screen(win);
AZone *az = NULL;
ScrArea *area = NULL;
ScrArea *area;
LISTBASE_FOREACH (ScrArea *, area_iter, &screen->areabase) {
for (area = screen->areabase.first; area; area = area->next) {
if ((az = ED_area_actionzone_find_xy(area, xy))) {
area = area_iter;
break;
}
}
@ -730,6 +733,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
}
ScrArea *area = NULL;
ARegion *region;
ARegion *region_prev = screen->active_region;
ED_screen_areas_iter (win, screen, area_iter) {
@ -746,7 +750,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
}
if (area) {
/* Make overlap active when mouse over. */
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
for (region = area->regionbase.first; region; region = region->next) {
if (ED_region_contains_xy(region, xy)) {
screen->active_region = region;
break;
@ -763,7 +767,8 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
ED_screen_areas_iter (win, screen, area_iter) {
bool do_draw = false;
LISTBASE_FOREACH (ARegion *, region, &area_iter->regionbase) {
for (region = area_iter->regionbase.first; region; region = region->next) {
/* Call old area's deactivate if assigned. */
if (region == region_prev && area_iter->type->deactivate) {
area_iter->type->deactivate(area_iter);
@ -784,7 +789,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
}
if (do_draw) {
LISTBASE_FOREACH (ARegion *, region, &area_iter->regionbase) {
for (region = area_iter->regionbase.first; region; region = region->next) {
if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
ED_region_tag_redraw_no_rebuild(region);
}
@ -821,12 +826,13 @@ int ED_screen_area_active(const bContext *C)
if (win && screen && area) {
AZone *az = ED_area_actionzone_find_xy(area, &win->eventstate->x);
ARegion *region;
if (az && az->type == AZONE_REGION) {
return 1;
}
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
for (region = area->regionbase.first; region; region = region->next) {
if (region == screen->active_region) {
return 1;
}
@ -877,8 +883,9 @@ static void screen_global_area_refresh(wmWindow *win,
const short height_min,
const short height_max)
{
ScrArea *area = NULL;
LISTBASE_FOREACH (ScrArea *, area_iter, &win->global_areas.areabase) {
ScrArea *area;
for (area = win->global_areas.areabase.first; area; area = area->next) {
if (area->spacetype == space_type) {
break;
}
@ -1074,6 +1081,7 @@ static void screen_set_3dview_camera(Scene *scene,
v3d->camera = BKE_view_layer_camera_find(view_layer);
// XXX if (screen == curscreen) handle_view3d_lock();
if (!v3d->camera) {
ARegion *region;
ListBase *regionbase;
/* regionbase is in different place depending if space is active */
@ -1084,7 +1092,7 @@ static void screen_set_3dview_camera(Scene *scene,
regionbase = &v3d->regionbase;
}
LISTBASE_FOREACH (ARegion *, region, regionbase) {
for (region = regionbase->first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = region->regiondata;
if (rv3d->persp == RV3D_CAMOB) {
@ -1232,12 +1240,13 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const
wmWindowManager *wm = CTX_wm_manager(C);
WorkSpace *workspace = WM_window_get_active_workspace(win);
bScreen *screen, *oldscreen;
ARegion *region;
if (area) {
/* ensure we don't have a button active anymore, can crash when
* switching screens with tooltip open because region and tooltip
* are no longer in the same screen */
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
for (region = area->regionbase.first; region; region = region->next) {
UI_blocklist_free(C, &region->uiblocks);
if (region->regiontimer) {
@ -1290,7 +1299,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const
glob_area->global->flag &= ~GLOBAL_AREA_IS_HIDDEN;
}
/* restore the old side panels/header visibility */
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
for (region = area->regionbase.first; region; region = region->next) {
region->flag = region->flagfullscreen;
}
}
@ -1355,7 +1364,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const
glob_area->global->flag |= GLOBAL_AREA_IS_HIDDEN;
}
/* temporarily hide the side panels/header */
LISTBASE_FOREACH (ARegion *, region, &newa->regionbase) {
for (region = newa->regionbase.first; region; region = region->next) {
region->flagfullscreen = region->flag;
if (ELEM(region->regiontype,
@ -1528,11 +1537,13 @@ void ED_screen_animation_timer(bContext *C, int redraws, int sync, int enable)
static ARegion *time_top_left_3dwindow(bScreen *screen)
{
ARegion *aret = NULL;
ScrArea *area;
int min = 10000;
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
for (area = screen->areabase.first; area; area = area->next) {
if (area->spacetype == SPACE_VIEW3D) {
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
ARegion *region;
for (region = area->regionbase.first; region; region = region->next) {
if (region->regiontype == RGN_TYPE_WINDOW) {
if (region->winrct.xmin - region->winrct.ymin < min) {
aret = region;
@ -1570,9 +1581,10 @@ void ED_update_for_newframe(Main *bmain, Depsgraph *depsgraph)
#ifdef DURIAN_CAMERA_SWITCH
void *camera = BKE_scene_camera_switch_find(scene);
if (camera && scene->camera != camera) {
bScreen *screen;
scene->camera = camera;
/* are there cameras in the views that are not in the scene? */
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
for (screen = bmain->screens.first; screen; screen = screen->id.next) {
BKE_screen_view3d_scene_sync(screen, scene);
}
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
@ -1590,9 +1602,10 @@ void ED_update_for_newframe(Main *bmain, Depsgraph *depsgraph)
*/
bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene)
{
ScrArea *area;
const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0;
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
for (area = screen->areabase.first; area; area = area->next) {
switch (area->spacetype) {
case SPACE_VIEW3D: {
View3D *v3d;
@ -1603,7 +1616,8 @@ bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene)
v3d = area->spacedata.first;
if (v3d->camera && v3d->stereo3d_camera == STEREO_3D_ID) {
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
ARegion *region;
for (region = area->regionbase.first; region; region = region->next) {
if (region->regiondata && region->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = region->regiondata;
if (rv3d->persp == RV3D_CAMOB) {

View File

@ -162,6 +162,7 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *screen)
const int screen_size_x = BLI_rcti_size_x(&screen_rect);
const int screen_size_y = BLI_rcti_size_y(&screen_rect);
ScrVert *sv = NULL;
int screen_size_x_prev, screen_size_y_prev;
float min[2], max[2];
@ -169,7 +170,7 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *screen)
min[0] = min[1] = 20000.0f;
max[0] = max[1] = 0.0f;
LISTBASE_FOREACH (ScrVert *, sv, &screen->vertbase) {
for (sv = screen->vertbase.first; sv; sv = sv->next) {
const float fv[2] = {(float)sv->vec.x, (float)sv->vec.y};
minmax_v2v2_v2(min, max, fv);
}
@ -182,7 +183,7 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *screen)
const float facy = ((float)screen_size_y - 1) / ((float)screen_size_y_prev - 1);
/* make sure it fits! */
LISTBASE_FOREACH (ScrVert *, sv, &screen->vertbase) {
for (sv = screen->vertbase.first; sv; sv = sv->next) {
sv->vec.x = screen_rect.xmin + round_fl_to_short((sv->vec.x - min[0]) * facx);
CLAMP(sv->vec.x, screen_rect.xmin, screen_rect.xmax - 1);
@ -207,7 +208,7 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *screen)
screen_geom_select_connected_edge(win, se);
/* all selected vertices get the right offset */
LISTBASE_FOREACH (ScrVert *, sv, &screen->vertbase) {
for (sv = screen->vertbase.first; sv; sv = sv->next) {
/* if is a collapsed area */
if (sv != area->v1 && sv != area->v4) {
if (sv->flag) {
@ -231,7 +232,7 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *screen)
screen_geom_select_connected_edge(win, se);
/* all selected vertices get the right offset */
LISTBASE_FOREACH (ScrVert *, sv, &screen->vertbase) {
for (sv = screen->vertbase.first; sv; sv = sv->next) {
/* if is not a collapsed area */
if (sv != area->v2 && sv != area->v3) {
if (sv->flag) {

View File

@ -692,9 +692,10 @@ static bool actionzone_area_poll(bContext *C)
if (screen && win && win->eventstate) {
const int *xy = &win->eventstate->x;
AZone *az;
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (AZone *, az, &area->actionzones) {
for (az = area->actionzones.first; az; az = az->next) {
if (BLI_rcti_isect_pt_v(&az->rect, xy)) {
return 1;
}
@ -3067,12 +3068,13 @@ static void SCREEN_OT_keyframe_jump(wmOperatorType *ot)
static int marker_jump_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
TimeMarker *marker;
int closest = CFRA;
const bool next = RNA_boolean_get(op->ptr, "next");
bool found = false;
/* find matching marker in the right direction */
LISTBASE_FOREACH (TimeMarker *, marker, &scene->markers) {
for (marker = scene->markers.first; marker; marker = marker->next) {
if (next) {
if ((marker->frame > CFRA) && (!found || closest > marker->frame)) {
closest = marker->frame;
@ -3168,9 +3170,8 @@ static int screen_maximize_area_exec(bContext *C, wmOperator *op)
/* search current screen for 'fullscreen' areas */
/* prevents restoring info header, when mouse is over it */
LISTBASE_FOREACH (ScrArea *, area_iter, &screen->areabase) {
if (area_iter->full) {
area = area_iter;
for (area = screen->areabase.first; area; area = area->next) {
if (area->full) {
break;
}
}
@ -3618,10 +3619,12 @@ static void SCREEN_OT_area_options(wmOperatorType *ot)
static int spacedata_cleanup_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
bScreen *screen;
ScrArea *area;
int tot = 0;
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
for (screen = bmain->screens.first; screen; screen = screen->id.next) {
for (area = screen->areabase.first; area; area = area->next) {
if (area->spacedata.first != area->spacedata.last) {
SpaceLink *sl = area->spacedata.first;
@ -3851,6 +3854,7 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
region->alignment = 0;
if (area->spacetype == SPACE_VIEW3D) {
ARegion *region_iter;
RegionView3D *rv3d = region->regiondata;
/* if this is a locked view, use settings from 'User' view */
@ -3874,7 +3878,7 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
rv3d->rflag |= RV3D_GPULIGHT_UPDATE;
/* Accumulate locks, in case they're mixed. */
LISTBASE_FOREACH (ARegion *, region_iter, &area->regionbase) {
for (region_iter = area->regionbase.first; region_iter; region_iter = region_iter->next) {
if (region_iter->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d_iter = region_iter->regiondata;
rv3d->viewlock_quad |= rv3d_iter->viewlock;
@ -4437,6 +4441,8 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
wmTimer *wt = screen->animtimer;
ScreenAnimData *sad = wt->customdata;
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *window;
ScrArea *area;
int sync;
double time;
@ -4582,11 +4588,12 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
ED_update_for_newframe(bmain, depsgraph);
}
LISTBASE_FOREACH (wmWindow *, window, &wm->windows) {
for (window = wm->windows.first; window; window = window->next) {
const bScreen *win_screen = WM_window_get_active_screen(window);
LISTBASE_FOREACH (ScrArea *, area, &win_screen->areabase) {
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
for (area = win_screen->areabase.first; area; area = area->next) {
ARegion *region;
for (region = area->regionbase.first; region; region = region->next) {
bool redraw = false;
if (region == sad->region) {
redraw = true;
@ -4860,9 +4867,8 @@ static int fullscreen_back_exec(bContext *C, wmOperator *op)
ScrArea *area = NULL;
/* search current screen for 'fullscreen' areas */
LISTBASE_FOREACH (ScrArea *, area_iter, &screen->areabase) {
for (area = screen->areabase.first; area; area = area->next) {
if (area->full) {
area = area_iter;
break;
}
}

View File

@ -409,7 +409,8 @@ static void workspace_add_menu(bContext *UNUSED(C), uiLayout *layout, void *temp
WorkspaceConfigFileData *builtin_config = workspace_system_file_read(app_template);
if (startup_config) {
LISTBASE_FOREACH (WorkSpace *, workspace, &startup_config->workspaces) {
for (WorkSpace *workspace = startup_config->workspaces.first; workspace;
workspace = workspace->id.next) {
uiLayout *row = uiLayoutRow(layout, false);
workspace_append_button(row, ot_append, workspace, startup_config->main);
has_startup_items = true;
@ -419,7 +420,8 @@ static void workspace_add_menu(bContext *UNUSED(C), uiLayout *layout, void *temp
if (builtin_config) {
bool has_title = false;
LISTBASE_FOREACH (WorkSpace *, workspace, &startup_config->workspaces) {
for (WorkSpace *workspace = builtin_config->workspaces.first; workspace;
workspace = workspace->id.next) {
if (startup_config &&
BLI_findstring(&startup_config->workspaces, workspace->id.name, offsetof(ID, name))) {
continue;

View File

@ -168,7 +168,8 @@ static bool workspace_change_find_new_layout_cb(const WorkSpaceLayout *layout, v
static bScreen *screen_fullscreen_find_associated_normal_screen(const Main *bmain, bScreen *screen)
{
LISTBASE_FOREACH (bScreen *, screen_iter, &bmain->screens) {
for (bScreen *screen_iter = bmain->screens.first; screen_iter;
screen_iter = screen_iter->id.next) {
if ((screen_iter != screen) && ELEM(screen_iter->state, SCREENMAXIMIZED, SCREENFULL)) {
ScrArea *area = screen_iter->areabase.first;
if (area && area->full == screen) {