# Copyright 2009 Autodesk, Inc.  All rights reserved.
# Use of this software is subject to the terms of the Autodesk license agreement 
# provided at the time of installation or download, or which otherwise accompanies
# this software in either electronic or hard copy form.
#
# Script description:
# Create a tool with a FCurve editor and shows how to create an interpolator fcurve 
# and sets its
#
# Topic: FBAnimationNode, FBFCurve, FBFCurveEditor
#

from pyfbsdk import *
from pyfbsdk_additions import *

AnimationNode = None

def PopulateLayout(mainLyt):
    #create Spread
    Editor = FBFCurveEditor()

    x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
    y = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
    w = FBAddRegionParam(0,FBAttachType.kFBAttachRight,"")
    h = FBAddRegionParam(0,FBAttachType.kFBAttachBottom,"")

    mainLyt.AddRegion("FCurveEditor","FCurveEditor", x, y, w, h)

    mainLyt.SetControl("FCurveEditor",Editor)

    AnimationNode = FBAnimationNode("Test")
    FCurve = FBFCurve().CreateInterpolatorCurve( FBInterpolatorCurveType.kFBInterpolatorCurveSmoothOut )
    AnimationNode.FCurve = FCurve
    Editor.AddAnimationNode( AnimationNode )
    FCurve.FBDelete()

def CreateTool():
    # Tool creation will serve as the hub for all other controls
    t = CreateUniqueTool("FCurve editor sample")

    t.StartSizeX = 300
    t.StartSizeY = 300

    PopulateLayout(t)
    ShowTool(t)


CreateTool()