From dd45e87f018dd3ab3166d3695be4239c52caaecb Mon Sep 17 00:00:00 2001 From: abakkk Date: Sat, 10 Oct 2020 15:02:01 +0200 Subject: [PATCH] layers and eraser Paint the current element in the `backLayer` when it is in "eraser mode". --- area.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/area.js b/area.js index 761f2b8..92213d5 100644 --- a/area.js +++ b/area.js @@ -328,10 +328,17 @@ var DrawingArea = new Lang.Class({ cr.stroke(); cr.restore(); } + + if (this.currentElement && this.currentElement.eraser) { + this.currentElement.buildCairo(cr, { showTextCursor: this.textHasCursor, + showTextRectangle: this.currentElement.shape != Shapes.TEXT || !this.isWriting, + dummyStroke: this.currentElement.fill && this.currentElement.line.lineWidth == 0 }); + cr.stroke(); + } }, _repaintFore: function(cr) { - if (!this.currentElement) + if (!this.currentElement || this.currentElement.eraser) return; this.currentElement.buildCairo(cr, { showTextCursor: this.textHasCursor, @@ -746,8 +753,10 @@ var DrawingArea = new Lang.Class({ this.currentElement.updateDrawing(x, y, controlPressed); - //this._redisplay(); - this.foreLayer.queue_repaint(); + if (this.currentElement.eraser) + this._redisplay(); + else + this.foreLayer.queue_repaint(); this.updatePointerCursor(controlPressed); },