mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2025-06-05 21:59:19 +02:00
adding an Undo button to editor drawing
This commit is contained in:
@ -460,6 +460,10 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||
config.lastEditorBrushSize = it
|
||||
updateBrushSize(it)
|
||||
}
|
||||
|
||||
bottom_draw_undo.setOnClickListener {
|
||||
editor_draw_canvas.undo()
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateBrushSize(percent: Int) {
|
||||
|
@ -139,4 +139,14 @@ class EditorDrawCanvas(context: Context, attrs: AttributeSet) : View(context, at
|
||||
draw(canvas)
|
||||
return bitmap
|
||||
}
|
||||
|
||||
fun undo() {
|
||||
if (mPaths.isEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
val lastKey = mPaths.keys.lastOrNull()
|
||||
mPaths.remove(lastKey)
|
||||
invalidate()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user