GUIProgressBar.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. namespace BansheeEngine
  4. {
  5. /// <summary>
  6. /// GUI element containing a background image and a fill image that is scaled depending on the percentage set by the
  7. /// caller.
  8. /// </summary>
  9. public sealed class GUIProgressBar : GUIElement
  10. {
  11. /// <summary>
  12. /// Value that controls the width of the progress bar fill image. Range [0, 1].
  13. /// </summary>
  14. public float Percent
  15. {
  16. get { return Internal_GetPercent(mCachedPtr); }
  17. set { Internal_SetPercent(mCachedPtr, value); }
  18. }
  19. /// <summary>
  20. /// Creates a new progress bar element.
  21. /// </summary>
  22. /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as
  23. /// default layout options. Style will be retrieved from the active GUISkin. If not specified default element style
  24. /// is used.
  25. /// </param>
  26. /// <param name="options">Options that allow you to control how is the element positioned and sized. This will
  27. /// override any similar options set by style.
  28. /// </param>
  29. public GUIProgressBar(string style, params GUIOption[] options)
  30. {
  31. Internal_CreateInstance(this, style, options);
  32. }
  33. /// <summary>
  34. /// Creates a new progress bar element.
  35. /// </summary>
  36. /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as
  37. /// default layout options. Style will be retrieved from the active GUISkin. If not specified default element style
  38. /// is used.
  39. /// </param>
  40. public GUIProgressBar(string style = "")
  41. {
  42. Internal_CreateInstance(this, style, new GUIOption[0]);
  43. }
  44. /// <summary>
  45. /// Colors the element with a specific tint.
  46. /// </summary>
  47. /// <param name="color">Tint to apply to the element.</param>
  48. public void SetTint(Color color)
  49. {
  50. Internal_SetTint(mCachedPtr, color);
  51. }
  52. [MethodImpl(MethodImplOptions.InternalCall)]
  53. private static extern void Internal_CreateInstance(GUIProgressBar instance, string style, GUIOption[] options);
  54. [MethodImpl(MethodImplOptions.InternalCall)]
  55. private static extern float Internal_GetPercent(IntPtr nativeInstance);
  56. [MethodImpl(MethodImplOptions.InternalCall)]
  57. private static extern void Internal_SetPercent(IntPtr nativeInstance, float percent);
  58. [MethodImpl(MethodImplOptions.InternalCall)]
  59. private static extern void Internal_SetTint(IntPtr nativeInstance, Color color);
  60. }
  61. }