mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-12 15:13:34 +00:00
working on window manager
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/05 16:30:19 by maldavid #+# #+# */
|
||||
/* Updated: 2022/10/05 16:39:42 by maldavid ### ########.fr */
|
||||
/* Updated: 2022/10/05 19:24:30 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
Input::Input()
|
||||
Input::Input(const std::vector<std::shared_ptr<Window>>& wins) : _wins(wins)
|
||||
{
|
||||
std::memset(_keys.data(), 0, SDL_NUM_SCANCODES);
|
||||
std::memset(_mouse.data(), 0, 8);
|
||||
|
||||
@@ -6,13 +6,17 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/05 16:27:35 by maldavid #+# #+# */
|
||||
/* Updated: 2022/10/05 16:45:55 by maldavid ### ########.fr */
|
||||
/* Updated: 2022/10/05 19:53:18 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <cstdint>
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
#include "window.h"
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
@@ -21,7 +25,7 @@ namespace mlx
|
||||
class Input
|
||||
{
|
||||
public:
|
||||
Input();
|
||||
Input(const std::vector<std::shared_ptr<Window>>& wins);
|
||||
|
||||
void update();
|
||||
|
||||
@@ -37,14 +41,15 @@ namespace mlx
|
||||
inline int getYRel() const noexcept { return _yRel; }
|
||||
|
||||
inline bool is_running() const noexcept { return !_end; }
|
||||
inline void finish() noexcept { _end = true; }
|
||||
inline constexpr void finish() noexcept { _end = true; }
|
||||
|
||||
~Input() = default;
|
||||
|
||||
private:
|
||||
SDL_Event _event;
|
||||
std::array<uint8_t, SDL_NUM_SCANCODES> _keys;
|
||||
std::array<uint8_t, 8> _mouse;
|
||||
SDL_Event _event;
|
||||
std::vector<std::shared_ptr<Window>> _wins;
|
||||
|
||||
int _x = 0;
|
||||
int _y = 0;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 17:36:44 by maldavid #+# #+# */
|
||||
/* Updated: 2022/10/04 22:09:27 by maldavid ### ########.fr */
|
||||
/* Updated: 2022/10/05 18:39:11 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
Window::Window(std::size_t w, std::size_t h, std::string title)
|
||||
Window::Window(std::size_t w, std::size_t h, std::string title, int id) : _id(id)
|
||||
{
|
||||
_win = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, /*SDL_WINDOW_VULKAN |*/ SDL_WINDOW_SHOWN);
|
||||
if(!_win)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 21:53:12 by maldavid #+# #+# */
|
||||
/* Updated: 2022/10/04 21:59:54 by maldavid ### ########.fr */
|
||||
/* Updated: 2022/10/05 19:10:35 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -21,12 +21,15 @@ namespace mlx
|
||||
class Window
|
||||
{
|
||||
public:
|
||||
Window(std::size_t w, std::size_t h, std::string title);
|
||||
Window(std::size_t w, std::size_t h, std::string title, int id);
|
||||
|
||||
inline int& get_id() noexcept { return _id; }
|
||||
|
||||
~Window();
|
||||
|
||||
private:
|
||||
SDL_Window* _win = nullptr;
|
||||
int _id;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user