BsGUIProgressBar.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsPrerequisites.h"
  5. #include "BsGUIElementContainer.h"
  6. #include "BsEvent.h"
  7. namespace BansheeEngine
  8. {
  9. /** @addtogroup GUI
  10. * @{
  11. */
  12. /**
  13. * GUI element containing a background image and a fill image that is scaled depending on the percentage set by the
  14. * caller.
  15. */
  16. class BS_EXPORT GUIProgressBar : public GUIElementContainer
  17. {
  18. public:
  19. /** Returns type name of the GUI element used for finding GUI element styles. */
  20. static const String& getGUITypeName();
  21. /** Name of the style for the fill image used by the progress bar. */
  22. static const String& getBarStyleType();
  23. /** Name of the style for the background image used by the progress bar. */
  24. static const String& getBackgroundStyleType();
  25. /**
  26. * Creates a new progress bar.
  27. *
  28. * @param[in] styleName Optional style to use for the element. Style will be retrieved from GUISkin of the
  29. * GUIWidget the element is used on. If not specified default style is used.
  30. */
  31. static GUIProgressBar* create(const String& styleName = StringUtil::BLANK);
  32. /**
  33. * Creates a new progress bar.
  34. *
  35. * @param[in] options Options that allow you to control how is the element positioned and sized. This will
  36. * override any similar options set by style.
  37. * @param[in] styleName Optional style to use for the element. Style will be retrieved from GUISkin of the
  38. * GUIWidget the element is used on. If not specified default style is used.
  39. */
  40. static GUIProgressBar* create(const GUIOptions& options, const String& styleName = StringUtil::BLANK);
  41. /**
  42. * Fills up the progress bar up to the specified percentage.
  43. *
  44. * @param[in] pct How far to extend the fill image, in percent ranging [0.0f, 1.0f]
  45. */
  46. void setPercent(float pct);
  47. /** Gets the percentage of how full is the progress bar currently. */
  48. float getPercent() const { return mPercent; }
  49. /** @copydoc GUIElement::setTint */
  50. virtual void setTint(const Color& color) override;
  51. public: // ***** INTERNAL ******
  52. /** @name Internal
  53. * @{
  54. */
  55. /** @copydoc GUIElementContainer::_getOptimalSize */
  56. virtual Vector2I _getOptimalSize() const override;
  57. /** @} */
  58. protected:
  59. GUIProgressBar(const String& styleName, const GUIDimensions& dimensions);
  60. /** @copydoc GUIElementContainer::_updateLayoutInternal */
  61. virtual void _updateLayoutInternal(const GUILayoutData& data) override;
  62. /** @copydoc GUIElementContainer::styleUpdated */
  63. void styleUpdated() override;
  64. private:
  65. GUITexture* mBar;
  66. GUITexture* mBackground;
  67. float mPercent;
  68. };
  69. /** @} */
  70. }