initial commit
This commit is contained in:
commit
41b72e6fdf
46 changed files with 9134 additions and 0 deletions
71
Crafter.Graphics-Window.cppm
Normal file
71
Crafter.Graphics-Window.cppm
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
module;
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <wayland-client.h>
|
||||
#include "xdg-shell-client-protocol.h"
|
||||
#include "wayland-xdg-decoration-unstable-v1-client-protocol.h"
|
||||
|
||||
export module Crafter.Graphics:Window;
|
||||
import Crafter.Event;
|
||||
import :UiElement;
|
||||
import :Types;
|
||||
import Crafter.Component;
|
||||
|
||||
export namespace Crafter {
|
||||
class Window {
|
||||
public:
|
||||
Event<MousePoint> onMouseRightClick;
|
||||
Event<MousePoint> onMouseLeftClick;
|
||||
Event<MousePoint> onMouseRightHold;
|
||||
Event<MousePoint> onMouseLeftHold;
|
||||
Event<MousePoint> onMouseRightRelease;
|
||||
Event<MousePoint> onMouseLeftRelease;
|
||||
Event<MouseMoveEvent> onMouseMove;
|
||||
Event<MouseMoveEvent> onMouseEnter;
|
||||
Event<MouseMoveEvent> onMouseLeave;
|
||||
Event<double> onMouseScroll;
|
||||
Event<void> onClose;
|
||||
MousePoint currentMousePos;
|
||||
MousePoint lastMousePos;
|
||||
MousePoint mouseDelta;
|
||||
bool mouseLeftHeld = false;
|
||||
bool mouseRightHeld = false;
|
||||
ComponentRefVectorOwning<UiElement> elements;
|
||||
std::uint32_t width;
|
||||
std::uint32_t height;
|
||||
float scale = 1;
|
||||
Window(std::string name, std::uint32_t width, std::uint32_t height);
|
||||
~Window();
|
||||
void Start();
|
||||
void Draw(std::uint32_t x, std::uint32_t y, std::uint32_t right, std::uint32_t down);
|
||||
private:
|
||||
Pixel* shm_data = NULL;
|
||||
bool configured = false;
|
||||
wl_shm* shm = NULL;
|
||||
wl_seat* seat = NULL;
|
||||
xdg_toplevel* xdgToplevel = NULL;
|
||||
xdg_wm_base* xdgWmBase = NULL;
|
||||
zxdg_decoration_manager_v1* manager = NULL;
|
||||
wl_surface* surface = NULL;
|
||||
wl_buffer* buffer = NULL;
|
||||
xdg_surface* xdgSurface = NULL;
|
||||
wl_display* display = NULL;
|
||||
inline static wl_compositor* compositor = NULL;
|
||||
static wl_pointer_listener pointer_listener;
|
||||
static wl_seat_listener seat_listener;
|
||||
static wl_registry_listener registry_listener;
|
||||
static xdg_surface_listener xdg_surface_listener;
|
||||
static xdg_toplevel_listener xdg_toplevel_listener;
|
||||
static void PointerListenerHandleMotion(void* data, wl_pointer* wl_pointer, uint time, wl_fixed_t surface_x, wl_fixed_t surface_y);
|
||||
static void PointerListenerHandleAxis(void*, wl_pointer*, std::uint32_t, std::uint32_t, wl_fixed_t value);
|
||||
static void PointerListenerHandleEnter(void* data, wl_pointer* wl_pointer, uint serial, wl_surface* surface, wl_fixed_t surface_x, wl_fixed_t surface_y);
|
||||
static void PointerListenerHandleLeave(void*, wl_pointer*, std::uint32_t, wl_surface*);
|
||||
static void xdg_toplevel_handle_close(void* data, xdg_toplevel*);
|
||||
static void handle_global(void* data, wl_registry* registry, std::uint32_t name, const char* interface, std::uint32_t version);
|
||||
static void pointer_handle_button(void* data, wl_pointer* pointer, std::uint32_t serial, std::uint32_t time, std::uint32_t button, std::uint32_t state);
|
||||
static void seat_handle_capabilities(void* data, wl_seat* seat, uint32_t capabilities);
|
||||
static void xdg_surface_handle_configure(void* data, xdg_surface* xdg_surface, std::uint32_t serial);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue