Animation.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * This source file is part of libRocket, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://www.librocket.com
  5. *
  6. * Copyright (c) 2018 Michael Ragazzon
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. *
  26. */
  27. #ifndef ROCKETCOREANIMATION_H
  28. #define ROCKETCOREANIMATION_H
  29. #include "String.h"
  30. #include "Tween.h"
  31. namespace Rocket {
  32. namespace Core {
  33. /* Data parsed from the 'animation' property. */
  34. struct Animation {
  35. float duration = 0.0f;
  36. Tween tween;
  37. float delay = 0.0f;
  38. bool alternate = false;
  39. bool paused = false;
  40. int num_iterations = 1;
  41. String name;
  42. };
  43. typedef std::vector<Animation> AnimationList;
  44. /* Data parsed from the 'transition' property. */
  45. struct Transition {
  46. String name;
  47. Tween tween;
  48. float duration = 0.0f;
  49. float delay = 0.0f;
  50. float reverse_adjustment_factor = 0.0f;
  51. };
  52. struct TransitionList {
  53. bool none = true;
  54. bool all = false;
  55. std::vector<Transition> transitions;
  56. };
  57. inline bool operator==(const Animation& a, const Animation& b) { return a.duration == b.duration && a.tween == b.tween && a.delay == b.delay && a.alternate == b.alternate && a.paused == b.paused && a.num_iterations == b.num_iterations && a.name == b.name; }
  58. inline bool operator!=(const Animation& a, const Animation& b) { return !(a == b); }
  59. inline bool operator==(const Transition& a, const Transition& b) { return a.name == b.name && a.tween == b.tween && a.duration == b.duration && a.delay == b.delay && a.reverse_adjustment_factor == b.reverse_adjustment_factor; }
  60. inline bool operator!=(const Transition& a, const Transition& b) { return !(a == b); }
  61. inline bool operator==(const TransitionList& a, const TransitionList& b) { return a.none == b.none && a.all == b.all && a.transitions == b.transitions; }
  62. inline bool operator!=(const TransitionList& a, const TransitionList& b) { return !(a == b); }
  63. }
  64. }
  65. #endif