GPv3: Hide the paint cursor while drawing

This matches the behavior of GPv2. While drawing a stroke
the paint cursor is not shown.
This commit is contained in:
Falk David 2024-06-19 16:26:19 +02:00
parent c0ff8cf030
commit 60de2752be
3 changed files with 19 additions and 1 deletions

@ -848,8 +848,15 @@ class GreasePencilRuntime {
* Allocated and freed by the drawing code. See `DRW_grease_pencil_batch_cache_*` functions.
*/
void *batch_cache = nullptr;
/* The frame on which the object was evaluated (only valid for evaluated object). */
/**
* The frame on which the object was evaluated (only valid for evaluated object).
*/
int eval_frame = 0;
/**
* Set to true while drawing a stroke (e.g. with the draw tool).
* Used for example to temporarily hide the paint cursor in the viewport.
*/
bool is_drawing_stroke = false;
public:
GreasePencilRuntime() {}

@ -719,6 +719,9 @@ void PaintOperation::on_stroke_begin(const bContext &C, const InputSample &start
CTX_data_main(&C), object, brush);
const int material_index = BKE_object_material_index_get(object, material);
/* We're now starting to draw. */
grease_pencil->runtime->is_drawing_stroke = true;
PaintOperationExecutor executor{C};
executor.process_start_sample(*this, C, start_sample, material_index);
@ -949,6 +952,9 @@ void PaintOperation::on_stroke_done(const bContext &C)
drawing.set_texture_matrices({texture_space_}, IndexRange::from_single(active_curve));
drawing.tag_topology_changed();
/* Now we're done drawing. */
grease_pencil.runtime->is_drawing_stroke = false;
DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(&C, NC_GEOM | ND_DATA, &grease_pencil.id);
}

@ -1540,6 +1540,11 @@ static void grease_pencil_brush_cursor_draw(PaintCursorContext *pcontext)
return;
}
/* Hide the cursor while drwaing. */
if (grease_pencil->runtime->is_drawing_stroke) {
return;
}
if ((brush->flag & BRUSH_LOCK_SIZE) != 0) {
const bke::greasepencil::Layer *layer = grease_pencil->get_active_layer();
const ed::greasepencil::DrawingPlacement placement(