CWallpaperApplication.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #pragma once
  2. #include "WallpaperEngine/Application/CApplicationContext.h"
  3. #include "WallpaperEngine/Assets/CCombinedContainer.h"
  4. #include "WallpaperEngine/Core/CProject.h"
  5. #include "WallpaperEngine/Render/CRenderContext.h"
  6. #include "WallpaperEngine/Render/CWallpaper.h"
  7. #include "WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.h"
  8. #include "WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h"
  9. #ifdef ENABLE_WAYLAND
  10. #include "WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h"
  11. #endif
  12. #ifdef ENABLE_X11
  13. #include "WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h"
  14. #endif
  15. #ifdef ENABLE_WAYLAND
  16. #include "WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.h"
  17. #endif
  18. #include "WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h"
  19. #ifdef ENABLE_X11
  20. #include "WallpaperEngine/Render/Drivers/Output/CX11Output.h"
  21. #endif
  22. #ifdef ENABLE_WAYLAND
  23. #include "WallpaperEngine/Render/Drivers/Output/CWaylandOutput.h"
  24. #endif
  25. #include "WallpaperEngine/Audio/Drivers/CSDLAudioDriver.h"
  26. #include "WallpaperEngine/Input/CInputContext.h"
  27. #include "WallpaperEngine/WebBrowser/CWebBrowserContext.h"
  28. namespace WallpaperEngine::Application {
  29. /**
  30. * Small wrapper class over the actual wallpaper's main application skeleton
  31. *
  32. * @author Alexis Maiquez <almamu@almamu.com>
  33. */
  34. class CWallpaperApplication {
  35. public:
  36. explicit CWallpaperApplication (CApplicationContext& context, WallpaperEngine::WebBrowser::CWebBrowserContext& browserContext);
  37. ~CWallpaperApplication ();
  38. /**
  39. * Shows the application until it's closed
  40. */
  41. void show ();
  42. /**
  43. * Handles a OS signal sent to this PID
  44. *
  45. * @param signal
  46. */
  47. void signal (int signal);
  48. /**
  49. * @return Maps screens to loaded backgrounds
  50. */
  51. [[nodiscard]] const std::map<std::string, Core::CProject*>& getBackgrounds () const;
  52. /**
  53. * @return The current application context
  54. */
  55. [[nodiscard]] CApplicationContext& getContext () const;
  56. /**
  57. * Renders a frame
  58. */
  59. void update (Render::Drivers::Output::COutputViewport* viewport);
  60. /**
  61. * Gets the output
  62. */
  63. [[nodiscard]] const WallpaperEngine::Render::Drivers::Output::COutput& getOutput () const;
  64. private:
  65. /**
  66. * Sets up a combined container for the given background, adding default files and directories to the list
  67. *
  68. * @param container
  69. * @param bg
  70. */
  71. void setupContainer (CCombinedContainer& container, const std::string& bg) const;
  72. /**
  73. * Loads projects based off the settings
  74. */
  75. void loadBackgrounds ();
  76. /**
  77. * Loads the given project
  78. *
  79. * @param bg
  80. * @return
  81. */
  82. Core::CProject* loadBackground (const std::string& bg);
  83. /**
  84. * Prepares all background's values and updates their properties if required
  85. */
  86. void setupProperties ();
  87. /**
  88. * Updates the properties for the given background based on the current context
  89. *
  90. * @param project
  91. */
  92. void setupPropertiesForProject (const Core::CProject* project);
  93. /**
  94. * Takes an screenshot of the background and saves it to the specified path
  95. *
  96. * @param context
  97. * @param filename
  98. * @param format
  99. */
  100. void takeScreenshot (const std::filesystem::path& filename, FREE_IMAGE_FORMAT format);
  101. /** The application context that contains the current app settings */
  102. CApplicationContext& m_context;
  103. /** Maps screens to backgrounds */
  104. std::map<std::string, Core::CProject*> m_backgrounds;
  105. WallpaperEngine::Audio::CAudioContext* m_audioContext;
  106. WallpaperEngine::Audio::Drivers::CSDLAudioDriver* m_audioDriver;
  107. WallpaperEngine::Audio::Drivers::Recorders::CPlaybackRecorder* m_audioRecorder;
  108. WallpaperEngine::Input::CInputContext* m_inputContext;
  109. WallpaperEngine::Render::CRenderContext* m_renderContext;
  110. WallpaperEngine::Render::Drivers::CVideoDriver* m_videoDriver;
  111. WallpaperEngine::Render::Drivers::Detectors::CFullScreenDetector* m_fullScreenDetector;
  112. WallpaperEngine::WebBrowser::CWebBrowserContext& m_browserContext;
  113. };
  114. } // namespace WallpaperEngine::Application