diff options
Diffstat (limited to 'src/ui/include')
| -rw-r--r-- | src/ui/include/font_symbols.hpp | 11 | ||||
| -rw-r--r-- | src/ui/include/screen.hpp | 9 | ||||
| -rw-r--r-- | src/ui/include/screen_playing.hpp | 1 | ||||
| -rw-r--r-- | src/ui/include/widget_top_bar.hpp | 31 |
4 files changed, 49 insertions, 3 deletions
diff --git a/src/ui/include/font_symbols.hpp b/src/ui/include/font_symbols.hpp new file mode 100644 index 00000000..08bb4f6e --- /dev/null +++ b/src/ui/include/font_symbols.hpp @@ -0,0 +1,11 @@ +/* + * Copyright 2023 jacqueline <me@jacqueline.id.au> + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#pragma once + +#include "font/lv_font.h" + +LV_FONT_DECLARE(font_symbols); diff --git a/src/ui/include/screen.hpp b/src/ui/include/screen.hpp index c6b2f137..0ec72a63 100644 --- a/src/ui/include/screen.hpp +++ b/src/ui/include/screen.hpp @@ -12,6 +12,7 @@ #include "core/lv_obj.h" #include "core/lv_obj_tree.h" #include "lvgl.h" +#include "widget_top_bar.hpp" namespace ui { @@ -37,12 +38,20 @@ class Screen { */ virtual auto Tick() -> void {} + auto UpdateTopBar(const widgets::TopBar::State& state) -> void; + auto root() -> lv_obj_t* { return root_; } auto group() -> lv_group_t* { return group_; } protected: + auto CreateTopBar(lv_obj_t* parent, const widgets::TopBar::Configuration&) + -> widgets::TopBar*; + lv_obj_t* const root_; lv_group_t* const group_; + + private: + std::unique_ptr<widgets::TopBar> top_bar_; }; } // namespace ui diff --git a/src/ui/include/screen_playing.hpp b/src/ui/include/screen_playing.hpp index 0e15a85b..c684ddff 100644 --- a/src/ui/include/screen_playing.hpp +++ b/src/ui/include/screen_playing.hpp @@ -71,6 +71,7 @@ class Playing : public Screen { lv_obj_t* next_up_header_; lv_obj_t* next_up_label_; + lv_obj_t* next_up_hint_; lv_obj_t* next_up_container_; }; diff --git a/src/ui/include/widget_top_bar.hpp b/src/ui/include/widget_top_bar.hpp index 9019807f..adb889fc 100644 --- a/src/ui/include/widget_top_bar.hpp +++ b/src/ui/include/widget_top_bar.hpp @@ -6,6 +6,7 @@ #pragma once +#include <cstdint> #include <string> #include "lvgl.h" @@ -16,13 +17,37 @@ namespace widgets { class TopBar { public: - TopBar(lv_obj_t* parent, lv_group_t* group); + struct Configuration { + bool show_back_button; + std::string title; + }; - auto set_title(const std::string&) -> void; + enum class PlaybackState { + kIdle, + kPaused, + kPlaying, + }; + struct State { + PlaybackState playback_state; + uint_fast8_t battery_percent; + bool is_charging; + }; + + explicit TopBar(lv_obj_t* parent, const Configuration& config); + + auto root() -> lv_obj_t* { return container_; } + auto button() -> lv_obj_t* { return back_button_; } + + auto Update(const State&) -> void; + + private: lv_obj_t* container_; - lv_obj_t* title_; + lv_obj_t* back_button_; + lv_obj_t* title_; + lv_obj_t* playback_; + lv_obj_t* battery_; }; } // namespace widgets |
