mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53: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/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;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user