import { _decorator, Color, Component, Label, Node, Sprite } from 'cc';
import { frame_item } from './frame_item';
const { ccclass, property } = _decorator;

@ccclass('opt_frame')
export class opt_frame extends Component {
    @property(Node) lab_title:Node = null;
    @property(Node) btn_delete:Node = null;
    @property(Node) btn_edit:Node = null;
    @property(Node) btn_cancel:Node = null;
    private m_call_delete = null;
    private m_call_edit = null;
    private m_item = null;
    public show(item:frame_item){
        this.m_item = item;
        this.lab_title.getComponent(Label).string = '第' + item.getIndex() + '帧'
        this.node.active = true;
    }

    public initView(delete_call,edit_call){
        this.m_call_delete = delete_call;
        this.m_call_edit = edit_call;
        this.btn_delete.on(Node.EventType.TOUCH_END,()=>{
            if(this.m_call_delete!=null){
                this.m_call_delete(this.m_item)
            }
            this.close()
        })

        this.btn_edit.on(Node.EventType.TOUCH_END,()=>{
            if(this.m_call_edit!=null){
                this.m_call_edit(this.m_item)
            }
            this.close()
        })
        this.btn_cancel.on(Node.EventType.TOUCH_END,()=>{
            this.close()
        })
    }

    close(){
        this.node.active = false;
    }




}


