linux-wallpaperengine/src/WallpaperEngine/Application/CWallpaperApplication.h
2023-04-20 13:52:25 +01:00

128 lines
4.3 KiB
C++

#pragma once
#include "WallpaperEngine/Application/CApplicationContext.h"
#include "WallpaperEngine/Assets/CCombinedContainer.h"
#include "WallpaperEngine/Core/CProject.h"
#include "WallpaperEngine/Render/CWallpaper.h"
#include "WallpaperEngine/Render/CRenderContext.h"
#include "WallpaperEngine/Render/Drivers/CX11OpenGLDriver.h"
#ifdef ENABLE_WAYLAND
#include "WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h"
#endif
#include "WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h"
#ifdef ENABLE_WAYLAND
#include "WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.h"
#endif
#include "WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h"
#include "WallpaperEngine/Render/Drivers/Output/CX11Output.h"
#ifdef ENABLE_WAYLAND
#include "WallpaperEngine/Render/Drivers/Output/CWaylandOutput.h"
#endif
#include "WallpaperEngine/Audio/Drivers/CSDLAudioDriver.h"
#include "WallpaperEngine/Input/CInputContext.h"
namespace WallpaperEngine::Application
{
/**
* Small wrapper class over the actual wallpaper's main application skeleton
*
* @author Alexis Maiquez <almamu@almamu.com>
*/
class CWallpaperApplication
{
public:
explicit CWallpaperApplication (CApplicationContext& context);
/**
* Shows the application until it's closed
*/
void show ();
/**
* Handles a OS signal sent to this PID
*
* @param signal
*/
void signal (int signal);
/**
* @return Maps screens to loaded backgrounds
*/
[[nodiscard]] const std::map <std::string, Core::CProject*>& getBackgrounds () const;
/**
* @return The default background to use if no specific project is loaded
*/
[[nodiscard]] Core::CProject* getDefaultBackground () const;
/**
* @return The current application context
*/
[[nodiscard]] CApplicationContext& getContext () const;
/**
* Renders a frame
*/
void renderFrame();
/**
* Gets the output
*/
WallpaperEngine::Render::Drivers::Output::COutput* getOutput() const;
private:
/**
* Sets up a combined container for the given background, adding default files and directories to the list
*
* @param container
* @param bg
*/
void setupContainer (CCombinedContainer& container, const std::string& bg) const;
/**
* Loads projects based off the settings
*/
void loadBackgrounds ();
/**
* Loads the given project
*
* @param bg
* @return
*/
Core::CProject* loadBackground (const std::string& bg);
/**
* Prepares all background's values and updates their properties if required
*/
void setupProperties ();
/**
* Updates the properties for the given background based on the current context
*
* @param project
*/
void setupPropertiesForProject (Core::CProject* project);
/**
* Takes an screenshot of the background and saves it to the specified path
*
* @param context
* @param filename
* @param format
*/
static void takeScreenshot (const Render::CRenderContext& context, const std::filesystem::path& filename, FREE_IMAGE_FORMAT format);
/** The default background to display if no specific background was loaded */
Core::CProject* m_defaultBackground;
/** The application context that contains the current app settings */
CApplicationContext& m_context;
/** Maps screens to backgrounds */
std::map <std::string, Core::CProject*> m_backgrounds;
std::unique_ptr<WallpaperEngine::Render::Drivers::CVideoDriver> videoDriver;
std::unique_ptr<WallpaperEngine::Input::CInputContext> inputContext;
WallpaperEngine::Render::Drivers::Output::COutput* output;
std::unique_ptr<WallpaperEngine::Render::Drivers::Detectors::CFullScreenDetector> fullscreenDetector;
std::unique_ptr<WallpaperEngine::Audio::Drivers::CSDLAudioDriver> audioDriver;
std::unique_ptr<WallpaperEngine::Render::CRenderContext> context;
std::unique_ptr<WallpaperEngine::Audio::CAudioContext> audioContext;
};
}