/Scenes/Tests/BaseControlsTests.cs
C# | 120 lines | 54 code | 7 blank | 59 comment | 3 complexity | 5d646861bc888f9c5dcd9d53baf0894d MD5 | raw file
Possible License(s): Apache-2.0
- using Delta.Engine;
- using Delta.InputSystem;
- using Delta.Scenes.Enums;
- using Delta.Scenes.UserInterfaces;
- using Delta.Scenes.UserInterfaces.Controls;
- using Delta.Scenes.UserInterfaces.Designs;
- using Delta.Utilities.Datatypes;
- using NUnit.Framework;
-
- namespace Delta.Scenes.Tests
- {
- /// <summary>
- /// Base controls tests
- /// </summary>
- internal static class BaseControlsTests
- {
- #region Dragging (LongRunning)
- /// <summary>
- /// Dragging
- /// </summary>
- [Test, Category("Visual")]
- public static void Dragging()
- {
- Settings.Extra.LimitFramerateNumber = 30;
-
- // Create our test scene
- Screen testScene = new Screen();
-
- // a label as
- Label dragLabel = new Label
- {
- LocalArea = new Rectangle(0.3f, 0.3f, 0.2f, 0.2f),
- CustomDesign = new TextControlDesign
- {
- Background = BaseTheme.GetUIMaterial(Color.Green),
- TextFont = Theme.Current.LabelDesign.TextFont,
- }
- };
-
- bool isDragging = false;
- dragLabel.Dragging += delegate(BaseControl sender, DragState dragState,
- CommandTrigger input)
- {
- isDragging = dragState != DragState.DragEnd;
- if (dragState == DragState.DragMove)
- {
- sender.LocalArea = sender.LocalArea.Move(input.Movement);
- } // if
- input.IsHandled = true;
- };
- testScene.Add(dragLabel);
-
- // Open now the scene to "activate" for the test
- testScene.Open();
-
- // Finally start the test app
- Application.Start(delegate
- {
- // whereby we show the current mode in the text of the child label
- dragLabel.Text = "IsDragging=" + isDragging;
- });
- }
- #endregion
-
- #region AnchorPoint
- /// <summary>
- /// Anchor point
- /// </summary>
- [Test]
- public static void AnchorPoint()
- {
- // // Create our test scene
- // UserScreen testScene = new UserScreen();
- //
- // // a normal label as a parent
- // Label parentLabel = new Label
- // {
- // LocalArea = new Rectangle(0.3f, 0.3f, 0.2f, 0.2f),
- // CustomDesign = new TextControlDesign
- // {
- // Background = UserTheme.GetUIMaterial(Color.Green),
- // TextFont = UserTheme.Current.LabelDesign.TextFont,
- // }
- // };
- // testScene.Add(parentLabel);
- //
- // // for the child control because without a parent the anchor point
- // // feature doesn't make sense and the scene root control has the mostly
- // // time a bigger area as is visible on the screen
- // Label childLabel = new Label
- // {
- // LocalArea = new Rectangle(0.05f, 0.03f, 0.05f, 0.05f),
- // CustomDesign = new TextControlDesign
- // {
- // Background = UserTheme.GetUIMaterial(Color.Yellow),
- // TextFont = UserTheme.Current.LabelDesign.TextFont,
- // }
- // };
- // parentLabel.Add(childLabel);
- //
- // // Open now the scene to "activate" for the test
- // testScene.Open();
- //
- // // Finally start the test app
- // Application.Start(delegate
- // {
- // // and allow toggle the anchor point modes by the "Space" key
- // if (Input.Keyboard.SpaceReleased)
- // {
- // childLabel.AnchorPoint =
- // EnumHelper.NextValue(childLabel.AnchorPoint);
- // }
- //
- // // whereby we show the current mode in the text of the (child)label
- // childLabel.Text = "AnchorPoint." + childLabel.AnchorPoint;
- // });
- }
- #endregion
- }
- }