Skip to content

Commit

Permalink
feat(#328): 움직임 모드에서 선택된 노드와 부모 노드 간의 연결선 해제
Browse files Browse the repository at this point in the history
  • Loading branch information
hegleB committed Mar 28, 2024
1 parent e161489 commit 8b15274
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 14 additions & 2 deletions AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/LineView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import boostcamp.and07.mindsync.ui.util.toPx
import boostcamp.and07.mindsync.ui.view.model.DrawInfo

class LineView constructor(
private val mindMapContainer: MindMapContainer,
context: Context,
attrs: AttributeSet? = null,
) : View(context, attrs) {
private val drawInfo = DrawInfo(context)
private val path = Path()
private lateinit var tree: Tree
private val paint = Paint()

override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
Expand Down Expand Up @@ -64,6 +64,7 @@ class LineView constructor(

else -> drawInfo.linePaint
}

val startX = getNodeEdgeX(fromNode, true)
val startY = fromNode.path.centerY.toPx(context)
val endX = getNodeEdgeX(toNode, false)
Expand All @@ -75,7 +76,18 @@ class LineView constructor(
moveTo(startX, startY)
cubicTo(midX, startY, midX, endY, endX, endY)
}
canvas.drawPath(path, linePaint)
drawPathConditionally(toNode, canvas, path, linePaint)
}

private fun drawPathConditionally(
toNode: Node,
canvas: Canvas,
path: Path,
linePaint: Paint,
) {
if (!mindMapContainer.isMoving || mindMapContainer.selectNode?.id != toNode.id) {
canvas.drawPath(path, linePaint)
}
}

private fun getNodeEdgeX(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class ZoomLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout(co
lateinit var mindMapContainer: MindMapContainer

fun initializeZoomLayout() {
nodeView = NodeView(mindMapContainer, context, attrs = null)
lineView = LineView(context, attrs = null)
lineView = LineView(mindMapContainer, context, attrs = null)
nodeView = NodeView(lineView, mindMapContainer, context, attrs = null)
addView(lineView)
addView(nodeView)
}
Expand Down

0 comments on commit 8b15274

Please sign in to comment.