ProgressBar.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include "BorderImage.h"
  5. #include "../Math/Vector2.h"
  6. #include "Text.h"
  7. namespace Urho3D
  8. {
  9. /// %ProgressBar bar %UI element.
  10. class URHO3D_API ProgressBar : public BorderImage
  11. {
  12. URHO3D_OBJECT(ProgressBar, BorderImage);
  13. public:
  14. /// Construct.
  15. explicit ProgressBar(Context *context);
  16. /// Destruct.
  17. ~ProgressBar() override;
  18. /// Register object factory.
  19. /// @nobind
  20. static void RegisterObject(Context *context);
  21. /// React to resize.
  22. void OnResize(const IntVector2& newSize, const IntVector2& delta) override;
  23. /// Set orientation type.
  24. /// @property
  25. void SetOrientation(Orientation orientation);
  26. /// Set ProgressBar range maximum value (minimum value is always 0).
  27. /// @property
  28. void SetRange(float range);
  29. /// Set ProgressBar current value.
  30. /// @property
  31. void SetValue(float value);
  32. /// Change value by a delta.
  33. void ChangeValue(float delta);
  34. /// Return orientation type.
  35. /// @property
  36. Orientation GetOrientation() const { return orientation_; }
  37. /// Return ProgressBar range.
  38. /// @property
  39. float GetRange() const { return range_; }
  40. /// Return ProgressBar current value.
  41. /// @property
  42. float GetValue() const { return value_; }
  43. /// Return knob element.
  44. /// @property
  45. BorderImage *GetKnob() const { return knob_; }
  46. /// Sets the loading percent style.
  47. void SetLoadingPercentStyle(const String &style) { loadingPercentStyle_ = style; }
  48. /// Returns the loading percent style.
  49. const String& GetLoadingPercentStyle() const { return loadingPercentStyle_; }
  50. /// Sets the flag to display the percent text.
  51. /// @property
  52. void SetShowPercentText(bool enable);
  53. /// Returns the flag to display the percent text.
  54. /// @property
  55. bool GetShowPercentText() const { return showPercentText_; }
  56. protected:
  57. /// Filter implicit attributes in serialization process.
  58. bool FilterImplicitAttributes(XMLElement &dest) const override;
  59. /// Update ProgressBar knob position & size.
  60. void UpdateProgressBar();
  61. /// ProgressBar knob.
  62. SharedPtr<BorderImage> knob_;
  63. /// ProgressBar text.
  64. SharedPtr<Text> loadingText_;
  65. /// Orientation.
  66. Orientation orientation_;
  67. /// ProgressBar text style.
  68. String loadingPercentStyle_;
  69. /// ProgressBar range.
  70. float range_;
  71. /// ProgressBar current value.
  72. float value_;
  73. /// Flag to show the percent text.
  74. bool showPercentText_;
  75. };
  76. }