CImage.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #pragma once
  2. #include "WallpaperEngine/Core/Objects/Images/CMaterial.h"
  3. #include "WallpaperEngine/Core/Core.h"
  4. #include "WallpaperEngine/Core/CObject.h"
  5. #include "WallpaperEngine/Assets/CContainer.h"
  6. #include "WallpaperEngine/Core/UserSettings/CUserSettingBoolean.h"
  7. #include "WallpaperEngine/Core/UserSettings/CUserSettingFloat.h"
  8. #include "WallpaperEngine/Core/UserSettings/CUserSettingVector3.h"
  9. namespace WallpaperEngine::Core
  10. {
  11. class CScene;
  12. }
  13. namespace WallpaperEngine::Core::Objects
  14. {
  15. using json = nlohmann::json;
  16. using namespace WallpaperEngine::Assets;
  17. using namespace WallpaperEngine::Core::UserSettings;
  18. /**
  19. * Represents an image in a background
  20. */
  21. class CImage : public CObject
  22. {
  23. friend class CObject;
  24. public:
  25. static CObject* fromJSON (
  26. CScene* scene, json data, CContainer* container, CUserSettingBoolean* visible, uint32_t id,
  27. std::string name, CUserSettingVector3* origin, CUserSettingVector3* scale, const glm::vec3& angles
  28. );
  29. /**
  30. * @return The base material to use for the image
  31. */
  32. [[nodiscard]] const Images::CMaterial* getMaterial () const;
  33. /**
  34. * @return The size of the image
  35. */
  36. [[nodiscard]] const glm::vec2& getSize () const;
  37. /**
  38. * @return The type of alignment to use for image positioning
  39. */
  40. [[nodiscard]] const std::string& getAlignment () const;
  41. /**
  42. * @return The alpha value for the image's rendering
  43. */
  44. [[nodiscard]] float getAlpha () const;
  45. /**
  46. * @return The color to use for the image
  47. */
  48. [[nodiscard]] glm::vec3 getColor () const;
  49. /**
  50. * @return The brightness to use for the image
  51. */
  52. [[nodiscard]] float getBrightness () const;
  53. /**
  54. * @return The color blending mode to be used, special value for shaders
  55. */
  56. [[nodiscard]] uint32_t getColorBlendMode () const;
  57. /**
  58. * @return Parallax depth of the image
  59. */
  60. [[nodiscard]] const glm::vec2& getParallaxDepth () const;
  61. /**
  62. * @return If the image is fullscreen or not
  63. */
  64. [[nodiscard]] bool isFullscreen () const;
  65. /**
  66. * @return If the image is passthrough or not
  67. */
  68. [[nodiscard]] bool isPassthrough () const;
  69. /**
  70. * @return If the image is autosized or not
  71. */
  72. [[nodiscard]] bool isAutosize () const;
  73. protected:
  74. CImage (
  75. CScene* scene, Images::CMaterial* material, CUserSettingBoolean* visible, uint32_t id, std::string name,
  76. CUserSettingVector3* origin, CUserSettingVector3* scale, const glm::vec3& angles, const glm::vec2& size,
  77. std::string alignment, CUserSettingVector3* color, CUserSettingFloat* alpha, float brightness,
  78. uint32_t colorBlendMode, const glm::vec2& parallaxDepth, bool fullscreen, bool passthrough, bool autosize
  79. );
  80. /**
  81. * Type value used to differentiate the different types of objects in a background
  82. */
  83. static const std::string Type;
  84. private:
  85. /** The image's size */
  86. glm::vec2 m_size;
  87. /** Parallax depth */
  88. const glm::vec2 m_parallaxDepth;
  89. /** Base material for the image */
  90. Images::CMaterial* m_material;
  91. /** What type of alignment to use for the image's position */
  92. std::string m_alignment;
  93. /** The alpha value for the image */
  94. CUserSettingFloat* m_alpha;
  95. /** The brightness for the image */
  96. float m_brightness;
  97. /** The color to use for the image */
  98. CUserSettingVector3* m_color;
  99. /** The color blending mode used for the image, special value for shaders */
  100. uint32_t m_colorBlendMode;
  101. /** If the image is fullscreen or not */
  102. bool m_fullscreen;
  103. /** If the image is passthrough or not */
  104. bool m_passthrough;
  105. /** If the image's size should be automatically determined */
  106. bool m_autosize;
  107. };
  108. }