From b6d4e614af3e563c5e51df48127ebbdc1a187c9d Mon Sep 17 00:00:00 2001 From: chatlanin Date: Sun, 7 May 2023 15:48:45 +0300 Subject: [PATCH] fix new font path --- .../system_event/category/mouse_event.hpp | 99 +++++++++++++++++++ src/try_engine/gui/style/fonts.hpp | 4 +- src/try_engine/window/window.cpp | 42 ++++++++ 3 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 src/try_engine/event/system_event/category/mouse_event.hpp diff --git a/src/try_engine/event/system_event/category/mouse_event.hpp b/src/try_engine/event/system_event/category/mouse_event.hpp new file mode 100644 index 0000000..5a48baf --- /dev/null +++ b/src/try_engine/event/system_event/category/mouse_event.hpp @@ -0,0 +1,99 @@ +#pragma once + +#include "try_engine/utils/define.hpp" +#include "try_engine/event/system_event/event.hpp" +#include "try_engine/event/event_classificator.hpp" + +namespace try_engine::system_event +{ + + + // Разобрать и привести в порядок по подобию + // key_event.hpp + // + // class MouseMovedEvent : public Event + // { + // public: + // MouseMovedEvent(float x, float y) : m_MouseX(x), m_MouseY(y) {} + // + // inline float GetX() const { return m_MouseX; } + // inline float GetY() const { return m_MouseY; } + // + // std::string ToString() const override + // { + // std::stringstream ss; + // ss << "MouseMovedEvent: " << m_MouseX << ", " << m_MouseY; + // return ss.str(); + // } + // + // EVENT_CLASS_TYPE(MouseMoved) + // EVENT_CLASS_CATEGORY(EventCategoryMouse | EventCategoryInput) + // + // private: + // float m_MouseX, m_MouseY; + // }; + // + // class MouseScrolledEvent : public Event + // { + // public: + // MouseScrolledEvent(float xOffset, float yOffset) : m_XOffset(xOffset), m_YOffset(yOffset) {} + // + // inline float GetXOffset() const { return m_XOffset; } + // inline float GetYOffset() const { return m_YOffset; } + // + // std::string ToString() const override + // { + // std::stringstream ss; + // ss << "MouseScrolledEvent: " << GetXOffset() << ", " << GetYOffset(); + // return ss.str(); + // } + // + // EVENT_CLASS_TYPE(MouseScrolled) + // EVENT_CLASS_CATEGORY(EventCategoryMouse | EventCategoryInput) + // + // private: + // float m_XOffset, m_YOffset; + // }; + + // class MouseButtonEvent : public Event + // { + // public: + // inline int GetMouseButton() const { return m_Button; } + // EVENT_CLASS_CATEGORY(EventCategoryMouse | EventCategoryInput) + // + // protected: + // MouseButtonEvent(int button) : m_Button(button) {} + // int m_Button; + // }; + // + // class MouseButtonPressedEvent : public MouseButtonEvent + // { + // public: + // MouseButtonPressedEvent(int button) : MouseButtonEvent(button) {} + // + // std::string ToString() const override + // { + // std::stringstream ss; + // ss << "MouseButtonPressedEvent: " << m_Button; + // return ss.str(); + // } + // + // EVENT_CLASS_TYPE(MouseButtonPressed) + // }; + // + // class MouseButtonReleasedEvent : public MouseButtonEvent + // { + // public: + // MouseButtonReleasedEvent(int button) : MouseButtonEvent(button) {} + // + // std::string ToString() const override + // { + // std::stringstream ss; + // ss << "MouseButtonReleasedEvent: " << m_Button; + // return ss.str(); + // } + // + // EVENT_CLASS_TYPE(MouseButtonReleased) + // }; + +} diff --git a/src/try_engine/gui/style/fonts.hpp b/src/try_engine/gui/style/fonts.hpp index f60f2ec..c8207a3 100644 --- a/src/try_engine/gui/style/fonts.hpp +++ b/src/try_engine/gui/style/fonts.hpp @@ -22,8 +22,8 @@ namespace try_engine::style::fonts // HERE // эту порнографию с путями нужно решить - inline const std::string ICONS_PATH = "/mnt/develop/projects/cpp/try_engine/src/try_engine/internal/fonts/FontAwesome/forkawesome-webfont.ttf"; - inline const std::string FONT_PATH = "/mnt/develop/projects/cpp/try_engine/src/try_engine/internal/fonts/"; + inline const std::string ICONS_PATH = "/mnt/raid/projects/cpp/try_engine/src/try_engine/internal/fonts/FontAwesome/forkawesome-webfont.ttf"; + inline const std::string FONT_PATH = "/mnt/raid/projects/cpp/try_engine/src/try_engine/internal/fonts/"; inline std::vector fonts_path { diff --git a/src/try_engine/window/window.cpp b/src/try_engine/window/window.cpp index c42e4db..b0b0ca8 100644 --- a/src/try_engine/window/window.cpp +++ b/src/try_engine/window/window.cpp @@ -1,5 +1,6 @@ #include "window.hpp" +#include "GLFW/glfw3.h" #include "renderer/renderer.hpp" #include "event/system_event/category/key_event.hpp" #include "event/system_event/category/window_event.hpp" @@ -131,6 +132,47 @@ namespace try_engine } } }); + + // HERE + // это нужнореализовать и в событиях + // там есть классы которые нужно разобрать и привести в порядок + // + // glfwSetMouseButtonCallback(win, [](GLFWwindow* window, int button, int action, int mods) + // { + // auto data = static_cast(glfwGetWindowUserPointer(w)); + // + // switch (action) + // { + // case GLFW_PRESS: + // { + // system_event::mouse_button_pressed_event e { button }; + // data->callback(e); + // break; + // } + // case GLFW_RELEASE: + // { + // MouseButtonReleasedEvent event{button}; + // data.EventCallback(event); + // break; + // } + // } + // }); + + // glfwSetScrollCallback(win, [](GLFWwindow* window, double xOffset, double yOffset) + // { + // WindowData& data = *(WindowData*)glfwGetWindowUserPointer(window); + // + // MouseScrolledEvent event{(float)xOffset, (float)yOffset}; + // data.EventCallback(event); + // }); + // + // glfwSetCursorPosCallback(win, [](GLFWwindow* window, double xPos, double yPos) + // { + // WindowData& data = *(WindowData*)glfwGetWindowUserPointer(window); + // + // MouseMovedEvent event{(float)xPos, (float)yPos}; + // data.EventCallback(event); + // }); } void window::set_window_callback()