import { _decorator, Color, Component, Node } from 'cc';
import cp_palette from '../palette/cp_palette';
import { control } from '../palette/control';
const { ccclass, property } = _decorator;

@ccclass('set_color')
export class set_color extends Component {
    @property(Node) btn_close:Node = null;
    @property(cp_palette) palette:cp_palette = null;
    @property(control) ctrl:control = null;
    private m_call_back = null;
    public show(origin_color:Color,call_back){
        this.m_call_back = call_back;
        this.btn_close.on(Node.EventType.TOUCH_START,()=>{
            this.close()
        })

        this.palette.show({
            color: origin_color,
            alpha:origin_color.a,
            update_listener: (color: Color, alpha: number) => {
                if(this.m_call_back!=null){
                    this.m_call_back(color)
                }
            }
        });
    }

    close(){
        this.node.removeFromParent();
    }
}


