Skip to content

Commit 840d36f

Browse files
committed
PAINTROID-396 Multiline tool with movable intermediate points
CR
1 parent d572eb6 commit 840d36f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Paintroid/src/main/java/org/catrobat/paintroid/presenter/MainActivityPresenter.kt

+2
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,8 @@ open class MainActivityPresenter(
600600
idlingResource.increment()
601601
if (view.isKeyboardShown) {
602602
view.hideKeyboard()
603+
} else if (toolController.currentTool is DynamicLineTool) {
604+
commandManager.undo()
603605
} else {
604606
if (commandManager.isLastColorCommandOnTop() || commandManager.getColorCommandCount() == 0) {
605607
toolController.currentTool?.changePaintColor(Color.BLACK)

Paintroid/src/main/java/org/catrobat/paintroid/tools/implementation/DynamicLineTool.kt

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.graphics.Color
55
import android.graphics.Paint
66
import android.graphics.PointF
77
import android.view.View
8+
import androidx.annotation.ColorInt
89
import androidx.test.espresso.idling.CountingIdlingResource
910
import org.catrobat.paintroid.command.CommandManager
1011
import org.catrobat.paintroid.command.implementation.DynamicPathCommand
@@ -142,7 +143,7 @@ class DynamicLineTool(
142143
}
143144

144145
fun setToolPaint(command: DynamicPathCommand) {
145-
super.changePaintColor(command.paint.color)
146+
super.changePaintColor(command.paint.color, false)
146147
super.changePaintStrokeCap(command.paint.strokeCap)
147148
super.changePaintStrokeWidth(command.paint.strokeWidth.toInt())
148149
}
@@ -324,8 +325,8 @@ class DynamicLineTool(
324325
}
325326
}
326327

327-
override fun changePaintColor(color: Int) {
328-
super.changePaintColor(color)
328+
override fun changePaintColor(@ColorInt color: Int, invalidate: Boolean) {
329+
super.changePaintColor(color, false)
329330
if (vertexStack.isEmpty()) return
330331
vertexStack.last.ingoingPathCommand?.setPaintColor(toolPaint.color)
331332
commandManager.executeAllCommands()
@@ -417,7 +418,7 @@ class DynamicLineTool(
417418
paint.run {
418419
style = Paint.Style.FILL
419420
color = originalPaint.color
420-
alpha = 128
421+
alpha = GHOST_PAINT_ALPHA
421422
strokeWidth = originalPaint.strokeWidth
422423
strokeCap = originalPaint.strokeCap
423424
}

0 commit comments

Comments
 (0)