Skip to content

Commit

Permalink
PAINTROID-498 Line Color Changing
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenkomotive committed Dec 13, 2022
1 parent f61f587 commit 03e4d23
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class DefaultCommandManager(
notifyCommandExecuted()
}

private fun handleUndo(command: Command) {
private fun handleUndo(command: Command, ignoreColorCommand: Boolean = false) {
var success = true
var layerCount = layerModel.layerCount
val currentCommandName = command.javaClass.simpleName
Expand Down Expand Up @@ -153,9 +153,13 @@ class DefaultCommandManager(

val iterator = undoCommandList.descendingIterator()
while (iterator.hasNext()) {
var nextCommand = iterator.next()
if (nextCommand is ColorChangedCommand && ignoreColorCommand) {
continue
}
val currentLayer = layerModel.currentLayer
canvas.setBitmap(currentLayer?.bitmap)
iterator.next().run(canvas, layerModel)
nextCommand.run(canvas, layerModel)
}

if (!currentCommandName.matches(mergeLayerCommandRegex)) {
Expand Down Expand Up @@ -231,7 +235,7 @@ class DefaultCommandManager(
if (undoCommandList.isNotEmpty() && undoCommandList.first != null) {
val command = undoCommandList.pop()
redoCommandList.addFirst(command)
handleUndo(command)
handleUndo(command, true)
}
return colorCommandList
}
Expand Down

0 comments on commit 03e4d23

Please sign in to comment.