saber icon indicating copy to clipboard operation
saber copied to clipboard

Cannot draw over a shape

Open MK73DS opened this issue 1 year ago • 2 comments

Before submitting an issue, please check the following

  • [X] I have searched for similar issues (both open and closed) and cannot find a duplicate
  • [X] I agree to follow the Code of Conduct

Describe the bug

When drawing a shape (for example, a straight line or a circle), I cannot draw over it. The line automatically gets under the shape.

To reproduce

  1. Draw a shape (for example a circle)
  2. Draw something on top of it in another color
  3. It's sent behind the shape

Expected behavior

I expected the latest thing I drew to be on top.

Saber version

v.0.24.1

Device

  • Device: Samsung Galaxy S24 Ultra
  • OS: Android 14 (One UI 6.1)

Anything else?

Here is a screenshot of the issue. I drew the circle first, then drew something over it. But it's displayed behind. Screenshot_20240711_152927

MK73DS avatar Jul 11 '24 13:07 MK73DS

I found these two functions,

  • sortStrokes https://github.com/saber-notes/saber/blob/ab73f0268e7475a13002227822ae7982215476df/lib/data/editor/page.dart#L206
  • insertStroke https://github.com/saber-notes/saber/blob/ab73f0268e7475a13002227822ae7982215476df/lib/data/editor/page.dart#L185

They always keep the strokes in a particular order, and especially shapes are always drawn after regular strokes. By replacing these functions with dumb ones (no sorting for sortStrokes and adding the new stroke at the end for insertStroke) the faulty behavior I experienced in OP is gone.

I am no programmer and have no knowledge about the Saber's code. This sorting probably is very important in the app. However, I hope a fix for this issue won't be too difficult. The strokes are somewhere sorted by age because the "undo" feature works, so I hope displaying the strokes from oldest to newest is not difficult to implement in the code.

MK73DS avatar Aug 15 '24 21:08 MK73DS

I see that the strokes are sorted by pen type, including Pen, Pencil, Shape Pen and Highlighter. Is there a reason why we need to separate the Pen, Pencil and Shape Pen? I understand the Highlighter should always be in the background but is there a practical reason for this sorting on the rest of the pen types?

Moreover, Fountain Pen and Ballpoint Pen are not separated, and Shape Pen is in the same category as "Pen" in the app, so maybe at least Shape Pen should belong to the same category as Pen and not always be on top of it (this would still separate them from Pencil).

Also, the Pens seem to be sorted by lexicographic order on their names (Highlighter < Pen < Pencil < Shape Pen). This seems a bit arbitrary, and merely a coincidence that Highlighter is always first. Is there a reason why a Pencil should always be on top of a Pen for example?

If that is a conscious and motivated decision then this issue doesn't have any reason to exist. If not, I can try and open a PR to fix that.

MK73DS avatar Sep 29 '25 15:09 MK73DS