PageRenderTime 42ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/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
  1. using Delta.Engine;
  2. using Delta.InputSystem;
  3. using Delta.Scenes.Enums;
  4. using Delta.Scenes.UserInterfaces;
  5. using Delta.Scenes.UserInterfaces.Controls;
  6. using Delta.Scenes.UserInterfaces.Designs;
  7. using Delta.Utilities.Datatypes;
  8. using NUnit.Framework;
  9. namespace Delta.Scenes.Tests
  10. {
  11. /// <summary>
  12. /// Base controls tests
  13. /// </summary>
  14. internal static class BaseControlsTests
  15. {
  16. #region Dragging (LongRunning)
  17. /// <summary>
  18. /// Dragging
  19. /// </summary>
  20. [Test, Category("Visual")]
  21. public static void Dragging()
  22. {
  23. Settings.Extra.LimitFramerateNumber = 30;
  24. // Create our test scene
  25. Screen testScene = new Screen();
  26. // a label as
  27. Label dragLabel = new Label
  28. {
  29. LocalArea = new Rectangle(0.3f, 0.3f, 0.2f, 0.2f),
  30. CustomDesign = new TextControlDesign
  31. {
  32. Background = BaseTheme.GetUIMaterial(Color.Green),
  33. TextFont = Theme.Current.LabelDesign.TextFont,
  34. }
  35. };
  36. bool isDragging = false;
  37. dragLabel.Dragging += delegate(BaseControl sender, DragState dragState,
  38. CommandTrigger input)
  39. {
  40. isDragging = dragState != DragState.DragEnd;
  41. if (dragState == DragState.DragMove)
  42. {
  43. sender.LocalArea = sender.LocalArea.Move(input.Movement);
  44. } // if
  45. input.IsHandled = true;
  46. };
  47. testScene.Add(dragLabel);
  48. // Open now the scene to "activate" for the test
  49. testScene.Open();
  50. // Finally start the test app
  51. Application.Start(delegate
  52. {
  53. // whereby we show the current mode in the text of the child label
  54. dragLabel.Text = "IsDragging=" + isDragging;
  55. });
  56. }
  57. #endregion
  58. #region AnchorPoint
  59. /// <summary>
  60. /// Anchor point
  61. /// </summary>
  62. [Test]
  63. public static void AnchorPoint()
  64. {
  65. // // Create our test scene
  66. // UserScreen testScene = new UserScreen();
  67. //
  68. // // a normal label as a parent
  69. // Label parentLabel = new Label
  70. // {
  71. // LocalArea = new Rectangle(0.3f, 0.3f, 0.2f, 0.2f),
  72. // CustomDesign = new TextControlDesign
  73. // {
  74. // Background = UserTheme.GetUIMaterial(Color.Green),
  75. // TextFont = UserTheme.Current.LabelDesign.TextFont,
  76. // }
  77. // };
  78. // testScene.Add(parentLabel);
  79. //
  80. // // for the child control because without a parent the anchor point
  81. // // feature doesn't make sense and the scene root control has the mostly
  82. // // time a bigger area as is visible on the screen
  83. // Label childLabel = new Label
  84. // {
  85. // LocalArea = new Rectangle(0.05f, 0.03f, 0.05f, 0.05f),
  86. // CustomDesign = new TextControlDesign
  87. // {
  88. // Background = UserTheme.GetUIMaterial(Color.Yellow),
  89. // TextFont = UserTheme.Current.LabelDesign.TextFont,
  90. // }
  91. // };
  92. // parentLabel.Add(childLabel);
  93. //
  94. // // Open now the scene to "activate" for the test
  95. // testScene.Open();
  96. //
  97. // // Finally start the test app
  98. // Application.Start(delegate
  99. // {
  100. // // and allow toggle the anchor point modes by the "Space" key
  101. // if (Input.Keyboard.SpaceReleased)
  102. // {
  103. // childLabel.AnchorPoint =
  104. // EnumHelper.NextValue(childLabel.AnchorPoint);
  105. // }
  106. //
  107. // // whereby we show the current mode in the text of the (child)label
  108. // childLabel.Text = "AnchorPoint." + childLabel.AnchorPoint;
  109. // });
  110. }
  111. #endregion
  112. }
  113. }