diff options
author | Joseph Eagar <joeedh@gmail.com> | 2022-06-08 22:37:29 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2022-06-08 22:37:29 +0300 |
commit | 371fc68678d51576809e4a2e4e70906ef32be69e (patch) | |
tree | 56ebed6b3a696dc79bf23fae39e81ceb90b3909f /source/blender | |
parent | 285a68b7bbf2fa40e41d507991467387f5dd5264 (diff) |
Paint: Fix Image Editor Cursor Disappearing (T90120)
This patch fixes T90120. The fundamental problem is that 2d and the old 3d paint modes share a single Paint struct, ToolSettings->imapaint. This patch is a temporary fix until the new 3d paint mode (which has its own Paint struct) is released.
The patch works by listening for `NC_SCENE|ND_MODE` inside `image_listener` in `space_image.c`. It does not use `ED_space_image_paint_update` since that requires a `bMain.` Instead it calls `paint_cursor_start` (which is promoted to `ED_paint_cursor_start`). `image_paint_poll` is also promoted to an `ED_` function.
Reviewed By: Campbell Barton
Differential Revision: https://developer.blender.org/D14946
Ref D14946
Diffstat (limited to 'source/blender')
9 files changed, 26 insertions, 15 deletions
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h index 774115fa188..89e396c8035 100644 --- a/source/blender/editors/include/ED_image.h +++ b/source/blender/editors/include/ED_image.h @@ -24,6 +24,7 @@ struct Scene; struct SpaceImage; struct View2D; struct bContext; +struct Paint; struct wmOperator; struct wmWindowManager; @@ -187,6 +188,9 @@ ListBase ED_image_filesel_detect_sequences(struct Main *bmain, struct wmOperator *op, bool detect_udim); +bool ED_image_tools_paint_poll(struct bContext *C); +void ED_paint_cursor_start(struct Paint *p, bool (*poll)(struct bContext *C)); + #ifdef __cplusplus } #endif diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc index dc3dacf9c81..f5f7726a7f8 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc @@ -17,6 +17,7 @@ #include "WM_api.h" #include "WM_toolsystem.h" +#include "ED_image.h" #include "ED_curves_sculpt.h" #include "ED_object.h" #include "ED_screen.h" @@ -271,7 +272,7 @@ static void curves_sculptmode_enter(bContext *C) ob->mode = OB_MODE_SCULPT_CURVES; - paint_cursor_start(&curves_sculpt->paint, CURVES_SCULPT_mode_poll_view3d); + ED_paint_cursor_start(&curves_sculpt->paint, CURVES_SCULPT_mode_poll_view3d); /* Update for mode change. */ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 861da185975..c097ddc6191 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -1932,7 +1932,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) /* Public API */ -void paint_cursor_start(Paint *p, bool (*poll)(bContext *C)) +void ED_paint_cursor_start(Paint *p, bool (*poll)(bContext *C)) { if (p && !p->paint_cursor) { p->paint_cursor = WM_paint_cursor_activate( diff --git a/source/blender/editors/sculpt_paint/paint_image.cc b/source/blender/editors/sculpt_paint/paint_image.cc index e726fd3f338..e326d385593 100644 --- a/source/blender/editors/sculpt_paint/paint_image.cc +++ b/source/blender/editors/sculpt_paint/paint_image.cc @@ -272,7 +272,7 @@ static bool image_paint_poll_ex(bContext *C, bool check_tool) SpaceImage *sima = CTX_wm_space_image(C); if (sima) { - if (sima->image != nullptr && + if (sima->image != NULL && (ID_IS_LINKED(sima->image) || ID_IS_OVERRIDE_LIBRARY(sima->image))) { return false; } @@ -287,7 +287,7 @@ static bool image_paint_poll_ex(bContext *C, bool check_tool) return false; } -bool image_paint_poll(bContext *C) +bool ED_image_tools_paint_poll(bContext *C) { return image_paint_poll_ex(C, true); } @@ -301,7 +301,7 @@ static bool image_paint_2d_clone_poll(bContext *C) { Brush *brush = image_paint_brush(C); - if (!CTX_wm_region_view3d(C) && image_paint_poll(C)) { + if (!CTX_wm_region_view3d(C) && ED_image_tools_paint_poll(C)) { if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) { if (brush->clone.image) { return true; @@ -430,7 +430,7 @@ static void toggle_paint_cursor(Scene *scene, bool enable) paint_cursor_delete_textures(); } else if (enable) { - paint_cursor_start(p, image_paint_poll); + ED_paint_cursor_start(p, ED_image_tools_paint_poll); } } @@ -455,7 +455,7 @@ void ED_space_image_paint_update(Main *bmain, wmWindowManager *wm, Scene *scene) if (enabled) { BKE_paint_init(bmain, scene, PAINT_MODE_TEXTURE_2D, PAINT_CURSOR_TEXTURE_PAINT); - paint_cursor_start(&imapaint->paint, image_paint_poll); + ED_paint_cursor_start(&imapaint->paint, ED_image_tools_paint_poll); } else { paint_cursor_delete_textures(); @@ -925,7 +925,7 @@ static int brush_colors_flip_exec(bContext *C, wmOperator *UNUSED(op)) static bool brush_colors_flip_poll(bContext *C) { - if (image_paint_poll(C)) { + if (ED_image_tools_paint_poll(C)) { Brush *br = image_paint_brush(C); if (ELEM(br->imagepaint_tool, PAINT_TOOL_DRAW, PAINT_TOOL_FILL)) { return true; @@ -991,7 +991,7 @@ static bool texture_paint_poll(bContext *C) bool image_texture_paint_poll(bContext *C) { - return (texture_paint_poll(C) || image_paint_poll(C)); + return (texture_paint_poll(C) || ED_image_tools_paint_poll(C)); } bool facemask_paint_poll(bContext *C) diff --git a/source/blender/editors/sculpt_paint/paint_image_ops_paint.cc b/source/blender/editors/sculpt_paint/paint_image_ops_paint.cc index 8ddf1614e41..a671c24c514 100644 --- a/source/blender/editors/sculpt_paint/paint_image_ops_paint.cc +++ b/source/blender/editors/sculpt_paint/paint_image_ops_paint.cc @@ -34,6 +34,8 @@ #include "WM_toolsystem.h" #include "WM_types.h" +#include "ED_image.h" + #include "paint_intern.h" namespace blender::ed::sculpt_paint::image::ops::paint { @@ -316,7 +318,7 @@ static PaintOperation *texture_paint_init(bContext *C, wmOperator *op, const flo if ((brush->imagepaint_tool == PAINT_TOOL_FILL) && (brush->flag & BRUSH_USE_GRADIENT)) { pop->cursor = WM_paint_cursor_activate( - SPACE_TYPE_ANY, RGN_TYPE_ANY, image_paint_poll, gradient_draw_line, pop); + SPACE_TYPE_ANY, RGN_TYPE_ANY, ED_image_tools_paint_poll, gradient_draw_line, pop); } settings->imapaint.flag |= IMAGEPAINT_DRAWING; @@ -520,7 +522,7 @@ void PAINT_OT_image_paint(wmOperatorType *ot) ot->invoke = paint_invoke; ot->modal = paint_modal; ot->exec = paint_exec; - ot->poll = image_paint_poll; + ot->poll = ED_image_tools_paint_poll; ot->cancel = paint_cancel; /* flags */ diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 187f793eefe..3f4e660b229 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -98,7 +98,6 @@ 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); bool PAINT_brush_tool_poll(struct bContext *C); -void paint_cursor_start(struct Paint *p, bool (*poll)(struct bContext *C)); /** * Delete overlay cursor textures to preserve memory and invalidate all overlay flags. */ diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc index 0419f013455..cb054ea3319 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex.cc @@ -55,6 +55,7 @@ #include "WM_toolsystem.h" #include "WM_types.h" +#include "ED_image.h" #include "ED_armature.h" #include "ED_mesh.h" #include "ED_object.h" @@ -1322,7 +1323,7 @@ static void ed_vwpaintmode_enter_generic( BKE_paint_ensure(scene->toolsettings, (Paint **)&scene->toolsettings->vpaint); Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode); - paint_cursor_start(paint, vertex_paint_poll); + ED_paint_cursor_start(paint, vertex_paint_poll); BKE_paint_init(bmain, scene, paint_mode, PAINT_CURSOR_VERTEX_PAINT); } else if (mode_flag == OB_MODE_WEIGHT_PAINT) { @@ -1330,7 +1331,7 @@ static void ed_vwpaintmode_enter_generic( BKE_paint_ensure(scene->toolsettings, (Paint **)&scene->toolsettings->wpaint); Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode); - paint_cursor_start(paint, weight_paint_poll); + ED_paint_cursor_start(paint, weight_paint_poll); BKE_paint_init(bmain, scene, paint_mode, PAINT_CURSOR_WEIGHT_PAINT); /* weight paint specific */ diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.c b/source/blender/editors/sculpt_paint/sculpt_ops.c index eef344c3d90..477c7d5ae00 100644 --- a/source/blender/editors/sculpt_paint/sculpt_ops.c +++ b/source/blender/editors/sculpt_paint/sculpt_ops.c @@ -84,6 +84,7 @@ #include "WM_toolsystem.h" #include "WM_types.h" +#include "ED_image.h" #include "ED_object.h" #include "ED_screen.h" #include "ED_sculpt.h" @@ -349,7 +350,7 @@ void ED_object_sculptmode_enter_ex(Main *bmain, Paint *paint = BKE_paint_get_active_from_paintmode(scene, PAINT_MODE_SCULPT); BKE_paint_init(bmain, scene, PAINT_MODE_SCULPT, PAINT_CURSOR_SCULPT); - paint_cursor_start(paint, SCULPT_mode_poll_view3d); + ED_paint_cursor_start(paint, SCULPT_mode_poll_view3d); /* Check dynamic-topology flag; re-enter dynamic-topology mode when changing modes, * As long as no data was added that is not supported. */ diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 9832fcfdb70..fa0b7d75a30 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -316,6 +316,9 @@ static void image_listener(const wmSpaceTypeListenerParams *params) ED_area_tag_redraw(area); break; case ND_MODE: + ED_paint_cursor_start(¶ms->scene->toolsettings->imapaint.paint, + ED_image_tools_paint_poll); + if (wmn->subtype == NS_EDITMODE_MESH) { ED_area_tag_refresh(area); } |