Example #1
0
        public UserInterfaceScene(GraphicsDevice graphicsDevice,
                                  IUserInterfaceRenderer userInterfaceRenderer,
                                  IContentLayoutEngine contentLayoutEngine,
                                  IFontProvider fontProvider,
                                  IStyleConfigurator styleConfigurator,
                                  IAnimationFactory animationFactory = null,
                                  IUserInterfaceAudio audio          = null,
                                  IDoubleBuffer doubleBuffer         = null,
                                  RenderTarget2D renderTarget        = null)
        {
            DrawBelow   = true;
            UpdateBelow = false;

            Animations     = animationFactory ?? new AnimationFactory();
            GraphicsDevice = graphicsDevice;

            renderContext = new UserInterfaceRenderContext(
                graphicsDevice,
                contentLayoutEngine,
                userInterfaceRenderer,
                styleConfigurator,
                fontProvider,
                Animations,
                renderTarget,
                null,
                doubleBuffer);

            driver = new UserInterfaceSceneDriver(
                renderContext,
                styleConfigurator,
                fontProvider,
                audio);

            driver.ScreenArea = new Rectangle(Point.Zero,
                                              GraphicsDeviceRenderTargetSize);

            driver.Desktop.Empty += () =>
            {
                if (ExitWhenEmpty)
                {
                    IsFinished = true;
                }
            };

            BlendState = new BlendState
            {
                ColorSourceBlend      = Blend.SourceAlpha,
                ColorDestinationBlend = Blend.InverseSourceAlpha,
                AlphaSourceBlend      = Blend.One,
                AlphaDestinationBlend = Blend.InverseSourceAlpha,
            };
        }
        public UserInterfaceRenderContext(UserInterfaceRenderContext parent,
                                          SpriteBatch spriteBatch,
                                          RenderTarget2D renderTarget)
        {
            this.GraphicsDevice = parent.GraphicsDevice;
            this.SpriteBatch    = spriteBatch;
            this.RenderTarget   = renderTarget;

            this.contentLayoutEngine   = parent.contentLayoutEngine;
            this.GameTime              = parent.GameTime;
            this.UserInterfaceRenderer = parent.UserInterfaceRenderer;
            this.DoubleBuffer          = parent.DoubleBuffer;

            this.WorkspaceIsActive = parent.WorkspaceIsActive;

            this.parentRenderContext = parent;
        }