handle mouse events
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
@@ -2,42 +2,53 @@
|
||||
|
||||
#include "ui/Matrix.h"
|
||||
|
||||
auto AppContext::window() const -> SDL_Window* {
|
||||
auto AppContext::MainWindow() const -> SDL_Window *
|
||||
{
|
||||
return m_window->window();
|
||||
}
|
||||
|
||||
auto AppContext::renderer() const -> SDL_Renderer* {
|
||||
auto AppContext::MainRenderer() const -> SDL_Renderer *
|
||||
{
|
||||
return m_window->renderer();
|
||||
}
|
||||
|
||||
auto AppContext::surface() const -> SDL_Surface* {
|
||||
auto AppContext::MainSurface() const -> SDL_Surface *
|
||||
{
|
||||
return SDL_GetWindowSurface(m_window->window());
|
||||
}
|
||||
|
||||
void AppContext::setMatrix(Matrix* matrix) {
|
||||
void AppContext::SetMatrix(Matrix *matrix)
|
||||
{
|
||||
m_matrix = matrix;
|
||||
}
|
||||
|
||||
auto AppContext::matrix() const -> Matrix* {
|
||||
auto AppContext::LedMatrix() const -> Matrix *
|
||||
{
|
||||
return m_matrix;
|
||||
}
|
||||
|
||||
auto AppContext::matrix_window() const -> SDL_Window* {
|
||||
if(m_matrix && m_matrix->window()) {
|
||||
auto AppContext::LedMatrixWindow() const -> SDL_Window *
|
||||
{
|
||||
if (m_matrix && m_matrix->window())
|
||||
{
|
||||
return m_matrix->window()->window();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto AppContext::matrix_renderer() const -> SDL_Renderer* {
|
||||
if(m_matrix && m_matrix->window()) {
|
||||
auto AppContext::LedMatrixRenderer() const -> SDL_Renderer *
|
||||
{
|
||||
if (m_matrix && m_matrix->window())
|
||||
{
|
||||
return m_matrix->window()->renderer();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void AppContext::matrix_render() const {
|
||||
if(m_matrix && m_matrix->window()) {
|
||||
m_matrix->render();
|
||||
void AppContext::Render() const
|
||||
{
|
||||
if (m_matrix && m_matrix->window())
|
||||
{
|
||||
m_matrix->Render();
|
||||
}
|
||||
}
|
||||
|
@@ -5,39 +5,41 @@
|
||||
|
||||
class Matrix;
|
||||
|
||||
class AppContext {
|
||||
public:
|
||||
explicit AppContext(const Window* window)
|
||||
: m_window(window) {
|
||||
m_font_default = TTF_OpenFont("assets/haxrcorp-4089.otf", 21);
|
||||
m_font_text = TTF_OpenFont("assets/Helvetica-Bold.otf", 21);
|
||||
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() {
|
||||
~AppContext()
|
||||
{
|
||||
TTF_CloseFont(m_font_default);
|
||||
TTF_CloseFont(m_font_text);
|
||||
}
|
||||
|
||||
[[nodiscard]] auto window() const -> SDL_Window*;
|
||||
[[nodiscard]] auto MainWindow() const -> SDL_Window *;
|
||||
|
||||
[[nodiscard]] auto renderer() const -> SDL_Renderer*;
|
||||
[[nodiscard]] auto MainRenderer() const -> SDL_Renderer *;
|
||||
|
||||
[[nodiscard]] auto surface() const -> SDL_Surface*;
|
||||
[[nodiscard]] auto MainSurface() const -> SDL_Surface *;
|
||||
|
||||
void setMatrix(Matrix* matrix);
|
||||
void SetMatrix(Matrix *matrix);
|
||||
|
||||
[[nodiscard]] auto matrix() const -> Matrix*;
|
||||
[[nodiscard]] auto LedMatrix() const -> Matrix *;
|
||||
|
||||
[[nodiscard]] auto matrix_window() const -> SDL_Window*;
|
||||
[[nodiscard]] auto LedMatrixWindow() const -> SDL_Window *;
|
||||
|
||||
[[nodiscard]] auto matrix_renderer() const -> SDL_Renderer*;
|
||||
[[nodiscard]] auto LedMatrixRenderer() const -> SDL_Renderer *;
|
||||
|
||||
void matrix_render() const;
|
||||
void Render() const;
|
||||
|
||||
TTF_Font* m_font_default = nullptr;
|
||||
TTF_Font *m_font_default = nullptr;
|
||||
|
||||
private:
|
||||
const Window* m_window;
|
||||
Matrix* m_matrix = nullptr;
|
||||
TTF_Font* m_font_text = nullptr;
|
||||
private:
|
||||
const Window *m_window;
|
||||
Matrix *m_matrix = nullptr;
|
||||
TTF_Font *m_font_text = nullptr;
|
||||
};
|
||||
|
@@ -1,9 +1,11 @@
|
||||
#include "model/Window.h"
|
||||
|
||||
auto Window::window() const -> SDL_Window* {
|
||||
auto Window::window() const -> SDL_Window *
|
||||
{
|
||||
return m_window;
|
||||
}
|
||||
|
||||
auto Window::renderer() const -> SDL_Renderer* {
|
||||
auto Window::renderer() const -> SDL_Renderer *
|
||||
{
|
||||
return SDL_GetRenderer(m_window);
|
||||
}
|
||||
|
@@ -2,16 +2,17 @@
|
||||
|
||||
#include "SDL3/SDL.h"
|
||||
|
||||
class Window {
|
||||
public:
|
||||
explicit Window(SDL_Window* window)
|
||||
: m_window(window) {
|
||||
class Window
|
||||
{
|
||||
public:
|
||||
explicit Window(SDL_Window *window) : m_window(window)
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] auto window() const -> SDL_Window*;
|
||||
[[nodiscard]] auto window() const -> SDL_Window *;
|
||||
|
||||
[[nodiscard]] auto renderer() const -> SDL_Renderer*;
|
||||
[[nodiscard]] auto renderer() const -> SDL_Renderer *;
|
||||
|
||||
private:
|
||||
SDL_Window* m_window = nullptr;
|
||||
private:
|
||||
SDL_Window *m_window = nullptr;
|
||||
};
|
||||
|
Reference in New Issue
Block a user