Skip to content

Commit

Permalink
pw menu
Browse files Browse the repository at this point in the history
  • Loading branch information
igagis committed Sep 17, 2024
1 parent c4e1fd6 commit 219e6ac
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/bedsidemon/spo2/spo2_parameter_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ std::vector<utki::shared_ref<ruis::widget>> make_widgets(utki::shared_ref<ruis::
.widget_params = {
.id = "pw_waveform"s,
.clip = true
},
.color_params = {
.color = color_main_value
}
}
),
Expand Down Expand Up @@ -240,6 +237,12 @@ spo2_parameter_window::spo2_parameter_window(utki::shared_ref<ruis::context> con
},
{}
),
ruis::color_widget(
this->context,
ruis::color_widget::parameters{
.color = color_main_value
}
),
ruis::container( //
this->context,
{.container_params =
Expand Down
11 changes: 11 additions & 0 deletions src/bedsidemon/spo2/spo2_parameter_window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once

#include <ruis/util/timer.hpp>
#include <ruis/widget/base/color_widget.hpp>
#include <ruis/widget/label/text.hpp>
#include <ruis/widget/widget.hpp>

Expand All @@ -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;
Expand Down Expand Up @@ -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<uint32_t, 4> possible_colors = {{
0xffffffff,
0xffffff00,
0xff00ff00,
0xff00ffff
}};
// clang-format on
};

} // namespace bedsidemon
91 changes: 90 additions & 1 deletion src/bedsidemon/spo2/spo2_parameter_window_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,107 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.

#include "spo2_parameter_window_menu.hpp"

#include <ruis/widget/button/selection_box.hpp>
#include <ruis/widget/group/margins.hpp>
#include <ruis/widget/label/gap.hpp>
#include <ruis/widget/label/rectangle.hpp>

#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<ruis::widget> 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<utki::shared_ref<ruis::widget>> make_menu_contents(utki::shared_ref<ruis::context> 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<selection_box_provider>()
}
}
)
};
// clang-format on
}
Expand Down
4 changes: 3 additions & 1 deletion src/bedsidemon/waveform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ruis::context> context, all_parameters params);
Expand Down

0 comments on commit 219e6ac

Please sign in to comment.