diff options
author | Benji Dial <benji@benjidial.net> | 2024-07-29 19:59:52 -0400 |
---|---|---|
committer | Benji Dial <benji@benjidial.net> | 2024-07-29 19:59:52 -0400 |
commit | e6c3a80b01ffb52079783cddd9be6d392d0f7039 (patch) | |
tree | 148276b9878f287bc81638f90249ec4d7b86eaf0 /libraries/pake/include | |
parent | be691582ee12613278af24cb5a824eeb357f6324 (diff) | |
download | hilbert-os-e6c3a80b01ffb52079783cddd9be6d392d0f7039.tar.gz |
redesign compositor protocol, start widget library
Diffstat (limited to 'libraries/pake/include')
-rw-r--r-- | libraries/pake/include/pake/dirtiable-image.hpp | 27 | ||||
-rw-r--r-- | libraries/pake/include/pake/widget.hpp | 19 | ||||
-rw-r--r-- | libraries/pake/include/pake/widgets/fixed-text.hpp | 31 | ||||
-rw-r--r-- | libraries/pake/include/pake/window.hpp | 32 |
4 files changed, 109 insertions, 0 deletions
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 <daguerre/image.hpp> +#include <list> + +namespace pake { + + struct region { + int start_x; + int start_y; + int width; + int height; + }; + + struct dirtiable_image { + + daguerre::image<daguerre::hilbert_color> image; + daguerre::image<bool> dirty; + + std::vector<region> 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 <pake/dirtiable-image.hpp> + +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 <daguerre/fixed-font.hpp> +#include <pake/widget.hpp> + +namespace pake::widgets { + + class fixed_text : public widget { + + const daguerre::fixed_font<bool> *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<bool> *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 <pake/dirtiable-image.hpp> +#include <pake/widget.hpp> +#include <memory> + +namespace pake { + + class window { + + euler::syscall::stream_handle socket; + + int width; + int height; + + dirtiable_image contents; + std::unique_ptr<widget> root; + + public: + window(int width, int height, const std::string &title); + ~window(); + + void show(); + void hide(); + + void set_root(std::unique_ptr<widget> &&w); + + void render_and_send_to_compositor(); + + }; + +} |