File tree Expand file tree Collapse file tree 8 files changed +78
-12
lines changed Expand file tree Collapse file tree 8 files changed +78
-12
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,6 @@ context::context(
3333) :
3434 post_to_ui_thread_function(std::move(params.post_to_ui_thread_function)),
3535 style_provider(std::move(style_provider)),
36- res_loader(this ->style_provider.get().res_loader),
3736 renderer(std::move(renderer)),
3837 updater(std::move(updater)),
3938 localization(std::move(params.localization)),
Original file line number Diff line number Diff line change @@ -69,19 +69,13 @@ class context : public std::enable_shared_from_this<context>
6969 return this ->style_provider .get ();
7070 }
7171
72- /* *
73- * @brief Resource loader.
74- * Allows loading and managing life time of resources.
75- */
76- const utki::shared_ref<resource_loader> res_loader;
77-
7872 /* *
7973 * @brief Shorthand alias for resource loader.
8074 * @return this->res_loader.get().
8175 */
8276 resource_loader& loader () noexcept
8377 {
84- return this ->res_loader .get ();
78+ return this ->style (). res_loader .get ();
8579 }
8680
8781 /* *
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ class native_window
1414
1515 bool is_fullscreen_v = false ;
1616
17- virtual void bind_rendering_context (){}
17+ virtual void bind_rendering_context () {}
1818
1919 virtual void set_fullscreen_internal (bool enable) {}
2020
Original file line number Diff line number Diff line change @@ -53,7 +53,11 @@ class text_widget : virtual public widget
5353private:
5454 parameters params;
5555
56- utki::enum_array<std::shared_ptr<const ruis::font>, res::font::style> fonts;
56+ utki::enum_array<
57+ std::shared_ptr<const ruis::font>, //
58+ res::font::style //
59+ >
60+ fonts;
5761
5862 void update_fonts ();
5963 void update_fonts_and_notify ();
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ class application : public ruisapp::application{
6868 .buffers = {ruisapp::buffer::depth}
6969 }))
7070 {
71- this ->window .close_hander = [this ](ruisapp::window&){
71+ this ->window .close_handler = [this ](ruisapp::window&){
7272 this ->quit ();
7373 };
7474
Original file line number Diff line number Diff line change 1+ #include " new_native_window.hpp"
2+
3+ #include < ruis/widget/button/push_button.hpp>
4+ #include < ruis/widget/label/text.hpp>
5+ #include < ruis/widget/container.hpp>
6+
7+ using namespace std ::string_literals;
8+
9+ namespace m {
10+ using namespace ruis ::make;
11+ }
12+
13+ utki::shared_ref<ruis::widget> make_new_native_window_root_widget (utki::shared_ref<ruis::context> c){
14+ // clang-format off
15+ auto button = m::push_button (c,
16+ {
17+ .layout_params {
18+ .dims {ruis::dim::fill, ruis::dim::fill},
19+ .weight = 1
20+ }
21+ },
22+ {
23+ m::text (c, {}, U" the button" s)
24+ }
25+ );
26+ // clang-format on
27+
28+ button.get ().click_handler = [](ruis::push_button& b){
29+ utki::logcat (" the button clicked" , ' \n ' );
30+ };
31+
32+ // clang-format off
33+ return m::column (c,
34+ {},
35+ {
36+ m::text (c,
37+ {
38+ .layout_params {
39+ .align = {ruis::align::front, ruis::align::center}
40+ }
41+ },
42+ U" Native window" s
43+ ),
44+ std::move (button)
45+ }
46+ );
47+ // clang-format on
48+ }
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include < ruis/widget/widget.hpp>
4+
5+ utki::shared_ref<ruis::widget> make_new_native_window_root_widget (utki::shared_ref<ruis::context> c);
Original file line number Diff line number Diff line change 77#include < ruis/widget/label/gap.hpp>
88#include < ruis/widget/input/text_input_line.hpp>
99#include < ruis/default_style.hpp>
10+ #include < ruisapp/application.hpp>
11+
12+ #include " new_native_window.hpp"
1013
1114using namespace std ::string_literals;
1215using namespace std ::string_view_literals;
@@ -58,7 +61,20 @@ utki::shared_ref<ruis::window> make_text_input_window(
5861
5962 new_native_window_button.get ().click_handler = [](ruis::push_button& b){
6063 utki::logcat (" new native window button clicked" , ' \n ' );
61- // TODO:
64+
65+ auto & nw = ruisapp::inst ().make_window (
66+ {
67+ .title = " new native_window" s
68+ }
69+ );
70+
71+ auto c = make_new_native_window_root_widget (nw.gui .context );
72+ nw.gui .set_root (c);
73+
74+ nw.close_handler = [](ruisapp::window& w){
75+ utki::logcat (" native window close handler called" , ' \n ' );
76+ ruisapp::inst ().destroy_window (w);
77+ };
6278 };
6379
6480 // clang-format off
You can’t perform that action at this time.
0 commit comments