<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
        layout="absolute" xmlns:preso="com.dcholth.preso.*"
        creationComplete="handleCreationComplete()" 
        width="520" height="520"
        xmlns:parts="com.dcholth.preso.parts.*" viewSourceURL="srcview/index.html">
    
    <mx:Script>
        <![CDATA[
            import com.dcholth.preso.AbstractPresoView;
            
            public static var DEPTH_MANAGEMENT_ON : Boolean = true;
            
            [Bindable]
            protected var gridVisible : Boolean = false;
            
            protected function handlePresoChanged( event:Event):void
            {
                if( _currentPreso != null )
                    _currentPreso.deactivate();
                    
                _currentPreso = event.currentTarget.selectedItem.data;
                
                _currentPreso.activate();
                
                presoViews.selectedChild = _currentPreso;
            }
            
            protected function handleCreationComplete():void
            {
                (presoViews.selectedChild as AbstractPresoView).activate();
            }
        
            protected var _currentPreso : AbstractPresoView;
        ]]>
    </mx:Script>
    
    <mx:Style source="assets/css/preso_style.css" />
    
    <parts:Grid id="grid"
            visible="{ gridVisible }"
            width="100%" height="100%" />
    
    <mx:HBox>
            <mx:ComboBox id="combo" change="{handlePresoChanged(event)}" >
            <mx:ArrayCollection>
                <mx:Object label="Spinng Cards"                         data="{rotatingCards}" />
                <mx:Object label="Simple Rotation Controls"             data="{simpleRotation}" />
                <mx:Object label="Focal Length"                         data="{focalLenght}" />
                <mx:Object label="Field Of View"                          data="{fieldOfView}" />
                <mx:Object label="Bouncing Balls Field of View"         data="{bouncingBalls}" />
                <mx:Object label="Projection Center Change"             data="{projectionCenterTest}" />
                <mx:Object label="Projection Panel"                     data="{panelTest}" />
                <mx:Object label="Mask: Positioner applied to Mask"     data="{maskPosition}" />
                <mx:Object label="Mask: Positioner applied to Maskee"     data="{maskeePosition}" />
                <mx:Object label="Good Masking"                         data="{correctMask}" />
                <mx:Object label="Proxy Masking"                         data="{superMask}" />
                <mx:Object label="Bouncing Balls Field of View"         data="{bouncingBalls}" />
                <mx:Object label="Flipping Card"                         data="{flippingCard}" />
                <mx:Object label="A Cube"                                 data="{cubeDepthTest}" />
                <mx:Object label="Cube Within Cube"                     data="{cubeWithinCube}" />
                <mx:Object label="Gimbal Lock"                             data="{gimbalLock}" />
          </mx:ArrayCollection>
        </mx:ComboBox>

        <mx:CheckBox id="depthManagementOn"
                label="Depth Management On: " 
                selected="true"
                change="{ DEPTH_MANAGEMENT_ON = depthManagementOn.selected }" />
                
        <mx:CheckBox id="gridVisibleCb"
                label="Grid Visible"
                selected="true"
                change="{ gridVisible = gridVisibleCb.selected}"/>
    </mx:HBox>

    
    <mx:HRule width="100%" y="45"  />
    
    <mx:ViewStack id="presoViews"
            top="50" bottom="0"
            right="0" left="0">
            
        <!-- Shows what rotating on each axis does -->
        <preso:RotatingCards id="rotatingCards" />
        
        
        <!-- Demonstrates objects bouncing in space -->
        <preso:BouncingBalls id="bouncingBalls" />
    
    
        <!--- Example of Gimbal Lock -->
        <preso:GimbalLock id="gimbalLock" />
        
        <!-- Demonstraton of rotating multiple objects -->
        <preso:CubeWithinCube id="cubeWithinCube" />
        
        <!-- Demonstraton of making a cube with depth management -->
        <preso:CubeDepths id="cubeDepthTest" />
    
        <!-- Demonstrating simple flipping depth management -->
        <preso:FlippingCard id="flippingCard" />    
        
        
        <!-- Demonstrates making a proxy image mask -->
        <preso:ProxyImageMask id="superMask" />
        
        <!-- Demonstrates incorrect positioning of the mask -->
        <preso:MaskPositioned id="maskPosition" />
        
        <!-- Demonstrates incorrect positioning of the maskee -->
        <preso:MaskeePositioned id="maskeePosition" />
        
        <!-- Demonstrates correct masking for a shape -->
        <preso:CorrectMasking id="correctMask" />
        
        <!-- Demonstrates the change in ProjectionCenter -->
        <preso:PerspectiveProjectionDraggable id="projectionCenterTest" />    
        
        <!-- Demonstrates field of view -->
        <preso:FIeldOfView id="fieldOfView" />
        
        <!-- Demonstrates focal length -->
        <preso:FocalLength id="focalLenght" />
        
        <!-- Demonstrates the controls - specifically the sameness of .rotation and .rotationZ -->
        <preso:SimpleRotation id="simpleRotation" />
        
        <!-- Shows how the Perspective Projection is incorrect -->
        <preso:PanelTest id="panelTest"/>

    </mx:ViewStack>             
    
</mx:Application>