adamwulf / JotUI

OpenGL based drawing view built for and used by Loose Leaf for iPad
http://getlooseleaf.com/opensource/
MIT License
268 stars 28 forks source link

Backing texture has any strokes? #27

Closed jsnprofessor closed 4 years ago

jsnprofessor commented 6 years ago

Hi Adam, First of all thanks for this amazing library. It saved me a lot of time.

My issue is that is there a convenient or clean way to know if there are any strokes in backing texture?

I want to enable a button if the drawing is not empty. I could get strokes that are not permanent drawn by using canUndo bool. The thing is user can undo all cache strokes but if the backing store has any stokes, the button must stay enabled. Thanks.

adamwulf commented 6 years ago

There's nothing currently in the code to know if something's been written to the backing texture, but it'd be fairly straightforward to add and track. You'd want to look at JotViewState.m:246. Whenever a stroke is added to strokesBeingWrittenToBackingTexture, then the backing texture has/will have a stroke written to it.

Just flipping a boolean inside that method would give you the information. Then you'd need to persist it through immutableState so that the boolean could save/load with the state.

I think that's all it'd take to add.