From 219e6ac6efb2bcc379a27026f5a11cfe6e3e786a Mon Sep 17 00:00:00 2001 From: Ivan Gagis Date: Tue, 17 Sep 2024 16:55:54 +0300 Subject: [PATCH] pw menu --- src/bedsidemon/spo2/spo2_parameter_window.cpp | 9 +- src/bedsidemon/spo2/spo2_parameter_window.hpp | 11 +++ .../spo2/spo2_parameter_window_menu.cpp | 91 ++++++++++++++++++- src/bedsidemon/waveform.hpp | 4 +- 4 files changed, 110 insertions(+), 5 deletions(-) diff --git a/src/bedsidemon/spo2/spo2_parameter_window.cpp b/src/bedsidemon/spo2/spo2_parameter_window.cpp index 71164b6..eabe33a 100644 --- a/src/bedsidemon/spo2/spo2_parameter_window.cpp +++ b/src/bedsidemon/spo2/spo2_parameter_window.cpp @@ -148,9 +148,6 @@ std::vector> make_widgets(utki::shared_ref con }, {} ), + ruis::color_widget( + this->context, + ruis::color_widget::parameters{ + .color = color_main_value + } + ), ruis::container( // this->context, {.container_params = diff --git a/src/bedsidemon/spo2/spo2_parameter_window.hpp b/src/bedsidemon/spo2/spo2_parameter_window.hpp index c9eeb1b..584951c 100644 --- a/src/bedsidemon/spo2/spo2_parameter_window.hpp +++ b/src/bedsidemon/spo2/spo2_parameter_window.hpp @@ -22,6 +22,7 @@ along with this program. If not, see . #pragma once #include +#include #include #include @@ -35,6 +36,7 @@ namespace bedsidemon { class spo2_parameter_window : virtual public ruis::widget, // + public ruis::color_widget, private ruis::container { friend class spo2_parameter_window_menu; @@ -65,6 +67,15 @@ class spo2_parameter_window : spo2_parameter_window& operator=(spo2_parameter_window&&) = delete; void set(const spo2_measurement& meas); + + // clang-format off + constexpr static const std::array possible_colors = {{ + 0xffffffff, + 0xffffff00, + 0xff00ff00, + 0xff00ffff + }}; + // clang-format on }; } // namespace bedsidemon diff --git a/src/bedsidemon/spo2/spo2_parameter_window_menu.cpp b/src/bedsidemon/spo2/spo2_parameter_window_menu.cpp index 3d2f5d2..87d8a53 100644 --- a/src/bedsidemon/spo2/spo2_parameter_window_menu.cpp +++ b/src/bedsidemon/spo2/spo2_parameter_window_menu.cpp @@ -21,18 +21,107 @@ along with this program. If not, see . #include "spo2_parameter_window_menu.hpp" +#include +#include +#include +#include + +#include "../style.hpp" + #include "spo2_parameter_window.hpp" using namespace std::string_literals; +using namespace ruis::length_literals; + using namespace bedsidemon; +namespace { +namespace m { +using namespace ruis::make; +} // namespace m +} // namespace + +namespace { +class selection_box_provider : public ruis::selection_box::provider +{ +public: + selection_box_provider() = default; + + size_t count() const noexcept override + { + return spo2_parameter_window::possible_colors.size(); + } + + utki::shared_ref get_widget(size_t index) override + { + auto& c = this->get_selection_box()->context; + + // clang-format off + return m::margins(c, + { + .container_params = { + .layout = ruis::layout::pile + }, + .frame_params = { + .borders = {3_pp} // NOLINT(cppcoreguidelines-avoid-magic-numbers, "TODO: fix") + } + }, + { + m::rectangle(c, + { + .layout_params{ + .dims{40_pp, 30_pp} // NOLINT(cppcoreguidelines-avoid-magic-numbers, "TODO: fix") + }, + .color_params{ + .color = spo2_parameter_window::possible_colors.at(index) + } + } + ) + } + ); + // clang-format on + } +}; +} // namespace + namespace { std::vector> make_menu_contents(utki::shared_ref c) { // clang-format off return { - // TODO: + m::text(c, + { + .layout_params = { + .align = {ruis::align::front, ruis::align::center} + }, + .text_params = { + .font_size = style::font_size_setting + } + }, + U"Color:"s + ), + m::gap(c, + { + .layout_params = { + .dims{0_px, style::gap_size_setting_label_value} + } + } + ), + m::selection_box(c, + { + .layout_params = { + .dims = {200_pp, ruis::dim::min}, // NOLINT(cppcoreguidelines-avoid-magic-numbers, "TODO: fix") + .align = {ruis::align::front, ruis::align::center} + }, + .widget_params = { + .id = "color_selection_box"s + }, + .selection_params = { + .provider = std::make_shared() + } + } + ) }; // clang-format on } diff --git a/src/bedsidemon/waveform.hpp b/src/bedsidemon/waveform.hpp index 4eddc45..3de12a9 100644 --- a/src/bedsidemon/waveform.hpp +++ b/src/bedsidemon/waveform.hpp @@ -64,7 +64,9 @@ class waveform : struct all_parameters { ruis::layout_parameters layout_params; ruis::widget::parameters widget_params; - ruis::color_widget::parameters color_params; + + constexpr static const auto default_waveform_color = 0xffffff00; + ruis::color_widget::parameters color_params = {.color = default_waveform_color}; }; waveform(utki::shared_ref context, all_parameters params);