Last active
February 1, 2019 22:36
-
-
Save ndugger/18cd7a054c2c839755abb6e4ea606f6e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # include "ui/button.h.cpp" | |
| # include "ui/pane.h.cpp" | |
| # include "ui/tooltip.h.cpp" | |
| # include "ui/typography.h.cpp" | |
| # include "wtk/event.h.cpp" | |
| # include "wtk/render.h.cpp" | |
| # include "wtk/state.h.cpp" | |
| # include "wtk/style.h.cpp" | |
| # include "wtk/tree.h.cpp" | |
| # include "wtk/widget.h.cpp" | |
| namespace foo { | |
| class bar : public wtk::widget<bar> { | |
| private: | |
| void handle_click (wtk::event event) { | |
| widget_state.emplace("click_count", widget_state.at<int>("click_count") + 1); | |
| } | |
| protected: | |
| wtk::state create () override { | |
| return { | |
| { "click_count", 0 } | |
| }; | |
| } | |
| wtk::style design () override { | |
| return { | |
| { "foo_bar", | |
| { | |
| { "height", 240 }, | |
| { "width", 640 } | |
| } | |
| } | |
| }; | |
| } | |
| wtk::tree render () override { | |
| int click_count = widget_state.at<int>("click_count"); | |
| return { | |
| wtk::render<ui::pane>({ { "id", "foo_bar" }, { "layout", "vertical" } }, { | |
| wtk::render<ui::typography>({ { "variant", "title" }, { | |
| "this is a title", | |
| wtk::render<ui::typography>({ { "variant", "bold" } }, { | |
| "this is bold" | |
| }); | |
| }), | |
| wtk::render<ui::button>({ { "on_click", this->handle_click } }, { | |
| "click me (" + click_count + ")" | |
| }), | |
| wtk::render<ui::tooltip>({ { "hidden", false }, { | |
| "click the button to increment the count" | |
| }) | |
| }) | |
| }; | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # pragma once | |
| # include "fusion/emitter.h.cpp" | |
| # include "wtk/event.h.cpp" | |
| # include "wtk/factory.h.cpp" | |
| # include "wtk/props.h.cpp" | |
| # include "wtk/state.h.cpp" | |
| # include "wtk/style.h.cpp" | |
| # include "wtk/tree.h.cpp" | |
| namespace wtk { | |
| template <typename widget_type> class widget : public fusion::emitter<wtk::event*> { | |
| friend wtk::factory; | |
| private: | |
| wtk::props widget_props; | |
| wtk::state widget_state; | |
| wtk::style widget_style; | |
| protected: | |
| explicit widget () { | |
| } | |
| virtual wtk::state create () { | |
| return { }; | |
| } | |
| virtual wtk::style design () { | |
| return { }; | |
| } | |
| virtual wtk::tree render () { | |
| return { }; | |
| } | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment