diff options
| author | cooljqln <cooljqln@noreply.codeberg.org> | 2024-05-03 04:48:17 +0000 |
|---|---|---|
| committer | cooljqln <cooljqln@noreply.codeberg.org> | 2024-05-03 04:48:17 +0000 |
| commit | 3ceb8025ee4330c177101ed30ec17dfb0002f41e (patch) | |
| tree | 58350210f15df7d00d967cac6f30eeceeb031a3c /src/tangara/ui/modal.cpp | |
| parent | 964da15a0b84f8e5f00e8abac2f7dfda0bf60488 (diff) | |
| parent | 9fafd797a5504f458b5fcae4a1d28a68da936315 (diff) | |
| download | tangara-fw-3ceb8025ee4330c177101ed30ec17dfb0002f41e.tar.gz | |
Merge pull request 'Break dependency cycles with our components by merging co-dependent components together' (#68) from jqln/component-merge into main
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/68
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..4f5a2432 --- /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 "ui/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 "database/index.hpp" +#include "events/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 "misc/lv_area.h" +#include "ui/screen.hpp" +#include "ui/themes.hpp" +#include "ui/ui_events.hpp" +#include "ui/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 |
