Pioneer
Loading...
Searching...
No Matches
GuiApplication.h
Go to the documentation of this file.
1// Copyright © 2008-2023 Pioneer Developers. See AUTHORS.txt for details
2// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3
4#pragma once
5
6#include "Application.h"
7#include "Input.h"
8#include "RefCounted.h"
9#include "SDL_events.h"
10#include "pigui/PiGui.h"
11
14#include "graphics/Renderer.h"
15
16class IniConfig;
17
19public:
20 GuiApplication(std::string title) :
21 Application(), m_applicationTitle(title)
22 {}
23
24 Graphics::Renderer *GetRenderer() { return m_renderer.get(); }
25 Input::Manager *GetInput() { return m_input.get(); }
26 PiGui::Instance *GetPiGui() { return m_pigui.Get(); }
27
28protected:
29 // Called at the end of the frame automatically, blits the RT onto the application
30 // framebuffer
31 void DrawRenderTarget();
32
33 // TODO: unify config handling, possibly make the config an Application member
34 // Call this from your Startup() method
35 Graphics::Renderer *StartupRenderer(IniConfig *config, bool hidden = false);
36
37 // Call this from your Startup() method
39
40 // Call this from your Startup() method
42
43 // Call this from your Shutdown() method
44 void ShutdownRenderer();
45
46 // Call this from your Shutdown() method
47 void ShutdownInput();
48
49 // Call this from your shutdown() method
50 void ShutdownPiGui();
51
52 // Hook to bind the RT and clear the screen.
53 // If you override BeginFrame, make sure you call this.
54 void BeginFrame() override;
55
56 // Hook to end the frame and draw to the application framebuffer.
57 // If you override EndFrame, make sure you call this.
58 void EndFrame() override;
59
60 // Consume events from SDL and dispatch to pigui / input
61 void HandleEvents();
62 // the function from above actually calls the following two:
63 void PollEvents(); // writes events to ImGui and Input structures, also generate signals for low-level handling
64 void DispatchEvents(); // triggers action-related signals, updates actions and axes
65
66 // Override point to handle an application quit notification
67 virtual void HandleQuit(SDL_QuitEvent &ev) { RequestQuit(); }
68
69private:
70 Graphics::RenderTarget *CreateRenderTarget(const Graphics::Settings &settings);
71
73 std::unique_ptr<Input::Manager> m_input;
74
75 std::string m_applicationTitle;
76
77 std::unique_ptr<Graphics::Renderer> m_renderer;
78 std::unique_ptr<Graphics::RenderTarget> m_renderTarget;
79};
Definition Application.h:16
void RequestQuit()
Definition Application.h:113
Definition RenderTarget.h:38
Definition Renderer.h:44
Definition GuiApplication.h:18
void ShutdownRenderer()
Definition GuiApplication.cpp:204
void BeginFrame() override
Definition GuiApplication.cpp:23
void HandleEvents()
Definition GuiApplication.cpp:158
void DrawRenderTarget()
Definition GuiApplication.cpp:34
GuiApplication(std::string title)
Definition GuiApplication.h:20
Input::Manager * StartupInput(IniConfig *config)
Definition GuiApplication.cpp:213
PiGui::Instance * GetPiGui()
Definition GuiApplication.h:26
Input::Manager * GetInput()
Definition GuiApplication.h:25
void EndFrame() override
Definition GuiApplication.cpp:64
void PollEvents()
Definition GuiApplication.cpp:109
PiGui::Instance * StartupPiGui()
Definition GuiApplication.cpp:227
void ShutdownInput()
Definition GuiApplication.cpp:221
void DispatchEvents()
Definition GuiApplication.cpp:153
Graphics::Renderer * GetRenderer()
Definition GuiApplication.h:24
void ShutdownPiGui()
Definition GuiApplication.cpp:235
Graphics::Renderer * StartupRenderer(IniConfig *config, bool hidden=false)
Definition GuiApplication.cpp:164
virtual void HandleQuit(SDL_QuitEvent &ev)
Definition GuiApplication.h:67
Definition IniConfig.h:16
Definition Input.h:122
Definition PiGui.h:86
Definition RefCounted.h:36
T * Get() const
Definition SmartPtr.h:37
Definition Graphics.h:27