#-------------------------------------------------------------------------------
# Name:        YJ_IKFK_RIG_UI
# Purpose:     Create IKFK UI
#
# Author:      YangJie
#
# Created:     23/6/2014
# Email:691633493@
#-------------------------------------------------------------------------------
from maya.cmds import*
from YJ_FK_Rig import*
from YJ_Load_Jnt import*
from YJ_IK_Rig import*
from YJ_spline_ik import*

def YJ_IKFK_RIG_UI_F():
#Create window
    if window('YJ_IKFK_UI',q=1,ex=1):
        deleteUI('YJ_IKFK_UI',window=1)
    window('YJ_IKFK_UI')

#Creat Main columnLayout
    columnLayout('MainCL')

#Create FK Layout
    frameLayout('FK_Fy', label='FK_RIG_FY', borderStyle='in' ,cll=1,p='MainCL',cl=0,w=400)
    columnLayout('FK_Ly',adjustableColumn=True,p='FK_Fy',w=400)
    rowLayout('FK_Ry',p='FK_Ly',nc=4,cw4=(50,175,50,175))
    text('FK_star_t',label='StarJnt:')
    textField('FK_star_tf')
    text('FK_end_t',label='StarJnt:')
    textField('FK_end_tf')
    columnLayout('FK_Button_Ly',p='FK_Ly',adjustableColumn=True,w=400)
    button( 'FK_Jnt_Lod_Button',label='Load',c="load_jnt_tx('FK_star_tf','FK_end_tf')")
    button( 'FK_Button',label='FK_RIG',c="YJ_CreatFkRig('yj','yj',0,0)")

#Create IK Layout
    frameLayout('IK_Fy', label='IK_RIG_FY', borderStyle='in' ,cll=1,p='MainCL',cl=0,w=400)
    columnLayout('IK_Ly',adjustableColumn=True,p='IK_Fy',w=400)

    rowLayout('IK_RL',nc=3,cw3=(145,145,145),p='IK_Ly')
    radioCollection('IK_RC',p='IK_RL')
    radioButton( 'rx',label='rotateX' )
    radioButton('ry', label='rotateY' )
    radioButton( 'rz',label='rotateZ' )
    radioCollection('IK_RC',e=1,sl='rz')

    rowLayout('IK_PN_RL',nc=2,cw2=(260,260),p='IK_Ly')
    radioCollection('IK_PN_RC',p='IK_RL')
    radioButton("Positive",label='Positive(+) ' )
    radioButton("Negative", label='Negative(-)' )
    radioCollection('IK_PN_RC',e=1,sl="Positive")

    rowLayout('IK_Ry',p='IK_Ly',nc=4,cw4=(50,175,50,175))
    text('IK_star_t',label='StarJnt:')
    textField('IK_star_tf')
    text('IK_end_t',label='StarJnt:')
    textField('IK_end_tf')
    columnLayout('IK_Button_Ly',p='IK_Ly',adjustableColumn=True,w=400)
    button( 'IK_Jnt_Lod_Button',label='Load',c="load_jnt_tx('IK_star_tf','IK_end_tf')")
    button( 'IK_Button',label='IK_RIG',c='YJ_CreateIkRig("yj","yj",0,"yj","yj")')
#Create SpineIK Layout
    frameLayout('SpineIK_Fy', label='SpineIK_RIG_FY', borderStyle='in' ,cll=1,p='MainCL',cl=0,w=400)
    columnLayout('Spline_IK_Ly',adjustableColumn=True,p='SpineIK_Fy',w=400)
    rowLayout('Spline_IK_Ry',p='Spline_IK_Ly',nc=4,cw4=(50,175,50,175))
    text('Spline_IK_star_t',label='StarJnt:')
    textField('Spline_IK_star_tf')
    text('Spline_IK_end_t',label='StarJnt:')
    textField('Spline_IK_end_tf')
    rowLayout('Spline_IK_CtrlNub_Ry',p='Spline_IK_Ly',nc=2,cw2=(100,350))
    text('Spline_Ctrl_Nub_t',label='Spline_Ctrl_Nub:')
    textField('Spline_Ctrl_Nub_tf',tx='3')

    columnLayout('Spline_IK_Button_Ly',p='Spline_IK_Ly',adjustableColumn=True,w=400)
    button( 'Spline_IK_Jnt_Lod_Button',label='Load',c="load_jnt_tx('Spline_IK_star_tf','Spline_IK_end_tf')")
    button( 'Spline_IK_Button',label='Spline_IK_RIG',c='YJ_CreateSplineIK_All("yj","yj",0,0)')


    showWindow('YJ_IKFK_UI')

def load_jnt_tx(text_name1,text_name2):
    star_jnt,end_jnt = YJ_Load_Star_End_Jnt()
    textField(text_name1,e = 1,tx = star_jnt)
    textField(text_name2,e = 1,tx = end_jnt)
if __name__ == '__main__':
    YJ_IKFK_RIG_UI_F()