guiFadeinBitmapCtrl.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _GUIFADEINBITMAPCTRL_H_
  23. #define _GUIFADEINBITMAPCTRL_H_
  24. #ifndef _GUIBITMAPCTRL_H_
  25. #include "gui/controls/guiBitmapCtrl.h"
  26. #endif
  27. #ifndef _MEASE_H_
  28. #include "math/mEase.h"
  29. #endif
  30. /// A control that fades a bitmap in and out.
  31. class GuiFadeinBitmapCtrl : public GuiBitmapCtrl
  32. {
  33. public:
  34. typedef GuiBitmapCtrl Parent;
  35. protected:
  36. /// Color we fade in from and fade out to.
  37. LinearColorF mFadeColor;
  38. /// Reference time on which to base all fade timings.
  39. U32 mStartTime;
  40. /// Milliseconds for bitmap to fade in.
  41. U32 mFadeInTime;
  42. /// Milliseconds to wait before fade-out.
  43. U32 mWaitTime;
  44. /// Milliseconds for bitmap to fade out.
  45. U32 mFadeOutTime;
  46. /// Easing curve for fade-in.
  47. EaseF mFadeInEase;
  48. /// Easing curve for fade-out.
  49. EaseF mFadeOutEase;
  50. /// Whether the fade cycle has run completely.
  51. bool mDone;
  52. public:
  53. GuiFadeinBitmapCtrl();
  54. // GuiControl.
  55. virtual void onPreRender();
  56. virtual void onMouseDown(const GuiEvent &);
  57. virtual bool onKeyDown(const GuiEvent &);
  58. virtual bool onGamepadButtonDown(const GuiEvent& event);
  59. virtual bool onWake();
  60. virtual void onRender(Point2I offset, const RectI &updateRect);
  61. static void initPersistFields();
  62. DECLARE_CONOBJECT( GuiFadeinBitmapCtrl );
  63. DECLARE_DESCRIPTION( "A control that shows a bitmap. It fades the bitmap in a set amount of time,\n"
  64. "then waits a set amount of time, and finally fades the bitmap back out in\n"
  65. "another set amount of time." );
  66. DECLARE_CALLBACK( void, click, ());
  67. DECLARE_CALLBACK( void, onDone, ());
  68. };
  69. #endif // !_GUIFADEINBITMAPCTRL_H_