diff --git a/src/bedsidemon/application.cpp b/src/bedsidemon/application.cpp
index 7106584..d026a79 100644
--- a/src/bedsidemon/application.cpp
+++ b/src/bedsidemon/application.cpp
@@ -25,6 +25,7 @@ along with this program. If not, see .
#include
#include
+#include
#include "spo2/contec_cms50d_plus.hpp"
#include "spo2/fake_spo2_sensor.hpp"
@@ -33,6 +34,7 @@ along with this program. If not, see .
#include "about_menu.hpp"
#include "gui.hpp"
+#include "quit_dialog.hpp"
#include "settings_menu.hpp"
using namespace std::string_literals;
@@ -129,7 +131,10 @@ application::application(bool window, std::string_view res_path) :
c.get().get_widget_as("exit_button"sv).click_handler = [](ruis::push_button& b) {
auto& app = bedsidemon::application::inst();
- app.quit();
+ auto& o = app.gui.get_root().get_widget();
+ o.context.get().post_to_ui_thread([&o]() {
+ o.push_back(utki::make_shared(o.context));
+ });
};
}
}
diff --git a/src/bedsidemon/dialog.cpp b/src/bedsidemon/dialog.cpp
index 7cb1f92..792aced 100644
--- a/src/bedsidemon/dialog.cpp
+++ b/src/bedsidemon/dialog.cpp
@@ -35,7 +35,7 @@ using namespace ruis::make;
} // namespace m
namespace {
-constexpr auto color_dialog_surroundings = 0xa0000000;
+constexpr auto color_dialog_surroundings = 0xb0000000;
} // namespace
namespace {
@@ -67,17 +67,35 @@ std::vector> make_root_widget_structure(
}
}
),
- m::nine_patch(c,
+ m::pile(c,
+ {},
{
- .widget_params{
- .id = "ruis_nine_patch"s
- },
- .container_params = std::move(container_params),
- .nine_patch_params{
- .nine_patch = c.get().loader.load("ruis_npt_window_bg")
- }
- },
- contents
+ [&](){
+ auto mp = m::mouse_proxy(c,
+ {
+ .layout_params{
+ .dims{ruis::dim::fill, ruis::dim::fill}
+ }
+ }
+ );
+ mp.get().mouse_button_handler = [](mouse_proxy& w, const mouse_button_event&){return true;};
+ mp.get().mouse_move_handler = [](mouse_proxy& w, const mouse_move_event&){return true;};
+ mp.get().hovered_change_handler = [](mouse_proxy& w, unsigned pointer_id){return true;};
+ return mp;
+ }(),
+ m::nine_patch(c,
+ {
+ .widget_params{
+ .id = "ruis_nine_patch"s
+ },
+ .container_params = std::move(container_params),
+ .nine_patch_params{
+ .nine_patch = c.get().loader.load("ruis_npt_window_bg")
+ }
+ },
+ contents
+ )
+ }
)
};
// clang-format on
diff --git a/src/bedsidemon/quit_dialog.cpp b/src/bedsidemon/quit_dialog.cpp
index a36869c..37c8d57 100644
--- a/src/bedsidemon/quit_dialog.cpp
+++ b/src/bedsidemon/quit_dialog.cpp
@@ -1,29 +1,42 @@
#include "quit_dialog.hpp"
-#include
-#include
#include
+#include
+#include
+
+#include "application.hpp"
using namespace std::string_literals;
+using namespace std::string_view_literals;
using namespace ruis::length_literals;
using namespace bedsidemon;
-namespace m{
+namespace m {
using namespace ruis::make;
-}
+} // namespace m
-namespace{
-constexpr auto dimension_buttons_gap = 10_pp;
-}
+namespace {
+constexpr auto dimension_gap = 10_pp;
+constexpr auto dimension_button_width = 100_pp;
+constexpr auto dimension_button_height = 40_pp;
+} // namespace
-namespace{
-std::vector> make_root_widget_structure(utki::shared_ref c){
- auto make_button = [&](std::string id, std::u32string text){
- // clang-format off
+namespace {
+std::vector> make_root_widget_structure(utki::shared_ref c)
+{
+ auto make_button = [&](std::string id, std::u32string text) {
+ // clang-format off
return m::push_button(c,
- {},
+ {
+ .layout_params{
+ .dims = {dimension_button_width, dimension_button_height}
+ },
+ .widget_params{
+ .id = std::move(id)
+ }
+ },
{
m::text(c,
{},
@@ -31,33 +44,47 @@ std::vector> make_root_widget_structure(utki::sha
)
}
);
- // clang-format on
- };
+ // clang-format on
+ };
- // clang-format off
+ // clang-format off
return {
m::text(c,
{},
U"Quit program?"s
),
+ m::gap(c,
+ {
+ .layout_params{
+ .dims = {0_px, dimension_gap}
+ }
+ }
+ ),
m::row(c,
{},
{
- make_button("yet_button", U"Yes"s),
+ make_button("yes_button"s, U"Yes"s),
m::gap(c,
{
.layout_params{
- .dims = {dimension_buttons_gap, 0_px}
+ .dims = {dimension_gap, 0_px}
}
}
),
- make_button("no_button", U"No"s),
+ make_button("no_button"s, U"No"s),
+ }
+ ),
+ m::gap(c,
+ {
+ .layout_params{
+ .dims = {0_px, dimension_gap}
+ }
}
)
};
- // clang-format on
-}
+ // clang-format on
}
+} // namespace
quit_dialog::quit_dialog(utki::shared_ref context) :
ruis::widget(
@@ -69,11 +96,21 @@ quit_dialog::quit_dialog(utki::shared_ref context) :
),
ruis::dialog(
this->context, //
- {
- .container_params{
- .layout = ruis::layout::column
- }
- },
+ {.container_params{.layout = ruis::layout::column}},
make_root_widget_structure(this->context)
)
-{}
+{
+ {
+ auto& b = this->get_widget_as("yes_button"sv);
+ b.click_handler = [](ruis::push_button& b) {
+ bedsidemon::application::inst().quit();
+ };
+ }
+
+ {
+ auto& b = this->get_widget_as("no_button"sv);
+ b.click_handler = [this](ruis::push_button& b) {
+ this->close();
+ };
+ }
+}