move into firmware subfolder
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
54
firmware/src/model/AppContext.cpp
Normal file
54
firmware/src/model/AppContext.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#include "model/AppContext.h"
|
||||
|
||||
#include "Matrix.h"
|
||||
|
||||
auto AppContext::MainWindow() const -> SDL_Window *
|
||||
{
|
||||
return m_window->window();
|
||||
}
|
||||
|
||||
auto AppContext::MainRenderer() const -> SDL_Renderer *
|
||||
{
|
||||
return m_window->renderer();
|
||||
}
|
||||
|
||||
auto AppContext::MainSurface() const -> SDL_Surface *
|
||||
{
|
||||
return SDL_GetWindowSurface(m_window->window());
|
||||
}
|
||||
|
||||
void AppContext::SetMatrix(Matrix *matrix)
|
||||
{
|
||||
m_matrix = matrix;
|
||||
}
|
||||
|
||||
auto AppContext::LedMatrix() const -> Matrix *
|
||||
{
|
||||
return m_matrix;
|
||||
}
|
||||
|
||||
auto AppContext::LedMatrixId() const -> SDL_WindowID
|
||||
{
|
||||
if (m_matrix)
|
||||
{
|
||||
return m_matrix->windowId();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto AppContext::LedMatrixRenderer() const -> SDL_Renderer *
|
||||
{
|
||||
if (m_matrix && m_matrix->renderer())
|
||||
{
|
||||
return m_matrix->renderer();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void AppContext::Render() const
|
||||
{
|
||||
if (m_matrix && m_matrix->renderer())
|
||||
{
|
||||
m_matrix->Render();
|
||||
}
|
||||
}
|
45
firmware/src/model/AppContext.h
Normal file
45
firmware/src/model/AppContext.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
#include "SDL3_ttf/SDL_ttf.h"
|
||||
#include "Window.h"
|
||||
|
||||
class Matrix;
|
||||
|
||||
class AppContext
|
||||
{
|
||||
public:
|
||||
explicit AppContext(const Window *window) : m_window(window)
|
||||
{
|
||||
m_font_default = TTF_OpenFont("haxrcorp-4089.otf", 21);
|
||||
m_font_text = TTF_OpenFont("Helvetica-Bold.otf", 21);
|
||||
}
|
||||
|
||||
~AppContext()
|
||||
{
|
||||
TTF_CloseFont(m_font_default);
|
||||
TTF_CloseFont(m_font_text);
|
||||
}
|
||||
|
||||
[[nodiscard]] auto MainWindow() const -> SDL_Window *;
|
||||
|
||||
[[nodiscard]] auto MainRenderer() const -> SDL_Renderer *;
|
||||
|
||||
[[nodiscard]] auto MainSurface() const -> SDL_Surface *;
|
||||
|
||||
void SetMatrix(Matrix *matrix);
|
||||
|
||||
[[nodiscard]] auto LedMatrix() const -> Matrix *;
|
||||
|
||||
[[nodiscard]] auto LedMatrixId() const -> SDL_WindowID;
|
||||
|
||||
[[nodiscard]] auto LedMatrixRenderer() const -> SDL_Renderer *;
|
||||
|
||||
void Render() const;
|
||||
|
||||
TTF_Font *m_font_default = nullptr;
|
||||
|
||||
private:
|
||||
const Window *m_window;
|
||||
Matrix *m_matrix = nullptr;
|
||||
TTF_Font *m_font_text = nullptr;
|
||||
};
|
11
firmware/src/model/Window.cpp
Normal file
11
firmware/src/model/Window.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "model/Window.h"
|
||||
|
||||
auto Window::window() const -> SDL_Window *
|
||||
{
|
||||
return m_window;
|
||||
}
|
||||
|
||||
auto Window::renderer() const -> SDL_Renderer *
|
||||
{
|
||||
return SDL_GetRenderer(m_window);
|
||||
}
|
18
firmware/src/model/Window.h
Normal file
18
firmware/src/model/Window.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "SDL3/SDL.h"
|
||||
|
||||
class Window
|
||||
{
|
||||
public:
|
||||
explicit Window(SDL_Window *window) : m_window(window)
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] auto window() const -> SDL_Window *;
|
||||
|
||||
[[nodiscard]] auto renderer() const -> SDL_Renderer *;
|
||||
|
||||
private:
|
||||
SDL_Window *m_window = nullptr;
|
||||
};
|
Reference in New Issue
Block a user