PageRenderTime 52ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llui/llloadingindicator.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 104 lines | 40 code | 18 blank | 46 comment | 0 complexity | f84122a35ccdcdb103ac4d22e71432d8 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llloadingindicator.h
  3. * @brief Perpetual loading indicator
  4. *
  5. * $LicenseInfo:firstyear=2010&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLLOADINGINDICATOR_H
  27. #define LL_LLLOADINGINDICATOR_H
  28. #include "lluictrl.h"
  29. #include "lluiimage.h"
  30. ///////////////////////////////////////////////////////////////////////////////
  31. // class LLLoadingIndicator
  32. ///////////////////////////////////////////////////////////////////////////////
  33. /**
  34. * Perpetual loading indicator (a la MacOSX or YouTube)
  35. *
  36. * Number of rotations per second can be overridden
  37. * with the "images_per_sec" parameter.
  38. *
  39. * Can start/stop spinning.
  40. *
  41. * @see start()
  42. * @see stop()
  43. */
  44. class LLLoadingIndicator
  45. : public LLUICtrl
  46. {
  47. LOG_CLASS(LLLoadingIndicator);
  48. public:
  49. struct Images : public LLInitParam::BatchBlock<Images>
  50. {
  51. Multiple<LLUIImage*> image;
  52. Images()
  53. : image("image")
  54. {}
  55. };
  56. struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
  57. {
  58. Optional<F32> images_per_sec;
  59. Optional<Images> images;
  60. Params()
  61. : images_per_sec("images_per_sec", 1.0f),
  62. images("images")
  63. {}
  64. };
  65. virtual ~LLLoadingIndicator() {}
  66. // llview overrides
  67. virtual void draw();
  68. /**
  69. * Stop spinning.
  70. */
  71. void stop();
  72. /**
  73. * Start spinning.
  74. */
  75. void start();
  76. void reset() { mCurImageIdx = 0; }
  77. private:
  78. LLLoadingIndicator(const Params&);
  79. void initFromParams(const Params&);
  80. friend class LLUICtrlFactory;
  81. F32 mImagesPerSec;
  82. S8 mCurImageIdx;
  83. LLFrameTimer mImageSwitchTimer;
  84. std::vector<LLUIImagePtr> mImages;
  85. };
  86. #endif // LL_LLLOADINGINDICATOR_H