GUILabel.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. using System.Runtime.CompilerServices;
  5. namespace BansheeEngine
  6. {
  7. /** @addtogroup GUI_Engine
  8. * @{
  9. */
  10. /// <summary>
  11. /// GUI element that displays text.
  12. /// </summary>
  13. public sealed class GUILabel : GUIElement
  14. {
  15. /// <summary>
  16. /// Creates a new label element.
  17. /// </summary>
  18. /// <param name="content">Content to display on the label.</param>
  19. /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as
  20. /// default layout options. Style will be retrieved from the active GUISkin. If not specified
  21. /// default element style is used.</param>
  22. /// <param name="options">Options that allow you to control how is the element positioned and sized. This will
  23. /// override any similar options set by style.</param>
  24. public GUILabel(GUIContent content, string style, params GUIOption[] options)
  25. {
  26. Internal_CreateInstance(this, ref content, style, options);
  27. }
  28. /// <summary>
  29. /// Creates a new label element.
  30. /// </summary>
  31. /// <param name="content">Content to display on the label.</param>
  32. /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as
  33. /// default layout options. Style will be retrieved from the active GUISkin. If not specified
  34. /// default element style is used.</param>
  35. public GUILabel(GUIContent content, string style = "")
  36. {
  37. Internal_CreateInstance(this, ref content, style, new GUIOption[0]);
  38. }
  39. /// <summary>
  40. /// Creates a new label element.
  41. /// </summary>
  42. /// <param name="content">Content to display on the label.</param>
  43. /// <param name="options">Options that allow you to control how is the element positioned and sized. This will
  44. /// override any similar options set by style.</param>
  45. public GUILabel(GUIContent content, params GUIOption[] options)
  46. {
  47. Internal_CreateInstance(this, ref content, "", options);
  48. }
  49. /// <summary>
  50. /// Updates the contents display on the label.
  51. /// </summary>
  52. /// <param name="content">Content to display on the label.</param>
  53. public void SetContent(GUIContent content)
  54. {
  55. Internal_SetContent(mCachedPtr, ref content);
  56. }
  57. /// <summary>
  58. /// Colors the element with a specific tint.
  59. /// </summary>
  60. /// <param name="color">Tint to apply to the element.</param>
  61. public void SetTint(Color color)
  62. {
  63. Internal_SetTint(mCachedPtr, ref color);
  64. }
  65. [MethodImpl(MethodImplOptions.InternalCall)]
  66. private static extern void Internal_CreateInstance(GUILabel instance, ref GUIContent content, string style,
  67. GUIOption[] options);
  68. [MethodImpl(MethodImplOptions.InternalCall)]
  69. private static extern void Internal_SetContent(IntPtr nativeInstance, ref GUIContent content);
  70. [MethodImpl(MethodImplOptions.InternalCall)]
  71. private static extern void Internal_SetTint(IntPtr nativeInstance, ref Color color);
  72. }
  73. /** @} */
  74. }