#-------------------------------------------------------------------------------
# Name:        YJ_Body_RIG_UI
# Purpose:     Creat_Rig_UI
#
# Author:      YangJie
#
# Created:     25/06/2014
#Email:        691633493@
#-------------------------------------------------------------------------------
from maya.cmds import*
from YJ_CreatBodyBone_P import*
from YJ_RebulidBodyBone_P import*


def Create_Body_Rig_UI():
    #Ctreat window
    if window('YJ_Body_Rig',q=1,ex=1):
        deleteUI('YJ_Body_Rig',window=1)
    window('YJ_Body_Rig',w=480,h=800,s=1)
    tabLayout('Body_Rig_Tab')
    #SkeltonTab
    columnLayout('Skelton_CL',p='Body_Rig_Tab')
    frameLayout('Choose_Sk_FL',p='Skelton_CL',l='Choose',cll=0,cl=0,mh=10,mw=50,w=300)

    columnLayout('Chr_Choose_CL',p='Choose_Sk_FL')
    optionMenuGrp('Chr_Choose_OPMG',p='Chr_Choose_CL',l='Type:',cw2=[70,100],ad2=2,cc='')
    menuItem( label='Human' )
    menuItem( label='Horse' )
    menuItem( label='Cat' )

    rowLayout('Rad_Set_RL',nc=2,cw2=(100,100),p='Chr_Choose_CL')
    text('Bone_Rad_t',label='Rad:', align='left' )
    textField( 'Bone_Rad_tf',tx=0.2)





    frameLayout('Choose_Sk__RM_FL',p='Skelton_CL',l='Remove(NoRig)',cll=0,cl=0,mh=10,mw=60,w=300)
    rowLayout('Choose_Sk__RM_RL_1',nc=2,cw2=(100,100),p='Choose_Sk__RM_FL')
    checkBox('Neck_CB', label='Neck', p='Choose_Sk__RM_RL_1')
    checkBox( 'Arm_CB',label='Arm', p='Choose_Sk__RM_RL_1')
    rowLayout('Choose_Sk__RM_RL_2',nc=2,cw2=(100,100),p='Choose_Sk__RM_FL')
    checkBox('Finger_CB',label='Finger', p='Choose_Sk__RM_RL_2')
    checkBox('Leg_CB', label='Leg', p='Choose_Sk__RM_RL_2')
#

    frameLayout('JntSeg_FL',p='Skelton_CL',l='JntSegment',cll=0,cl=0,mh=10,mw=20,w=300)
    columnLayout('JntSeg_CL',p='JntSeg_FL')
    intFieldGrp('NeckSegIFG',l='Neck Seg:',extraLabel='seg',v1=3,cw3=[90,80,50],ad3=3)
    intFieldGrp('SpineSegIFG',l='Spine Seg:',extraLabel='seg',v1=6,cw3=[90,80,50],ad3=3)
    intFieldGrp('FingerNubIFG',l='Finger Nub:',extraLabel='Nub',bgc = [0.1,0.2,0.4],v1=4,cw3=[90,80,50],ad3=3)
    intFieldGrp('FingerSegIFG',l='Finger Seg:',extraLabel='Seg',v1=3,cw3=[90,80,50],ad3=3)
    rowLayout('TailSeg_RL',p='JntSeg_FL',nc=2,cw2=[200,100])
    intFieldGrp('TailSegIFG',l='Tail Seg:',en=0,extraLabel='seg',v1=5,cw3=[90,80,50],ad3=3)
    checkBox('TailSegCB',l='',cc='YJ_changeTailControl()')
