Files
pixelarium/lib/app/AppGLFW.hpp
T

68 lines
1.9 KiB
C++
Raw Normal View History

2025-08-18 22:39:43 +00:00
#pragma once
#include <GLFW/glfw3.h>
2026-01-23 23:00:35 +00:00
#include <format>
2025-08-18 22:39:43 +00:00
#include "utilities/ILog.hpp"
namespace pixelarium::application
{
2025-09-26 21:09:51 +02:00
/// @brief Base class providing scaffolding with GLFW and some default
/// implementations that can be extended and/or overridden by consumers
2025-08-18 22:39:43 +00:00
class AppGLFW
{
public:
explicit AppGLFW(const utils::log::ILog& log) : logger_(log) { this->InitMainWindow(); }
2025-09-26 21:09:51 +02:00
/// @brief Start the main render loop
2025-08-18 22:39:43 +00:00
void Start() { this->RunLoop(); }
2026-01-23 23:00:35 +00:00
void SetStatusTimed(const std::string& status, size_t second);
void SetStatus(const std::string& status)
{
logger_.Info(std::format("{}(): {}", __PRETTY_FUNCTION__, status));
status_message_ = status;
show_status_ = true;
}
void ResetStatus()
{
status_message_.clear();
show_status_ = false;
}
2025-08-18 22:39:43 +00:00
protected:
2025-09-26 21:09:51 +02:00
/// @brief Function implementing the first column of the menu bar (e.g. "Menu")
2025-08-18 22:39:43 +00:00
virtual void MenuBarOptionsColumn1() {}
2025-09-26 21:09:51 +02:00
/// @brief Function implementing the second column of the menu bar (e.g. "File")
2025-08-18 22:39:43 +00:00
virtual void MenuBarOptionsColumn2() {}
2025-09-26 21:09:51 +02:00
/// @brief Function implementing the third column of the menu bar (e.g. "Options")
2025-08-18 22:39:43 +00:00
virtual void MenuBarOptionsColumn3() {}
2025-09-26 21:09:51 +02:00
/// @brief Function implementing the fourth column of the menu bar (e.g. "More")
2025-08-18 22:39:43 +00:00
virtual void MenuBarOptionsColumn4() {}
2025-09-26 21:09:51 +02:00
/// @brief Function implementing the first column of the menu bar (e.g. "Help")
2025-08-18 22:39:43 +00:00
virtual void MenuBarOptionsColumn5() {}
2025-09-26 21:09:51 +02:00
/// @brief Main function that gets called within the render loop.
2025-08-18 22:39:43 +00:00
virtual void Run() {}
const utils::log::ILog& logger_;
private:
int RunLoop();
void InitMainWindow();
void MenuBar();
void LogLevelSelect();
int log_level_{0};
GLFWwindow* window = nullptr;
2026-01-23 23:00:35 +00:00
bool show_status_{false};
std::string status_message_{};
2025-08-18 22:39:43 +00:00
};
} // namespace pixelarium::application