GUIProgressBar.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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
  24. /// default element style is used.</param>
  25. /// <param name="options">Options that allow you to control how is the element positioned and sized. This will
  26. /// override any similar options set by style.</param>
  27. public GUIProgressBar(string style, params GUIOption[] options)
  28. {
  29. Internal_CreateInstance(this, style, options);
  30. }
  31. /// <summary>
  32. /// Creates a new progress bar element.
  33. /// </summary>
  34. /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as
  35. /// default layout options. Style will be retrieved from the active GUISkin. If not specified
  36. /// default element style is used.</param>
  37. public GUIProgressBar(string style = "")
  38. {
  39. Internal_CreateInstance(this, style, new GUIOption[0]);
  40. }
  41. /// <summary>
  42. /// Colors the element with a specific tint.
  43. /// </summary>
  44. /// <param name="color">Tint to apply to the element.</param>
  45. public void SetTint(Color color)
  46. {
  47. Internal_SetTint(mCachedPtr, color);
  48. }
  49. [MethodImpl(MethodImplOptions.InternalCall)]
  50. private static extern void Internal_CreateInstance(GUIProgressBar instance, string style, GUIOption[] options);
  51. [MethodImpl(MethodImplOptions.InternalCall)]
  52. private static extern float Internal_GetPercent(IntPtr nativeInstance);
  53. [MethodImpl(MethodImplOptions.InternalCall)]
  54. private static extern void Internal_SetPercent(IntPtr nativeInstance, float percent);
  55. [MethodImpl(MethodImplOptions.InternalCall)]
  56. private static extern void Internal_SetTint(IntPtr nativeInstance, Color color);
  57. }
  58. }