the great text and type rewrite
This commit is contained in:
parent
a220e40d13
commit
d0cc3ad16a
15 changed files with 628 additions and 318 deletions
|
|
@ -47,10 +47,11 @@ import Crafter.Event;
|
|||
|
||||
export namespace Crafter {
|
||||
class Transform;
|
||||
class MouseElement;
|
||||
class Window {
|
||||
public:
|
||||
std::int_fast32_t width;
|
||||
std::int_fast32_t height;
|
||||
std::int32_t width;
|
||||
std::int32_t height;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> lastFrameBegin;
|
||||
std::vector<Transform*> elements;
|
||||
Event<void> onClose;
|
||||
|
|
@ -61,7 +62,7 @@ export namespace Crafter {
|
|||
float scale;
|
||||
|
||||
Window() = default;
|
||||
Window(std::int_fast32_t width, std::int_fast32_t height);
|
||||
Window(std::int32_t width, std::int32_t height);
|
||||
Window(Window&) = delete;
|
||||
Window(Window&&) = delete;
|
||||
virtual ~Window() = default;
|
||||
|
|
@ -72,13 +73,13 @@ export namespace Crafter {
|
|||
virtual void StopUpdate() = 0;
|
||||
void ScaleElement(Transform& element, Transform& parent);
|
||||
void ScaleElement(Transform& element);
|
||||
void ScaleMouse(Transform& element, Transform& parent);
|
||||
void ScaleMouse(Transform& element);
|
||||
void ScaleMouse(MouseElement& element, Transform& parent);
|
||||
void ScaleMouse(MouseElement& element);
|
||||
#ifdef CRAFTER_TIMING
|
||||
std::chrono::nanoseconds totalUpdate;
|
||||
std::vector<std::pair<const EventListener<FrameTime>*, std::chrono::nanoseconds>> updateTimings;
|
||||
std::chrono::nanoseconds totalRender;
|
||||
std::vector<std::tuple<const Transform*, std::uint_fast32_t, std::uint_fast32_t, std::chrono::nanoseconds>> renderTimings;
|
||||
std::vector<std::tuple<const Transform*, std::uint32_t, std::uint32_t, std::chrono::nanoseconds>> renderTimings;
|
||||
std::chrono::nanoseconds vblank;
|
||||
std::chrono::nanoseconds totalFrame;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> frameEnd;
|
||||
|
|
@ -110,10 +111,10 @@ export namespace Crafter {
|
|||
Event<MouseMoveEvent> onMouseMove;
|
||||
Event<MouseMoveEvent> onMouseEnter;
|
||||
Event<MouseMoveEvent> onMouseLeave;
|
||||
Event<std::uint_fast32_t> onMouseScroll;
|
||||
Event<std::uint32_t> onMouseScroll;
|
||||
MousePoint currentMousePos;
|
||||
MousePoint lastMousePos;
|
||||
MousePoint mouseDelta;
|
||||
MouseDelta mouseDelta;
|
||||
bool mouseLeftHeld = false;
|
||||
bool mouseRightHeld = false;
|
||||
std::vector<MouseElement*> mouseElements;
|
||||
|
|
@ -129,11 +130,11 @@ export namespace Crafter {
|
|||
class WindowFramebuffer : public Window {
|
||||
public:
|
||||
WindowFramebuffer() = default;
|
||||
WindowFramebuffer(std::uint_fast32_t width, std::uint_fast32_t height);
|
||||
virtual void Resize(std::uint_fast32_t width, std::uint_fast32_t height) = 0;
|
||||
WindowFramebuffer(std::uint32_t width, std::uint32_t height);
|
||||
virtual void Resize(std::uint32_t width, std::uint32_t height) = 0;
|
||||
virtual void Write(Pixel_BU8_GU8_RU8_AU8* pixels) = 0;
|
||||
virtual void Write(std::uint_fast32_t x, std::uint_fast32_t y, Pixel_BU8_GU8_RU8_AU8 pixel) = 0;
|
||||
virtual Pixel_BU8_GU8_RU8_AU8 Read(std::uint_fast32_t x, std::uint_fast32_t y) const = 0;
|
||||
virtual void Write(std::uint32_t x, std::uint32_t y, Pixel_BU8_GU8_RU8_AU8 pixel) = 0;
|
||||
virtual Pixel_BU8_GU8_RU8_AU8 Read(std::uint32_t x, std::uint32_t y) const = 0;
|
||||
virtual const Pixel_BU8_GU8_RU8_AU8* Read() const = 0;
|
||||
virtual Pixel_BU8_GU8_RU8_AU8* Get() = 0;
|
||||
virtual void Store() = 0;
|
||||
|
|
@ -144,8 +145,8 @@ export namespace Crafter {
|
|||
class WindowWayland final : public WindowKeyboard, public WindowMouse, public WindowFramebuffer, public WindowTitle {
|
||||
public:
|
||||
Pixel_BU8_GU8_RU8_AU8* framebuffer = nullptr;
|
||||
WindowWayland(std::uint_fast32_t width, std::uint_fast32_t height);
|
||||
WindowWayland(std::uint_fast32_t width, std::uint_fast32_t height, const std::string_view title);
|
||||
WindowWayland(std::uint32_t width, std::uint32_t height);
|
||||
WindowWayland(std::uint32_t width, std::uint32_t height, const std::string_view title);
|
||||
~WindowWayland();
|
||||
bool configured = false;
|
||||
wl_shm* shm = nullptr;
|
||||
|
|
@ -173,10 +174,10 @@ export namespace Crafter {
|
|||
void StartUpdate() override;
|
||||
void StopUpdate() override;
|
||||
void SetTitle(const std::string_view title) override;
|
||||
void Resize(std::uint_fast32_t width, std::uint_fast32_t height) override;
|
||||
void Resize(std::uint32_t width, std::uint32_t height) override;
|
||||
void Write(Pixel_BU8_GU8_RU8_AU8* pixels) override;
|
||||
void Write(std::uint_fast32_t x, std::uint_fast32_t y, Pixel_BU8_GU8_RU8_AU8 pixel) override;
|
||||
Pixel_BU8_GU8_RU8_AU8 Read(std::uint_fast32_t x, std::uint_fast32_t y) const override;
|
||||
void Write(std::uint32_t x, std::uint32_t y, Pixel_BU8_GU8_RU8_AU8 pixel) override;
|
||||
Pixel_BU8_GU8_RU8_AU8 Read(std::uint32_t x, std::uint32_t y) const override;
|
||||
const Pixel_BU8_GU8_RU8_AU8* Read() const override;
|
||||
Pixel_BU8_GU8_RU8_AU8* Get() override;
|
||||
void Store() override;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue