diff options
author | Hans Goudey <h.goudey@me.com> | 2021-01-19 02:28:47 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-01-19 02:28:47 +0300 |
commit | 09c7c638905230a608a9b0204b68c775cf71bf67 (patch) | |
tree | 4b21efd9b23283ef236e756f46e3f75f5d2e6c61 /source/blender/editors/space_clip | |
parent | 4b4aec288458dd24721fdd61af38d3c316c2520b (diff) |
UI Code Quality: Use "params" struct for area and region callbacks
These functions with many arguments can be unwieldy. Aside from the obvious issues
with rewriting the list of arguments and the opportunities for error and frustration
that presents, the long list of arguments make these systems hard to change. So when
an argument should be added, someone might skip that and add some hack instead.
So, as proposed in T73586#1037210, this patch instead uses a "params" struct for
each of these callbacks.
- Use param argument for `ARegionType.listener`
- Remove unused window field in region listener
- Use param argument for `SpaceType.listener`
- Use params struct for `ARegionType.message_subscribe`
Differential Revision: https://developer.blender.org/D9750
Diffstat (limited to 'source/blender/editors/space_clip')
-rw-r--r-- | source/blender/editors/space_clip/space_clip.c | 56 |
1 files changed, 24 insertions, 32 deletions
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 085dbccabb2..3806c1494e3 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -229,7 +229,7 @@ static void clip_scopes_check_gpencil_change(ScrArea *area) } } -static void clip_area_sync_frame_from_scene(ScrArea *area, Scene *scene) +static void clip_area_sync_frame_from_scene(ScrArea *area, const Scene *scene) { SpaceClip *space_clip = (SpaceClip *)area->spacedata.first; BKE_movieclip_user_set_frame(&space_clip->user, scene->r.cfra); @@ -334,8 +334,12 @@ static SpaceLink *clip_duplicate(SpaceLink *sl) return (SpaceLink *)scn; } -static void clip_listener(wmWindow *UNUSED(win), ScrArea *area, wmNotifier *wmn, Scene *scene) +static void clip_listener(wmSpaceTypeListenerParams *params) { + ScrArea *area = params->area; + wmNotifier *wmn = params->notifier; + const Scene *scene = params->scene; + /* context changes */ switch (wmn->category) { case NC_SCENE: @@ -1004,12 +1008,11 @@ static void clip_main_region_draw(const bContext *C, ARegion *region) WM_gizmomap_draw(region->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D); } -static void clip_main_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(area), - ARegion *region, - wmNotifier *wmn, - const Scene *UNUSED(scene)) +static void clip_main_region_listener(wmRegionListenerParams *params) { + ARegion *region = params->region; + wmNotifier *wmn = params->notifier; + /* context changes */ switch (wmn->category) { case NC_GPENCIL: @@ -1140,11 +1143,7 @@ static void clip_preview_region_draw(const bContext *C, ARegion *region) } } -static void clip_preview_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(area), - ARegion *UNUSED(region), - wmNotifier *UNUSED(wmn), - const Scene *UNUSED(scene)) +static void clip_preview_region_listener(wmRegionListenerParams *UNUSED(params)) { } @@ -1185,11 +1184,7 @@ static void clip_channels_region_draw(const bContext *C, ARegion *region) UI_view2d_view_restore(C); } -static void clip_channels_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(area), - ARegion *UNUSED(region), - wmNotifier *UNUSED(wmn), - const Scene *UNUSED(scene)) +static void clip_channels_region_listener(wmRegionListenerParams *UNUSED(params)) { } @@ -1206,12 +1201,11 @@ static void clip_header_region_draw(const bContext *C, ARegion *region) ED_region_header(C, region); } -static void clip_header_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(area), - ARegion *region, - wmNotifier *wmn, - const Scene *UNUSED(scene)) +static void clip_header_region_listener(wmRegionListenerParams *params) { + ARegion *region = params->region; + wmNotifier *wmn = params->notifier; + /* context changes */ switch (wmn->category) { case NC_SCENE: @@ -1249,12 +1243,11 @@ static void clip_tools_region_draw(const bContext *C, ARegion *region) /****************** tool properties region ******************/ -static void clip_props_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(area), - ARegion *region, - wmNotifier *wmn, - const Scene *UNUSED(scene)) +static void clip_props_region_listener(wmRegionListenerParams *params) { + ARegion *region = params->region; + wmNotifier *wmn = params->notifier; + /* context changes */ switch (wmn->category) { case NC_WM: @@ -1302,12 +1295,11 @@ static void clip_properties_region_draw(const bContext *C, ARegion *region) ED_region_panels(C, region); } -static void clip_properties_region_listener(wmWindow *UNUSED(win), - ScrArea *UNUSED(area), - ARegion *region, - wmNotifier *wmn, - const Scene *UNUSED(scene)) +static void clip_properties_region_listener(wmRegionListenerParams *params) { + ARegion *region = params->region; + wmNotifier *wmn = params->notifier; + /* context changes */ switch (wmn->category) { case NC_GPENCIL: |