Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-01-19 02:28:47 +0300
committerHans Goudey <h.goudey@me.com>2021-01-19 02:28:47 +0300
commit09c7c638905230a608a9b0204b68c775cf71bf67 (patch)
tree4b21efd9b23283ef236e756f46e3f75f5d2e6c61 /source/blender/blenkernel/BKE_screen.h
parent4b4aec288458dd24721fdd61af38d3c316c2520b (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/blenkernel/BKE_screen.h')
-rw-r--r--source/blender/blenkernel/BKE_screen.h43
1 files changed, 27 insertions, 16 deletions
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 7b5df98d148..4274d59cb9f 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -67,6 +67,13 @@ struct wmWindowManager;
#define BKE_ST_MAXNAME 64
+typedef struct wmSpaceTypeListenerParams {
+ struct wmWindow *window;
+ struct ScrArea *area;
+ struct wmNotifier *notifier;
+ const struct Scene *scene;
+} wmSpaceTypeListenerParams;
+
typedef struct SpaceType {
struct SpaceType *next, *prev;
@@ -85,10 +92,7 @@ typedef struct SpaceType {
/* exit is called when the area is hidden or removed */
void (*exit)(struct wmWindowManager *wm, struct ScrArea *area);
/* Listeners can react to bContext changes */
- void (*listener)(struct wmWindow *win,
- struct ScrArea *area,
- struct wmNotifier *wmn,
- struct Scene *scene);
+ void (*listener)(wmSpaceTypeListenerParams *params);
/* called when the mouse moves out of the area */
void (*deactivate)(struct ScrArea *area);
@@ -134,6 +138,23 @@ typedef struct SpaceType {
/* region types are also defined using spacetypes_init, via a callback */
+typedef struct wmRegionListenerParams {
+ struct ScrArea *area; /* Can be NULL when the region is not part of an area. */
+ struct ARegion *region;
+ struct wmNotifier *notifier;
+ const struct Scene *scene;
+} wmRegionListenerParams;
+
+typedef struct wmRegionMessageSubscribeParams {
+ const struct bContext *context;
+ struct wmMsgBus *message_bus;
+ struct WorkSpace *workspace;
+ struct Scene *scene;
+ struct bScreen *screen;
+ struct ScrArea *area;
+ struct ARegion *region;
+} wmRegionMessageSubscribeParams;
+
typedef struct ARegionType {
struct ARegionType *next, *prev;
@@ -158,19 +179,9 @@ typedef struct ARegionType {
/* snap the size of the region (can be NULL for no snapping). */
int (*snap_size)(const struct ARegion *region, int size, int axis);
/* contextual changes should be handled here */
- void (*listener)(struct wmWindow *win,
- struct ScrArea *area,
- struct ARegion *region,
- struct wmNotifier *wmn,
- const struct Scene *scene);
+ void (*listener)(wmRegionListenerParams *params);
/* Optional callback to generate subscriptions. */
- void (*message_subscribe)(const struct bContext *C,
- struct WorkSpace *workspace,
- struct Scene *scene,
- struct bScreen *screen,
- struct ScrArea *area,
- struct ARegion *region,
- struct wmMsgBus *mbus);
+ void (*message_subscribe)(wmRegionMessageSubscribeParams *params);
void (*free)(struct ARegion *);