コード例 #1
0
        private void TestHeightDependsOnChildrenWithCenteredChildren()
        {
            GraphicalUiElement.IsAllLayoutSuspended = true;
            var parentContainer = new ContainerRuntime();

            parentContainer.Height      = 4;
            parentContainer.HeightUnits = Gum.DataTypes.DimensionUnitType.RelativeToChildren;

            var child = new ContainerRuntime();

            child.YOrigin     = VerticalAlignment.Center;
            child.YUnits      = Gum.Converters.GeneralUnitType.PixelsFromMiddle;
            child.Height      = 10;
            child.HeightUnits = Gum.DataTypes.DimensionUnitType.Absolute;
            child.Y           = 0;

            parentContainer.Children.Add(child);
            GraphicalUiElement.IsAllLayoutSuspended = false;

            parentContainer.UpdateLayout();

            var parentAbsoluteHeight = parentContainer.GetAbsoluteHeight();

            parentAbsoluteHeight.ShouldBe(child.Height + parentContainer.Height, "because the parent container should be the height of its child plus the padding");

            var childAbsoluteY = child.GetAbsoluteY();

            childAbsoluteY.ShouldBe(2, "because this child should be centered");
        }
コード例 #2
0
        private void CreatePauseResumeButton(ContainerRuntime stackPanel, Texture2D iconSpriteSheet)
        {
            var pauseResumeButton = new Button();

            var internalSprite = new global::RenderingLibrary.Graphics.Sprite(iconSpriteSheet);
            var sprite         = new GraphicalUiElement(internalSprite, null);

            sprite.Parent = pauseResumeButton.Visual;
            InitializeIconSprite(sprite);

            SetToPauseIcon(sprite);

            pauseResumeButton.Visual.Parent = stackPanel;
            pauseResumeButton.Text          = "";
            // do an absolute width because otherwise it will change size according to the icons
            pauseResumeButton.Visual.Width  = 36;
            pauseResumeButton.Visual.Height = 38;
            pauseResumeButton.X             = borderWidth;
            pauseResumeButton.Y             = borderWidth;
            pauseResumeButton.Push         += (not, used) =>
            {
                var screen = FlatRedBall.Screens.ScreenManager.CurrentScreen;
                if (screen.IsPaused)
                {
                    screen.UnpauseThisScreen();
                    SetToPauseIcon(sprite);
                }
                else
                {
                    screen.PauseThisScreen();
                    SetToPlayIcon(sprite);
                }
            };
        }
コード例 #3
0
        private void TestAddChildSetsParent()
        {
            var first  = new ContainerRuntime();
            var second = new ContainerRuntime();

            first.Children.Add(second);

            second.Parent.ShouldBe(first, "because adding to children should set the child's parent");

            first.Children.Remove(second);

            second.Parent.ShouldBe(null, "because removing the child should set the parent to null");
        }
コード例 #4
0
        private void CreateRestartButton(ContainerRuntime stackPanel, Texture2D iconSpriteSheet)
        {
            var restartButton = new Button();

            restartButton.Visual.Parent     = stackPanel;
            restartButton.Visual.WidthUnits = global::Gum.DataTypes.DimensionUnitType.RelativeToChildren;
            restartButton.Visual.Width      = 10;
            restartButton.Visual.Height     = 38;
            restartButton.X     = borderWidth;
            restartButton.Y     = borderWidth;
            restartButton.Text  = "";
            restartButton.Push += (not, used) => FlatRedBall.Screens.ScreenManager.CurrentScreen.RestartScreen(reloadContent: true);

            var internalSprite = new global::RenderingLibrary.Graphics.Sprite(iconSpriteSheet);
            var restartSprite  = new GraphicalUiElement(internalSprite, null);

            restartSprite.Parent = restartButton.Visual;
            InitializeIconSprite(restartSprite);
            restartSprite.TextureLeft   = 0;
            restartSprite.TextureTop    = 0;
            restartSprite.TextureWidth  = 30;
            restartSprite.TextureHeight = 30;
        }
コード例 #5
0
        private void CreateLayout()
        {
            this.Visual.WidthUnits  = global::Gum.DataTypes.DimensionUnitType.RelativeToChildren;
            this.Visual.HeightUnits = global::Gum.DataTypes.DimensionUnitType.RelativeToChildren;
            this.Width  = borderWidth;
            this.Height = borderWidth;

            var stackPanel = new ContainerRuntime();

            stackPanel.ExposeChildrenEvents = true;
            stackPanel.ChildrenLayout       = global::Gum.Managers.ChildrenLayout.LeftToRightStack;
            stackPanel.WidthUnits           = global::Gum.DataTypes.DimensionUnitType.RelativeToChildren;
            stackPanel.Width       = 0;
            stackPanel.HeightUnits = global::Gum.DataTypes.DimensionUnitType.RelativeToChildren;
            stackPanel.Height      = 0;
            stackPanel.Parent      = this.Visual;

            var iconSpriteSheet = FlatRedBallServices.Load <Texture2D>("content/globalContent/runtimedebugging/spritesheet.png");

            CreateRestartButton(stackPanel, iconSpriteSheet);

            CreatePauseResumeButton(stackPanel, iconSpriteSheet);
        }
コード例 #6
0
 /// <summary>
 /// Specifies a container runtime, e.g. NVIDIA for GPU workloads.
 /// </summary>
 /// <param name="runtime">A runtime to execute the container under.</param>
 /// <returns>Itself for fluent access.</returns>
 /// <remarks>
 /// By default, containers execute under docker provided default environment
 /// <see cref="ContainerRuntime.Default"/>. It is not neccesary to specify
 /// such. Instead, if a custom runtime is wanted for the container specify custom
 /// runtime such as <see cref="ContainerRuntime.Nvidia"/>.
 /// </remarks>
 public ContainerBuilder UseRuntime(ContainerRuntime runtime)
 {
     _config.CreateParams.Runtime = runtime;
     return(this);
 }