diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-05-02 19:12:26 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-05-02 19:12:26 +1000 |
| commit | 1573a8c4cde1cd9528b422b2dcc598e37ffe94a7 (patch) | |
| tree | d162822b8fd7054f81bace0c7a65ab4d5e6f93ef /src/tangara/ui/modal.cpp | |
| parent | a231fd1c8afedbeb14b0bc77d76bad61db986059 (diff) | |
| download | tangara-fw-1573a8c4cde1cd9528b422b2dcc598e37ffe94a7.tar.gz | |
WIP merge cyclically dependent components into one big component
Diffstat (limited to 'src/tangara/ui/modal.cpp')
| -rw-r--r-- | src/tangara/ui/modal.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/tangara/ui/modal.cpp b/src/tangara/ui/modal.cpp new file mode 100644 index 00000000..ec541914 --- /dev/null +++ b/src/tangara/ui/modal.cpp @@ -0,0 +1,57 @@ + +/* + * Copyright 2023 jacqueline <me@jacqueline.id.au> + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#include "modal.hpp" + +#include "misc/lv_color.h" + +#include "core/lv_event.h" +#include "esp_log.h" + +#include "core/lv_group.h" +#include "core/lv_obj_pos.h" +#include "event_queue.hpp" +#include "extra/widgets/list/lv_list.h" +#include "extra/widgets/menu/lv_menu.h" +#include "extra/widgets/spinner/lv_spinner.h" +#include "hal/lv_hal_disp.h" +#include "index.hpp" +#include "misc/lv_area.h" +#include "screen.hpp" +#include "themes.hpp" +#include "ui_events.hpp" +#include "ui_fsm.hpp" +#include "widgets/lv_label.h" + +namespace ui { + +Modal::Modal(Screen* host) + : root_(lv_obj_create(host->modal_content())), + group_(lv_group_create()), + host_(host) { + lv_obj_set_style_bg_opa(host->modal_content(), LV_OPA_40, 0); + + lv_obj_set_size(root_, 120, LV_SIZE_CONTENT); + lv_obj_center(root_); + + lv_obj_set_style_bg_opa(root_, LV_OPA_COVER, 0); + lv_obj_set_style_bg_color(root_, lv_color_white(), 0); + + host_->modal_group(group_); +} + +Modal::~Modal() { + host_->modal_group(nullptr); + lv_obj_set_style_bg_opa(host_->modal_content(), LV_OPA_TRANSP, 0); + + // The group *must* be deleted first. Otherwise, focus events will be + // generated whilst deleting the object tree, which causes a big mess. + lv_group_del(group_); + lv_obj_del(root_); +} + +} // namespace ui |
