working on window manager

This commit is contained in:
Kbz-8
2022-10-05 20:37:04 +02:00
parent 5df9b4d39f
commit f52c4e51c9
10 changed files with 83 additions and 24 deletions

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 21:49:46 by maldavid #+# #+# */
/* Updated: 2022/10/05 16:58:25 by maldavid ### ########.fr */
/* Updated: 2022/10/05 19:23:15 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -17,6 +17,8 @@
#include <memory>
#include <utility>
#include "errors.h"
#include <platform/inputs.h>
#include <platform/window.h>
@@ -25,11 +27,21 @@ namespace mlx::core
class Application
{
public:
Application() = default;
Application() : _in(_wins) {}
inline void new_window(std::size_t w, std::size_t h, std::string title)
inline void* new_window(std::size_t w, std::size_t h, std::string title)
{
_wins.emplace_back(std::make_unique<Window>(w, h, std::move(title)));
_wins.emplace_back(std::make_shared<Window>(w, h, std::move(title), _wins.size()));
return reinterpret_cast<void*>(&_wins.back()->get_id());
}
inline int get_mouse_pos(void* win_ptr, int* x, int* y) noexcept
{
if(*reinterpret_cast<int*>(win_ptr) > _wins.size())
{
error::report(e_kind::error, "Invalid window pointer");
return -1;
}
}
void run() noexcept;
@@ -38,7 +50,7 @@ namespace mlx::core
private:
Input _in;
std::vector<std::unique_ptr<Window>> _wins;
std::vector<std::shared_ptr<Window>> _wins;
bool _is_loop_running = false;
};
}