11#include " application.hxx"
22
3- #include " android_globals.hxx"
3+ #include < ruis/render/opengles/context.hpp>
4+
45#include " asset_file.hxx"
6+ #include " globals.hxx"
57#include " window.hxx"
68
79application_glue::application_glue (utki::version_duplet gl_version) :
@@ -18,11 +20,23 @@ app_window& application_glue::make_window(ruisapp::window_parameters window_para
1820
1921 utki::assert (!this ->window .has_value (), SL );
2022
21- auto ruis_native_window = utki::make_shared<native_window>(this ->gl_version , window_params);
23+ auto ruis_native_window = utki::make_shared<native_window>(
24+ this ->gl_version , //
25+ window_params
26+ );
2227
23- // TODO: std::move(ruis_native_window)?
2428 auto rendering_context = utki::make_shared<ruis::render::opengles::context>(ruis_native_window);
2529
30+ auto common_render_objects = utki::make_shared<ruis::render::renderer::objects>(rendering_context);
31+ auto common_shaders = rendering_context.get ().make_shaders ();
32+
33+ auto ruis_resource_loader = utki::make_shared<ruis::resource_loader>(
34+ rendering_context, //
35+ common_render_objects
36+ );
37+
38+ auto ruis_style_provider = utki::make_shared<ruis::style_provider>(std::move (ruis_resource_loader));
39+
2640 auto ruis_context = utki::make_shared<ruis::context>(ruis::context::parameters{
2741 .post_to_ui_thread_function =
2842 [this ](std::function<void ()> procedure) {
@@ -40,19 +54,19 @@ app_window& application_glue::make_window(ruisapp::window_parameters window_para
4054 },
4155 .updater = this ->updater ,
4256 .renderer = utki::make_shared<ruis::render::renderer>(
43- rendering_context,
44- this -> rendering_context . get (). make_shaders ( ),
45- utki::make_shared<ruis::render::renderer::objects>(rendering_context )
57+ std::move ( rendering_context) ,
58+ std::move (common_shaders ),
59+ std::move (common_render_objects )
4660 ),
47- .style_provider = this -> ruis_style_provider ,
61+ .style_provider = std::move ( ruis_style_provider) ,
4862 // TODO:
4963 // .units = ruis::units(
5064 // ruis_native_window.get().get_dots_per_inch(), //
5165 // ruis_native_window.get().get_dots_per_pp()
5266 // )
5367 });
5468
55- auto ruisapp_window = utki::make_shared<app_window> (
69+ this -> window . emplace (
5670 std::move (ruis_context), //
5771 std::move (ruis_native_window)
5872 );
@@ -67,8 +81,6 @@ app_window& application_glue::make_window(ruisapp::window_parameters window_para
6781 // )
6882 // );
6983
70- this ->window = std::move (ruisapp_window);
71-
7284 utki::assert (this ->window .has_value (), SL );
7385 return this ->window .value ();
7486}
@@ -121,3 +133,39 @@ ruisapp::window& ruisapp::application::make_window(ruisapp::window_parameters wi
121133 auto & glue = get_glue (*this );
122134 return glue.make_window (std::move (window_params));
123135}
136+
137+ void ruisapp::application::destroy_window (ruisapp::window& w)
138+ {
139+ auto & glue = get_glue (*this );
140+
141+ utki::assert (dynamic_cast <app_window*>(&w), SL );
142+ glue.destroy_window ();
143+ }
144+
145+ void ruisapp::application::quit () noexcept
146+ {
147+ utki::assert (globals_wrapper::native_activity, SL );
148+ ANativeActivity_finish (globals_wrapper::native_activity);
149+ }
150+
151+ void ruisapp::application::show_virtual_keyboard () noexcept
152+ {
153+ // NOTE:
154+ // ANativeActivity_showSoftInput(native_activity,
155+ // ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED); did not work for some reason.
156+
157+ auto & glob = get_glob ();
158+
159+ glob.java_functions .show_virtual_keyboard ();
160+ }
161+
162+ void ruisapp::application::hide_virtual_keyboard () noexcept
163+ {
164+ // NOTE:
165+ // ANativeActivity_hideSoftInput(native_activity,
166+ // ANATIVEACTIVITY_HIDE_SOFT_INPUT_NOT_ALWAYS); did not work for some reason
167+
168+ auto & glob = get_glob ();
169+
170+ glob.java_functions .hide_virtual_keyboard ();
171+ }
0 commit comments