From e6c3a80b01ffb52079783cddd9be6d392d0f7039 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Mon, 29 Jul 2024 19:59:52 -0400 Subject: redesign compositor protocol, start widget library --- libraries/pake/include/pake/dirtiable-image.hpp | 27 ++++++++++++++++++ libraries/pake/include/pake/widget.hpp | 19 +++++++++++++ libraries/pake/include/pake/widgets/fixed-text.hpp | 31 +++++++++++++++++++++ libraries/pake/include/pake/window.hpp | 32 ++++++++++++++++++++++ 4 files changed, 109 insertions(+) create mode 100644 libraries/pake/include/pake/dirtiable-image.hpp create mode 100644 libraries/pake/include/pake/widget.hpp create mode 100644 libraries/pake/include/pake/widgets/fixed-text.hpp create mode 100644 libraries/pake/include/pake/window.hpp (limited to 'libraries/pake/include') diff --git a/libraries/pake/include/pake/dirtiable-image.hpp b/libraries/pake/include/pake/dirtiable-image.hpp new file mode 100644 index 0000000..af09ade --- /dev/null +++ b/libraries/pake/include/pake/dirtiable-image.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include +#include + +namespace pake { + + struct region { + int start_x; + int start_y; + int width; + int height; + }; + + struct dirtiable_image { + + daguerre::image image; + daguerre::image dirty; + + std::vector get_dirty_regions(); + void clear_dirty(); + + dirtiable_image(int width, int height); + + }; + +} diff --git a/libraries/pake/include/pake/widget.hpp b/libraries/pake/include/pake/widget.hpp new file mode 100644 index 0000000..dad5651 --- /dev/null +++ b/libraries/pake/include/pake/widget.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include + +namespace pake { + + class widget { + + public: + virtual ~widget() {} + + virtual void render( + dirtiable_image &onto, int x_off, int y_off, bool force) = 0; + + virtual void notify_size(int width, int height) = 0; + + }; + +} diff --git a/libraries/pake/include/pake/widgets/fixed-text.hpp b/libraries/pake/include/pake/widgets/fixed-text.hpp new file mode 100644 index 0000000..c6dafab --- /dev/null +++ b/libraries/pake/include/pake/widgets/fixed-text.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include +#include + +namespace pake::widgets { + + class fixed_text : public widget { + + const daguerre::fixed_font *font; + daguerre::hilbert_color bg, fg; + std::string text; + + int width, height; + + public: + //TODO: look up font in some kind of catalogue + fixed_text( + std::string &&text, + const daguerre::fixed_font *font, + daguerre::hilbert_color bg, + daguerre::hilbert_color fg); + + virtual void render( + dirtiable_image &onto, int x_off, int y_off, bool force) override; + + virtual void notify_size(int width, int height) override; + + }; + +} diff --git a/libraries/pake/include/pake/window.hpp b/libraries/pake/include/pake/window.hpp new file mode 100644 index 0000000..bb63b9d --- /dev/null +++ b/libraries/pake/include/pake/window.hpp @@ -0,0 +1,32 @@ +#pragma once + +#include +#include +#include + +namespace pake { + + class window { + + euler::syscall::stream_handle socket; + + int width; + int height; + + dirtiable_image contents; + std::unique_ptr root; + + public: + window(int width, int height, const std::string &title); + ~window(); + + void show(); + void hide(); + + void set_root(std::unique_ptr &&w); + + void render_and_send_to_compositor(); + + }; + +} -- cgit v1.2.3