2
0

UITexturedQuad.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #pragma once
  5. #include <Renderer/Texture.h>
  6. /// Helper class that points to a subsection of a texture for rendering it as a quad. Can specify borders which won't scale (only inner part of the quad will scale).
  7. class UITexturedQuad
  8. {
  9. public:
  10. /// Constructor
  11. UITexturedQuad() = default;
  12. UITexturedQuad(const Texture *inTexture) : mTexture(inTexture), mWidth(inTexture->GetWidth()), mHeight(inTexture->GetHeight()) { }
  13. UITexturedQuad(const Texture *inTexture, int inX, int inY, int inWidth, int inHeight) : mTexture(inTexture), mX(inX), mY(inY), mWidth(inWidth), mHeight(inHeight) { }
  14. UITexturedQuad(const Texture *inTexture, int inX, int inY, int inWidth, int inHeight, int inInnerX, int inInnerY, int inInnerWidth, int inInnerHeight) : mTexture(inTexture), mX(inX), mY(inY), mWidth(inWidth), mHeight(inHeight), mInnerX(inInnerX), mInnerY(inInnerY), mInnerWidth(inInnerWidth), mInnerHeight(inInnerHeight) { }
  15. /// Check if this quad consists of 9 parts
  16. bool HasInnerPart() const { return mInnerX >= 0 && mInnerY >= 0 && mInnerWidth >= 0 && mInnerHeight >= 0; }
  17. /// The texture to use
  18. RefConst<Texture> mTexture;
  19. /// These are the normal texel coordinates for the quad
  20. int mX = 0;
  21. int mY = 0;
  22. int mWidth = 0;
  23. int mHeight = 0;
  24. /// This quad can also scale its inner part leaving borders in tact, in this case the inner scaling part is defined here
  25. int mInnerX = -1;
  26. int mInnerY = -1;
  27. int mInnerWidth = -1;
  28. int mInnerHeight = -1;
  29. };