#


    frameLayout('ImportBone_FL',p='Skelton_CL',l='ImportJnt',cll=0,cl=0,mh=10,mw=30,w=300)
    button('ImportBone_B',w=230,h=35,l='ImportBone',rs=1,p='ImportBone_FL',c='YJ_CreateBone_All()')

    #Rig_Tab
    columnLayout('Rig_CL',p='Body_Rig_Tab')
    frameLayout('RebulidBone_FL',p='Rig_CL',l='Rebulid',cll=0,cl=0,mh=10,mw=20,w=300)
    button('RebulidBone_B',w=230,h=35,l='RebulidBone',rs=1,p='RebulidBone_FL',c='YJ_Rebulid_Bone_Main()')

    #
    frameLayout('CtrlSeg_FL',p='Rig_CL',l='CtrlSegment',cll=0,cl=0,mh=10,mw=20,w=300)
    columnLayout('CtrlSeg_CL',p='CtrlSeg_FL')
    intFieldGrp('NeckCtrlSegIFG',l='Neck Seg:',extraLabel='seg',v1=3,cw3=[90,80,50],ad3=3)
    intFieldGrp('SpineCtrlSegIFG',l='Spine Seg:',extraLabel='seg',v1=4,cw3=[90,80,50],ad3=3)
    intFieldGrp('TailCtrlSegIFG',l='Tail Seg:',en=0,extraLabel='seg',v1=3,cw3=[90,80,50],ad3=3)
    ####
    frameLayout('CtrlIKFK_FL',p='Rig_CL',l="Rigging IKFK",cll=0,cl=0,mh=10,mw=10,w=300)
    columnLayout('CtrlIKFK_CL',p='CtrlIKFK_FL')
    rowLayout('ArmIKFK_RL',p='CtrlIKFK_CL',nc=4,cw4=[55,60,60,60],cal=[(1,'right')])
    radioCollection('Arm_radioCollection')
    text(l='Arm:',w=40)
    radioButton('Arm_FK',l='FK')
    radioButton('Arm_IK',l='IK')
    radioButton('Arm_IKFK',l='IKFK',sl=1)
    ####

    rowLayout('LegIKFK_RL',p='CtrlIKFK_CL',nc=4,cw4=[55,60,60,60],cal=[(1,'right')])
    radioCollection('Leg_radioCollection')
    text(l='Leg:',w=40)
    radioButton('Leg_FK',l='FK')
    radioButton('Leg_IK',l='IK')
    radioButton('Leg_IKFK',l='IKFK',sl=1)

    ####

    rowLayout('SpineIKFK_RL',p='CtrlIKFK_CL',nc=4,cw4=[55,60,60,60],cal=[(1,'right')])
    radioCollection('Spine_radioCollection')
    text(l='Spine:',w=40)
    radioButton('Spine_FK',l='FK')
    radioButton('Spine_IK',l='IK')
    radioButton('Spine_IKFK',l='IKFK',sl=1)
    ####

    rowLayout('NeckIKFK_RL',p='CtrlIKFK_CL',nc=4,cw4=[55,60,60,60],cal=[(1,'right')])
    radioCollection('Neck_radioCollection')
    text(l='Neck:',w=40)
    radioButton('Neck_FK',l='FK')
    radioButton('Neck_IK',l='IK')
    radioButton('Neck_IKFK',l='IKFK',sl=1)

    ####

    rowLayout('TailIKFK_RL',p='CtrlIKFK_CL',nc=4,cw4=[55,60,60,60],cal=[(1,'right')])
    radioCollection('Tail_radioCollection')
    text(l='Tail:',w=40)
    radioButton('Tail_FK',l='FK')
    radioButton('Tail_IK',l='IK')
    radioButton('Tail_IKFK',l='IKFK',sl=1)




    frameLayout('Rig_FL',p='Rig_CL',l='Rig',cll=0,cl=0,mh=10,mw=20,w=300)
    button('Rig_B',w=230,h=35,l='Rig',rs=1,p='Rig_FL',c='')




    #
    tabLayout('Body_Rig_Tab',e=1,tli=[(1,'Create_Skelton'),(2,'Ringging')])
    showWindow()
def YJ_changeTailControl():
    enb=1
    if(intFieldGrp('TailSegIFG',q=1,en=1)):
        enb=0
    intFieldGrp('TailSegIFG',e=1,en=enb)
    intFieldGrp('TailCtrlSegIFG',e=1,en=enb)