Transform.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * This source file is part of RmlUi, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://github.com/mikke89/RmlUi
  5. *
  6. * Copyright (c) 2014 Markus Schöngart
  7. * Copyright (c) 2019-2023 The RmlUi Team, and contributors
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10. * of this software and associated documentation files (the "Software"), to deal
  11. * in the Software without restriction, including without limitation the rights
  12. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. * copies of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included in
  17. * all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. * THE SOFTWARE.
  26. *
  27. */
  28. #ifndef RMLUI_CORE_TRANSFORM_H
  29. #define RMLUI_CORE_TRANSFORM_H
  30. #include "Header.h"
  31. #include "TransformPrimitive.h"
  32. #include "Types.h"
  33. namespace Rml {
  34. class Property;
  35. /**
  36. The Transform class holds the information parsed from an element's `transform' property.
  37. The class holds a list of transform primitives making up a complete transformation specification
  38. of an element. Each transform instance is relative to the element's parent coordinate system.
  39. During the Context::Render call, the transforms of the current element and its ancestors will be
  40. used to find the final transformation matrix for the global coordinate system.
  41. @author Markus Schöngart
  42. @see Rml::Variant
  43. */
  44. class RMLUICORE_API Transform {
  45. public:
  46. using PrimitiveList = Vector<TransformPrimitive>;
  47. /// Default constructor, initializes an identity transform
  48. Transform();
  49. /// Construct transform with a list of primitives
  50. Transform(PrimitiveList primitives);
  51. /// Helper function to create a 'transform' Property from the given list of primitives
  52. static Property MakeProperty(PrimitiveList primitives);
  53. /// Remove all Primitives from this Transform
  54. void ClearPrimitives();
  55. /// Add a Primitive to this Transform
  56. void AddPrimitive(const TransformPrimitive& p);
  57. /// Return the number of Primitives in this Transform
  58. int GetNumPrimitives() const noexcept;
  59. /// Return the i-th Primitive in this Transform
  60. const TransformPrimitive& GetPrimitive(int i) const noexcept;
  61. PrimitiveList& GetPrimitives() noexcept { return primitives; }
  62. const PrimitiveList& GetPrimitives() const noexcept { return primitives; }
  63. private:
  64. PrimitiveList primitives;
  65. };
  66. } // namespace Rml
  67. #endif