diff options
author | Hans Goudey <h.goudey@me.com> | 2020-10-17 05:56:58 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-10-17 05:56:58 +0300 |
commit | e2c5439cb4eb423373750dae0dec8c5db3912b88 (patch) | |
tree | 44fa41d356e3b6963e7af82d7fff5241a279a9ab /source | |
parent | 20276e4b00a228ab2ef80e58cc0171cec811015a (diff) |
Cleanup: Reduce variable scope in screen directory
Also return early and use LISTBASE_FOREACH in a few places
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/screen/screen_context.c | 66 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_draw.c | 25 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 49 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_geometry.c | 33 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 262 | ||||
-rw-r--r-- | source/blender/editors/screen/screendump.c | 2 | ||||
-rw-r--r-- | source/blender/editors/screen/workspace_edit.c | 3 | ||||
-rw-r--r-- | source/blender/editors/screen/workspace_layout_edit.c | 18 |
8 files changed, 191 insertions, 267 deletions
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 0fa19f76fed..3924c334541 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -486,10 +486,9 @@ static eContextResult screen_ctx_active_pose_bone(const bContext *C, bContextDat wmWindow *win = CTX_wm_window(C); ViewLayer *view_layer = WM_window_get_active_view_layer(win); Object *obact = view_layer->basact ? view_layer->basact->object : NULL; - bPoseChannel *pchan; Object *obpose = BKE_object_pose_armature_get(obact); - pchan = BKE_pose_channel_active(obpose); + bPoseChannel *pchan = BKE_pose_channel_active(obpose); if (pchan) { CTX_data_pointer_set(result, &obpose->id, &RNA_PoseBone, pchan); return CTX_RESULT_OK; @@ -699,13 +698,11 @@ static eContextResult screen_ctx_gpencil_data_owner(const bContext *C, bContextD ScrArea *area = CTX_wm_area(C); ViewLayer *view_layer = WM_window_get_active_view_layer(win); Object *obact = view_layer->basact ? view_layer->basact->object : NULL; + /* Pointer to which data/datablock owns the reference to the Grease Pencil data being used * (as gpencil_data). */ - bGPdata **gpd_ptr = NULL; PointerRNA ptr; - - /* get pointer to Grease Pencil Data */ - gpd_ptr = ED_gpencil_data_get_pointers_direct(area, obact, &ptr); + bGPdata **gpd_ptr = ED_gpencil_data_get_pointers_direct(area, obact, &ptr); if (gpd_ptr) { CTX_data_pointer_set(result, ptr.owner_id, ptr.type, ptr.data); @@ -734,12 +731,10 @@ static eContextResult screen_ctx_annotation_data_owner(const bContext *C, bScreen *screen = CTX_wm_screen(C); ScrArea *area = CTX_wm_area(C); Scene *scene = WM_window_get_active_scene(win); + /* Pointer to which data/datablock owns the reference to the Grease Pencil data being used. */ - bGPdata **gpd_ptr = NULL; PointerRNA ptr; - - /* Get pointer to Grease Pencil Data. */ - gpd_ptr = ED_annotation_data_get_pointers_direct((ID *)screen, area, scene, &ptr); + bGPdata **gpd_ptr = ED_annotation_data_get_pointers_direct((ID *)screen, area, scene, &ptr); if (gpd_ptr) { CTX_data_pointer_set(result, ptr.owner_id, ptr.type, ptr.data); @@ -855,39 +850,40 @@ static eContextResult screen_ctx_editable_gpencil_strokes(const bContext *C, bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact); const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); - if (gpd) { - LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { - if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe)) { - bGPDframe *gpf; - bGPDframe *init_gpf = gpl->actframe; - if (is_multiedit) { - init_gpf = gpl->frames.first; - } + if (gpd == NULL) { + return CTX_RESULT_NO_DATA; + } - 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) { - 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) { - continue; - } + LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { + if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe)) { + bGPDframe *gpf; + bGPDframe *init_gpf = gpl->actframe; + if (is_multiedit) { + init_gpf = gpl->frames.first; + } - CTX_data_list_add(result, &gpd->id, &RNA_GPencilStroke, gps); + 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) { + 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) { + continue; } + + CTX_data_list_add(result, &gpd->id, &RNA_GPencilStroke, gps); } } - /* if not multiedit out of loop */ - if (!is_multiedit) { - break; - } + } + /* if not multiedit out of loop */ + if (!is_multiedit) { + break; } } } - CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); - return CTX_RESULT_OK; } - return CTX_RESULT_NO_DATA; + CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); + return CTX_RESULT_OK; } static eContextResult screen_ctx_active_operator(const bContext *C, bContextDataResult *result) { @@ -918,7 +914,6 @@ static eContextResult screen_ctx_sel_edit_fcurves_(const bContext *C, const int extra_filter) { bAnimContext ac; - if (ANIM_animdata_get_context(C, &ac) && ELEM(ac.spacetype, SPACE_ACTION, SPACE_GRAPH)) { ListBase anim_data = {NULL, NULL}; @@ -964,7 +959,6 @@ static eContextResult screen_ctx_active_editable_fcurve(const bContext *C, bContextDataResult *result) { bAnimContext ac; - if (ANIM_animdata_get_context(C, &ac) && ELEM(ac.spacetype, SPACE_GRAPH)) { ListBase anim_data = {NULL, NULL}; diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c index 8ded845b008..ddb1f5c87ba 100644 --- a/source/blender/editors/screen/screen_draw.c +++ b/source/blender/editors/screen/screen_draw.c @@ -45,10 +45,8 @@ static void draw_horizontal_join_shape(ScrArea *area, char dir, uint pos) { const float width = screen_geom_area_width(area) - 1; const float height = screen_geom_area_height(area) - 1; - vec2f points[10]; - short i; - float w, h; + float w, h; if (height < width) { h = height / 8; w = height / 4; @@ -58,6 +56,7 @@ static void draw_horizontal_join_shape(ScrArea *area, char dir, uint pos) w = width / 4; } + vec2f points[10]; points[0].x = area->v1->vec.x; points[0].y = area->v1->vec.y + height / 2; @@ -91,7 +90,7 @@ static void draw_horizontal_join_shape(ScrArea *area, char dir, uint pos) if (dir == 'l') { /* when direction is left, then we flip direction of arrow */ float cx = area->v1->vec.x + width; - for (i = 0; i < 10; i++) { + for (int i = 0; i < 10; i++) { points[i].x -= cx; points[i].x = -points[i].x; points[i].x += area->v1->vec.x; @@ -100,7 +99,7 @@ static void draw_horizontal_join_shape(ScrArea *area, char dir, uint pos) immBegin(GPU_PRIM_TRI_FAN, 5); - for (i = 0; i < 5; i++) { + for (int i = 0; i < 5; i++) { immVertex2f(pos, points[i].x, points[i].y); } @@ -108,7 +107,7 @@ static void draw_horizontal_join_shape(ScrArea *area, char dir, uint pos) immBegin(GPU_PRIM_TRI_FAN, 5); - for (i = 4; i < 8; i++) { + for (int i = 4; i < 8; i++) { immVertex2f(pos, points[i].x, points[i].y); } @@ -126,10 +125,8 @@ static void draw_vertical_join_shape(ScrArea *area, char dir, uint pos) { const float width = screen_geom_area_width(area) - 1; const float height = screen_geom_area_height(area) - 1; - vec2f points[10]; - short i; - float w, h; + float w, h; if (height < width) { h = height / 4; w = height / 8; @@ -139,6 +136,7 @@ static void draw_vertical_join_shape(ScrArea *area, char dir, uint pos) w = width / 8; } + vec2f points[10]; points[0].x = area->v1->vec.x + width / 2; points[0].y = area->v3->vec.y; @@ -172,7 +170,7 @@ static void draw_vertical_join_shape(ScrArea *area, char dir, uint pos) if (dir == 'u') { /* when direction is up, then we flip direction of arrow */ float cy = area->v1->vec.y + height; - for (i = 0; i < 10; i++) { + for (int i = 0; i < 10; i++) { points[i].y -= cy; points[i].y = -points[i].y; points[i].y += area->v1->vec.y; @@ -181,7 +179,7 @@ static void draw_vertical_join_shape(ScrArea *area, char dir, uint pos) immBegin(GPU_PRIM_TRI_FAN, 5); - for (i = 0; i < 5; i++) { + for (int i = 0; i < 5; i++) { immVertex2f(pos, points[i].x, points[i].y); } @@ -189,7 +187,7 @@ static void draw_vertical_join_shape(ScrArea *area, char dir, uint pos) immBegin(GPU_PRIM_TRI_FAN, 5); - for (i = 4; i < 8; i++) { + for (int i = 4; i < 8; i++) { immVertex2f(pos, points[i].x, points[i].y); } @@ -217,12 +215,13 @@ static void draw_join_shape(ScrArea *area, char dir, uint pos) static void do_vert_pair(GPUVertBuf *vbo, uint pos, uint *vidx, int corner, int i) { - float inter[2], exter[2]; + float inter[2]; inter[0] = cosf(corner * M_PI_2 + (i * M_PI_2 / (CORNER_RESOLUTION - 1.0f))); inter[1] = sinf(corner * M_PI_2 + (i * M_PI_2 / (CORNER_RESOLUTION - 1.0f))); /* Snap point to edge */ float div = 1.0f / max_ff(fabsf(inter[0]), fabsf(inter[1])); + float exter[2]; mul_v2_v2fl(exter, inter, div); exter[0] = roundf(exter[0]); exter[1] = roundf(exter[1]); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index ee8dacd28fc..5f56bbaef9d 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -108,17 +108,15 @@ ScrArea *area_split( const wmWindow *win, bScreen *screen, ScrArea *area, char dir, float fac, int merge) { ScrArea *newa = NULL; - ScrVert *sv1, *sv2; - short split; - rcti window_rect; if (area == NULL) { return NULL; } + rcti window_rect; WM_window_rect_calc(win, &window_rect); - split = screen_geom_find_area_split_point(area, &window_rect, dir, fac); + short split = screen_geom_find_area_split_point(area, &window_rect, dir, fac); if (split == 0) { return NULL; } @@ -129,8 +127,8 @@ ScrArea *area_split( if (dir == 'h') { /* new vertices */ - sv1 = screen_geom_vertex_add(screen, area->v1->vec.x, split); - sv2 = screen_geom_vertex_add(screen, area->v4->vec.x, split); + ScrVert *sv1 = screen_geom_vertex_add(screen, area->v1->vec.x, split); + ScrVert *sv2 = screen_geom_vertex_add(screen, area->v4->vec.x, split); /* new edges */ screen_geom_edge_add(screen, area->v1, sv1); @@ -160,8 +158,8 @@ ScrArea *area_split( } else { /* new vertices */ - sv1 = screen_geom_vertex_add(screen, split, area->v1->vec.y); - sv2 = screen_geom_vertex_add(screen, split, area->v2->vec.y); + ScrVert *sv1 = screen_geom_vertex_add(screen, split, area->v1->vec.y); + ScrVert *sv2 = screen_geom_vertex_add(screen, split, area->v2->vec.y); /* new edges */ screen_geom_edge_add(screen, area->v1, sv1); @@ -205,17 +203,14 @@ ScrArea *area_split( */ bScreen *screen_add(Main *bmain, const char *name, const rcti *rect) { - bScreen *screen; - ScrVert *sv1, *sv2, *sv3, *sv4; - - screen = BKE_libblock_alloc(bmain, ID_SCR, name, 0); + bScreen *screen = BKE_libblock_alloc(bmain, ID_SCR, name, 0); screen->do_refresh = true; screen->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN; - sv1 = screen_geom_vertex_add(screen, rect->xmin, rect->ymin); - sv2 = screen_geom_vertex_add(screen, rect->xmin, rect->ymax - 1); - sv3 = screen_geom_vertex_add(screen, rect->xmax - 1, rect->ymax - 1); - sv4 = screen_geom_vertex_add(screen, rect->xmax - 1, rect->ymin); + ScrVert *sv1 = screen_geom_vertex_add(screen, rect->xmin, rect->ymin); + ScrVert *sv2 = screen_geom_vertex_add(screen, rect->xmin, rect->ymax - 1); + ScrVert *sv3 = screen_geom_vertex_add(screen, rect->xmax - 1, rect->ymax - 1); + ScrVert *sv4 = screen_geom_vertex_add(screen, rect->xmax - 1, rect->ymin); screen_geom_edge_add(screen, sv1, sv2); screen_geom_edge_add(screen, sv2, sv3); @@ -230,9 +225,6 @@ bScreen *screen_add(Main *bmain, const char *name, const rcti *rect) void screen_data_copy(bScreen *to, bScreen *from) { - ScrVert *s2; - ScrArea *area, *saf; - /* free contents of 'to', is from blenkernel screen.c */ BKE_screen_free(to); @@ -243,7 +235,7 @@ void screen_data_copy(bScreen *to, bScreen *from) BLI_duplicatelist(&to->areabase, &from->areabase); BLI_listbase_clear(&to->regionbase); - s2 = to->vertbase.first; + ScrVert *s2 = to->vertbase.first; for (ScrVert *s1 = from->vertbase.first; s1; s1 = s1->next, s2 = s2->next) { s1->newv = s2; } @@ -254,8 +246,8 @@ void screen_data_copy(bScreen *to, bScreen *from) BKE_screen_sort_scrvert(&(se->v1), &(se->v2)); } - saf = from->areabase.first; - for (area = to->areabase.first; area; area = area->next, saf = saf->next) { + ScrArea *from_area = from->areabase.first; + LISTBASE_FOREACH (ScrArea *, area, &to->areabase) { area->v1 = area->v1->newv; area->v2 = area->v2->newv; area->v3 = area->v3->newv; @@ -266,7 +258,9 @@ void screen_data_copy(bScreen *to, bScreen *from) BLI_listbase_clear(&area->actionzones); BLI_listbase_clear(&area->handlers); - ED_area_data_copy(area, saf, true); + ED_area_data_copy(area, from_area, true); + + from_area = from_area->next; } /* put at zero (needed?) */ @@ -1232,7 +1226,6 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const Main *bmain = CTX_data_main(C); wmWindowManager *wm = CTX_wm_manager(C); WorkSpace *workspace = WM_window_get_active_workspace(win); - bScreen *screen, *oldscreen; if (area) { /* ensure we don't have a button active anymore, can crash when @@ -1251,12 +1244,12 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const ED_area_status_text(area, NULL); ED_workspace_status_text(C, NULL); } - + bScreen *screen; if (area && area->full) { WorkSpaceLayout *layout_old = WM_window_get_active_layout(win); /* restoring back to SCREENNORMAL */ - screen = area->full; /* the old screen to restore */ - oldscreen = WM_window_get_active_screen(win); /* the one disappearing */ + screen = area->full; /* the old screen to restore */ + bScreen *oldscreen = WM_window_get_active_screen(win); /* the one disappearing */ BLI_assert(BKE_workspace_layout_screen_get(layout_old) != screen); BLI_assert(BKE_workspace_layout_screen_get(layout_old)->state != SCREENNORMAL); @@ -1321,7 +1314,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const BLI_assert(ELEM(state, SCREENMAXIMIZED, SCREENFULL)); - oldscreen = WM_window_get_active_screen(win); + bScreen *oldscreen = WM_window_get_active_screen(win); oldscreen->state = state; BLI_snprintf(newname, sizeof(newname), "%s-%s", oldscreen->id.name + 2, "nonnormal"); diff --git a/source/blender/editors/screen/screen_geometry.c b/source/blender/editors/screen/screen_geometry.c index 50bfd6619e6..4acf3dd7ba5 100644 --- a/source/blender/editors/screen/screen_geometry.c +++ b/source/blender/editors/screen/screen_geometry.c @@ -132,10 +132,9 @@ ScrEdge *screen_geom_find_active_scredge(const wmWindow *win, { /* Use layout size (screen excluding global areas) for screen-layout area edges */ rcti screen_rect; - ScrEdge *se; - WM_window_screen_rect_calc(win, &screen_rect); - se = screen_geom_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(screen), &screen_rect, mx, my); + ScrEdge *se = screen_geom_area_map_find_active_scredge( + AREAMAP_FROM_SCREEN(screen), &screen_rect, mx, my); if (!se) { /* Use entire window size (screen including global areas) for global area edges */ @@ -157,21 +156,19 @@ static bool screen_geom_vertices_scale_pass(const wmWindow *win, const int screen_size_x = BLI_rcti_size_x(screen_rect); const int screen_size_y = BLI_rcti_size_y(screen_rect); - int screen_size_x_prev, screen_size_y_prev; - float min[2], max[2]; bool needs_another_pass = false; /* calculate size */ - min[0] = min[1] = 20000.0f; - max[0] = max[1] = 0.0f; + float min[2] = {20000.0f, 20000.0f}; + float max[2] = {0.0f, 0.0f}; LISTBASE_FOREACH (ScrVert *, sv, &screen->vertbase) { const float fv[2] = {(float)sv->vec.x, (float)sv->vec.y}; minmax_v2v2_v2(min, max, fv); } - screen_size_x_prev = (max[0] - min[0]) + 1; - screen_size_y_prev = (max[1] - min[1]) + 1; + int screen_size_x_prev = (max[0] - min[0]) + 1; + int screen_size_y_prev = (max[1] - min[1]) + 1; if (screen_size_x_prev != screen_size_x || screen_size_y_prev != screen_size_y) { const float facx = ((float)screen_size_x - 1) / ((float)screen_size_x_prev - 1); @@ -258,7 +255,6 @@ static bool screen_geom_vertices_scale_pass(const wmWindow *win, void screen_geom_vertices_scale(const wmWindow *win, bScreen *screen) { rcti window_rect, screen_rect; - WM_window_rect_calc(win, &window_rect); WM_window_screen_rect_calc(win, &screen_rect); @@ -311,12 +307,10 @@ short screen_geom_find_area_split_point(const ScrArea *area, char dir, float fac) { - short x, y; const int cur_area_width = screen_geom_area_width(area); const int cur_area_height = screen_geom_area_height(area); const short area_min_x = AREAMINX; const short area_min_y = ED_area_headersize(); - int area_min; /* area big enough? */ if ((dir == 'v') && (cur_area_width <= 2 * area_min_x)) { @@ -330,9 +324,9 @@ short screen_geom_find_area_split_point(const ScrArea *area, CLAMP(fac, 0.0f, 1.0f); if (dir == 'h') { - y = area->v1->vec.y + round_fl_to_short(fac * cur_area_height); + short y = area->v1->vec.y + round_fl_to_short(fac * cur_area_height); - area_min = area_min_y; + int area_min = area_min_y; if (area->v1->vec.y > window_rect->ymin) { area_min += U.pixelsize; @@ -351,9 +345,9 @@ short screen_geom_find_area_split_point(const ScrArea *area, return y; } - x = area->v1->vec.x + round_fl_to_short(fac * cur_area_width); + short x = area->v1->vec.x + round_fl_to_short(fac * cur_area_width); - area_min = area_min_x; + int area_min = area_min_x; if (area->v1->vec.x > window_rect->xmin) { area_min += U.pixelsize; @@ -378,12 +372,9 @@ short screen_geom_find_area_split_point(const ScrArea *area, void screen_geom_select_connected_edge(const wmWindow *win, ScrEdge *edge) { bScreen *screen = WM_window_get_active_screen(win); - bool oneselected = true; - char dir; - /* select connected, only in the right direction */ /* 'dir' is the direction of EDGE */ - + char dir; if (edge->v1->vec.x == edge->v2->vec.x) { dir = 'v'; } @@ -399,6 +390,8 @@ void screen_geom_select_connected_edge(const wmWindow *win, ScrEdge *edge) edge->v1->flag = 1; edge->v2->flag = 1; + /* select connected, only in the right direction */ + bool oneselected = true; while (oneselected) { oneselected = false; LISTBASE_FOREACH (ScrEdge *, se, &screen->edgebase) { diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 6d5580f58ea..8fc2bf96639 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -159,11 +159,10 @@ static bool ED_operator_screenactive_norender(bContext *C) /* when mouse is over area-edge */ bool ED_operator_screen_mainwinactive(bContext *C) { - bScreen *screen; if (CTX_wm_window(C) == NULL) { return false; } - screen = CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); if (screen == NULL) { return false; } @@ -448,8 +447,8 @@ bool ED_operator_posemode_exclusive(bContext *C) Object *obact = CTX_data_active_object(C); if (obact && !(obact->mode & OB_MODE_EDIT)) { - Object *obpose; - if ((obpose = BKE_object_pose_armature_get(obact))) { + Object *obpose = BKE_object_pose_armature_get(obact); + if (obpose != NULL) { if (obact == obpose) { return true; } @@ -479,8 +478,8 @@ bool ED_operator_posemode(bContext *C) Object *obact = CTX_data_active_object(C); if (obact && !(obact->mode & OB_MODE_EDIT)) { - Object *obpose; - if ((obpose = BKE_object_pose_armature_get(obact))) { + Object *obpose = BKE_object_pose_armature_get(obact); + if (obpose != NULL) { if ((obact == obpose) || (obact->mode & OB_MODE_ALL_WEIGHT_PAINT)) { return true; } @@ -958,12 +957,12 @@ static void actionzone_exit(wmOperator *op) /* send EVT_ACTIONZONE event */ static void actionzone_apply(bContext *C, wmOperator *op, int type) { - wmEvent event; wmWindow *win = CTX_wm_window(C); sActionzoneData *sad = op->customdata; sad->modifier = RNA_int_get(op->ptr, "modifier"); + wmEvent event; wm_event_init_from_window(win, &event); if (type == AZONE_AREA) { @@ -988,7 +987,6 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event) { bScreen *screen = CTX_wm_screen(C); AZone *az = screen_actionzone_find_xy(screen, &event->x); - sActionzoneData *sad; /* Quick escape - Scroll azones only hide/unhide the scroll-bars, * they have their own handling. */ @@ -997,7 +995,7 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event) } /* ok we do the action-zone */ - sad = op->customdata = MEM_callocN(sizeof(sActionzoneData), "sActionzoneData"); + sActionzoneData *sad = op->customdata = MEM_callocN(sizeof(sActionzoneData), "sActionzoneData"); sad->sa1 = screen_actionzone_area(screen, az); sad->az = az; sad->x = event->x; @@ -1025,8 +1023,6 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event) switch (event->type) { case MOUSEMOVE: { - bool is_gesture; - const int delta_x = (event->x - sad->x); const int delta_y = (event->y - sad->y); @@ -1052,10 +1048,11 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event) sad->gesture_dir = 'w'; } + bool is_gesture; if (sad->az->type == AZONE_AREA) { wmWindow *win = CTX_wm_window(C); - rcti screen_rect; + rcti screen_rect; WM_window_screen_rect_calc(win, &screen_rect); /* Have we dragged off the zone and are not on an edge? */ @@ -1154,10 +1151,9 @@ static ScrEdge *screen_area_edge_from_cursor(const bContext *C, { wmWindow *win = CTX_wm_window(C); bScreen *screen = CTX_wm_screen(C); - ScrEdge *actedge; rcti window_rect; WM_window_rect_calc(win, &window_rect); - actedge = screen_geom_area_map_find_active_scredge( + ScrEdge *actedge = screen_geom_area_map_find_active_scredge( AREAMAP_FROM_SCREEN(screen), &window_rect, cursor[0], cursor[1]); *r_sa1 = NULL; *r_sa2 = NULL; @@ -1215,14 +1211,13 @@ typedef struct sAreaSwapData { static bool area_swap_init(wmOperator *op, const wmEvent *event) { - sAreaSwapData *sd = NULL; sActionzoneData *sad = event->customdata; if (sad == NULL || sad->sa1 == NULL) { return false; } - sd = MEM_callocN(sizeof(sAreaSwapData), "sAreaSwapData"); + sAreaSwapData *sd = MEM_callocN(sizeof(sAreaSwapData), "sAreaSwapData"); sd->sa1 = sad->sa1; sd->sa2 = sad->sa2; op->customdata = sd; @@ -1337,18 +1332,12 @@ static void SCREEN_OT_area_swap(wmOperatorType *ot) static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event) { Main *bmain = CTX_data_main(C); - wmWindow *newwin, *win = CTX_wm_window(C); - Scene *scene; + wmWindow *win = CTX_wm_window(C); WorkSpace *workspace = WM_window_get_active_workspace(win); WorkSpaceLayout *layout_old = WM_window_get_active_layout(win); - WorkSpaceLayout *layout_new; - bScreen *newsc; - ScrArea *area; - rcti rect; - win = CTX_wm_window(C); - scene = CTX_data_scene(C); - area = CTX_wm_area(C); + Scene *scene = CTX_data_scene(C); + ScrArea *area = CTX_wm_area(C); /* XXX hrmf! */ if (event->type == EVT_ACTIONZONE_AREA) { @@ -1362,12 +1351,12 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event) } /* adds window to WM */ - rect = area->totrct; + rcti rect = area->totrct; BLI_rcti_translate(&rect, win->posx, win->posy); rect.xmax = rect.xmin + BLI_rcti_size_x(&rect) / U.pixelsize; rect.ymax = rect.ymin + BLI_rcti_size_y(&rect) / U.pixelsize; - newwin = WM_window_open(C, &rect); + wmWindow *newwin = WM_window_open(C, &rect); if (newwin == NULL) { BKE_report(op->reports, RPT_ERROR, "Failed to open window!"); goto finally; @@ -1381,9 +1370,9 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event) BKE_workspace_active_set(newwin->workspace_hook, workspace); /* allocs new screen and adds to newly created window, using window size */ - layout_new = ED_workspace_layout_add( + WorkSpaceLayout *layout_new = ED_workspace_layout_add( bmain, workspace, newwin, BKE_workspace_layout_name_get(layout_old)); - newsc = BKE_workspace_layout_screen_get(layout_new); + bScreen *newsc = BKE_workspace_layout_screen_get(layout_new); WM_window_set_active_layout(newwin, workspace, layout_new); /* copy area to new screen */ @@ -1475,10 +1464,6 @@ static void area_move_set_limits(wmWindow *win, int *smaller, bool *use_bigger_smaller_snap) { - rcti window_rect; - int areaminy = ED_area_headersize(); - int areamin; - /* we check all areas and test for free space with MINSIZE */ *bigger = *smaller = 100000; @@ -1523,12 +1508,12 @@ static void area_move_set_limits(wmWindow *win, } } + rcti window_rect; WM_window_rect_calc(win, &window_rect); LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (dir == 'h') { - int y1; - areamin = areaminy; + int areamin = ED_area_headersize(); if (area->v1->vec.y > window_rect.ymin) { areamin += U.pixelsize; @@ -1537,7 +1522,7 @@ static void area_move_set_limits(wmWindow *win, areamin += U.pixelsize; } - y1 = screen_geom_area_height(area) - areamin; + int y1 = screen_geom_area_height(area) - areamin; /* if top or down edge selected, test height */ if (area->v1->editflag && area->v4->editflag) { @@ -1548,8 +1533,7 @@ static void area_move_set_limits(wmWindow *win, } } else { - int x1; - areamin = AREAMINX; + int areamin = AREAMINX; if (area->v1->vec.x > window_rect.xmin) { areamin += U.pixelsize; @@ -1558,7 +1542,7 @@ static void area_move_set_limits(wmWindow *win, areamin += U.pixelsize; } - x1 = screen_geom_area_width(area) - areamin; + int x1 = screen_geom_area_width(area) - areamin; /* if left or right edge selected, test width */ if (area->v1->editflag && area->v2->editflag) { @@ -1577,21 +1561,18 @@ static bool area_move_init(bContext *C, wmOperator *op) { bScreen *screen = CTX_wm_screen(C); wmWindow *win = CTX_wm_window(C); - ScrEdge *actedge; - sAreaMoveData *md; - int x, y; /* required properties */ - x = RNA_int_get(op->ptr, "x"); - y = RNA_int_get(op->ptr, "y"); + int x = RNA_int_get(op->ptr, "x"); + int y = RNA_int_get(op->ptr, "y"); /* setup */ - actedge = screen_geom_find_active_scredge(win, screen, x, y); + ScrEdge *actedge = screen_geom_find_active_scredge(win, screen, x, y); if (actedge == NULL) { return false; } - md = MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData"); + sAreaMoveData *md = MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData"); op->customdata = md; md->dir = screen_geom_edge_is_horizontal(actedge) ? 'h' : 'v'; @@ -1850,15 +1831,14 @@ static void area_move_cancel(bContext *C, wmOperator *op) static int area_move_modal(bContext *C, wmOperator *op, const wmEvent *event) { sAreaMoveData *md = op->customdata; - int delta, x, y; /* execute the events */ switch (event->type) { case MOUSEMOVE: { - x = RNA_int_get(op->ptr, "x"); - y = RNA_int_get(op->ptr, "y"); + int x = RNA_int_get(op->ptr, "x"); + int y = RNA_int_get(op->ptr, "y"); - delta = (md->dir == 'v') ? event->x - x : event->y - y; + int delta = (md->dir == 'v') ? event->x - x : event->y - y; RNA_int_set(op->ptr, "delta", delta); area_move_apply(C, op); @@ -1986,10 +1966,8 @@ static void area_split_draw_cb(const struct wmWindow *UNUSED(win), void *userdat /* generic init, menu case, doesn't need active area */ static bool area_split_menu_init(bContext *C, wmOperator *op) { - sAreaSplitData *sd; - /* custom data */ - sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split"); + sAreaSplitData *sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split"); op->customdata = sd; sd->sarea = CTX_wm_area(C); @@ -2001,9 +1979,6 @@ static bool area_split_menu_init(bContext *C, wmOperator *op) static bool area_split_init(bContext *C, wmOperator *op) { ScrArea *area = CTX_wm_area(C); - sAreaSplitData *sd; - int areaminy = ED_area_headersize(); - int dir; /* required context */ if (area == NULL) { @@ -2011,18 +1986,18 @@ static bool area_split_init(bContext *C, wmOperator *op) } /* required properties */ - dir = RNA_enum_get(op->ptr, "direction"); + int dir = RNA_enum_get(op->ptr, "direction"); /* minimal size */ if (dir == 'v' && area->winx < 2 * AREAMINX) { return false; } - if (dir == 'h' && area->winy < 2 * areaminy) { + if (dir == 'h' && area->winy < 2 * ED_area_headersize()) { return false; } /* custom data */ - sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split"); + sAreaSplitData *sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split"); op->customdata = sd; sd->sarea = area; @@ -2073,44 +2048,42 @@ static bool area_split_apply(bContext *C, wmOperator *op) const wmWindow *win = CTX_wm_window(C); bScreen *screen = CTX_wm_screen(C); sAreaSplitData *sd = (sAreaSplitData *)op->customdata; - float fac; - int dir; - fac = RNA_float_get(op->ptr, "factor"); - dir = RNA_enum_get(op->ptr, "direction"); + float fac = RNA_float_get(op->ptr, "factor"); + int dir = RNA_enum_get(op->ptr, "direction"); sd->narea = area_split(win, screen, sd->sarea, dir, fac, 0); /* 0 = no merge */ - if (sd->narea) { - sd->nedge = area_findsharededge(screen, sd->sarea, sd->narea); + if (sd->narea == NULL) { + return false; + } - /* select newly created edge, prepare for moving edge */ - ED_screen_verts_iter(win, screen, sv) - { - sv->editflag = 0; - } + sd->nedge = area_findsharededge(screen, sd->sarea, sd->narea); - sd->nedge->v1->editflag = 1; - sd->nedge->v2->editflag = 1; + /* select newly created edge, prepare for moving edge */ + ED_screen_verts_iter(win, screen, sv) + { + sv->editflag = 0; + } - if (dir == 'h') { - sd->origval = sd->nedge->v1->vec.y; - } - else { - sd->origval = sd->nedge->v1->vec.x; - } + sd->nedge->v1->editflag = 1; + sd->nedge->v2->editflag = 1; - ED_area_tag_redraw(sd->sarea); - ED_area_tag_redraw(sd->narea); + if (dir == 'h') { + sd->origval = sd->nedge->v1->vec.y; + } + else { + sd->origval = sd->nedge->v1->vec.x; + } - WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); - /* Update preview thumbnail */ - BKE_icon_changed(screen->id.icon_id); + ED_area_tag_redraw(sd->sarea); + ED_area_tag_redraw(sd->narea); - return true; - } + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); + /* Update preview thumbnail */ + BKE_icon_changed(screen->id.icon_id); - return false; + return true; } static void area_split_exit(bContext *C, wmOperator *op) @@ -2154,8 +2127,6 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event) { wmWindow *win = CTX_wm_window(C); bScreen *screen = CTX_wm_screen(C); - sAreaSplitData *sd; - int dir; /* no full window splitting allowed */ BLI_assert(screen->state == SCREENNORMAL); @@ -2164,6 +2135,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event) PropertyRNA *prop_factor = RNA_struct_find_property(op->ptr, "factor"); PropertyRNA *prop_cursor = RNA_struct_find_property(op->ptr, "cursor"); + int dir; if (event->type == EVT_ACTIONZONE_AREA) { sActionzoneData *sad = event->customdata; @@ -2233,8 +2205,6 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event) } } else { - ScrEdge *actedge; - rcti window_rect; int event_co[2]; /* retrieve initial mouse coord, so we can find the active edge */ @@ -2245,9 +2215,10 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event) copy_v2_v2_int(event_co, &event->x); } + rcti window_rect; WM_window_rect_calc(win, &window_rect); - actedge = screen_geom_area_map_find_active_scredge( + ScrEdge *actedge = screen_geom_area_map_find_active_scredge( AREAMAP_FROM_SCREEN(screen), &window_rect, event_co[0], event_co[1]); if (actedge == NULL) { return OPERATOR_CANCELLED; @@ -2263,10 +2234,9 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event) } } - sd = (sAreaSplitData *)op->customdata; + sAreaSplitData *sd = (sAreaSplitData *)op->customdata; if (event->type == EVT_ACTIONZONE_AREA) { - /* do the split */ if (area_split_apply(C, op)) { area_move_set_limits(win, screen, dir, &sd->bigger, &sd->smaller, NULL); @@ -2294,7 +2264,6 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* function to be called outside UI context, or for redo */ static int area_split_exec(bContext *C, wmOperator *op) { - if (!area_split_init(C, op)) { return OPERATOR_CANCELLED; } @@ -2565,14 +2534,13 @@ static void region_scale_exit(wmOperator *op) static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event) { sActionzoneData *sad = event->customdata; - AZone *az; if (event->type != EVT_ACTIONZONE_REGION) { BKE_report(op->reports, RPT_ERROR, "Can only scale region size from an action zone"); return OPERATOR_CANCELLED; } - az = sad->az; + AZone *az = sad->az; if (az->region) { RegionMoveData *rmd = MEM_callocN(sizeof(RegionMoveData), "RegionMoveData"); @@ -2853,9 +2821,8 @@ static void areas_do_frame_follow(bContext *C, bool middle) static int frame_offset_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - int delta; - delta = RNA_int_get(op->ptr, "delta"); + int delta = RNA_int_get(op->ptr, "delta"); CFRA += delta; FRAMENUMBER_MIN_CLAMP(CFRA); @@ -2960,9 +2927,6 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); bDopeSheet ads = {NULL}; - DLRBT_Tree keys; - ActKeyColumn *ak; - float cfra; const bool next = RNA_boolean_get(op->ptr, "next"); bool done = false; @@ -2971,9 +2935,10 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - cfra = (float)(CFRA); + float cfra = (float)(CFRA); /* init binarytree-list for getting keyframes */ + DLRBT_Tree keys; BLI_dlrbTree_init(&keys); /* seed up dummy dopesheet context with flags to perform necessary filtering */ @@ -3003,6 +2968,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op) } /* find matching keyframe in the right direction */ + ActKeyColumn *ak; if (next) { ak = (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &cfra); } @@ -3355,7 +3321,6 @@ static int area_join_exec(bContext *C, wmOperator *op) /* interaction callback */ static int area_join_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - if (event->type == EVT_ACTIONZONE_AREA) { sActionzoneData *sad = event->customdata; @@ -3395,14 +3360,13 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event) { bScreen *screen = CTX_wm_screen(C); wmWindow *win = CTX_wm_window(C); - sAreaJoinData *jd; if (op->customdata == NULL) { if (!area_join_init(C, op, NULL, NULL)) { return OPERATOR_CANCELLED; } } - jd = (sAreaJoinData *)op->customdata; + sAreaJoinData *jd = (sAreaJoinData *)op->customdata; /* execute the events */ switch (event->type) { @@ -3524,20 +3488,16 @@ static void SCREEN_OT_area_join(wmOperatorType *ot) static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - uiPopupMenu *pup; - uiLayout *layout; - PointerRNA ptr; - ScrArea *sa1, *sa2; - if (screen_area_edge_from_cursor(C, &event->x, &sa1, &sa2) == NULL) { return OPERATOR_CANCELLED; } - pup = UI_popup_menu_begin(C, WM_operatortype_name(op->type, op->ptr), ICON_NONE); - layout = UI_popup_menu_layout(pup); + uiPopupMenu *pup = UI_popup_menu_begin(C, WM_operatortype_name(op->type, op->ptr), ICON_NONE); + uiLayout *layout = UI_popup_menu_layout(pup); /* Vertical Split */ + PointerRNA ptr; uiItemFullO(layout, "SCREEN_OT_area_split", IFACE_("Vertical Split"), @@ -3712,19 +3672,17 @@ static void SCREEN_OT_repeat_last(wmOperatorType *ot) static int repeat_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { wmWindowManager *wm = CTX_wm_manager(C); - wmOperator *lastop; - uiPopupMenu *pup; - uiLayout *layout; - int items, i; - items = BLI_listbase_count(&wm->operators); + int items = BLI_listbase_count(&wm->operators); if (items == 0) { return OPERATOR_CANCELLED; } - pup = UI_popup_menu_begin(C, WM_operatortype_name(op->type, op->ptr), ICON_NONE); - layout = UI_popup_menu_layout(pup); + uiPopupMenu *pup = UI_popup_menu_begin(C, WM_operatortype_name(op->type, op->ptr), ICON_NONE); + uiLayout *layout = UI_popup_menu_layout(pup); + wmOperator *lastop; + int i; for (i = items - 1, lastop = wm->operators.last; lastop; lastop = lastop->prev, i--) { if ((lastop->type->flag & OPTYPE_REGISTER) && WM_operator_repeat_check(C, lastop)) { uiItemIntO(layout, @@ -3850,7 +3808,6 @@ static int region_quadview_exec(bContext *C, wmOperator *op) else if (region->alignment == RGN_ALIGN_QSPLIT) { /* Exit quad-view */ ScrArea *area = CTX_wm_area(C); - ARegion *arn; /* keep current region */ region->alignment = 0; @@ -3887,10 +3844,9 @@ static int region_quadview_exec(bContext *C, wmOperator *op) } } - for (region = area->regionbase.first; region; region = arn) { - arn = region->next; - if (region->alignment == RGN_ALIGN_QSPLIT) { - ED_region_remove(C, area, region); + LISTBASE_FOREACH_MUTABLE (ARegion *, region_iter, &area->regionbase) { + if (region_iter->alignment == RGN_ALIGN_QSPLIT) { + ED_region_remove(C, area, region_iter); } } ED_area_tag_redraw(area); @@ -3902,14 +3858,12 @@ static int region_quadview_exec(bContext *C, wmOperator *op) else { /* Enter quad-view */ ScrArea *area = CTX_wm_area(C); - ARegion *newar; - int count; region->alignment = RGN_ALIGN_QSPLIT; - for (count = 0; count < 3; count++) { - newar = BKE_area_region_copy(area->type, region); - BLI_addtail(&area->regionbase, newar); + for (int count = 0; count < 3; count++) { + ARegion *new_region = BKE_area_region_copy(area->type, region); + BLI_addtail(&area->regionbase, new_region); } /* lock views and set them */ @@ -3981,8 +3935,8 @@ static void SCREEN_OT_region_quadview(wmOperatorType *ot) static int region_toggle_exec(bContext *C, wmOperator *op) { PropertyRNA *prop = RNA_struct_find_property(op->ptr, "region_type"); - ARegion *region; + ARegion *region; if (RNA_property_is_set(op->ptr, prop)) { region = BKE_area_find_region_type(CTX_wm_area(C), RNA_property_enum_get(op->ptr, prop)); } @@ -4235,32 +4189,30 @@ static int screen_context_menu_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) { - uiPopupMenu *pup; - uiLayout *layout; const ScrArea *area = CTX_wm_area(C); const ARegion *region = CTX_wm_region(C); if (area && area->spacetype == SPACE_STATUSBAR) { - pup = UI_popup_menu_begin(C, IFACE_("Status Bar"), ICON_NONE); - layout = UI_popup_menu_layout(pup); + uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Status Bar"), ICON_NONE); + uiLayout *layout = UI_popup_menu_layout(pup); ed_screens_statusbar_menu_create(layout, NULL); UI_popup_menu_end(C, pup); } else if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) { - pup = UI_popup_menu_begin(C, IFACE_("Header"), ICON_NONE); - layout = UI_popup_menu_layout(pup); + uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Header"), ICON_NONE); + uiLayout *layout = UI_popup_menu_layout(pup); ED_screens_header_tools_menu_create(C, layout, NULL); UI_popup_menu_end(C, pup); } else if (region->regiontype == RGN_TYPE_FOOTER) { - pup = UI_popup_menu_begin(C, IFACE_("Footer"), ICON_NONE); - layout = UI_popup_menu_layout(pup); + uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Footer"), ICON_NONE); + uiLayout *layout = UI_popup_menu_layout(pup); ED_screens_footer_tools_menu_create(C, layout, NULL); UI_popup_menu_end(C, pup); } else if (region->regiontype == RGN_TYPE_NAV_BAR) { - pup = UI_popup_menu_begin(C, IFACE_("Navigation Bar"), ICON_NONE); - layout = UI_popup_menu_layout(pup); + uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Navigation Bar"), ICON_NONE); + uiLayout *layout = UI_popup_menu_layout(pup); ED_screens_navigation_bar_tools_menu_create(C, layout, NULL); UI_popup_menu_end(C, pup); } @@ -4953,10 +4905,6 @@ static int drivers_editor_show_exec(bContext *C, wmOperator *op) wmWindow *win_cur = CTX_wm_window(C); /* Use eventstate, not event from _invoke, so this can be called through exec(). */ const wmEvent *event = win_cur->eventstate; - PointerRNA ptr = {NULL}; - PropertyRNA *prop = NULL; - int index = -1; - uiBut *but = NULL; int sizex = 900 * UI_DPI_FAC; int sizey = 580 * UI_DPI_FAC; @@ -4965,7 +4913,10 @@ static int drivers_editor_show_exec(bContext *C, wmOperator *op) * - Need to grab it first, or else this info disappears * after we've created the window */ - but = UI_context_active_but_prop_get(C, &ptr, &prop, &index); + int index; + PointerRNA ptr; + PropertyRNA *prop; + uiBut *but = UI_context_active_but_prop_get(C, &ptr, &prop, &index); /* changes context! */ if (WM_window_open_temp(C, @@ -4980,10 +4931,10 @@ static int drivers_editor_show_exec(bContext *C, wmOperator *op) /* activate driver F-Curve for the property under the cursor */ if (but) { - FCurve *fcu; bool driven, special; + FCurve *fcu = BKE_fcurve_find_by_rna_context_ui( + C, &ptr, prop, index, NULL, NULL, &driven, &special); - fcu = BKE_fcurve_find_by_rna_context_ui(C, &ptr, prop, index, NULL, NULL, &driven, &special); if (fcu) { /* Isolate this F-Curve... */ bAnimContext ac; @@ -5072,9 +5023,9 @@ static int screen_new_exec(bContext *C, wmOperator *UNUSED(op)) wmWindow *win = CTX_wm_window(C); WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook); WorkSpaceLayout *layout_old = BKE_workspace_active_layout_get(win->workspace_hook); - WorkSpaceLayout *layout_new; - layout_new = ED_workspace_layout_duplicate(bmain, workspace, layout_old, win); + WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate(bmain, workspace, layout_old, win); + WM_event_add_notifier(C, NC_SCREEN | ND_LAYOUTBROWSE, layout_new); return OPERATOR_FINISHED; @@ -5198,14 +5149,13 @@ void ED_region_visibility_change_update_animated(bContext *C, ScrArea *area, ARe { wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); - RegionAlphaInfo *rgi; /* end running timer */ if (region->regiontimer) { region_blend_end(C, region, true); } - rgi = MEM_callocN(sizeof(RegionAlphaInfo), "RegionAlphaInfo"); + RegionAlphaInfo *rgi = MEM_callocN(sizeof(RegionAlphaInfo), "RegionAlphaInfo"); rgi->hidden = region->flag & RGN_FLAG_HIDDEN; rgi->area = area; @@ -5234,7 +5184,6 @@ void ED_region_visibility_change_update_animated(bContext *C, ScrArea *area, ARe /* timer runs in win->handlers, so it cannot use context to find area/region */ static int region_blend_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) { - RegionAlphaInfo *rgi; wmTimer *timer = event->customdata; /* event type is TIMERREGION, but we better check */ @@ -5242,7 +5191,7 @@ static int region_blend_invoke(bContext *C, wmOperator *UNUSED(op), const wmEven return OPERATOR_PASS_THROUGH; } - rgi = timer->customdata; + RegionAlphaInfo *rgi = timer->customdata; /* always send redraws */ ED_region_tag_redraw(rgi->region); @@ -5577,10 +5526,9 @@ static void keymap_modal_set(wmKeyConfig *keyconf) {KM_MODAL_SNAP_OFF, "SNAP_OFF", 0, "Snap off", ""}, {0, NULL, 0, NULL, NULL}, }; - wmKeyMap *keymap; /* Standard Modal keymap ------------------------------------------------ */ - keymap = WM_modalkeymap_ensure(keyconf, "Standard Modal Map", modal_items); + wmKeyMap *keymap = WM_modalkeymap_ensure(keyconf, "Standard Modal Map", modal_items); WM_modalkeymap_assign(keymap, "SCREEN_OT_area_move"); } @@ -5607,8 +5555,6 @@ static void blend_file_drop_copy(wmDrag *drag, wmDropBox *drop) /* called in spacetypes.c */ void ED_keymap_screen(wmKeyConfig *keyconf) { - ListBase *lb; - /* Screen Editing ------------------------------------------------ */ WM_keymap_ensure(keyconf, "Screen Editing", 0, 0); @@ -5623,7 +5569,7 @@ void ED_keymap_screen(wmKeyConfig *keyconf) WM_keymap_ensure(keyconf, "Frames", 0, 0); /* dropbox for entire window */ - lb = WM_dropboxmap_find("Window", 0, 0); + ListBase *lb = WM_dropboxmap_find("Window", 0, 0); WM_dropbox_add(lb, "WM_OT_drop_blend_file", blend_file_drop_poll, blend_file_drop_copy); WM_dropbox_add(lb, "UI_OT_drop_color", UI_drop_color_poll, UI_drop_color_copy); diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 9fb11899d78..5d0ae292ffa 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -203,12 +203,12 @@ static void screenshot_draw(bContext *UNUSED(C), wmOperator *op) { uiLayout *layout = op->layout; ScreenshotData *scd = op->customdata; - PointerRNA ptr; uiLayoutSetPropSep(layout, true); uiLayoutSetPropDecorate(layout, false); /* image template */ + PointerRNA ptr; RNA_pointer_create(NULL, &RNA_ImageFormatSettings, &scd->im_format, &ptr); uiTemplateImageSettings(layout, &ptr, false); diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c index aca2b48a937..cab2d32bdcf 100644 --- a/source/blender/editors/screen/workspace_edit.c +++ b/source/blender/editors/screen/workspace_edit.c @@ -385,7 +385,6 @@ static void workspace_append_button(uiLayout *layout, const Main *from_main) { const ID *id = (ID *)workspace; - PointerRNA opptr; const char *filepath = from_main->name; if (strlen(filepath) == 0) { @@ -393,6 +392,8 @@ static void workspace_append_button(uiLayout *layout, } BLI_assert(STREQ(ot_append->idname, "WORKSPACE_OT_append_activate")); + + PointerRNA opptr; uiItemFullO_ptr( layout, ot_append, workspace->id.name + 2, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &opptr); RNA_string_set(&opptr, "idname", id->name + 2); diff --git a/source/blender/editors/screen/workspace_layout_edit.c b/source/blender/editors/screen/workspace_layout_edit.c index f4b076aca00..31ca11bb847 100644 --- a/source/blender/editors/screen/workspace_layout_edit.c +++ b/source/blender/editors/screen/workspace_layout_edit.c @@ -61,11 +61,9 @@ WorkSpaceLayout *ED_workspace_layout_duplicate(Main *bmain, { bScreen *screen_old = BKE_workspace_layout_screen_get(layout_old); const char *name = BKE_workspace_layout_name_get(layout_old); - bScreen *screen_new; - WorkSpaceLayout *layout_new; - layout_new = ED_workspace_layout_add(bmain, workspace, win, name); - screen_new = BKE_workspace_layout_screen_get(layout_new); + WorkSpaceLayout *layout_new = ED_workspace_layout_add(bmain, workspace, win, name); + bScreen *screen_new = BKE_workspace_layout_screen_get(layout_new); if (BKE_screen_is_fullscreen_area(screen_old)) { LISTBASE_FOREACH (ScrArea *, area_old, &screen_old->areabase) { @@ -229,7 +227,6 @@ bool ED_workspace_layout_cycle(WorkSpace *workspace, const short direction, bCon { wmWindow *win = CTX_wm_window(C); WorkSpaceLayout *old_layout = BKE_workspace_active_layout_get(win->workspace_hook); - WorkSpaceLayout *new_layout; const bScreen *old_screen = BKE_workspace_layout_screen_get(old_layout); ScrArea *area = CTX_wm_area(C); @@ -238,11 +235,12 @@ bool ED_workspace_layout_cycle(WorkSpace *workspace, const short direction, bCon } BLI_assert(ELEM(direction, 1, -1)); - new_layout = BKE_workspace_layout_iter_circular(workspace, - old_layout, - workspace_layout_cycle_iter_cb, - NULL, - (direction == -1) ? true : false); + WorkSpaceLayout *new_layout = BKE_workspace_layout_iter_circular(workspace, + old_layout, + workspace_layout_cycle_iter_cb, + NULL, + (direction == -1) ? true : + false); if (new_layout && (old_layout != new_layout)) { bScreen *new_screen = BKE_workspace_layout_screen_get(new_layout); |