diff options
Diffstat (limited to 'libraries/pake/include')
-rw-r--r-- | libraries/pake/include/pake/widgets/fixed-text.hpp | 25 | ||||
-rw-r--r-- | libraries/pake/include/pake/window.hpp | 21 |
2 files changed, 44 insertions, 2 deletions
diff --git a/libraries/pake/include/pake/widgets/fixed-text.hpp b/libraries/pake/include/pake/widgets/fixed-text.hpp index dc2e277..fb8a49e 100644 --- a/libraries/pake/include/pake/widgets/fixed-text.hpp +++ b/libraries/pake/include/pake/widgets/fixed-text.hpp @@ -5,18 +5,36 @@ namespace pake::widgets { + //a widget that draws text with a daguerre::fixed_font<bool> class fixed_text : public widget { + //the font to use const daguerre::fixed_font<bool> *font; - daguerre::hilbert_color bg, fg; + + //background color of the widget + daguerre::hilbert_color bg; + + //color of the text + daguerre::hilbert_color fg; + + //the text to draw std::string text; + //has the text changed since the last draw to render + bool text_changed; + + //the width and height of this widget, as set by notify_size int width, height; + + //the alignment of the text within the region halign ha; valign va; public: - //TODO: look up font in some kind of catalogue + //text: the text to draw. this can be changed later by set_text. + //font: the font to use. TODO: pass a string and look up the font with that name + //bg: the background color of the widget. fg: the color of the text. + //ha, va: the alignment of the text within the widget fixed_text( std::string &&text, const daguerre::fixed_font<bool> *font, @@ -24,6 +42,9 @@ namespace pake::widgets { daguerre::hilbert_color fg, halign ha, valign va); + //change the text to draw + void set_text(std::string &&text); + virtual void render( dirtiable_image &onto, int x_off, int y_off, bool force) override; diff --git a/libraries/pake/include/pake/window.hpp b/libraries/pake/include/pake/window.hpp index bb63b9d..3f23d41 100644 --- a/libraries/pake/include/pake/window.hpp +++ b/libraries/pake/include/pake/window.hpp @@ -6,25 +6,46 @@ namespace pake { + //a window / a connection to the compositor. class window { + //the socket that connects us to the compositor euler::syscall::stream_handle socket; + //the size of the window int width; int height; + //the rendered contents of the window. pixels are dirty when + //the compositor has not been informed of them changing. dirtiable_image contents; + + //the root widget, or an unset pointer if there is no root widget set std::unique_ptr<widget> root; public: + //create a new window / connection to the compositor window(int width, int height, const std::string &title); + + //destroy the window / connection to the compositor ~window(); + //tell the compositor to show this window. you probably want to call + //set_root and render_and_send_to_compositor before calling this. void show(); + + //tell the compositor to hide this window void hide(); + //set the root widget. the widget is notified that its size is the + //size of the window, and then it is rendered with force = true. void set_root(std::unique_ptr<widget> &&w); + //get the root widget (assumes there is one) + widget *get_root(); + + //renders the root widget with force = false and + //then sends the new contents to the compositor. void render_and_send_to_compositor(); }; |