# 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 which shows the FBArrowButton and how to show/hide content
#
# Topic: FBArrowButton
#

from pyfbsdk import *
from pyfbsdk_additions import *


def PopulateLayout(mainLyt):
    anchor = FBAttachType.kFBAttachTop
    anchorRegion = ""
    for i in range(3):
        lytName = "Border" + str(i)
        lyt = FBLayout()
        x = FBAddRegionParam(10,FBAttachType.kFBAttachLeft,"")
        y = FBAddRegionParam(10,FBAttachType.kFBAttachTop,"")
        w = FBAddRegionParam(200,FBAttachType.kFBAttachNone,"")
        h = FBAddRegionParam(200,FBAttachType.kFBAttachNone,"")
        lyt.AddRegion(lytName,lytName, x, y, w, h)
        lyt.SetBorder(lytName,FBBorderStyle.kFBStandardBorder,True, True,1,0,90,0)

        arrowName = "ButtonArrow" + str(i)
        x = FBAddRegionParam(10,FBAttachType.kFBAttachLeft,"")
        y = FBAddRegionParam(10,anchor,anchorRegion)
        w = FBAddRegionParam(0,FBAttachType.kFBAttachNone,"")
        h = FBAddRegionParam(0,FBAttachType.kFBAttachNone,"")
        mainLyt.AddRegion(arrowName ,arrowName , x, y, w, h)

        b = FBArrowButton()
        mainLyt.SetControl(arrowName ,b)

        # important : we set the content AFTER having added the button arrow
        # to its parent layout
        b.SetContent( "A layout border" + str(i), lyt, 250, 250 )
        anchor = FBAttachType.kFBAttachBottom
        anchorRegion = arrowName


    # dummy label to show the layout moves
    x = FBAddRegionParam(10,FBAttachType.kFBAttachLeft,"")
    y = FBAddRegionParam(10,FBAttachType.kFBAttachBottom,arrowName)
    w = FBAddRegionParam(100,FBAttachType.kFBAttachNone,"")
    h = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")

    l = FBLabel()
    l.Caption = "Dummy label!"
    mainLyt.AddRegion("DummyLabel","DummyLabel", x, y, w, h)
    mainLyt.SetControl("DummyLabel", l)

def CreateTool():
    # Tool creation will serve as the hub for all other controls
    t = CreateUniqueTool("Arrow Button Example")
    PopulateLayout(t)
    ShowTool(t)

CreateTool()