# 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 slider and shows how to hook to its value change callback
#
# Topic: FBSlider,FBOrientation
#

from pyfbsdk import *
from pyfbsdk_additions import *

def ValueChange(control,event):
    print control.Value

def Transaction(control,event):
    print "Transaction, is begin: ", event.IsBeginTransaction


def PopulateLayout(mainLyt):
    x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
    y = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
    w = FBAddRegionParam(0,FBAttachType.kFBAttachRight,"")
    h = FBAddRegionParam(0,FBAttachType.kFBAttachBottom,"")
    mainLyt.AddRegion("main","main", x, y, w, h)

    lyt = HBoxLayout()
    mainLyt.SetControl('main', lyt)

    hs = FBSlider()
    hs.Orientation = FBOrientation.kFBHorizontal
    hs.SmallStep = 10
    hs.LargeStep = 10
    hs.OnChange.Add(ValueChange)
    hs.OnTransaction.Add(Transaction)
    lyt.Add(hs, 150, height=25)

    vs = FBSlider()
    vs.Orientation = FBOrientation.kFBVertical
    lyt.Add(vs, 25, height=150)


def CreateTool():
    # Tool creation will serve as the hub for all other controls
    t = CreateUniqueTool("Slider Example")
    t.StartSizeX = 400
    t.StartSizeY = 400


    PopulateLayout(t)
    ShowTool(t)


CreateTool()