# -*- coding: utf-8 -*-
import pymel.core as pm
from mtoa.ui.ae.shaderTemplate import ShaderAETemplate

class AEaiMotionVectorTemplate(ShaderAETemplate):
    def checkRaw(self, nodeName):
        fullAttr = '%s.%s'%(nodeName, "raw")
        rawValue = pm.getAttr(fullAttr)
        
        dim = rawValue
        pm.editorTemplate(dimControl=(nodeName, "maxDisplace", dim))
        
    def setup(self):
        self.addSwatch()
        self.beginScrollLayout()
        
        self.beginLayout("运动向量属性", collapse=False)
    
        self.addControl("time0", label="开始时间")
        self.addControl("time1", label="结束时间")
        self.addSeparator()
        self.addControl("raw", changeCommand=self.checkRaw, label="原始编码向量")
        self.addControl("maxDisplace", label="最大位移")
        
        self.endLayout()
        
        pm.mel.AEdependNodeTemplate(self.nodeName)

        self.addExtraControls()
        self.endScrollLayout()
    
