package com.bomostory.sceneeditmodule.view

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.RelativeLayout
import com.bomostory.sceneeditmodule.basicdata.Actor
import com.example.tfat.myapplication.navigationbar.actor.ActorAdapter

class LayerView : RelativeLayout {

    constructor(context: Context) : super(context)

    constructor(context: Context, attrs: AttributeSet) : super(context, attrs)

    constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle)

    var actors = ArrayList<Actor>()
        set(value) {
            for (actor in value) {
                val actorView = ActorView(context)
                addView(actorView)
                val layoutParams = RelativeLayout.LayoutParams(actor.sideLength, actor.sideLength)
                layoutParams.leftMargin = actor.positionX
                layoutParams.topMargin = actor.positionY
                actorView.layoutParams = layoutParams
                actorView.actor = actor
            }
        }

    var editActors = ArrayList<Actor>()
        set(value) {
            for (actor in value) {
                val actorView = EditActorView(context)
                actorView.actorCallback = context as EditActorView.OnActorChangeListener
                addView(actorView)
                val layoutParams = RelativeLayout.LayoutParams(actor.sideLength, actor.sideLength)
                layoutParams.leftMargin = actor.positionX
                layoutParams.topMargin = actor.positionY
                actorView.actor = actor
            }
        }
}