From b88e51dd55c62bdc160f33f9b2ae1727a892560a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Jul 2018 11:47:00 +0200 Subject: Cleanup: use bool for poll functions --- source/blender/editors/sculpt_paint/paint_cursor.c | 4 ++-- source/blender/editors/sculpt_paint/paint_curve.c | 2 +- source/blender/editors/sculpt_paint/paint_image.c | 20 ++++++++-------- .../editors/sculpt_paint/paint_image_proj.c | 2 +- source/blender/editors/sculpt_paint/paint_intern.h | 28 +++++++++++----------- source/blender/editors/sculpt_paint/paint_ops.c | 4 ++-- source/blender/editors/sculpt_paint/paint_stroke.c | 2 +- source/blender/editors/sculpt_paint/paint_utils.c | 2 +- source/blender/editors/sculpt_paint/paint_vertex.c | 10 ++++---- .../editors/sculpt_paint/paint_vertex_color_ops.c | 2 +- .../editors/sculpt_paint/paint_vertex_weight_ops.c | 2 +- source/blender/editors/sculpt_paint/sculpt.c | 12 +++++----- .../blender/editors/sculpt_paint/sculpt_intern.h | 8 +++---- source/blender/editors/sculpt_paint/sculpt_uv.c | 13 +++++----- 14 files changed, 56 insertions(+), 55 deletions(-) (limited to 'source/blender/editors/sculpt_paint') diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 3c3b9e91ab9..769f6116dc6 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -1103,7 +1103,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) /* Public API */ -void paint_cursor_start(bContext *C, int (*poll)(bContext *C)) +void paint_cursor_start(bContext *C, bool (*poll)(bContext *C)) { Paint *p = BKE_paint_get_active_from_context(C); @@ -1114,7 +1114,7 @@ void paint_cursor_start(bContext *C, int (*poll)(bContext *C)) BKE_paint_invalidate_overlay_all(); } -void paint_cursor_start_explicit(Paint *p, wmWindowManager *wm, int (*poll)(bContext *C)) +void paint_cursor_start_explicit(Paint *p, wmWindowManager *wm, bool (*poll)(bContext *C)) { if (p && !p->paint_cursor) p->paint_cursor = WM_paint_cursor_activate(wm, poll, paint_draw_cursor, NULL); diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c index 44abdc34ffb..8d31ad19a99 100644 --- a/source/blender/editors/sculpt_paint/paint_curve.c +++ b/source/blender/editors/sculpt_paint/paint_curve.c @@ -55,7 +55,7 @@ #define PAINT_CURVE_SELECT_THRESHOLD 40.0f #define PAINT_CURVE_POINT_SELECT(pcp, i) (*(&pcp->bez.f1 + i) = SELECT) -int paint_curve_poll(bContext *C) +bool paint_curve_poll(bContext *C) { Object *ob = CTX_data_active_object(C); Paint *p; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 4902fd78e33..3760dec96d0 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -264,7 +264,7 @@ static Brush *image_paint_brush(bContext *C) return BKE_paint_brush(&settings->imapaint.paint); } -static int image_paint_poll(bContext *C) +static bool image_paint_poll(bContext *C) { Object *obact; @@ -290,7 +290,7 @@ static int image_paint_poll(bContext *C) return 0; } -static int image_paint_2d_clone_poll(bContext *C) +static bool image_paint_2d_clone_poll(bContext *C) { Brush *brush = image_paint_brush(C); @@ -976,7 +976,7 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -static int sample_color_poll(bContext *C) +static bool sample_color_poll(bContext *C) { return (image_paint_poll(C) || vertex_paint_poll(C)); } @@ -1009,7 +1009,7 @@ void PAINT_OT_sample_color(wmOperatorType *ot) /******************** texture paint toggle operator ********************/ -static int texture_paint_toggle_poll(bContext *C) +static bool texture_paint_toggle_poll(bContext *C) { Object *ob = CTX_data_active_object(C); if (ob == NULL || ob->type != OB_MESH) @@ -1145,7 +1145,7 @@ static int brush_colors_flip_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -static int brush_colors_flip_poll(bContext *C) +static bool brush_colors_flip_poll(bContext *C) { if (image_paint_poll(C)) { Brush *br = image_paint_brush(C); @@ -1195,7 +1195,7 @@ void ED_imapaint_bucket_fill(struct bContext *C, float color[3], wmOperator *op) } -static int texture_paint_poll(bContext *C) +static bool texture_paint_poll(bContext *C) { if (texture_paint_toggle_poll(C)) if (CTX_data_active_object(C)->mode & OB_MODE_TEXTURE_PAINT) @@ -1204,22 +1204,22 @@ static int texture_paint_poll(bContext *C) return 0; } -int image_texture_paint_poll(bContext *C) +bool image_texture_paint_poll(bContext *C) { return (texture_paint_poll(C) || image_paint_poll(C)); } -int facemask_paint_poll(bContext *C) +bool facemask_paint_poll(bContext *C) { return BKE_paint_select_face_test(CTX_data_active_object(C)); } -int vert_paint_poll(bContext *C) +bool vert_paint_poll(bContext *C) { return BKE_paint_select_vert_test(CTX_data_active_object(C)); } -int mask_paint_poll(bContext *C) +bool mask_paint_poll(bContext *C) { return BKE_paint_select_elem_test(CTX_data_active_object(C)); } diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 4687ec3f5cb..e9fdbdb7f26 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -5921,7 +5921,7 @@ static int add_simple_uvs_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -static int add_simple_uvs_poll(bContext *C) +static bool add_simple_uvs_poll(bContext *C) { Object *ob = CTX_data_active_object(C); diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index e1ac35c3675..8ba773a2fc8 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -87,16 +87,16 @@ struct ViewContext *paint_stroke_view_context(struct PaintStroke *stroke); void *paint_stroke_mode_data(struct PaintStroke *stroke); float paint_stroke_distance_get(struct PaintStroke *stroke); void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data); -int paint_poll(struct bContext *C); -void paint_cursor_start(struct bContext *C, int (*poll)(struct bContext *C)); -void paint_cursor_start_explicit(struct Paint *p, struct wmWindowManager *wm, int (*poll)(struct bContext *C)); +bool paint_poll(struct bContext *C); +void paint_cursor_start(struct bContext *C, bool (*poll)(struct bContext *C)); +void paint_cursor_start_explicit(struct Paint *p, struct wmWindowManager *wm, bool (*poll)(struct bContext *C)); void paint_cursor_delete_textures(void); /* paint_vertex.c */ -int weight_paint_poll(struct bContext *C); -int weight_paint_mode_poll(struct bContext *C); -int vertex_paint_poll(struct bContext *C); -int vertex_paint_mode_poll(struct bContext *C); +bool weight_paint_poll(struct bContext *C); +bool weight_paint_mode_poll(struct bContext *C); +bool vertex_paint_poll(struct bContext *C); +bool vertex_paint_mode_poll(struct bContext *C); typedef void (*VPaintTransform_Callback)(const float col[3], const void *user_data, float r_col[3]); @@ -177,7 +177,7 @@ typedef struct ImagePaintPartialRedraw { #define IMAPAINT_TILE_SIZE (1 << IMAPAINT_TILE_BITS) #define IMAPAINT_TILE_NUMBER(size) (((size) + IMAPAINT_TILE_SIZE - 1) >> IMAPAINT_TILE_BITS) -int image_texture_paint_poll(struct bContext *C); +bool image_texture_paint_poll(struct bContext *C); void imapaint_image_update(struct SpaceImage *sima, struct Image *image, struct ImBuf *ibuf, short texpaint); struct ImagePaintPartialRedraw *get_imapaintpartial(void); void set_imapaintpartial(struct ImagePaintPartialRedraw *ippr); @@ -237,8 +237,8 @@ struct ListBase *ED_image_undosys_step_get_tiles(struct UndoStep *us_p); struct ListBase *ED_image_undo_get_tiles(void); /* sculpt_uv.c */ -int uv_sculpt_poll(struct bContext *C); -int uv_sculpt_keymap_poll(struct bContext *C); +bool uv_sculpt_poll(struct bContext *C); +bool uv_sculpt_keymap_poll(struct bContext *C); void SCULPT_OT_uv_sculpt_stroke(struct wmOperatorType *ot); @@ -282,11 +282,11 @@ void PAINT_OT_face_select_reveal(struct wmOperatorType *ot); void PAINT_OT_vert_select_all(struct wmOperatorType *ot); void PAINT_OT_vert_select_ungrouped(struct wmOperatorType *ot); -int vert_paint_poll(struct bContext *C); -int mask_paint_poll(struct bContext *C); -int paint_curve_poll(struct bContext *C); +bool vert_paint_poll(struct bContext *C); +bool mask_paint_poll(struct bContext *C); +bool paint_curve_poll(struct bContext *C); -int facemask_paint_poll(struct bContext *C); +bool facemask_paint_poll(struct bContext *C); void flip_v3_v3(float out[3], const float in[3], const char symm); void flip_qt_qt(float out[3], const float in[3], const char symm); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index f03c119a09e..89475d0de8a 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -183,7 +183,7 @@ static void PALETTE_OT_new(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int palette_poll(bContext *C) +static bool palette_poll(bContext *C) { Paint *paint = BKE_paint_get_active_from_context(C); @@ -778,7 +778,7 @@ static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *eve return OPERATOR_RUNNING_MODAL; } -static int stencil_control_poll(bContext *C) +static bool stencil_control_poll(bContext *C) { ePaintMode mode = BKE_paintmode_get_active_from_context(C); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index afd24f0fe90..a194b1b3e90 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -1312,7 +1312,7 @@ void paint_stroke_set_mode_data(PaintStroke *stroke, void *mode_data) stroke->mode_data = mode_data; } -int paint_poll(bContext *C) +bool paint_poll(bContext *C) { Paint *p = BKE_paint_get_active_from_context(C); Object *ob = CTX_data_active_object(C); diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 77c9dcf8ac6..f215fdcd579 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -571,7 +571,7 @@ static int brush_curve_preset_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int brush_curve_preset_poll(bContext *C) +static bool brush_curve_preset_poll(bContext *C) { Brush *br = BKE_paint_brush(BKE_paint_get_active_from_context(C)); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 71c2b66c8d3..483c8a77ab5 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -197,14 +197,14 @@ static void paint_last_stroke_update(Scene *scene, ARegion *ar, const float mval /* polling - retrieve whether cursor should be set or operator should be done */ /* Returns true if vertex paint mode is active */ -int vertex_paint_mode_poll(bContext *C) +bool vertex_paint_mode_poll(bContext *C) { Object *ob = CTX_data_active_object(C); return ob && ob->mode == OB_MODE_VERTEX_PAINT && ((Mesh *)ob->data)->totpoly; } -int vertex_paint_poll(bContext *C) +bool vertex_paint_poll(bContext *C) { if (vertex_paint_mode_poll(C) && BKE_paint_brush(&CTX_data_tool_settings(C)->vpaint->paint)) @@ -219,14 +219,14 @@ int vertex_paint_poll(bContext *C) return 0; } -int weight_paint_mode_poll(bContext *C) +bool weight_paint_mode_poll(bContext *C) { Object *ob = CTX_data_active_object(C); return ob && ob->mode == OB_MODE_WEIGHT_PAINT && ((Mesh *)ob->data)->totpoly; } -int weight_paint_poll(bContext *C) +bool weight_paint_poll(bContext *C) { Object *ob = CTX_data_active_object(C); ScrArea *sa; @@ -1232,7 +1232,7 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op) } /* for switching to/from mode */ -static int paint_poll_test(bContext *C) +static bool paint_poll_test(bContext *C) { Object *ob = CTX_data_active_object(C); if (ob == NULL || ob->type != OB_MESH) diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c index b69ca32e5af..4959c40c65e 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c @@ -48,7 +48,7 @@ #include "paint_intern.h" /* own include */ -static int vertex_weight_paint_mode_poll(bContext *C) +static bool vertex_weight_paint_mode_poll(bContext *C) { Object *ob = CTX_data_active_object(C); Mesh *me = BKE_mesh_from_object(ob); diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c index 957cb6a7389..fade31fff0d 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c @@ -115,7 +115,7 @@ static void wpaint_prev_destroy(struct WPaintPrev *wpp) /** \name Weight from Bones Operator * \{ */ -static int weight_from_bones_poll(bContext *C) +static bool weight_from_bones_poll(bContext *C) { Object *ob = CTX_data_active_object(C); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 280e22084cc..74baa267b69 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -4079,25 +4079,25 @@ static void sculpt_update_tex(const Scene *scene, Sculpt *sd, SculptSession *ss) -int sculpt_mode_poll(bContext *C) +bool sculpt_mode_poll(bContext *C) { Object *ob = CTX_data_active_object(C); return ob && ob->mode & OB_MODE_SCULPT; } -int sculpt_mode_poll_view3d(bContext *C) +bool sculpt_mode_poll_view3d(bContext *C) { return (sculpt_mode_poll(C) && CTX_wm_region_view3d(C)); } -int sculpt_poll_view3d(bContext *C) +bool sculpt_poll_view3d(bContext *C) { return (sculpt_poll(C) && CTX_wm_region_view3d(C)); } -int sculpt_poll(bContext *C) +bool sculpt_poll(bContext *C) { return sculpt_mode_poll(C) && paint_poll(C); } @@ -5527,7 +5527,7 @@ static int sculpt_optimize_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -static int sculpt_and_dynamic_topology_poll(bContext *C) +static bool sculpt_and_dynamic_topology_poll(bContext *C) { Object *ob = CTX_data_active_object(C); @@ -5826,7 +5826,7 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot) } -static int sculpt_and_dynamic_topology_constant_detail_poll(bContext *C) +static bool sculpt_and_dynamic_topology_constant_detail_poll(bContext *C) { Object *ob = CTX_data_active_object(C); Sculpt *sd = CTX_data_tool_settings(C)->sculpt; diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index 1c94c1d9198..137e957dce6 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -48,11 +48,11 @@ struct Object; struct SculptUndoNode; struct SculptOrigVertData; -int sculpt_mode_poll(struct bContext *C); -int sculpt_mode_poll_view3d(struct bContext *C); +bool sculpt_mode_poll(struct bContext *C); +bool sculpt_mode_poll_view3d(struct bContext *C); /* checks for a brush, not just sculpt mode */ -int sculpt_poll(struct bContext *C); -int sculpt_poll_view3d(struct bContext *C); +bool sculpt_poll(struct bContext *C); +bool sculpt_poll_view3d(struct bContext *C); /* Stroke */ bool sculpt_stroke_get_location(struct bContext *C, float out[3], const float mouse[2]); diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 78274332660..7e30c8b5b23 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -158,7 +158,7 @@ static Brush *uv_sculpt_brush(bContext *C) } -static int uv_sculpt_brush_poll_do(bContext *C, const bool check_region) +static bool uv_sculpt_brush_poll_do(bContext *C, const bool check_region) { BMEditMesh *em; int ret; @@ -186,7 +186,7 @@ static int uv_sculpt_brush_poll_do(bContext *C, const bool check_region) return ret; } -static int uv_sculpt_brush_poll(bContext *C) +static bool uv_sculpt_brush_poll(bContext *C) { return uv_sculpt_brush_poll_do(C, true); } @@ -246,8 +246,9 @@ void ED_space_image_uv_sculpt_update(Main *bmain, wmWindowManager *wm, Scene *sc BKE_paint_init(bmain, scene, ePaintSculptUV, PAINT_CURSOR_SCULPT); - settings->uvsculpt->paint.paint_cursor = WM_paint_cursor_activate(wm, uv_sculpt_brush_poll, - brush_drawcursor_uvsculpt, NULL); + settings->uvsculpt->paint.paint_cursor = WM_paint_cursor_activate( + wm, uv_sculpt_brush_poll, + brush_drawcursor_uvsculpt, NULL); } else { if (settings->uvsculpt) { @@ -257,12 +258,12 @@ void ED_space_image_uv_sculpt_update(Main *bmain, wmWindowManager *wm, Scene *sc } } -int uv_sculpt_poll(bContext *C) +bool uv_sculpt_poll(bContext *C) { return uv_sculpt_brush_poll_do(C, true); } -int uv_sculpt_keymap_poll(bContext *C) +bool uv_sculpt_keymap_poll(bContext *C) { return uv_sculpt_brush_poll_do(C, false); } -- cgit v1.2.3