1#ifndef GUI_WINDOW_WINDOW_BASE_H
2#define GUI_WINDOW_WINDOW_BASE_H
13#include "spdlog/spdlog.h"
26 template <
typename Canvas>
32 winSize({.width = width, .height = height}),
48 virtual
void run() = 0;
87 if (maybeHoveredBlock.has_value()) {
88 blocksManager->handleRightClickOnBlock(maybeHoveredBlock.value());
93 "Right clicked on empty space, but input is already active, ignoring "
96 logger->info(
"Right clicked on empty space, opening add block popup");
103 magic_enum::enum_values<business_logic::elements::blocks::BlockType>()
105 magic_enum::enum_values<business_logic::elements::blocks::BlockType>()
107 std::back_inserter(choices),
108 [](
const auto& choice) {
111 .
displayName = std::string(magic_enum::enum_name(choice)),
The delegate for the window.
The abstract base class for implementing a window.
void handleNumericKeyPress(int number)
Handles the numeric key press event; should be called internally by the window implementation.
void handleRightClick()
Handles the right click event; should be called internally by the window implementation.
business_logic::geometry::Size2D getFramebufferSize() override
Get the framebuffer size.
std::shared_ptr< spdlog::logger > logger
WindowBase(const WindowBase &)=delete
business_logic::geometry::Size2D winSize
business_logic::geometry::Size2D getWindowSize() override
Get the window size.
~WindowBase() override=default
virtual bool shouldClose() const =0
Whether the window should close.
WindowBase & operator=(const WindowBase &)=delete
virtual void run()=0
Runs the main window loop.
business_logic::geometry::Size2D framebufferSize
void handleMouseUp()
Handles the mouse up event; should be called internally by the window implementation.
std::shared_ptr< business_logic::BlocksManager > blocksManager
void handleMouseDown()
Handles the mouse down event; should be called internally by the window implementation.
WindowBase(int width, int height, std::shared_ptr< spdlog::logger > logger)
WindowBase(WindowBase &&) noexcept=default
void handleMouseMove(int x, int y)
Handles the mouse move event; should be called internally by the window implementation.
void handleEscapeKeyPress()
Handles the ESC key press event; should be called internally by the window implementation.
BlockType
The available block types.
The GUI window abstraction & implementation.
The actual GUI / renderer implementation counterpart.
A basic struct representing a 2D size.