Skip to content

Commit

Permalink
PAINTROID-396 Multiline tool with movable intermediate points
Browse files Browse the repository at this point in the history
fix redo clearing after moving line
  • Loading branch information
Lenkomotive committed Sep 4, 2023
1 parent e7718af commit 9daa735
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class DynamicLineToolIntegrationTest {

private val IMAGE_NAME = "fileName"
private val colorStringIndex0 = "#FF0074CD"
private val colorStringIndex1 = "#FF00B4F1"
private val colorStringIndex2 = "#FF078707"
private val colorStringBlack = "#FF000000"
private val colorStringTransparent = "#00000000"
Expand Down Expand Up @@ -389,7 +390,7 @@ class DynamicLineToolIntegrationTest {
}

@Test
fun testColorChangesAndQuittingConnectedLineMode() {
fun testColorChangesChangeLineColor() {
ToolPropertiesInteraction.onToolProperties().setColor(Color.BLACK)
touchAt(DrawingSurfaceLocationProvider.HALFWAY_LEFT_MIDDLE)
touchAt(DrawingSurfaceLocationProvider.HALFWAY_RIGHT_MIDDLE)
Expand All @@ -399,26 +400,24 @@ class DynamicLineToolIntegrationTest {
touchAt(DrawingSurfaceLocationProvider.HALFWAY_BOTTOM_RIGHT)

TestUtils.selectColorInDialog(0)

checkPixelColor(colorStringIndex0, BitmapLocationProvider.HALFWAY_BOTTOM_RIGHT)

TestUtils.selectColorInDialog(1)
TestUtils.selectColorInDialog(2)
checkPixelColor(colorStringIndex1, BitmapLocationProvider.HALFWAY_BOTTOM_RIGHT)

TestUtils.selectColorInDialog(2)
checkPixelColor(colorStringIndex2, BitmapLocationProvider.HALFWAY_BOTTOM_RIGHT)

TopBarViewInteraction.onTopBarView().performUndo()
TopBarViewInteraction.onTopBarView().performUndo()

checkPixelColor(colorStringIndex0, BitmapLocationProvider.HALFWAY_BOTTOM_RIGHT)

touchAt(DrawingSurfaceLocationProvider.HALFWAY_BOTTOM_LEFT)
checkPixelColor(colorStringIndex0, BitmapLocationProvider.HALFWAY_BOTTOM_LEFT)
TestUtils.selectColorInDialog(0)
checkPixelColor(colorStringIndex0, BitmapLocationProvider.HALFWAY_RIGHT_MIDDLE)

touchAt(DrawingSurfaceLocationProvider.HALFWAY_BOTTOM_RIGHT)
checkPixelColor(colorStringIndex0, BitmapLocationProvider.HALFWAY_BOTTOM_RIGHT)
TestUtils.selectColorInDialog(1)
checkPixelColor(colorStringIndex1, BitmapLocationProvider.HALFWAY_RIGHT_MIDDLE)

TopBarViewInteraction.onTopBarView().performClickCheckmark()
TestUtils.selectColorInDialog(2)
checkPixelColor(colorStringIndex2, BitmapLocationProvider.HALFWAY_RIGHT_MIDDLE)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ class DynamicLineTool(
addNewPath = false
return true
}
clearRedoIfPathWasAdjusted()
return true
}

Expand All @@ -204,19 +203,19 @@ class DynamicLineTool(

override fun handleMove(coordinate: PointF?): Boolean {
coordinate ?: return false
updateMovingGhostVertices(coordinate)
clearRedoIfPathWasAdjusted()
hideToolOptions()
super.handleMove(coordinate)
updateMovingGhostVertices(coordinate)
clearRedoIfPathWasAdjusted()
return true
}

override fun handleUp(coordinate: PointF?): Boolean {
coordinate ?: return false
super.handleUp(coordinate)
showToolOptions()
super.handleUp(coordinate)
updateMovingVertices(coordinate)
commandManager.executeAllCommands()
clearRedoIfPathWasAdjusted()
resetGhostPathCoordinates()
showPlusButton()
return true
Expand Down Expand Up @@ -318,6 +317,7 @@ class DynamicLineTool(
var endPoint = successorVertex?.vertexCenter?.let { center -> copyPointF(center) }
updatePathCommand(startPoint, endPoint, movingVertex?.outgoingPathCommand)
}
commandManager.executeAllCommands()
}
}

Expand Down Expand Up @@ -368,7 +368,7 @@ class DynamicLineTool(
}
}

fun hideToolOptions() {
private fun hideToolOptions() {
if (toolOptionsViewController.isVisible) {
if (brushToolOptionsView.getTopToolOptions().visibility == View.VISIBLE) {
toolOptionsViewController.slideUp(
Expand All @@ -388,7 +388,7 @@ class DynamicLineTool(
}
}

fun showToolOptions() {
private fun showToolOptions() {
if (!toolOptionsViewController.isVisible) {
if (brushToolOptionsView.getBottomToolOptions().visibility == View.INVISIBLE) {
toolOptionsViewController.slideDown(
Expand Down

0 comments on commit 9daa735

Please sign in to comment.